babylon.module.d.ts 6.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Check if the document object exists
  290. * @returns true if the document object exists
  291. */
  292. static IsDocumentAvailable(): boolean;
  293. /**
  294. * Extracts text content from a DOM element hierarchy
  295. * @param element defines the root element
  296. * @returns a string
  297. */
  298. static GetDOMTextContent(element: HTMLElement): string;
  299. }
  300. }
  301. declare module "babylonjs/Misc/logger" {
  302. /**
  303. * Logger used througouht the application to allow configuration of
  304. * the log level required for the messages.
  305. */
  306. export class Logger {
  307. /**
  308. * No log
  309. */
  310. static readonly NoneLogLevel: number;
  311. /**
  312. * Only message logs
  313. */
  314. static readonly MessageLogLevel: number;
  315. /**
  316. * Only warning logs
  317. */
  318. static readonly WarningLogLevel: number;
  319. /**
  320. * Only error logs
  321. */
  322. static readonly ErrorLogLevel: number;
  323. /**
  324. * All logs
  325. */
  326. static readonly AllLogLevel: number;
  327. private static _LogCache;
  328. /**
  329. * Gets a value indicating the number of loading errors
  330. * @ignorenaming
  331. */
  332. static errorsCount: number;
  333. /**
  334. * Callback called when a new log is added
  335. */
  336. static OnNewCacheEntry: (entry: string) => void;
  337. private static _AddLogEntry;
  338. private static _FormatMessage;
  339. private static _LogDisabled;
  340. private static _LogEnabled;
  341. private static _WarnDisabled;
  342. private static _WarnEnabled;
  343. private static _ErrorDisabled;
  344. private static _ErrorEnabled;
  345. /**
  346. * Log a message to the console
  347. */
  348. static Log: (message: string) => void;
  349. /**
  350. * Write a warning message to the console
  351. */
  352. static Warn: (message: string) => void;
  353. /**
  354. * Write an error message to the console
  355. */
  356. static Error: (message: string) => void;
  357. /**
  358. * Gets current log cache (list of logs)
  359. */
  360. static get LogCache(): string;
  361. /**
  362. * Clears the log cache
  363. */
  364. static ClearLogCache(): void;
  365. /**
  366. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  367. */
  368. static set LogLevels(level: number);
  369. }
  370. }
  371. declare module "babylonjs/Misc/typeStore" {
  372. /** @hidden */
  373. export class _TypeStore {
  374. /** @hidden */
  375. static RegisteredTypes: {
  376. [key: string]: Object;
  377. };
  378. /** @hidden */
  379. static GetClass(fqdn: string): any;
  380. }
  381. }
  382. declare module "babylonjs/Misc/stringTools" {
  383. /**
  384. * Helper to manipulate strings
  385. */
  386. export class StringTools {
  387. /**
  388. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  389. * @param str Source string
  390. * @param suffix Suffix to search for in the source string
  391. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  392. */
  393. static EndsWith(str: string, suffix: string): boolean;
  394. /**
  395. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  396. * @param str Source string
  397. * @param suffix Suffix to search for in the source string
  398. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  399. */
  400. static StartsWith(str: string, suffix: string): boolean;
  401. /**
  402. * Decodes a buffer into a string
  403. * @param buffer The buffer to decode
  404. * @returns The decoded string
  405. */
  406. static Decode(buffer: Uint8Array | Uint16Array): string;
  407. /**
  408. * Encode a buffer to a base64 string
  409. * @param buffer defines the buffer to encode
  410. * @returns the encoded string
  411. */
  412. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  413. /**
  414. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  415. * @param num the number to convert and pad
  416. * @param length the expected length of the string
  417. * @returns the padded string
  418. */
  419. static PadNumber(num: number, length: number): string;
  420. }
  421. }
  422. declare module "babylonjs/Misc/deepCopier" {
  423. /**
  424. * Class containing a set of static utilities functions for deep copy.
  425. */
  426. export class DeepCopier {
  427. /**
  428. * Tries to copy an object by duplicating every property
  429. * @param source defines the source object
  430. * @param destination defines the target object
  431. * @param doNotCopyList defines a list of properties to avoid
  432. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  433. */
  434. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  435. }
  436. }
  437. declare module "babylonjs/Misc/precisionDate" {
  438. /**
  439. * Class containing a set of static utilities functions for precision date
  440. */
  441. export class PrecisionDate {
  442. /**
  443. * Gets either window.performance.now() if supported or Date.now() else
  444. */
  445. static get Now(): number;
  446. }
  447. }
  448. declare module "babylonjs/Misc/devTools" {
  449. /** @hidden */
  450. export class _DevTools {
  451. static WarnImport(name: string): string;
  452. }
  453. }
  454. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  455. /**
  456. * Interface used to define the mechanism to get data from the network
  457. */
  458. export interface IWebRequest {
  459. /**
  460. * Returns client's response url
  461. */
  462. responseURL: string;
  463. /**
  464. * Returns client's status
  465. */
  466. status: number;
  467. /**
  468. * Returns client's status as a text
  469. */
  470. statusText: string;
  471. }
  472. }
  473. declare module "babylonjs/Misc/webRequest" {
  474. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  475. import { Nullable } from "babylonjs/types";
  476. /**
  477. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  478. */
  479. export class WebRequest implements IWebRequest {
  480. private _xhr;
  481. /**
  482. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  483. * i.e. when loading files, where the server/service expects an Authorization header
  484. */
  485. static CustomRequestHeaders: {
  486. [key: string]: string;
  487. };
  488. /**
  489. * Add callback functions in this array to update all the requests before they get sent to the network
  490. */
  491. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  492. private _injectCustomRequestHeaders;
  493. /**
  494. * Gets or sets a function to be called when loading progress changes
  495. */
  496. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  497. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  498. /**
  499. * Returns client's state
  500. */
  501. get readyState(): number;
  502. /**
  503. * Returns client's status
  504. */
  505. get status(): number;
  506. /**
  507. * Returns client's status as a text
  508. */
  509. get statusText(): string;
  510. /**
  511. * Returns client's response
  512. */
  513. get response(): any;
  514. /**
  515. * Returns client's response url
  516. */
  517. get responseURL(): string;
  518. /**
  519. * Returns client's response as text
  520. */
  521. get responseText(): string;
  522. /**
  523. * Gets or sets the expected response type
  524. */
  525. get responseType(): XMLHttpRequestResponseType;
  526. set responseType(value: XMLHttpRequestResponseType);
  527. /** @hidden */
  528. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  529. /** @hidden */
  530. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  531. /**
  532. * Cancels any network activity
  533. */
  534. abort(): void;
  535. /**
  536. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  537. * @param body defines an optional request body
  538. */
  539. send(body?: Document | BodyInit | null): void;
  540. /**
  541. * Sets the request method, request URL
  542. * @param method defines the method to use (GET, POST, etc..)
  543. * @param url defines the url to connect with
  544. */
  545. open(method: string, url: string): void;
  546. /**
  547. * Sets the value of a request header.
  548. * @param name The name of the header whose value is to be set
  549. * @param value The value to set as the body of the header
  550. */
  551. setRequestHeader(name: string, value: string): void;
  552. /**
  553. * Get the string containing the text of a particular header's value.
  554. * @param name The name of the header
  555. * @returns The string containing the text of the given header name
  556. */
  557. getResponseHeader(name: string): Nullable<string>;
  558. }
  559. }
  560. declare module "babylonjs/Misc/fileRequest" {
  561. import { Observable } from "babylonjs/Misc/observable";
  562. /**
  563. * File request interface
  564. */
  565. export interface IFileRequest {
  566. /**
  567. * Raised when the request is complete (success or error).
  568. */
  569. onCompleteObservable: Observable<IFileRequest>;
  570. /**
  571. * Aborts the request for a file.
  572. */
  573. abort: () => void;
  574. }
  575. }
  576. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  577. /**
  578. * Define options used to create a render target texture
  579. */
  580. export class RenderTargetCreationOptions {
  581. /**
  582. * Specifies is mipmaps must be generated
  583. */
  584. generateMipMaps?: boolean;
  585. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  586. generateDepthBuffer?: boolean;
  587. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  588. generateStencilBuffer?: boolean;
  589. /** Defines texture type (int by default) */
  590. type?: number;
  591. /** Defines sampling mode (trilinear by default) */
  592. samplingMode?: number;
  593. /** Defines format (RGBA by default) */
  594. format?: number;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  693. static readonly GEQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and no mip */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** mag = nearest and min = nearest and mip = none */
  779. static readonly TEXTURE_NEAREST_NEAREST: number;
  780. /** Bilinear is mag = linear and min = linear and no mip */
  781. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  782. /** mag = linear and min = linear and mip = none */
  783. static readonly TEXTURE_LINEAR_LINEAR: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** nearest is mag = nearest and min = nearest and mip = linear */
  797. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  803. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Offline (baking) quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  828. /** High quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  830. /** Medium quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  832. /** Low quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  834. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  835. static readonly SCALEMODE_FLOOR: number;
  836. /** Defines that texture rescaling will look for the nearest power of 2 size */
  837. static readonly SCALEMODE_NEAREST: number;
  838. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  839. static readonly SCALEMODE_CEILING: number;
  840. /**
  841. * The dirty texture flag value
  842. */
  843. static readonly MATERIAL_TextureDirtyFlag: number;
  844. /**
  845. * The dirty light flag value
  846. */
  847. static readonly MATERIAL_LightDirtyFlag: number;
  848. /**
  849. * The dirty fresnel flag value
  850. */
  851. static readonly MATERIAL_FresnelDirtyFlag: number;
  852. /**
  853. * The dirty attribute flag value
  854. */
  855. static readonly MATERIAL_AttributesDirtyFlag: number;
  856. /**
  857. * The dirty misc flag value
  858. */
  859. static readonly MATERIAL_MiscDirtyFlag: number;
  860. /**
  861. * The all dirty flag value
  862. */
  863. static readonly MATERIAL_AllDirtyFlag: number;
  864. /**
  865. * Returns the triangle fill mode
  866. */
  867. static readonly MATERIAL_TriangleFillMode: number;
  868. /**
  869. * Returns the wireframe mode
  870. */
  871. static readonly MATERIAL_WireFrameFillMode: number;
  872. /**
  873. * Returns the point fill mode
  874. */
  875. static readonly MATERIAL_PointFillMode: number;
  876. /**
  877. * Returns the point list draw mode
  878. */
  879. static readonly MATERIAL_PointListDrawMode: number;
  880. /**
  881. * Returns the line list draw mode
  882. */
  883. static readonly MATERIAL_LineListDrawMode: number;
  884. /**
  885. * Returns the line loop draw mode
  886. */
  887. static readonly MATERIAL_LineLoopDrawMode: number;
  888. /**
  889. * Returns the line strip draw mode
  890. */
  891. static readonly MATERIAL_LineStripDrawMode: number;
  892. /**
  893. * Returns the triangle strip draw mode
  894. */
  895. static readonly MATERIAL_TriangleStripDrawMode: number;
  896. /**
  897. * Returns the triangle fan draw mode
  898. */
  899. static readonly MATERIAL_TriangleFanDrawMode: number;
  900. /**
  901. * Stores the clock-wise side orientation
  902. */
  903. static readonly MATERIAL_ClockWiseSideOrientation: number;
  904. /**
  905. * Stores the counter clock-wise side orientation
  906. */
  907. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  908. /**
  909. * Nothing
  910. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_NothingTrigger: number;
  913. /**
  914. * On pick
  915. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickTrigger: number;
  918. /**
  919. * On left pick
  920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnLeftPickTrigger: number;
  923. /**
  924. * On right pick
  925. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnRightPickTrigger: number;
  928. /**
  929. * On center pick
  930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnCenterPickTrigger: number;
  933. /**
  934. * On pick down
  935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnPickDownTrigger: number;
  938. /**
  939. * On double pick
  940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnDoublePickTrigger: number;
  943. /**
  944. * On pick up
  945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  946. */
  947. static readonly ACTION_OnPickUpTrigger: number;
  948. /**
  949. * On pick out.
  950. * This trigger will only be raised if you also declared a OnPickDown
  951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickOutTrigger: number;
  954. /**
  955. * On long press
  956. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnLongPressTrigger: number;
  959. /**
  960. * On pointer over
  961. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPointerOverTrigger: number;
  964. /**
  965. * On pointer out
  966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnPointerOutTrigger: number;
  969. /**
  970. * On every frame
  971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnEveryFrameTrigger: number;
  974. /**
  975. * On intersection enter
  976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnIntersectionEnterTrigger: number;
  979. /**
  980. * On intersection exit
  981. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnIntersectionExitTrigger: number;
  984. /**
  985. * On key down
  986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnKeyDownTrigger: number;
  989. /**
  990. * On key up
  991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  992. */
  993. static readonly ACTION_OnKeyUpTrigger: number;
  994. /**
  995. * Billboard mode will only apply to Y axis
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  998. /**
  999. * Billboard mode will apply to all axes
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1002. /**
  1003. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1004. */
  1005. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1006. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1007. * Test order :
  1008. * Is the bounding sphere outside the frustum ?
  1009. * If not, are the bounding box vertices outside the frustum ?
  1010. * It not, then the cullable object is in the frustum.
  1011. */
  1012. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1013. /** Culling strategy : Bounding Sphere Only.
  1014. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1015. * It's also less accurate than the standard because some not visible objects can still be selected.
  1016. * Test : is the bounding sphere outside the frustum ?
  1017. * If not, then the cullable object is in the frustum.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1020. /** Culling strategy : Optimistic Inclusion.
  1021. * This in an inclusion test first, then the standard exclusion test.
  1022. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1023. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1024. * Anyway, it's as accurate as the standard strategy.
  1025. * Test :
  1026. * Is the cullable object bounding sphere center in the frustum ?
  1027. * If not, apply the default culling strategy.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1030. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1031. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1032. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1033. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1034. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1035. * Test :
  1036. * Is the cullable object bounding sphere center in the frustum ?
  1037. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1038. */
  1039. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1040. /**
  1041. * No logging while loading
  1042. */
  1043. static readonly SCENELOADER_NO_LOGGING: number;
  1044. /**
  1045. * Minimal logging while loading
  1046. */
  1047. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1048. /**
  1049. * Summary logging while loading
  1050. */
  1051. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1052. /**
  1053. * Detailled logging while loading
  1054. */
  1055. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1056. }
  1057. }
  1058. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1059. import { Nullable } from "babylonjs/types";
  1060. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1061. /**
  1062. * This represents the required contract to create a new type of texture loader.
  1063. */
  1064. export interface IInternalTextureLoader {
  1065. /**
  1066. * Defines wether the loader supports cascade loading the different faces.
  1067. */
  1068. supportCascades: boolean;
  1069. /**
  1070. * This returns if the loader support the current file information.
  1071. * @param extension defines the file extension of the file being loaded
  1072. * @param mimeType defines the optional mime type of the file being loaded
  1073. * @returns true if the loader can load the specified file
  1074. */
  1075. canLoad(extension: string, mimeType?: string): boolean;
  1076. /**
  1077. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1078. * @param data contains the texture data
  1079. * @param texture defines the BabylonJS internal texture
  1080. * @param createPolynomials will be true if polynomials have been requested
  1081. * @param onLoad defines the callback to trigger once the texture is ready
  1082. * @param onError defines the callback to trigger in case of error
  1083. */
  1084. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1085. /**
  1086. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1087. * @param data contains the texture data
  1088. * @param texture defines the BabylonJS internal texture
  1089. * @param callback defines the method to call once ready to upload
  1090. */
  1091. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1092. }
  1093. }
  1094. declare module "babylonjs/Engines/IPipelineContext" {
  1095. /**
  1096. * Class used to store and describe the pipeline context associated with an effect
  1097. */
  1098. export interface IPipelineContext {
  1099. /**
  1100. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1101. */
  1102. isAsync: boolean;
  1103. /**
  1104. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1105. */
  1106. isReady: boolean;
  1107. /** @hidden */
  1108. _getVertexShaderCode(): string | null;
  1109. /** @hidden */
  1110. _getFragmentShaderCode(): string | null;
  1111. /** @hidden */
  1112. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1113. }
  1114. }
  1115. declare module "babylonjs/Meshes/dataBuffer" {
  1116. /**
  1117. * Class used to store gfx data (like WebGLBuffer)
  1118. */
  1119. export class DataBuffer {
  1120. /**
  1121. * Gets or sets the number of objects referencing this buffer
  1122. */
  1123. references: number;
  1124. /** Gets or sets the size of the underlying buffer */
  1125. capacity: number;
  1126. /**
  1127. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1128. */
  1129. is32Bits: boolean;
  1130. /**
  1131. * Gets the underlying buffer
  1132. */
  1133. get underlyingResource(): any;
  1134. }
  1135. }
  1136. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1137. /** @hidden */
  1138. export interface IShaderProcessor {
  1139. attributeProcessor?: (attribute: string) => string;
  1140. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1141. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1142. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1143. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1144. lineProcessor?: (line: string, isFragment: boolean) => string;
  1145. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1146. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1147. }
  1148. }
  1149. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1150. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1151. /** @hidden */
  1152. export interface ProcessingOptions {
  1153. defines: string[];
  1154. indexParameters: any;
  1155. isFragment: boolean;
  1156. shouldUseHighPrecisionShader: boolean;
  1157. supportsUniformBuffers: boolean;
  1158. shadersRepository: string;
  1159. includesShadersStore: {
  1160. [key: string]: string;
  1161. };
  1162. processor?: IShaderProcessor;
  1163. version: string;
  1164. platformName: string;
  1165. lookForClosingBracketForUniformBuffer?: boolean;
  1166. }
  1167. }
  1168. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1169. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1170. /** @hidden */
  1171. export class ShaderCodeNode {
  1172. line: string;
  1173. children: ShaderCodeNode[];
  1174. additionalDefineKey?: string;
  1175. additionalDefineValue?: string;
  1176. isValid(preprocessors: {
  1177. [key: string]: string;
  1178. }): boolean;
  1179. process(preprocessors: {
  1180. [key: string]: string;
  1181. }, options: ProcessingOptions): string;
  1182. }
  1183. }
  1184. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1185. /** @hidden */
  1186. export class ShaderCodeCursor {
  1187. private _lines;
  1188. lineIndex: number;
  1189. get currentLine(): string;
  1190. get canRead(): boolean;
  1191. set lines(value: string[]);
  1192. }
  1193. }
  1194. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1195. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1196. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1197. /** @hidden */
  1198. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1199. process(preprocessors: {
  1200. [key: string]: string;
  1201. }, options: ProcessingOptions): string;
  1202. }
  1203. }
  1204. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1205. /** @hidden */
  1206. export class ShaderDefineExpression {
  1207. isTrue(preprocessors: {
  1208. [key: string]: string;
  1209. }): boolean;
  1210. private static _OperatorPriority;
  1211. private static _Stack;
  1212. static postfixToInfix(postfix: string[]): string;
  1213. static infixToPostfix(infix: string): string[];
  1214. }
  1215. }
  1216. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1217. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1218. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1219. /** @hidden */
  1220. export class ShaderCodeTestNode extends ShaderCodeNode {
  1221. testExpression: ShaderDefineExpression;
  1222. isValid(preprocessors: {
  1223. [key: string]: string;
  1224. }): boolean;
  1225. }
  1226. }
  1227. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1228. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1229. /** @hidden */
  1230. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1231. define: string;
  1232. not: boolean;
  1233. constructor(define: string, not?: boolean);
  1234. isTrue(preprocessors: {
  1235. [key: string]: string;
  1236. }): boolean;
  1237. }
  1238. }
  1239. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1240. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1241. /** @hidden */
  1242. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1243. leftOperand: ShaderDefineExpression;
  1244. rightOperand: ShaderDefineExpression;
  1245. isTrue(preprocessors: {
  1246. [key: string]: string;
  1247. }): boolean;
  1248. }
  1249. }
  1250. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1251. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1252. /** @hidden */
  1253. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1254. leftOperand: ShaderDefineExpression;
  1255. rightOperand: ShaderDefineExpression;
  1256. isTrue(preprocessors: {
  1257. [key: string]: string;
  1258. }): boolean;
  1259. }
  1260. }
  1261. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1262. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1263. /** @hidden */
  1264. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1265. define: string;
  1266. operand: string;
  1267. testValue: string;
  1268. constructor(define: string, operand: string, testValue: string);
  1269. isTrue(preprocessors: {
  1270. [key: string]: string;
  1271. }): boolean;
  1272. }
  1273. }
  1274. declare module "babylonjs/Offline/IOfflineProvider" {
  1275. /**
  1276. * Class used to enable access to offline support
  1277. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1278. */
  1279. export interface IOfflineProvider {
  1280. /**
  1281. * Gets a boolean indicating if scene must be saved in the database
  1282. */
  1283. enableSceneOffline: boolean;
  1284. /**
  1285. * Gets a boolean indicating if textures must be saved in the database
  1286. */
  1287. enableTexturesOffline: boolean;
  1288. /**
  1289. * Open the offline support and make it available
  1290. * @param successCallback defines the callback to call on success
  1291. * @param errorCallback defines the callback to call on error
  1292. */
  1293. open(successCallback: () => void, errorCallback: () => void): void;
  1294. /**
  1295. * Loads an image from the offline support
  1296. * @param url defines the url to load from
  1297. * @param image defines the target DOM image
  1298. */
  1299. loadImage(url: string, image: HTMLImageElement): void;
  1300. /**
  1301. * Loads a file from offline support
  1302. * @param url defines the URL to load from
  1303. * @param sceneLoaded defines a callback to call on success
  1304. * @param progressCallBack defines a callback to call when progress changed
  1305. * @param errorCallback defines a callback to call on error
  1306. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1307. */
  1308. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1309. }
  1310. }
  1311. declare module "babylonjs/Misc/filesInputStore" {
  1312. /**
  1313. * Class used to help managing file picking and drag'n'drop
  1314. * File Storage
  1315. */
  1316. export class FilesInputStore {
  1317. /**
  1318. * List of files ready to be loaded
  1319. */
  1320. static FilesToLoad: {
  1321. [key: string]: File;
  1322. };
  1323. }
  1324. }
  1325. declare module "babylonjs/Misc/retryStrategy" {
  1326. import { WebRequest } from "babylonjs/Misc/webRequest";
  1327. /**
  1328. * Class used to define a retry strategy when error happens while loading assets
  1329. */
  1330. export class RetryStrategy {
  1331. /**
  1332. * Function used to defines an exponential back off strategy
  1333. * @param maxRetries defines the maximum number of retries (3 by default)
  1334. * @param baseInterval defines the interval between retries
  1335. * @returns the strategy function to use
  1336. */
  1337. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1338. }
  1339. }
  1340. declare module "babylonjs/Misc/baseError" {
  1341. /**
  1342. * @ignore
  1343. * Application error to support additional information when loading a file
  1344. */
  1345. export abstract class BaseError extends Error {
  1346. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1347. }
  1348. }
  1349. declare module "babylonjs/Misc/fileTools" {
  1350. import { WebRequest } from "babylonjs/Misc/webRequest";
  1351. import { Nullable } from "babylonjs/types";
  1352. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1353. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1354. import { BaseError } from "babylonjs/Misc/baseError";
  1355. /** @ignore */
  1356. export class LoadFileError extends BaseError {
  1357. request?: WebRequest;
  1358. file?: File;
  1359. /**
  1360. * Creates a new LoadFileError
  1361. * @param message defines the message of the error
  1362. * @param request defines the optional web request
  1363. * @param file defines the optional file
  1364. */
  1365. constructor(message: string, object?: WebRequest | File);
  1366. }
  1367. /** @ignore */
  1368. export class RequestFileError extends BaseError {
  1369. request: WebRequest;
  1370. /**
  1371. * Creates a new LoadFileError
  1372. * @param message defines the message of the error
  1373. * @param request defines the optional web request
  1374. */
  1375. constructor(message: string, request: WebRequest);
  1376. }
  1377. /** @ignore */
  1378. export class ReadFileError extends BaseError {
  1379. file: File;
  1380. /**
  1381. * Creates a new ReadFileError
  1382. * @param message defines the message of the error
  1383. * @param file defines the optional file
  1384. */
  1385. constructor(message: string, file: File);
  1386. }
  1387. /**
  1388. * @hidden
  1389. */
  1390. export class FileTools {
  1391. /**
  1392. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1393. */
  1394. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1395. /**
  1396. * Gets or sets the base URL to use to load assets
  1397. */
  1398. static BaseUrl: string;
  1399. /**
  1400. * Default behaviour for cors in the application.
  1401. * It can be a string if the expected behavior is identical in the entire app.
  1402. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1403. */
  1404. static CorsBehavior: string | ((url: string | string[]) => string);
  1405. /**
  1406. * Gets or sets a function used to pre-process url before using them to load assets
  1407. */
  1408. static PreprocessUrl: (url: string) => string;
  1409. /**
  1410. * Removes unwanted characters from an url
  1411. * @param url defines the url to clean
  1412. * @returns the cleaned url
  1413. */
  1414. private static _CleanUrl;
  1415. /**
  1416. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1417. * @param url define the url we are trying
  1418. * @param element define the dom element where to configure the cors policy
  1419. */
  1420. static SetCorsBehavior(url: string | string[], element: {
  1421. crossOrigin: string | null;
  1422. }): void;
  1423. /**
  1424. * Loads an image as an HTMLImageElement.
  1425. * @param input url string, ArrayBuffer, or Blob to load
  1426. * @param onLoad callback called when the image successfully loads
  1427. * @param onError callback called when the image fails to load
  1428. * @param offlineProvider offline provider for caching
  1429. * @param mimeType optional mime type
  1430. * @returns the HTMLImageElement of the loaded image
  1431. */
  1432. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1433. /**
  1434. * Reads a file from a File object
  1435. * @param file defines the file to load
  1436. * @param onSuccess defines the callback to call when data is loaded
  1437. * @param onProgress defines the callback to call during loading process
  1438. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1439. * @param onError defines the callback to call when an error occurs
  1440. * @returns a file request object
  1441. */
  1442. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1443. /**
  1444. * Loads a file from a url
  1445. * @param url url to load
  1446. * @param onSuccess callback called when the file successfully loads
  1447. * @param onProgress callback called while file is loading (if the server supports this mode)
  1448. * @param offlineProvider defines the offline provider for caching
  1449. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1450. * @param onError callback called when the file fails to load
  1451. * @returns a file request object
  1452. */
  1453. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1454. /**
  1455. * Loads a file
  1456. * @param url url to load
  1457. * @param onSuccess callback called when the file successfully loads
  1458. * @param onProgress callback called while file is loading (if the server supports this mode)
  1459. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1460. * @param onError callback called when the file fails to load
  1461. * @param onOpened callback called when the web request is opened
  1462. * @returns a file request object
  1463. */
  1464. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1465. /**
  1466. * Checks if the loaded document was accessed via `file:`-Protocol.
  1467. * @returns boolean
  1468. */
  1469. static IsFileURL(): boolean;
  1470. }
  1471. }
  1472. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1473. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1474. import { WebRequest } from "babylonjs/Misc/webRequest";
  1475. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1476. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1477. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1478. /** @hidden */
  1479. export class ShaderProcessor {
  1480. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1481. private static _ProcessPrecision;
  1482. private static _ExtractOperation;
  1483. private static _BuildSubExpression;
  1484. private static _BuildExpression;
  1485. private static _MoveCursorWithinIf;
  1486. private static _MoveCursor;
  1487. private static _EvaluatePreProcessors;
  1488. private static _PreparePreProcessors;
  1489. private static _ProcessShaderConversion;
  1490. private static _ProcessIncludes;
  1491. /**
  1492. * Loads a file from a url
  1493. * @param url url to load
  1494. * @param onSuccess callback called when the file successfully loads
  1495. * @param onProgress callback called while file is loading (if the server supports this mode)
  1496. * @param offlineProvider defines the offline provider for caching
  1497. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1498. * @param onError callback called when the file fails to load
  1499. * @returns a file request object
  1500. * @hidden
  1501. */
  1502. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1503. }
  1504. }
  1505. declare module "babylonjs/Maths/math.like" {
  1506. import { float, int, DeepImmutable } from "babylonjs/types";
  1507. /**
  1508. * @hidden
  1509. */
  1510. export interface IColor4Like {
  1511. r: float;
  1512. g: float;
  1513. b: float;
  1514. a: float;
  1515. }
  1516. /**
  1517. * @hidden
  1518. */
  1519. export interface IColor3Like {
  1520. r: float;
  1521. g: float;
  1522. b: float;
  1523. }
  1524. /**
  1525. * @hidden
  1526. */
  1527. export interface IVector4Like {
  1528. x: float;
  1529. y: float;
  1530. z: float;
  1531. w: float;
  1532. }
  1533. /**
  1534. * @hidden
  1535. */
  1536. export interface IVector3Like {
  1537. x: float;
  1538. y: float;
  1539. z: float;
  1540. }
  1541. /**
  1542. * @hidden
  1543. */
  1544. export interface IVector2Like {
  1545. x: float;
  1546. y: float;
  1547. }
  1548. /**
  1549. * @hidden
  1550. */
  1551. export interface IMatrixLike {
  1552. toArray(): DeepImmutable<Float32Array>;
  1553. updateFlag: int;
  1554. }
  1555. /**
  1556. * @hidden
  1557. */
  1558. export interface IViewportLike {
  1559. x: float;
  1560. y: float;
  1561. width: float;
  1562. height: float;
  1563. }
  1564. /**
  1565. * @hidden
  1566. */
  1567. export interface IPlaneLike {
  1568. normal: IVector3Like;
  1569. d: float;
  1570. normalize(): void;
  1571. }
  1572. }
  1573. declare module "babylonjs/Materials/iEffectFallbacks" {
  1574. import { Effect } from "babylonjs/Materials/effect";
  1575. /**
  1576. * Interface used to define common properties for effect fallbacks
  1577. */
  1578. export interface IEffectFallbacks {
  1579. /**
  1580. * Removes the defines that should be removed when falling back.
  1581. * @param currentDefines defines the current define statements for the shader.
  1582. * @param effect defines the current effect we try to compile
  1583. * @returns The resulting defines with defines of the current rank removed.
  1584. */
  1585. reduce(currentDefines: string, effect: Effect): string;
  1586. /**
  1587. * Removes the fallback from the bound mesh.
  1588. */
  1589. unBindMesh(): void;
  1590. /**
  1591. * Checks to see if more fallbacks are still availible.
  1592. */
  1593. hasMoreFallbacks: boolean;
  1594. }
  1595. }
  1596. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1597. /**
  1598. * Class used to evalaute queries containing `and` and `or` operators
  1599. */
  1600. export class AndOrNotEvaluator {
  1601. /**
  1602. * Evaluate a query
  1603. * @param query defines the query to evaluate
  1604. * @param evaluateCallback defines the callback used to filter result
  1605. * @returns true if the query matches
  1606. */
  1607. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1608. private static _HandleParenthesisContent;
  1609. private static _SimplifyNegation;
  1610. }
  1611. }
  1612. declare module "babylonjs/Misc/tags" {
  1613. /**
  1614. * Class used to store custom tags
  1615. */
  1616. export class Tags {
  1617. /**
  1618. * Adds support for tags on the given object
  1619. * @param obj defines the object to use
  1620. */
  1621. static EnableFor(obj: any): void;
  1622. /**
  1623. * Removes tags support
  1624. * @param obj defines the object to use
  1625. */
  1626. static DisableFor(obj: any): void;
  1627. /**
  1628. * Gets a boolean indicating if the given object has tags
  1629. * @param obj defines the object to use
  1630. * @returns a boolean
  1631. */
  1632. static HasTags(obj: any): boolean;
  1633. /**
  1634. * Gets the tags available on a given object
  1635. * @param obj defines the object to use
  1636. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1637. * @returns the tags
  1638. */
  1639. static GetTags(obj: any, asString?: boolean): any;
  1640. /**
  1641. * Adds tags to an object
  1642. * @param obj defines the object to use
  1643. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1644. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1645. */
  1646. static AddTagsTo(obj: any, tagsString: string): void;
  1647. /**
  1648. * @hidden
  1649. */
  1650. static _AddTagTo(obj: any, tag: string): void;
  1651. /**
  1652. * Removes specific tags from a specific object
  1653. * @param obj defines the object to use
  1654. * @param tagsString defines the tags to remove
  1655. */
  1656. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1657. /**
  1658. * @hidden
  1659. */
  1660. static _RemoveTagFrom(obj: any, tag: string): void;
  1661. /**
  1662. * Defines if tags hosted on an object match a given query
  1663. * @param obj defines the object to use
  1664. * @param tagsQuery defines the tag query
  1665. * @returns a boolean
  1666. */
  1667. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1668. }
  1669. }
  1670. declare module "babylonjs/Maths/math.scalar" {
  1671. /**
  1672. * Scalar computation library
  1673. */
  1674. export class Scalar {
  1675. /**
  1676. * Two pi constants convenient for computation.
  1677. */
  1678. static TwoPi: number;
  1679. /**
  1680. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1681. * @param a number
  1682. * @param b number
  1683. * @param epsilon (default = 1.401298E-45)
  1684. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1685. */
  1686. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1687. /**
  1688. * Returns a string : the upper case translation of the number i to hexadecimal.
  1689. * @param i number
  1690. * @returns the upper case translation of the number i to hexadecimal.
  1691. */
  1692. static ToHex(i: number): string;
  1693. /**
  1694. * Returns -1 if value is negative and +1 is value is positive.
  1695. * @param value the value
  1696. * @returns the value itself if it's equal to zero.
  1697. */
  1698. static Sign(value: number): number;
  1699. /**
  1700. * Returns the value itself if it's between min and max.
  1701. * Returns min if the value is lower than min.
  1702. * Returns max if the value is greater than max.
  1703. * @param value the value to clmap
  1704. * @param min the min value to clamp to (default: 0)
  1705. * @param max the max value to clamp to (default: 1)
  1706. * @returns the clamped value
  1707. */
  1708. static Clamp(value: number, min?: number, max?: number): number;
  1709. /**
  1710. * the log2 of value.
  1711. * @param value the value to compute log2 of
  1712. * @returns the log2 of value.
  1713. */
  1714. static Log2(value: number): number;
  1715. /**
  1716. * Loops the value, so that it is never larger than length and never smaller than 0.
  1717. *
  1718. * This is similar to the modulo operator but it works with floating point numbers.
  1719. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1720. * With t = 5 and length = 2.5, the result would be 0.0.
  1721. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1722. * @param value the value
  1723. * @param length the length
  1724. * @returns the looped value
  1725. */
  1726. static Repeat(value: number, length: number): number;
  1727. /**
  1728. * Normalize the value between 0.0 and 1.0 using min and max values
  1729. * @param value value to normalize
  1730. * @param min max to normalize between
  1731. * @param max min to normalize between
  1732. * @returns the normalized value
  1733. */
  1734. static Normalize(value: number, min: number, max: number): number;
  1735. /**
  1736. * Denormalize the value from 0.0 and 1.0 using min and max values
  1737. * @param normalized value to denormalize
  1738. * @param min max to denormalize between
  1739. * @param max min to denormalize between
  1740. * @returns the denormalized value
  1741. */
  1742. static Denormalize(normalized: number, min: number, max: number): number;
  1743. /**
  1744. * Calculates the shortest difference between two given angles given in degrees.
  1745. * @param current current angle in degrees
  1746. * @param target target angle in degrees
  1747. * @returns the delta
  1748. */
  1749. static DeltaAngle(current: number, target: number): number;
  1750. /**
  1751. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1752. * @param tx value
  1753. * @param length length
  1754. * @returns The returned value will move back and forth between 0 and length
  1755. */
  1756. static PingPong(tx: number, length: number): number;
  1757. /**
  1758. * Interpolates between min and max with smoothing at the limits.
  1759. *
  1760. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1761. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1762. * @param from from
  1763. * @param to to
  1764. * @param tx value
  1765. * @returns the smooth stepped value
  1766. */
  1767. static SmoothStep(from: number, to: number, tx: number): number;
  1768. /**
  1769. * Moves a value current towards target.
  1770. *
  1771. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1772. * Negative values of maxDelta pushes the value away from target.
  1773. * @param current current value
  1774. * @param target target value
  1775. * @param maxDelta max distance to move
  1776. * @returns resulting value
  1777. */
  1778. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1779. /**
  1780. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1781. *
  1782. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1783. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1784. * @param current current value
  1785. * @param target target value
  1786. * @param maxDelta max distance to move
  1787. * @returns resulting angle
  1788. */
  1789. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1790. /**
  1791. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1792. * @param start start value
  1793. * @param end target value
  1794. * @param amount amount to lerp between
  1795. * @returns the lerped value
  1796. */
  1797. static Lerp(start: number, end: number, amount: number): number;
  1798. /**
  1799. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1800. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1801. * @param start start value
  1802. * @param end target value
  1803. * @param amount amount to lerp between
  1804. * @returns the lerped value
  1805. */
  1806. static LerpAngle(start: number, end: number, amount: number): number;
  1807. /**
  1808. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1809. * @param a start value
  1810. * @param b target value
  1811. * @param value value between a and b
  1812. * @returns the inverseLerp value
  1813. */
  1814. static InverseLerp(a: number, b: number, value: number): number;
  1815. /**
  1816. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1817. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1818. * @param value1 spline value
  1819. * @param tangent1 spline value
  1820. * @param value2 spline value
  1821. * @param tangent2 spline value
  1822. * @param amount input value
  1823. * @returns hermite result
  1824. */
  1825. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1826. /**
  1827. * Returns a random float number between and min and max values
  1828. * @param min min value of random
  1829. * @param max max value of random
  1830. * @returns random value
  1831. */
  1832. static RandomRange(min: number, max: number): number;
  1833. /**
  1834. * This function returns percentage of a number in a given range.
  1835. *
  1836. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1837. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1838. * @param number to convert to percentage
  1839. * @param min min range
  1840. * @param max max range
  1841. * @returns the percentage
  1842. */
  1843. static RangeToPercent(number: number, min: number, max: number): number;
  1844. /**
  1845. * This function returns number that corresponds to the percentage in a given range.
  1846. *
  1847. * PercentToRange(0.34,0,100) will return 34.
  1848. * @param percent to convert to number
  1849. * @param min min range
  1850. * @param max max range
  1851. * @returns the number
  1852. */
  1853. static PercentToRange(percent: number, min: number, max: number): number;
  1854. /**
  1855. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1856. * @param angle The angle to normalize in radian.
  1857. * @return The converted angle.
  1858. */
  1859. static NormalizeRadians(angle: number): number;
  1860. }
  1861. }
  1862. declare module "babylonjs/Maths/math.constants" {
  1863. /**
  1864. * Constant used to convert a value to gamma space
  1865. * @ignorenaming
  1866. */
  1867. export const ToGammaSpace: number;
  1868. /**
  1869. * Constant used to convert a value to linear space
  1870. * @ignorenaming
  1871. */
  1872. export const ToLinearSpace = 2.2;
  1873. /**
  1874. * Constant used to define the minimal number value in Babylon.js
  1875. * @ignorenaming
  1876. */
  1877. let Epsilon: number;
  1878. export { Epsilon };
  1879. }
  1880. declare module "babylonjs/Maths/math.viewport" {
  1881. /**
  1882. * Class used to represent a viewport on screen
  1883. */
  1884. export class Viewport {
  1885. /** viewport left coordinate */
  1886. x: number;
  1887. /** viewport top coordinate */
  1888. y: number;
  1889. /**viewport width */
  1890. width: number;
  1891. /** viewport height */
  1892. height: number;
  1893. /**
  1894. * Creates a Viewport object located at (x, y) and sized (width, height)
  1895. * @param x defines viewport left coordinate
  1896. * @param y defines viewport top coordinate
  1897. * @param width defines the viewport width
  1898. * @param height defines the viewport height
  1899. */
  1900. constructor(
  1901. /** viewport left coordinate */
  1902. x: number,
  1903. /** viewport top coordinate */
  1904. y: number,
  1905. /**viewport width */
  1906. width: number,
  1907. /** viewport height */
  1908. height: number);
  1909. /**
  1910. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1911. * @param renderWidth defines the rendering width
  1912. * @param renderHeight defines the rendering height
  1913. * @returns a new Viewport
  1914. */
  1915. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1916. /**
  1917. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1918. * @param renderWidth defines the rendering width
  1919. * @param renderHeight defines the rendering height
  1920. * @param ref defines the target viewport
  1921. * @returns the current viewport
  1922. */
  1923. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1924. /**
  1925. * Returns a new Viewport copied from the current one
  1926. * @returns a new Viewport
  1927. */
  1928. clone(): Viewport;
  1929. }
  1930. }
  1931. declare module "babylonjs/Misc/arrayTools" {
  1932. /**
  1933. * Class containing a set of static utilities functions for arrays.
  1934. */
  1935. export class ArrayTools {
  1936. /**
  1937. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1938. * @param size the number of element to construct and put in the array
  1939. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1940. * @returns a new array filled with new objects
  1941. */
  1942. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1943. }
  1944. }
  1945. declare module "babylonjs/Maths/math.plane" {
  1946. import { DeepImmutable } from "babylonjs/types";
  1947. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1948. /**
  1949. * Represents a plane by the equation ax + by + cz + d = 0
  1950. */
  1951. export class Plane {
  1952. private static _TmpMatrix;
  1953. /**
  1954. * Normal of the plane (a,b,c)
  1955. */
  1956. normal: Vector3;
  1957. /**
  1958. * d component of the plane
  1959. */
  1960. d: number;
  1961. /**
  1962. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1963. * @param a a component of the plane
  1964. * @param b b component of the plane
  1965. * @param c c component of the plane
  1966. * @param d d component of the plane
  1967. */
  1968. constructor(a: number, b: number, c: number, d: number);
  1969. /**
  1970. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1971. */
  1972. asArray(): number[];
  1973. /**
  1974. * @returns a new plane copied from the current Plane.
  1975. */
  1976. clone(): Plane;
  1977. /**
  1978. * @returns the string "Plane".
  1979. */
  1980. getClassName(): string;
  1981. /**
  1982. * @returns the Plane hash code.
  1983. */
  1984. getHashCode(): number;
  1985. /**
  1986. * Normalize the current Plane in place.
  1987. * @returns the updated Plane.
  1988. */
  1989. normalize(): Plane;
  1990. /**
  1991. * Applies a transformation the plane and returns the result
  1992. * @param transformation the transformation matrix to be applied to the plane
  1993. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1994. */
  1995. transform(transformation: DeepImmutable<Matrix>): Plane;
  1996. /**
  1997. * Compute the dot product between the point and the plane normal
  1998. * @param point point to calculate the dot product with
  1999. * @returns the dot product (float) of the point coordinates and the plane normal.
  2000. */
  2001. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2002. /**
  2003. * Updates the current Plane from the plane defined by the three given points.
  2004. * @param point1 one of the points used to contruct the plane
  2005. * @param point2 one of the points used to contruct the plane
  2006. * @param point3 one of the points used to contruct the plane
  2007. * @returns the updated Plane.
  2008. */
  2009. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2010. /**
  2011. * Checks if the plane is facing a given direction
  2012. * @param direction the direction to check if the plane is facing
  2013. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2014. * @returns True is the vector "direction" is the same side than the plane normal.
  2015. */
  2016. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2017. /**
  2018. * Calculates the distance to a point
  2019. * @param point point to calculate distance to
  2020. * @returns the signed distance (float) from the given point to the Plane.
  2021. */
  2022. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2023. /**
  2024. * Creates a plane from an array
  2025. * @param array the array to create a plane from
  2026. * @returns a new Plane from the given array.
  2027. */
  2028. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2029. /**
  2030. * Creates a plane from three points
  2031. * @param point1 point used to create the plane
  2032. * @param point2 point used to create the plane
  2033. * @param point3 point used to create the plane
  2034. * @returns a new Plane defined by the three given points.
  2035. */
  2036. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2037. /**
  2038. * Creates a plane from an origin point and a normal
  2039. * @param origin origin of the plane to be constructed
  2040. * @param normal normal of the plane to be constructed
  2041. * @returns a new Plane the normal vector to this plane at the given origin point.
  2042. * Note : the vector "normal" is updated because normalized.
  2043. */
  2044. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2045. /**
  2046. * Calculates the distance from a plane and a point
  2047. * @param origin origin of the plane to be constructed
  2048. * @param normal normal of the plane to be constructed
  2049. * @param point point to calculate distance to
  2050. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2051. */
  2052. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2053. }
  2054. }
  2055. declare module "babylonjs/Maths/math.vector" {
  2056. import { Viewport } from "babylonjs/Maths/math.viewport";
  2057. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2058. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2059. import { Plane } from "babylonjs/Maths/math.plane";
  2060. /**
  2061. * Class representing a vector containing 2 coordinates
  2062. */
  2063. export class Vector2 {
  2064. /** defines the first coordinate */
  2065. x: number;
  2066. /** defines the second coordinate */
  2067. y: number;
  2068. /**
  2069. * Creates a new Vector2 from the given x and y coordinates
  2070. * @param x defines the first coordinate
  2071. * @param y defines the second coordinate
  2072. */
  2073. constructor(
  2074. /** defines the first coordinate */
  2075. x?: number,
  2076. /** defines the second coordinate */
  2077. y?: number);
  2078. /**
  2079. * Gets a string with the Vector2 coordinates
  2080. * @returns a string with the Vector2 coordinates
  2081. */
  2082. toString(): string;
  2083. /**
  2084. * Gets class name
  2085. * @returns the string "Vector2"
  2086. */
  2087. getClassName(): string;
  2088. /**
  2089. * Gets current vector hash code
  2090. * @returns the Vector2 hash code as a number
  2091. */
  2092. getHashCode(): number;
  2093. /**
  2094. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2095. * @param array defines the source array
  2096. * @param index defines the offset in source array
  2097. * @returns the current Vector2
  2098. */
  2099. toArray(array: FloatArray, index?: number): Vector2;
  2100. /**
  2101. * Copy the current vector to an array
  2102. * @returns a new array with 2 elements: the Vector2 coordinates.
  2103. */
  2104. asArray(): number[];
  2105. /**
  2106. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2107. * @param source defines the source Vector2
  2108. * @returns the current updated Vector2
  2109. */
  2110. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2111. /**
  2112. * Sets the Vector2 coordinates with the given floats
  2113. * @param x defines the first coordinate
  2114. * @param y defines the second coordinate
  2115. * @returns the current updated Vector2
  2116. */
  2117. copyFromFloats(x: number, y: number): Vector2;
  2118. /**
  2119. * Sets the Vector2 coordinates with the given floats
  2120. * @param x defines the first coordinate
  2121. * @param y defines the second coordinate
  2122. * @returns the current updated Vector2
  2123. */
  2124. set(x: number, y: number): Vector2;
  2125. /**
  2126. * Add another vector with the current one
  2127. * @param otherVector defines the other vector
  2128. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2129. */
  2130. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2131. /**
  2132. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2133. * @param otherVector defines the other vector
  2134. * @param result defines the target vector
  2135. * @returns the unmodified current Vector2
  2136. */
  2137. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2138. /**
  2139. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2140. * @param otherVector defines the other vector
  2141. * @returns the current updated Vector2
  2142. */
  2143. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2144. /**
  2145. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2146. * @param otherVector defines the other vector
  2147. * @returns a new Vector2
  2148. */
  2149. addVector3(otherVector: Vector3): Vector2;
  2150. /**
  2151. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2152. * @param otherVector defines the other vector
  2153. * @returns a new Vector2
  2154. */
  2155. subtract(otherVector: Vector2): Vector2;
  2156. /**
  2157. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2158. * @param otherVector defines the other vector
  2159. * @param result defines the target vector
  2160. * @returns the unmodified current Vector2
  2161. */
  2162. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2163. /**
  2164. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2165. * @param otherVector defines the other vector
  2166. * @returns the current updated Vector2
  2167. */
  2168. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2169. /**
  2170. * Multiplies in place the current Vector2 coordinates by the given ones
  2171. * @param otherVector defines the other vector
  2172. * @returns the current updated Vector2
  2173. */
  2174. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2175. /**
  2176. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2177. * @param otherVector defines the other vector
  2178. * @returns a new Vector2
  2179. */
  2180. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2181. /**
  2182. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2183. * @param otherVector defines the other vector
  2184. * @param result defines the target vector
  2185. * @returns the unmodified current Vector2
  2186. */
  2187. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2188. /**
  2189. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2190. * @param x defines the first coordinate
  2191. * @param y defines the second coordinate
  2192. * @returns a new Vector2
  2193. */
  2194. multiplyByFloats(x: number, y: number): Vector2;
  2195. /**
  2196. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2197. * @param otherVector defines the other vector
  2198. * @returns a new Vector2
  2199. */
  2200. divide(otherVector: Vector2): Vector2;
  2201. /**
  2202. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2203. * @param otherVector defines the other vector
  2204. * @param result defines the target vector
  2205. * @returns the unmodified current Vector2
  2206. */
  2207. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2208. /**
  2209. * Divides the current Vector2 coordinates by the given ones
  2210. * @param otherVector defines the other vector
  2211. * @returns the current updated Vector2
  2212. */
  2213. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2214. /**
  2215. * Gets a new Vector2 with current Vector2 negated coordinates
  2216. * @returns a new Vector2
  2217. */
  2218. negate(): Vector2;
  2219. /**
  2220. * Negate this vector in place
  2221. * @returns this
  2222. */
  2223. negateInPlace(): Vector2;
  2224. /**
  2225. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2226. * @param result defines the Vector3 object where to store the result
  2227. * @returns the current Vector2
  2228. */
  2229. negateToRef(result: Vector2): Vector2;
  2230. /**
  2231. * Multiply the Vector2 coordinates by scale
  2232. * @param scale defines the scaling factor
  2233. * @returns the current updated Vector2
  2234. */
  2235. scaleInPlace(scale: number): Vector2;
  2236. /**
  2237. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2238. * @param scale defines the scaling factor
  2239. * @returns a new Vector2
  2240. */
  2241. scale(scale: number): Vector2;
  2242. /**
  2243. * Scale the current Vector2 values by a factor to a given Vector2
  2244. * @param scale defines the scale factor
  2245. * @param result defines the Vector2 object where to store the result
  2246. * @returns the unmodified current Vector2
  2247. */
  2248. scaleToRef(scale: number, result: Vector2): Vector2;
  2249. /**
  2250. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2251. * @param scale defines the scale factor
  2252. * @param result defines the Vector2 object where to store the result
  2253. * @returns the unmodified current Vector2
  2254. */
  2255. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2256. /**
  2257. * Gets a boolean if two vectors are equals
  2258. * @param otherVector defines the other vector
  2259. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2260. */
  2261. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2262. /**
  2263. * Gets a boolean if two vectors are equals (using an epsilon value)
  2264. * @param otherVector defines the other vector
  2265. * @param epsilon defines the minimal distance to consider equality
  2266. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2267. */
  2268. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2269. /**
  2270. * Gets a new Vector2 from current Vector2 floored values
  2271. * @returns a new Vector2
  2272. */
  2273. floor(): Vector2;
  2274. /**
  2275. * Gets a new Vector2 from current Vector2 floored values
  2276. * @returns a new Vector2
  2277. */
  2278. fract(): Vector2;
  2279. /**
  2280. * Gets the length of the vector
  2281. * @returns the vector length (float)
  2282. */
  2283. length(): number;
  2284. /**
  2285. * Gets the vector squared length
  2286. * @returns the vector squared length (float)
  2287. */
  2288. lengthSquared(): number;
  2289. /**
  2290. * Normalize the vector
  2291. * @returns the current updated Vector2
  2292. */
  2293. normalize(): Vector2;
  2294. /**
  2295. * Gets a new Vector2 copied from the Vector2
  2296. * @returns a new Vector2
  2297. */
  2298. clone(): Vector2;
  2299. /**
  2300. * Gets a new Vector2(0, 0)
  2301. * @returns a new Vector2
  2302. */
  2303. static Zero(): Vector2;
  2304. /**
  2305. * Gets a new Vector2(1, 1)
  2306. * @returns a new Vector2
  2307. */
  2308. static One(): Vector2;
  2309. /**
  2310. * Gets a new Vector2 set from the given index element of the given array
  2311. * @param array defines the data source
  2312. * @param offset defines the offset in the data source
  2313. * @returns a new Vector2
  2314. */
  2315. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2316. /**
  2317. * Sets "result" from the given index element of the given array
  2318. * @param array defines the data source
  2319. * @param offset defines the offset in the data source
  2320. * @param result defines the target vector
  2321. */
  2322. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2323. /**
  2324. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2325. * @param value1 defines 1st point of control
  2326. * @param value2 defines 2nd point of control
  2327. * @param value3 defines 3rd point of control
  2328. * @param value4 defines 4th point of control
  2329. * @param amount defines the interpolation factor
  2330. * @returns a new Vector2
  2331. */
  2332. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2333. /**
  2334. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2335. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2336. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2337. * @param value defines the value to clamp
  2338. * @param min defines the lower limit
  2339. * @param max defines the upper limit
  2340. * @returns a new Vector2
  2341. */
  2342. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2343. /**
  2344. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2345. * @param value1 defines the 1st control point
  2346. * @param tangent1 defines the outgoing tangent
  2347. * @param value2 defines the 2nd control point
  2348. * @param tangent2 defines the incoming tangent
  2349. * @param amount defines the interpolation factor
  2350. * @returns a new Vector2
  2351. */
  2352. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2353. /**
  2354. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2355. * @param start defines the start vector
  2356. * @param end defines the end vector
  2357. * @param amount defines the interpolation factor
  2358. * @returns a new Vector2
  2359. */
  2360. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2361. /**
  2362. * Gets the dot product of the vector "left" and the vector "right"
  2363. * @param left defines first vector
  2364. * @param right defines second vector
  2365. * @returns the dot product (float)
  2366. */
  2367. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2368. /**
  2369. * Returns a new Vector2 equal to the normalized given vector
  2370. * @param vector defines the vector to normalize
  2371. * @returns a new Vector2
  2372. */
  2373. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2374. /**
  2375. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2376. * @param left defines 1st vector
  2377. * @param right defines 2nd vector
  2378. * @returns a new Vector2
  2379. */
  2380. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2381. /**
  2382. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2383. * @param left defines 1st vector
  2384. * @param right defines 2nd vector
  2385. * @returns a new Vector2
  2386. */
  2387. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2388. /**
  2389. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2390. * @param vector defines the vector to transform
  2391. * @param transformation defines the matrix to apply
  2392. * @returns a new Vector2
  2393. */
  2394. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2395. /**
  2396. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2397. * @param vector defines the vector to transform
  2398. * @param transformation defines the matrix to apply
  2399. * @param result defines the target vector
  2400. */
  2401. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2402. /**
  2403. * Determines if a given vector is included in a triangle
  2404. * @param p defines the vector to test
  2405. * @param p0 defines 1st triangle point
  2406. * @param p1 defines 2nd triangle point
  2407. * @param p2 defines 3rd triangle point
  2408. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2409. */
  2410. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2411. /**
  2412. * Gets the distance between the vectors "value1" and "value2"
  2413. * @param value1 defines first vector
  2414. * @param value2 defines second vector
  2415. * @returns the distance between vectors
  2416. */
  2417. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2418. /**
  2419. * Returns the squared distance between the vectors "value1" and "value2"
  2420. * @param value1 defines first vector
  2421. * @param value2 defines second vector
  2422. * @returns the squared distance between vectors
  2423. */
  2424. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2425. /**
  2426. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2427. * @param value1 defines first vector
  2428. * @param value2 defines second vector
  2429. * @returns a new Vector2
  2430. */
  2431. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2432. /**
  2433. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2434. * @param p defines the middle point
  2435. * @param segA defines one point of the segment
  2436. * @param segB defines the other point of the segment
  2437. * @returns the shortest distance
  2438. */
  2439. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2440. }
  2441. /**
  2442. * Class used to store (x,y,z) vector representation
  2443. * A Vector3 is the main object used in 3D geometry
  2444. * It can represent etiher the coordinates of a point the space, either a direction
  2445. * Reminder: js uses a left handed forward facing system
  2446. */
  2447. export class Vector3 {
  2448. private static _UpReadOnly;
  2449. private static _ZeroReadOnly;
  2450. /** @hidden */
  2451. _x: number;
  2452. /** @hidden */
  2453. _y: number;
  2454. /** @hidden */
  2455. _z: number;
  2456. /** @hidden */
  2457. _isDirty: boolean;
  2458. /** Gets or sets the x coordinate */
  2459. get x(): number;
  2460. set x(value: number);
  2461. /** Gets or sets the y coordinate */
  2462. get y(): number;
  2463. set y(value: number);
  2464. /** Gets or sets the z coordinate */
  2465. get z(): number;
  2466. set z(value: number);
  2467. /**
  2468. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2469. * @param x defines the first coordinates (on X axis)
  2470. * @param y defines the second coordinates (on Y axis)
  2471. * @param z defines the third coordinates (on Z axis)
  2472. */
  2473. constructor(x?: number, y?: number, z?: number);
  2474. /**
  2475. * Creates a string representation of the Vector3
  2476. * @returns a string with the Vector3 coordinates.
  2477. */
  2478. toString(): string;
  2479. /**
  2480. * Gets the class name
  2481. * @returns the string "Vector3"
  2482. */
  2483. getClassName(): string;
  2484. /**
  2485. * Creates the Vector3 hash code
  2486. * @returns a number which tends to be unique between Vector3 instances
  2487. */
  2488. getHashCode(): number;
  2489. /**
  2490. * Creates an array containing three elements : the coordinates of the Vector3
  2491. * @returns a new array of numbers
  2492. */
  2493. asArray(): number[];
  2494. /**
  2495. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2496. * @param array defines the destination array
  2497. * @param index defines the offset in the destination array
  2498. * @returns the current Vector3
  2499. */
  2500. toArray(array: FloatArray, index?: number): Vector3;
  2501. /**
  2502. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2503. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2504. */
  2505. toQuaternion(): Quaternion;
  2506. /**
  2507. * Adds the given vector to the current Vector3
  2508. * @param otherVector defines the second operand
  2509. * @returns the current updated Vector3
  2510. */
  2511. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2512. /**
  2513. * Adds the given coordinates to the current Vector3
  2514. * @param x defines the x coordinate of the operand
  2515. * @param y defines the y coordinate of the operand
  2516. * @param z defines the z coordinate of the operand
  2517. * @returns the current updated Vector3
  2518. */
  2519. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2520. /**
  2521. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2522. * @param otherVector defines the second operand
  2523. * @returns the resulting Vector3
  2524. */
  2525. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2526. /**
  2527. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2528. * @param otherVector defines the second operand
  2529. * @param result defines the Vector3 object where to store the result
  2530. * @returns the current Vector3
  2531. */
  2532. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2533. /**
  2534. * Subtract the given vector from the current Vector3
  2535. * @param otherVector defines the second operand
  2536. * @returns the current updated Vector3
  2537. */
  2538. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2539. /**
  2540. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2541. * @param otherVector defines the second operand
  2542. * @returns the resulting Vector3
  2543. */
  2544. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2545. /**
  2546. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2547. * @param otherVector defines the second operand
  2548. * @param result defines the Vector3 object where to store the result
  2549. * @returns the current Vector3
  2550. */
  2551. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2552. /**
  2553. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2554. * @param x defines the x coordinate of the operand
  2555. * @param y defines the y coordinate of the operand
  2556. * @param z defines the z coordinate of the operand
  2557. * @returns the resulting Vector3
  2558. */
  2559. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2560. /**
  2561. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2562. * @param x defines the x coordinate of the operand
  2563. * @param y defines the y coordinate of the operand
  2564. * @param z defines the z coordinate of the operand
  2565. * @param result defines the Vector3 object where to store the result
  2566. * @returns the current Vector3
  2567. */
  2568. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2569. /**
  2570. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2571. * @returns a new Vector3
  2572. */
  2573. negate(): Vector3;
  2574. /**
  2575. * Negate this vector in place
  2576. * @returns this
  2577. */
  2578. negateInPlace(): Vector3;
  2579. /**
  2580. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2581. * @param result defines the Vector3 object where to store the result
  2582. * @returns the current Vector3
  2583. */
  2584. negateToRef(result: Vector3): Vector3;
  2585. /**
  2586. * Multiplies the Vector3 coordinates by the float "scale"
  2587. * @param scale defines the multiplier factor
  2588. * @returns the current updated Vector3
  2589. */
  2590. scaleInPlace(scale: number): Vector3;
  2591. /**
  2592. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2593. * @param scale defines the multiplier factor
  2594. * @returns a new Vector3
  2595. */
  2596. scale(scale: number): Vector3;
  2597. /**
  2598. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2599. * @param scale defines the multiplier factor
  2600. * @param result defines the Vector3 object where to store the result
  2601. * @returns the current Vector3
  2602. */
  2603. scaleToRef(scale: number, result: Vector3): Vector3;
  2604. /**
  2605. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2606. * @param scale defines the scale factor
  2607. * @param result defines the Vector3 object where to store the result
  2608. * @returns the unmodified current Vector3
  2609. */
  2610. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2611. /**
  2612. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2613. * @param origin defines the origin of the projection ray
  2614. * @param plane defines the plane to project to
  2615. * @returns the projected vector3
  2616. */
  2617. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2618. /**
  2619. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2620. * @param origin defines the origin of the projection ray
  2621. * @param plane defines the plane to project to
  2622. * @param result defines the Vector3 where to store the result
  2623. */
  2624. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2625. /**
  2626. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2627. * @param otherVector defines the second operand
  2628. * @returns true if both vectors are equals
  2629. */
  2630. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2631. /**
  2632. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2633. * @param otherVector defines the second operand
  2634. * @param epsilon defines the minimal distance to define values as equals
  2635. * @returns true if both vectors are distant less than epsilon
  2636. */
  2637. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2638. /**
  2639. * Returns true if the current Vector3 coordinates equals the given floats
  2640. * @param x defines the x coordinate of the operand
  2641. * @param y defines the y coordinate of the operand
  2642. * @param z defines the z coordinate of the operand
  2643. * @returns true if both vectors are equals
  2644. */
  2645. equalsToFloats(x: number, y: number, z: number): boolean;
  2646. /**
  2647. * Multiplies the current Vector3 coordinates by the given ones
  2648. * @param otherVector defines the second operand
  2649. * @returns the current updated Vector3
  2650. */
  2651. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2652. /**
  2653. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2654. * @param otherVector defines the second operand
  2655. * @returns the new Vector3
  2656. */
  2657. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2658. /**
  2659. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2660. * @param otherVector defines the second operand
  2661. * @param result defines the Vector3 object where to store the result
  2662. * @returns the current Vector3
  2663. */
  2664. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2665. /**
  2666. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2667. * @param x defines the x coordinate of the operand
  2668. * @param y defines the y coordinate of the operand
  2669. * @param z defines the z coordinate of the operand
  2670. * @returns the new Vector3
  2671. */
  2672. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2673. /**
  2674. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2675. * @param otherVector defines the second operand
  2676. * @returns the new Vector3
  2677. */
  2678. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2679. /**
  2680. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2681. * @param otherVector defines the second operand
  2682. * @param result defines the Vector3 object where to store the result
  2683. * @returns the current Vector3
  2684. */
  2685. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2686. /**
  2687. * Divides the current Vector3 coordinates by the given ones.
  2688. * @param otherVector defines the second operand
  2689. * @returns the current updated Vector3
  2690. */
  2691. divideInPlace(otherVector: Vector3): Vector3;
  2692. /**
  2693. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2694. * @param other defines the second operand
  2695. * @returns the current updated Vector3
  2696. */
  2697. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2698. /**
  2699. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2700. * @param other defines the second operand
  2701. * @returns the current updated Vector3
  2702. */
  2703. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2704. /**
  2705. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2706. * @param x defines the x coordinate of the operand
  2707. * @param y defines the y coordinate of the operand
  2708. * @param z defines the z coordinate of the operand
  2709. * @returns the current updated Vector3
  2710. */
  2711. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2712. /**
  2713. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2714. * @param x defines the x coordinate of the operand
  2715. * @param y defines the y coordinate of the operand
  2716. * @param z defines the z coordinate of the operand
  2717. * @returns the current updated Vector3
  2718. */
  2719. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2720. /**
  2721. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2722. * Check if is non uniform within a certain amount of decimal places to account for this
  2723. * @param epsilon the amount the values can differ
  2724. * @returns if the the vector is non uniform to a certain number of decimal places
  2725. */
  2726. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2727. /**
  2728. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2729. */
  2730. get isNonUniform(): boolean;
  2731. /**
  2732. * Gets a new Vector3 from current Vector3 floored values
  2733. * @returns a new Vector3
  2734. */
  2735. floor(): Vector3;
  2736. /**
  2737. * Gets a new Vector3 from current Vector3 floored values
  2738. * @returns a new Vector3
  2739. */
  2740. fract(): Vector3;
  2741. /**
  2742. * Gets the length of the Vector3
  2743. * @returns the length of the Vector3
  2744. */
  2745. length(): number;
  2746. /**
  2747. * Gets the squared length of the Vector3
  2748. * @returns squared length of the Vector3
  2749. */
  2750. lengthSquared(): number;
  2751. /**
  2752. * Normalize the current Vector3.
  2753. * Please note that this is an in place operation.
  2754. * @returns the current updated Vector3
  2755. */
  2756. normalize(): Vector3;
  2757. /**
  2758. * Reorders the x y z properties of the vector in place
  2759. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2760. * @returns the current updated vector
  2761. */
  2762. reorderInPlace(order: string): this;
  2763. /**
  2764. * Rotates the vector around 0,0,0 by a quaternion
  2765. * @param quaternion the rotation quaternion
  2766. * @param result vector to store the result
  2767. * @returns the resulting vector
  2768. */
  2769. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2770. /**
  2771. * Rotates a vector around a given point
  2772. * @param quaternion the rotation quaternion
  2773. * @param point the point to rotate around
  2774. * @param result vector to store the result
  2775. * @returns the resulting vector
  2776. */
  2777. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2778. /**
  2779. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2780. * The cross product is then orthogonal to both current and "other"
  2781. * @param other defines the right operand
  2782. * @returns the cross product
  2783. */
  2784. cross(other: Vector3): Vector3;
  2785. /**
  2786. * Normalize the current Vector3 with the given input length.
  2787. * Please note that this is an in place operation.
  2788. * @param len the length of the vector
  2789. * @returns the current updated Vector3
  2790. */
  2791. normalizeFromLength(len: number): Vector3;
  2792. /**
  2793. * Normalize the current Vector3 to a new vector
  2794. * @returns the new Vector3
  2795. */
  2796. normalizeToNew(): Vector3;
  2797. /**
  2798. * Normalize the current Vector3 to the reference
  2799. * @param reference define the Vector3 to update
  2800. * @returns the updated Vector3
  2801. */
  2802. normalizeToRef(reference: Vector3): Vector3;
  2803. /**
  2804. * Creates a new Vector3 copied from the current Vector3
  2805. * @returns the new Vector3
  2806. */
  2807. clone(): Vector3;
  2808. /**
  2809. * Copies the given vector coordinates to the current Vector3 ones
  2810. * @param source defines the source Vector3
  2811. * @returns the current updated Vector3
  2812. */
  2813. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2814. /**
  2815. * Copies the given floats to the current Vector3 coordinates
  2816. * @param x defines the x coordinate of the operand
  2817. * @param y defines the y coordinate of the operand
  2818. * @param z defines the z coordinate of the operand
  2819. * @returns the current updated Vector3
  2820. */
  2821. copyFromFloats(x: number, y: number, z: number): Vector3;
  2822. /**
  2823. * Copies the given floats to the current Vector3 coordinates
  2824. * @param x defines the x coordinate of the operand
  2825. * @param y defines the y coordinate of the operand
  2826. * @param z defines the z coordinate of the operand
  2827. * @returns the current updated Vector3
  2828. */
  2829. set(x: number, y: number, z: number): Vector3;
  2830. /**
  2831. * Copies the given float to the current Vector3 coordinates
  2832. * @param v defines the x, y and z coordinates of the operand
  2833. * @returns the current updated Vector3
  2834. */
  2835. setAll(v: number): Vector3;
  2836. /**
  2837. * Get the clip factor between two vectors
  2838. * @param vector0 defines the first operand
  2839. * @param vector1 defines the second operand
  2840. * @param axis defines the axis to use
  2841. * @param size defines the size along the axis
  2842. * @returns the clip factor
  2843. */
  2844. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2845. /**
  2846. * Get angle between two vectors
  2847. * @param vector0 angle between vector0 and vector1
  2848. * @param vector1 angle between vector0 and vector1
  2849. * @param normal direction of the normal
  2850. * @return the angle between vector0 and vector1
  2851. */
  2852. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2853. /**
  2854. * Returns a new Vector3 set from the index "offset" of the given array
  2855. * @param array defines the source array
  2856. * @param offset defines the offset in the source array
  2857. * @returns the new Vector3
  2858. */
  2859. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2860. /**
  2861. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2862. * @param array defines the source array
  2863. * @param offset defines the offset in the source array
  2864. * @returns the new Vector3
  2865. * @deprecated Please use FromArray instead.
  2866. */
  2867. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2868. /**
  2869. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2870. * @param array defines the source array
  2871. * @param offset defines the offset in the source array
  2872. * @param result defines the Vector3 where to store the result
  2873. */
  2874. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2875. /**
  2876. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2877. * @param array defines the source array
  2878. * @param offset defines the offset in the source array
  2879. * @param result defines the Vector3 where to store the result
  2880. * @deprecated Please use FromArrayToRef instead.
  2881. */
  2882. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2883. /**
  2884. * Sets the given vector "result" with the given floats.
  2885. * @param x defines the x coordinate of the source
  2886. * @param y defines the y coordinate of the source
  2887. * @param z defines the z coordinate of the source
  2888. * @param result defines the Vector3 where to store the result
  2889. */
  2890. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2891. /**
  2892. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2893. * @returns a new empty Vector3
  2894. */
  2895. static Zero(): Vector3;
  2896. /**
  2897. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2898. * @returns a new unit Vector3
  2899. */
  2900. static One(): Vector3;
  2901. /**
  2902. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2903. * @returns a new up Vector3
  2904. */
  2905. static Up(): Vector3;
  2906. /**
  2907. * Gets a up Vector3 that must not be updated
  2908. */
  2909. static get UpReadOnly(): DeepImmutable<Vector3>;
  2910. /**
  2911. * Gets a zero Vector3 that must not be updated
  2912. */
  2913. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2914. /**
  2915. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2916. * @returns a new down Vector3
  2917. */
  2918. static Down(): Vector3;
  2919. /**
  2920. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2921. * @param rightHandedSystem is the scene right-handed (negative z)
  2922. * @returns a new forward Vector3
  2923. */
  2924. static Forward(rightHandedSystem?: boolean): Vector3;
  2925. /**
  2926. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2927. * @param rightHandedSystem is the scene right-handed (negative-z)
  2928. * @returns a new forward Vector3
  2929. */
  2930. static Backward(rightHandedSystem?: boolean): Vector3;
  2931. /**
  2932. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2933. * @returns a new right Vector3
  2934. */
  2935. static Right(): Vector3;
  2936. /**
  2937. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2938. * @returns a new left Vector3
  2939. */
  2940. static Left(): Vector3;
  2941. /**
  2942. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2943. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2944. * @param vector defines the Vector3 to transform
  2945. * @param transformation defines the transformation matrix
  2946. * @returns the transformed Vector3
  2947. */
  2948. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2949. /**
  2950. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2951. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2952. * @param vector defines the Vector3 to transform
  2953. * @param transformation defines the transformation matrix
  2954. * @param result defines the Vector3 where to store the result
  2955. */
  2956. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2957. /**
  2958. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2959. * This method computes tranformed coordinates only, not transformed direction vectors
  2960. * @param x define the x coordinate of the source vector
  2961. * @param y define the y coordinate of the source vector
  2962. * @param z define the z coordinate of the source vector
  2963. * @param transformation defines the transformation matrix
  2964. * @param result defines the Vector3 where to store the result
  2965. */
  2966. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2967. /**
  2968. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2969. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2970. * @param vector defines the Vector3 to transform
  2971. * @param transformation defines the transformation matrix
  2972. * @returns the new Vector3
  2973. */
  2974. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2975. /**
  2976. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2977. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2978. * @param vector defines the Vector3 to transform
  2979. * @param transformation defines the transformation matrix
  2980. * @param result defines the Vector3 where to store the result
  2981. */
  2982. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2983. /**
  2984. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2985. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2986. * @param x define the x coordinate of the source vector
  2987. * @param y define the y coordinate of the source vector
  2988. * @param z define the z coordinate of the source vector
  2989. * @param transformation defines the transformation matrix
  2990. * @param result defines the Vector3 where to store the result
  2991. */
  2992. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2993. /**
  2994. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2995. * @param value1 defines the first control point
  2996. * @param value2 defines the second control point
  2997. * @param value3 defines the third control point
  2998. * @param value4 defines the fourth control point
  2999. * @param amount defines the amount on the spline to use
  3000. * @returns the new Vector3
  3001. */
  3002. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3003. /**
  3004. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3005. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3006. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3007. * @param value defines the current value
  3008. * @param min defines the lower range value
  3009. * @param max defines the upper range value
  3010. * @returns the new Vector3
  3011. */
  3012. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3013. /**
  3014. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3015. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3016. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3017. * @param value defines the current value
  3018. * @param min defines the lower range value
  3019. * @param max defines the upper range value
  3020. * @param result defines the Vector3 where to store the result
  3021. */
  3022. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3023. /**
  3024. * Checks if a given vector is inside a specific range
  3025. * @param v defines the vector to test
  3026. * @param min defines the minimum range
  3027. * @param max defines the maximum range
  3028. */
  3029. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3030. /**
  3031. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3032. * @param value1 defines the first control point
  3033. * @param tangent1 defines the first tangent vector
  3034. * @param value2 defines the second control point
  3035. * @param tangent2 defines the second tangent vector
  3036. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3037. * @returns the new Vector3
  3038. */
  3039. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3040. /**
  3041. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3042. * @param start defines the start value
  3043. * @param end defines the end value
  3044. * @param amount max defines amount between both (between 0 and 1)
  3045. * @returns the new Vector3
  3046. */
  3047. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3048. /**
  3049. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3050. * @param start defines the start value
  3051. * @param end defines the end value
  3052. * @param amount max defines amount between both (between 0 and 1)
  3053. * @param result defines the Vector3 where to store the result
  3054. */
  3055. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3056. /**
  3057. * Returns the dot product (float) between the vectors "left" and "right"
  3058. * @param left defines the left operand
  3059. * @param right defines the right operand
  3060. * @returns the dot product
  3061. */
  3062. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3063. /**
  3064. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3065. * The cross product is then orthogonal to both "left" and "right"
  3066. * @param left defines the left operand
  3067. * @param right defines the right operand
  3068. * @returns the cross product
  3069. */
  3070. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3071. /**
  3072. * Sets the given vector "result" with the cross product of "left" and "right"
  3073. * The cross product is then orthogonal to both "left" and "right"
  3074. * @param left defines the left operand
  3075. * @param right defines the right operand
  3076. * @param result defines the Vector3 where to store the result
  3077. */
  3078. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3079. /**
  3080. * Returns a new Vector3 as the normalization of the given vector
  3081. * @param vector defines the Vector3 to normalize
  3082. * @returns the new Vector3
  3083. */
  3084. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3085. /**
  3086. * Sets the given vector "result" with the normalization of the given first vector
  3087. * @param vector defines the Vector3 to normalize
  3088. * @param result defines the Vector3 where to store the result
  3089. */
  3090. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3091. /**
  3092. * Project a Vector3 onto screen space
  3093. * @param vector defines the Vector3 to project
  3094. * @param world defines the world matrix to use
  3095. * @param transform defines the transform (view x projection) matrix to use
  3096. * @param viewport defines the screen viewport to use
  3097. * @returns the new Vector3
  3098. */
  3099. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3100. /** @hidden */
  3101. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3102. /**
  3103. * Unproject from screen space to object space
  3104. * @param source defines the screen space Vector3 to use
  3105. * @param viewportWidth defines the current width of the viewport
  3106. * @param viewportHeight defines the current height of the viewport
  3107. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3108. * @param transform defines the transform (view x projection) matrix to use
  3109. * @returns the new Vector3
  3110. */
  3111. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3112. /**
  3113. * Unproject from screen space to object space
  3114. * @param source defines the screen space Vector3 to use
  3115. * @param viewportWidth defines the current width of the viewport
  3116. * @param viewportHeight defines the current height of the viewport
  3117. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3118. * @param view defines the view matrix to use
  3119. * @param projection defines the projection matrix to use
  3120. * @returns the new Vector3
  3121. */
  3122. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3123. /**
  3124. * Unproject from screen space to object space
  3125. * @param source defines the screen space Vector3 to use
  3126. * @param viewportWidth defines the current width of the viewport
  3127. * @param viewportHeight defines the current height of the viewport
  3128. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3129. * @param view defines the view matrix to use
  3130. * @param projection defines the projection matrix to use
  3131. * @param result defines the Vector3 where to store the result
  3132. */
  3133. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3134. /**
  3135. * Unproject from screen space to object space
  3136. * @param sourceX defines the screen space x coordinate to use
  3137. * @param sourceY defines the screen space y coordinate to use
  3138. * @param sourceZ defines the screen space z coordinate to use
  3139. * @param viewportWidth defines the current width of the viewport
  3140. * @param viewportHeight defines the current height of the viewport
  3141. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3142. * @param view defines the view matrix to use
  3143. * @param projection defines the projection matrix to use
  3144. * @param result defines the Vector3 where to store the result
  3145. */
  3146. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3147. /**
  3148. * Gets the minimal coordinate values between two Vector3
  3149. * @param left defines the first operand
  3150. * @param right defines the second operand
  3151. * @returns the new Vector3
  3152. */
  3153. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3154. /**
  3155. * Gets the maximal coordinate values between two Vector3
  3156. * @param left defines the first operand
  3157. * @param right defines the second operand
  3158. * @returns the new Vector3
  3159. */
  3160. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3161. /**
  3162. * Returns the distance between the vectors "value1" and "value2"
  3163. * @param value1 defines the first operand
  3164. * @param value2 defines the second operand
  3165. * @returns the distance
  3166. */
  3167. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3168. /**
  3169. * Returns the squared distance between the vectors "value1" and "value2"
  3170. * @param value1 defines the first operand
  3171. * @param value2 defines the second operand
  3172. * @returns the squared distance
  3173. */
  3174. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3175. /**
  3176. * Returns a new Vector3 located at the center between "value1" and "value2"
  3177. * @param value1 defines the first operand
  3178. * @param value2 defines the second operand
  3179. * @returns the new Vector3
  3180. */
  3181. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3182. /**
  3183. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3184. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3185. * to something in order to rotate it from its local system to the given target system
  3186. * Note: axis1, axis2 and axis3 are normalized during this operation
  3187. * @param axis1 defines the first axis
  3188. * @param axis2 defines the second axis
  3189. * @param axis3 defines the third axis
  3190. * @returns a new Vector3
  3191. */
  3192. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3193. /**
  3194. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3195. * @param axis1 defines the first axis
  3196. * @param axis2 defines the second axis
  3197. * @param axis3 defines the third axis
  3198. * @param ref defines the Vector3 where to store the result
  3199. */
  3200. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3201. }
  3202. /**
  3203. * Vector4 class created for EulerAngle class conversion to Quaternion
  3204. */
  3205. export class Vector4 {
  3206. /** x value of the vector */
  3207. x: number;
  3208. /** y value of the vector */
  3209. y: number;
  3210. /** z value of the vector */
  3211. z: number;
  3212. /** w value of the vector */
  3213. w: number;
  3214. /**
  3215. * Creates a Vector4 object from the given floats.
  3216. * @param x x value of the vector
  3217. * @param y y value of the vector
  3218. * @param z z value of the vector
  3219. * @param w w value of the vector
  3220. */
  3221. constructor(
  3222. /** x value of the vector */
  3223. x: number,
  3224. /** y value of the vector */
  3225. y: number,
  3226. /** z value of the vector */
  3227. z: number,
  3228. /** w value of the vector */
  3229. w: number);
  3230. /**
  3231. * Returns the string with the Vector4 coordinates.
  3232. * @returns a string containing all the vector values
  3233. */
  3234. toString(): string;
  3235. /**
  3236. * Returns the string "Vector4".
  3237. * @returns "Vector4"
  3238. */
  3239. getClassName(): string;
  3240. /**
  3241. * Returns the Vector4 hash code.
  3242. * @returns a unique hash code
  3243. */
  3244. getHashCode(): number;
  3245. /**
  3246. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3247. * @returns the resulting array
  3248. */
  3249. asArray(): number[];
  3250. /**
  3251. * Populates the given array from the given index with the Vector4 coordinates.
  3252. * @param array array to populate
  3253. * @param index index of the array to start at (default: 0)
  3254. * @returns the Vector4.
  3255. */
  3256. toArray(array: FloatArray, index?: number): Vector4;
  3257. /**
  3258. * Adds the given vector to the current Vector4.
  3259. * @param otherVector the vector to add
  3260. * @returns the updated Vector4.
  3261. */
  3262. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3263. /**
  3264. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3265. * @param otherVector the vector to add
  3266. * @returns the resulting vector
  3267. */
  3268. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3269. /**
  3270. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3271. * @param otherVector the vector to add
  3272. * @param result the vector to store the result
  3273. * @returns the current Vector4.
  3274. */
  3275. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3276. /**
  3277. * Subtract in place the given vector from the current Vector4.
  3278. * @param otherVector the vector to subtract
  3279. * @returns the updated Vector4.
  3280. */
  3281. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3282. /**
  3283. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3284. * @param otherVector the vector to add
  3285. * @returns the new vector with the result
  3286. */
  3287. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3288. /**
  3289. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3290. * @param otherVector the vector to subtract
  3291. * @param result the vector to store the result
  3292. * @returns the current Vector4.
  3293. */
  3294. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3295. /**
  3296. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3297. */
  3298. /**
  3299. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3300. * @param x value to subtract
  3301. * @param y value to subtract
  3302. * @param z value to subtract
  3303. * @param w value to subtract
  3304. * @returns new vector containing the result
  3305. */
  3306. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3307. /**
  3308. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3309. * @param x value to subtract
  3310. * @param y value to subtract
  3311. * @param z value to subtract
  3312. * @param w value to subtract
  3313. * @param result the vector to store the result in
  3314. * @returns the current Vector4.
  3315. */
  3316. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3317. /**
  3318. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3319. * @returns a new vector with the negated values
  3320. */
  3321. negate(): Vector4;
  3322. /**
  3323. * Negate this vector in place
  3324. * @returns this
  3325. */
  3326. negateInPlace(): Vector4;
  3327. /**
  3328. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3329. * @param result defines the Vector3 object where to store the result
  3330. * @returns the current Vector4
  3331. */
  3332. negateToRef(result: Vector4): Vector4;
  3333. /**
  3334. * Multiplies the current Vector4 coordinates by scale (float).
  3335. * @param scale the number to scale with
  3336. * @returns the updated Vector4.
  3337. */
  3338. scaleInPlace(scale: number): Vector4;
  3339. /**
  3340. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3341. * @param scale the number to scale with
  3342. * @returns a new vector with the result
  3343. */
  3344. scale(scale: number): Vector4;
  3345. /**
  3346. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3347. * @param scale the number to scale with
  3348. * @param result a vector to store the result in
  3349. * @returns the current Vector4.
  3350. */
  3351. scaleToRef(scale: number, result: Vector4): Vector4;
  3352. /**
  3353. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3354. * @param scale defines the scale factor
  3355. * @param result defines the Vector4 object where to store the result
  3356. * @returns the unmodified current Vector4
  3357. */
  3358. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3359. /**
  3360. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3361. * @param otherVector the vector to compare against
  3362. * @returns true if they are equal
  3363. */
  3364. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3365. /**
  3366. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3367. * @param otherVector vector to compare against
  3368. * @param epsilon (Default: very small number)
  3369. * @returns true if they are equal
  3370. */
  3371. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3372. /**
  3373. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3374. * @param x x value to compare against
  3375. * @param y y value to compare against
  3376. * @param z z value to compare against
  3377. * @param w w value to compare against
  3378. * @returns true if equal
  3379. */
  3380. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3381. /**
  3382. * Multiplies in place the current Vector4 by the given one.
  3383. * @param otherVector vector to multiple with
  3384. * @returns the updated Vector4.
  3385. */
  3386. multiplyInPlace(otherVector: Vector4): Vector4;
  3387. /**
  3388. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3389. * @param otherVector vector to multiple with
  3390. * @returns resulting new vector
  3391. */
  3392. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3393. /**
  3394. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3395. * @param otherVector vector to multiple with
  3396. * @param result vector to store the result
  3397. * @returns the current Vector4.
  3398. */
  3399. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3400. /**
  3401. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3402. * @param x x value multiply with
  3403. * @param y y value multiply with
  3404. * @param z z value multiply with
  3405. * @param w w value multiply with
  3406. * @returns resulting new vector
  3407. */
  3408. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3409. /**
  3410. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3411. * @param otherVector vector to devide with
  3412. * @returns resulting new vector
  3413. */
  3414. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3415. /**
  3416. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3417. * @param otherVector vector to devide with
  3418. * @param result vector to store the result
  3419. * @returns the current Vector4.
  3420. */
  3421. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3422. /**
  3423. * Divides the current Vector3 coordinates by the given ones.
  3424. * @param otherVector vector to devide with
  3425. * @returns the updated Vector3.
  3426. */
  3427. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3428. /**
  3429. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3430. * @param other defines the second operand
  3431. * @returns the current updated Vector4
  3432. */
  3433. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3434. /**
  3435. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3436. * @param other defines the second operand
  3437. * @returns the current updated Vector4
  3438. */
  3439. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3440. /**
  3441. * Gets a new Vector4 from current Vector4 floored values
  3442. * @returns a new Vector4
  3443. */
  3444. floor(): Vector4;
  3445. /**
  3446. * Gets a new Vector4 from current Vector3 floored values
  3447. * @returns a new Vector4
  3448. */
  3449. fract(): Vector4;
  3450. /**
  3451. * Returns the Vector4 length (float).
  3452. * @returns the length
  3453. */
  3454. length(): number;
  3455. /**
  3456. * Returns the Vector4 squared length (float).
  3457. * @returns the length squared
  3458. */
  3459. lengthSquared(): number;
  3460. /**
  3461. * Normalizes in place the Vector4.
  3462. * @returns the updated Vector4.
  3463. */
  3464. normalize(): Vector4;
  3465. /**
  3466. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3467. * @returns this converted to a new vector3
  3468. */
  3469. toVector3(): Vector3;
  3470. /**
  3471. * Returns a new Vector4 copied from the current one.
  3472. * @returns the new cloned vector
  3473. */
  3474. clone(): Vector4;
  3475. /**
  3476. * Updates the current Vector4 with the given one coordinates.
  3477. * @param source the source vector to copy from
  3478. * @returns the updated Vector4.
  3479. */
  3480. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3481. /**
  3482. * Updates the current Vector4 coordinates with the given floats.
  3483. * @param x float to copy from
  3484. * @param y float to copy from
  3485. * @param z float to copy from
  3486. * @param w float to copy from
  3487. * @returns the updated Vector4.
  3488. */
  3489. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3490. /**
  3491. * Updates the current Vector4 coordinates with the given floats.
  3492. * @param x float to set from
  3493. * @param y float to set from
  3494. * @param z float to set from
  3495. * @param w float to set from
  3496. * @returns the updated Vector4.
  3497. */
  3498. set(x: number, y: number, z: number, w: number): Vector4;
  3499. /**
  3500. * Copies the given float to the current Vector3 coordinates
  3501. * @param v defines the x, y, z and w coordinates of the operand
  3502. * @returns the current updated Vector3
  3503. */
  3504. setAll(v: number): Vector4;
  3505. /**
  3506. * Returns a new Vector4 set from the starting index of the given array.
  3507. * @param array the array to pull values from
  3508. * @param offset the offset into the array to start at
  3509. * @returns the new vector
  3510. */
  3511. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3512. /**
  3513. * Updates the given vector "result" from the starting index of the given array.
  3514. * @param array the array to pull values from
  3515. * @param offset the offset into the array to start at
  3516. * @param result the vector to store the result in
  3517. */
  3518. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3519. /**
  3520. * Updates the given vector "result" from the starting index of the given Float32Array.
  3521. * @param array the array to pull values from
  3522. * @param offset the offset into the array to start at
  3523. * @param result the vector to store the result in
  3524. */
  3525. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3526. /**
  3527. * Updates the given vector "result" coordinates from the given floats.
  3528. * @param x float to set from
  3529. * @param y float to set from
  3530. * @param z float to set from
  3531. * @param w float to set from
  3532. * @param result the vector to the floats in
  3533. */
  3534. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3535. /**
  3536. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3537. * @returns the new vector
  3538. */
  3539. static Zero(): Vector4;
  3540. /**
  3541. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3542. * @returns the new vector
  3543. */
  3544. static One(): Vector4;
  3545. /**
  3546. * Returns a new normalized Vector4 from the given one.
  3547. * @param vector the vector to normalize
  3548. * @returns the vector
  3549. */
  3550. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3551. /**
  3552. * Updates the given vector "result" from the normalization of the given one.
  3553. * @param vector the vector to normalize
  3554. * @param result the vector to store the result in
  3555. */
  3556. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3557. /**
  3558. * Returns a vector with the minimum values from the left and right vectors
  3559. * @param left left vector to minimize
  3560. * @param right right vector to minimize
  3561. * @returns a new vector with the minimum of the left and right vector values
  3562. */
  3563. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3564. /**
  3565. * Returns a vector with the maximum values from the left and right vectors
  3566. * @param left left vector to maximize
  3567. * @param right right vector to maximize
  3568. * @returns a new vector with the maximum of the left and right vector values
  3569. */
  3570. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3571. /**
  3572. * Returns the distance (float) between the vectors "value1" and "value2".
  3573. * @param value1 value to calulate the distance between
  3574. * @param value2 value to calulate the distance between
  3575. * @return the distance between the two vectors
  3576. */
  3577. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3578. /**
  3579. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3580. * @param value1 value to calulate the distance between
  3581. * @param value2 value to calulate the distance between
  3582. * @return the distance between the two vectors squared
  3583. */
  3584. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3585. /**
  3586. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3587. * @param value1 value to calulate the center between
  3588. * @param value2 value to calulate the center between
  3589. * @return the center between the two vectors
  3590. */
  3591. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3592. /**
  3593. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3594. * This methods computes transformed normalized direction vectors only.
  3595. * @param vector the vector to transform
  3596. * @param transformation the transformation matrix to apply
  3597. * @returns the new vector
  3598. */
  3599. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3600. /**
  3601. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3602. * This methods computes transformed normalized direction vectors only.
  3603. * @param vector the vector to transform
  3604. * @param transformation the transformation matrix to apply
  3605. * @param result the vector to store the result in
  3606. */
  3607. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3608. /**
  3609. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3610. * This methods computes transformed normalized direction vectors only.
  3611. * @param x value to transform
  3612. * @param y value to transform
  3613. * @param z value to transform
  3614. * @param w value to transform
  3615. * @param transformation the transformation matrix to apply
  3616. * @param result the vector to store the results in
  3617. */
  3618. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3619. /**
  3620. * Creates a new Vector4 from a Vector3
  3621. * @param source defines the source data
  3622. * @param w defines the 4th component (default is 0)
  3623. * @returns a new Vector4
  3624. */
  3625. static FromVector3(source: Vector3, w?: number): Vector4;
  3626. }
  3627. /**
  3628. * Class used to store quaternion data
  3629. * @see https://en.wikipedia.org/wiki/Quaternion
  3630. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3631. */
  3632. export class Quaternion {
  3633. /** @hidden */
  3634. _x: number;
  3635. /** @hidden */
  3636. _y: number;
  3637. /** @hidden */
  3638. _z: number;
  3639. /** @hidden */
  3640. _w: number;
  3641. /** @hidden */
  3642. _isDirty: boolean;
  3643. /** Gets or sets the x coordinate */
  3644. get x(): number;
  3645. set x(value: number);
  3646. /** Gets or sets the y coordinate */
  3647. get y(): number;
  3648. set y(value: number);
  3649. /** Gets or sets the z coordinate */
  3650. get z(): number;
  3651. set z(value: number);
  3652. /** Gets or sets the w coordinate */
  3653. get w(): number;
  3654. set w(value: number);
  3655. /**
  3656. * Creates a new Quaternion from the given floats
  3657. * @param x defines the first component (0 by default)
  3658. * @param y defines the second component (0 by default)
  3659. * @param z defines the third component (0 by default)
  3660. * @param w defines the fourth component (1.0 by default)
  3661. */
  3662. constructor(x?: number, y?: number, z?: number, w?: number);
  3663. /**
  3664. * Gets a string representation for the current quaternion
  3665. * @returns a string with the Quaternion coordinates
  3666. */
  3667. toString(): string;
  3668. /**
  3669. * Gets the class name of the quaternion
  3670. * @returns the string "Quaternion"
  3671. */
  3672. getClassName(): string;
  3673. /**
  3674. * Gets a hash code for this quaternion
  3675. * @returns the quaternion hash code
  3676. */
  3677. getHashCode(): number;
  3678. /**
  3679. * Copy the quaternion to an array
  3680. * @returns a new array populated with 4 elements from the quaternion coordinates
  3681. */
  3682. asArray(): number[];
  3683. /**
  3684. * Check if two quaternions are equals
  3685. * @param otherQuaternion defines the second operand
  3686. * @return true if the current quaternion and the given one coordinates are strictly equals
  3687. */
  3688. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3689. /**
  3690. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3691. * @param otherQuaternion defines the other quaternion
  3692. * @param epsilon defines the minimal distance to consider equality
  3693. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3694. */
  3695. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3696. /**
  3697. * Clone the current quaternion
  3698. * @returns a new quaternion copied from the current one
  3699. */
  3700. clone(): Quaternion;
  3701. /**
  3702. * Copy a quaternion to the current one
  3703. * @param other defines the other quaternion
  3704. * @returns the updated current quaternion
  3705. */
  3706. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3707. /**
  3708. * Updates the current quaternion with the given float coordinates
  3709. * @param x defines the x coordinate
  3710. * @param y defines the y coordinate
  3711. * @param z defines the z coordinate
  3712. * @param w defines the w coordinate
  3713. * @returns the updated current quaternion
  3714. */
  3715. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3716. /**
  3717. * Updates the current quaternion from the given float coordinates
  3718. * @param x defines the x coordinate
  3719. * @param y defines the y coordinate
  3720. * @param z defines the z coordinate
  3721. * @param w defines the w coordinate
  3722. * @returns the updated current quaternion
  3723. */
  3724. set(x: number, y: number, z: number, w: number): Quaternion;
  3725. /**
  3726. * Adds two quaternions
  3727. * @param other defines the second operand
  3728. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3729. */
  3730. add(other: DeepImmutable<Quaternion>): Quaternion;
  3731. /**
  3732. * Add a quaternion to the current one
  3733. * @param other defines the quaternion to add
  3734. * @returns the current quaternion
  3735. */
  3736. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3737. /**
  3738. * Subtract two quaternions
  3739. * @param other defines the second operand
  3740. * @returns a new quaternion as the subtraction result of the given one from the current one
  3741. */
  3742. subtract(other: Quaternion): Quaternion;
  3743. /**
  3744. * Multiplies the current quaternion by a scale factor
  3745. * @param value defines the scale factor
  3746. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3747. */
  3748. scale(value: number): Quaternion;
  3749. /**
  3750. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3751. * @param scale defines the scale factor
  3752. * @param result defines the Quaternion object where to store the result
  3753. * @returns the unmodified current quaternion
  3754. */
  3755. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3756. /**
  3757. * Multiplies in place the current quaternion by a scale factor
  3758. * @param value defines the scale factor
  3759. * @returns the current modified quaternion
  3760. */
  3761. scaleInPlace(value: number): Quaternion;
  3762. /**
  3763. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3764. * @param scale defines the scale factor
  3765. * @param result defines the Quaternion object where to store the result
  3766. * @returns the unmodified current quaternion
  3767. */
  3768. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3769. /**
  3770. * Multiplies two quaternions
  3771. * @param q1 defines the second operand
  3772. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3773. */
  3774. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3775. /**
  3776. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3777. * @param q1 defines the second operand
  3778. * @param result defines the target quaternion
  3779. * @returns the current quaternion
  3780. */
  3781. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3782. /**
  3783. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3784. * @param q1 defines the second operand
  3785. * @returns the currentupdated quaternion
  3786. */
  3787. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3788. /**
  3789. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3790. * @param ref defines the target quaternion
  3791. * @returns the current quaternion
  3792. */
  3793. conjugateToRef(ref: Quaternion): Quaternion;
  3794. /**
  3795. * Conjugates in place (1-q) the current quaternion
  3796. * @returns the current updated quaternion
  3797. */
  3798. conjugateInPlace(): Quaternion;
  3799. /**
  3800. * Conjugates in place (1-q) the current quaternion
  3801. * @returns a new quaternion
  3802. */
  3803. conjugate(): Quaternion;
  3804. /**
  3805. * Gets length of current quaternion
  3806. * @returns the quaternion length (float)
  3807. */
  3808. length(): number;
  3809. /**
  3810. * Normalize in place the current quaternion
  3811. * @returns the current updated quaternion
  3812. */
  3813. normalize(): Quaternion;
  3814. /**
  3815. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3816. * @param order is a reserved parameter and is ignore for now
  3817. * @returns a new Vector3 containing the Euler angles
  3818. */
  3819. toEulerAngles(order?: string): Vector3;
  3820. /**
  3821. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3822. * @param result defines the vector which will be filled with the Euler angles
  3823. * @param order is a reserved parameter and is ignore for now
  3824. * @returns the current unchanged quaternion
  3825. */
  3826. toEulerAnglesToRef(result: Vector3): Quaternion;
  3827. /**
  3828. * Updates the given rotation matrix with the current quaternion values
  3829. * @param result defines the target matrix
  3830. * @returns the current unchanged quaternion
  3831. */
  3832. toRotationMatrix(result: Matrix): Quaternion;
  3833. /**
  3834. * Updates the current quaternion from the given rotation matrix values
  3835. * @param matrix defines the source matrix
  3836. * @returns the current updated quaternion
  3837. */
  3838. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3839. /**
  3840. * Creates a new quaternion from a rotation matrix
  3841. * @param matrix defines the source matrix
  3842. * @returns a new quaternion created from the given rotation matrix values
  3843. */
  3844. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3845. /**
  3846. * Updates the given quaternion with the given rotation matrix values
  3847. * @param matrix defines the source matrix
  3848. * @param result defines the target quaternion
  3849. */
  3850. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3851. /**
  3852. * Returns the dot product (float) between the quaternions "left" and "right"
  3853. * @param left defines the left operand
  3854. * @param right defines the right operand
  3855. * @returns the dot product
  3856. */
  3857. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3858. /**
  3859. * Checks if the two quaternions are close to each other
  3860. * @param quat0 defines the first quaternion to check
  3861. * @param quat1 defines the second quaternion to check
  3862. * @returns true if the two quaternions are close to each other
  3863. */
  3864. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3865. /**
  3866. * Creates an empty quaternion
  3867. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3868. */
  3869. static Zero(): Quaternion;
  3870. /**
  3871. * Inverse a given quaternion
  3872. * @param q defines the source quaternion
  3873. * @returns a new quaternion as the inverted current quaternion
  3874. */
  3875. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3876. /**
  3877. * Inverse a given quaternion
  3878. * @param q defines the source quaternion
  3879. * @param result the quaternion the result will be stored in
  3880. * @returns the result quaternion
  3881. */
  3882. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3883. /**
  3884. * Creates an identity quaternion
  3885. * @returns the identity quaternion
  3886. */
  3887. static Identity(): Quaternion;
  3888. /**
  3889. * Gets a boolean indicating if the given quaternion is identity
  3890. * @param quaternion defines the quaternion to check
  3891. * @returns true if the quaternion is identity
  3892. */
  3893. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3894. /**
  3895. * Creates a quaternion from a rotation around an axis
  3896. * @param axis defines the axis to use
  3897. * @param angle defines the angle to use
  3898. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3899. */
  3900. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3901. /**
  3902. * Creates a rotation around an axis and stores it into the given quaternion
  3903. * @param axis defines the axis to use
  3904. * @param angle defines the angle to use
  3905. * @param result defines the target quaternion
  3906. * @returns the target quaternion
  3907. */
  3908. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3909. /**
  3910. * Creates a new quaternion from data stored into an array
  3911. * @param array defines the data source
  3912. * @param offset defines the offset in the source array where the data starts
  3913. * @returns a new quaternion
  3914. */
  3915. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3916. /**
  3917. * Updates the given quaternion "result" from the starting index of the given array.
  3918. * @param array the array to pull values from
  3919. * @param offset the offset into the array to start at
  3920. * @param result the quaternion to store the result in
  3921. */
  3922. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3923. /**
  3924. * Create a quaternion from Euler rotation angles
  3925. * @param x Pitch
  3926. * @param y Yaw
  3927. * @param z Roll
  3928. * @returns the new Quaternion
  3929. */
  3930. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3931. /**
  3932. * Updates a quaternion from Euler rotation angles
  3933. * @param x Pitch
  3934. * @param y Yaw
  3935. * @param z Roll
  3936. * @param result the quaternion to store the result
  3937. * @returns the updated quaternion
  3938. */
  3939. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3940. /**
  3941. * Create a quaternion from Euler rotation vector
  3942. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3943. * @returns the new Quaternion
  3944. */
  3945. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3946. /**
  3947. * Updates a quaternion from Euler rotation vector
  3948. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3949. * @param result the quaternion to store the result
  3950. * @returns the updated quaternion
  3951. */
  3952. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3953. /**
  3954. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3955. * @param yaw defines the rotation around Y axis
  3956. * @param pitch defines the rotation around X axis
  3957. * @param roll defines the rotation around Z axis
  3958. * @returns the new quaternion
  3959. */
  3960. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3961. /**
  3962. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3963. * @param yaw defines the rotation around Y axis
  3964. * @param pitch defines the rotation around X axis
  3965. * @param roll defines the rotation around Z axis
  3966. * @param result defines the target quaternion
  3967. */
  3968. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3969. /**
  3970. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3971. * @param alpha defines the rotation around first axis
  3972. * @param beta defines the rotation around second axis
  3973. * @param gamma defines the rotation around third axis
  3974. * @returns the new quaternion
  3975. */
  3976. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3977. /**
  3978. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3979. * @param alpha defines the rotation around first axis
  3980. * @param beta defines the rotation around second axis
  3981. * @param gamma defines the rotation around third axis
  3982. * @param result defines the target quaternion
  3983. */
  3984. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3985. /**
  3986. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3987. * @param axis1 defines the first axis
  3988. * @param axis2 defines the second axis
  3989. * @param axis3 defines the third axis
  3990. * @returns the new quaternion
  3991. */
  3992. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3993. /**
  3994. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3995. * @param axis1 defines the first axis
  3996. * @param axis2 defines the second axis
  3997. * @param axis3 defines the third axis
  3998. * @param ref defines the target quaternion
  3999. */
  4000. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4001. /**
  4002. * Interpolates between two quaternions
  4003. * @param left defines first quaternion
  4004. * @param right defines second quaternion
  4005. * @param amount defines the gradient to use
  4006. * @returns the new interpolated quaternion
  4007. */
  4008. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4009. /**
  4010. * Interpolates between two quaternions and stores it into a target quaternion
  4011. * @param left defines first quaternion
  4012. * @param right defines second quaternion
  4013. * @param amount defines the gradient to use
  4014. * @param result defines the target quaternion
  4015. */
  4016. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4017. /**
  4018. * Interpolate between two quaternions using Hermite interpolation
  4019. * @param value1 defines first quaternion
  4020. * @param tangent1 defines the incoming tangent
  4021. * @param value2 defines second quaternion
  4022. * @param tangent2 defines the outgoing tangent
  4023. * @param amount defines the target quaternion
  4024. * @returns the new interpolated quaternion
  4025. */
  4026. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4027. }
  4028. /**
  4029. * Class used to store matrix data (4x4)
  4030. */
  4031. export class Matrix {
  4032. private static _updateFlagSeed;
  4033. private static _identityReadOnly;
  4034. private _isIdentity;
  4035. private _isIdentityDirty;
  4036. private _isIdentity3x2;
  4037. private _isIdentity3x2Dirty;
  4038. /**
  4039. * Gets the update flag of the matrix which is an unique number for the matrix.
  4040. * It will be incremented every time the matrix data change.
  4041. * You can use it to speed the comparison between two versions of the same matrix.
  4042. */
  4043. updateFlag: number;
  4044. private readonly _m;
  4045. /**
  4046. * Gets the internal data of the matrix
  4047. */
  4048. get m(): DeepImmutable<Float32Array>;
  4049. /** @hidden */
  4050. _markAsUpdated(): void;
  4051. /** @hidden */
  4052. private _updateIdentityStatus;
  4053. /**
  4054. * Creates an empty matrix (filled with zeros)
  4055. */
  4056. constructor();
  4057. /**
  4058. * Check if the current matrix is identity
  4059. * @returns true is the matrix is the identity matrix
  4060. */
  4061. isIdentity(): boolean;
  4062. /**
  4063. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4064. * @returns true is the matrix is the identity matrix
  4065. */
  4066. isIdentityAs3x2(): boolean;
  4067. /**
  4068. * Gets the determinant of the matrix
  4069. * @returns the matrix determinant
  4070. */
  4071. determinant(): number;
  4072. /**
  4073. * Returns the matrix as a Float32Array
  4074. * @returns the matrix underlying array
  4075. */
  4076. toArray(): DeepImmutable<Float32Array>;
  4077. /**
  4078. * Returns the matrix as a Float32Array
  4079. * @returns the matrix underlying array.
  4080. */
  4081. asArray(): DeepImmutable<Float32Array>;
  4082. /**
  4083. * Inverts the current matrix in place
  4084. * @returns the current inverted matrix
  4085. */
  4086. invert(): Matrix;
  4087. /**
  4088. * Sets all the matrix elements to zero
  4089. * @returns the current matrix
  4090. */
  4091. reset(): Matrix;
  4092. /**
  4093. * Adds the current matrix with a second one
  4094. * @param other defines the matrix to add
  4095. * @returns a new matrix as the addition of the current matrix and the given one
  4096. */
  4097. add(other: DeepImmutable<Matrix>): Matrix;
  4098. /**
  4099. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4100. * @param other defines the matrix to add
  4101. * @param result defines the target matrix
  4102. * @returns the current matrix
  4103. */
  4104. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4105. /**
  4106. * Adds in place the given matrix to the current matrix
  4107. * @param other defines the second operand
  4108. * @returns the current updated matrix
  4109. */
  4110. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4111. /**
  4112. * Sets the given matrix to the current inverted Matrix
  4113. * @param other defines the target matrix
  4114. * @returns the unmodified current matrix
  4115. */
  4116. invertToRef(other: Matrix): Matrix;
  4117. /**
  4118. * add a value at the specified position in the current Matrix
  4119. * @param index the index of the value within the matrix. between 0 and 15.
  4120. * @param value the value to be added
  4121. * @returns the current updated matrix
  4122. */
  4123. addAtIndex(index: number, value: number): Matrix;
  4124. /**
  4125. * mutiply the specified position in the current Matrix by a value
  4126. * @param index the index of the value within the matrix. between 0 and 15.
  4127. * @param value the value to be added
  4128. * @returns the current updated matrix
  4129. */
  4130. multiplyAtIndex(index: number, value: number): Matrix;
  4131. /**
  4132. * Inserts the translation vector (using 3 floats) in the current matrix
  4133. * @param x defines the 1st component of the translation
  4134. * @param y defines the 2nd component of the translation
  4135. * @param z defines the 3rd component of the translation
  4136. * @returns the current updated matrix
  4137. */
  4138. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4139. /**
  4140. * Adds the translation vector (using 3 floats) in the current matrix
  4141. * @param x defines the 1st component of the translation
  4142. * @param y defines the 2nd component of the translation
  4143. * @param z defines the 3rd component of the translation
  4144. * @returns the current updated matrix
  4145. */
  4146. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4147. /**
  4148. * Inserts the translation vector in the current matrix
  4149. * @param vector3 defines the translation to insert
  4150. * @returns the current updated matrix
  4151. */
  4152. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4153. /**
  4154. * Gets the translation value of the current matrix
  4155. * @returns a new Vector3 as the extracted translation from the matrix
  4156. */
  4157. getTranslation(): Vector3;
  4158. /**
  4159. * Fill a Vector3 with the extracted translation from the matrix
  4160. * @param result defines the Vector3 where to store the translation
  4161. * @returns the current matrix
  4162. */
  4163. getTranslationToRef(result: Vector3): Matrix;
  4164. /**
  4165. * Remove rotation and scaling part from the matrix
  4166. * @returns the updated matrix
  4167. */
  4168. removeRotationAndScaling(): Matrix;
  4169. /**
  4170. * Multiply two matrices
  4171. * @param other defines the second operand
  4172. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4173. */
  4174. multiply(other: DeepImmutable<Matrix>): Matrix;
  4175. /**
  4176. * Copy the current matrix from the given one
  4177. * @param other defines the source matrix
  4178. * @returns the current updated matrix
  4179. */
  4180. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4181. /**
  4182. * Populates the given array from the starting index with the current matrix values
  4183. * @param array defines the target array
  4184. * @param offset defines the offset in the target array where to start storing values
  4185. * @returns the current matrix
  4186. */
  4187. copyToArray(array: Float32Array, offset?: number): Matrix;
  4188. /**
  4189. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4190. * @param other defines the second operand
  4191. * @param result defines the matrix where to store the multiplication
  4192. * @returns the current matrix
  4193. */
  4194. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4195. /**
  4196. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4197. * @param other defines the second operand
  4198. * @param result defines the array where to store the multiplication
  4199. * @param offset defines the offset in the target array where to start storing values
  4200. * @returns the current matrix
  4201. */
  4202. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4203. /**
  4204. * Check equality between this matrix and a second one
  4205. * @param value defines the second matrix to compare
  4206. * @returns true is the current matrix and the given one values are strictly equal
  4207. */
  4208. equals(value: DeepImmutable<Matrix>): boolean;
  4209. /**
  4210. * Clone the current matrix
  4211. * @returns a new matrix from the current matrix
  4212. */
  4213. clone(): Matrix;
  4214. /**
  4215. * Returns the name of the current matrix class
  4216. * @returns the string "Matrix"
  4217. */
  4218. getClassName(): string;
  4219. /**
  4220. * Gets the hash code of the current matrix
  4221. * @returns the hash code
  4222. */
  4223. getHashCode(): number;
  4224. /**
  4225. * Decomposes the current Matrix into a translation, rotation and scaling components
  4226. * @param scale defines the scale vector3 given as a reference to update
  4227. * @param rotation defines the rotation quaternion given as a reference to update
  4228. * @param translation defines the translation vector3 given as a reference to update
  4229. * @returns true if operation was successful
  4230. */
  4231. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4232. /**
  4233. * Gets specific row of the matrix
  4234. * @param index defines the number of the row to get
  4235. * @returns the index-th row of the current matrix as a new Vector4
  4236. */
  4237. getRow(index: number): Nullable<Vector4>;
  4238. /**
  4239. * Sets the index-th row of the current matrix to the vector4 values
  4240. * @param index defines the number of the row to set
  4241. * @param row defines the target vector4
  4242. * @returns the updated current matrix
  4243. */
  4244. setRow(index: number, row: Vector4): Matrix;
  4245. /**
  4246. * Compute the transpose of the matrix
  4247. * @returns the new transposed matrix
  4248. */
  4249. transpose(): Matrix;
  4250. /**
  4251. * Compute the transpose of the matrix and store it in a given matrix
  4252. * @param result defines the target matrix
  4253. * @returns the current matrix
  4254. */
  4255. transposeToRef(result: Matrix): Matrix;
  4256. /**
  4257. * Sets the index-th row of the current matrix with the given 4 x float values
  4258. * @param index defines the row index
  4259. * @param x defines the x component to set
  4260. * @param y defines the y component to set
  4261. * @param z defines the z component to set
  4262. * @param w defines the w component to set
  4263. * @returns the updated current matrix
  4264. */
  4265. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4266. /**
  4267. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4268. * @param scale defines the scale factor
  4269. * @returns a new matrix
  4270. */
  4271. scale(scale: number): Matrix;
  4272. /**
  4273. * Scale the current matrix values by a factor to a given result matrix
  4274. * @param scale defines the scale factor
  4275. * @param result defines the matrix to store the result
  4276. * @returns the current matrix
  4277. */
  4278. scaleToRef(scale: number, result: Matrix): Matrix;
  4279. /**
  4280. * Scale the current matrix values by a factor and add the result to a given matrix
  4281. * @param scale defines the scale factor
  4282. * @param result defines the Matrix to store the result
  4283. * @returns the current matrix
  4284. */
  4285. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4286. /**
  4287. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4288. * @param ref matrix to store the result
  4289. */
  4290. toNormalMatrix(ref: Matrix): void;
  4291. /**
  4292. * Gets only rotation part of the current matrix
  4293. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4294. */
  4295. getRotationMatrix(): Matrix;
  4296. /**
  4297. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4298. * @param result defines the target matrix to store data to
  4299. * @returns the current matrix
  4300. */
  4301. getRotationMatrixToRef(result: Matrix): Matrix;
  4302. /**
  4303. * Toggles model matrix from being right handed to left handed in place and vice versa
  4304. */
  4305. toggleModelMatrixHandInPlace(): void;
  4306. /**
  4307. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4308. */
  4309. toggleProjectionMatrixHandInPlace(): void;
  4310. /**
  4311. * Creates a matrix from an array
  4312. * @param array defines the source array
  4313. * @param offset defines an offset in the source array
  4314. * @returns a new Matrix set from the starting index of the given array
  4315. */
  4316. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4317. /**
  4318. * Copy the content of an array into a given matrix
  4319. * @param array defines the source array
  4320. * @param offset defines an offset in the source array
  4321. * @param result defines the target matrix
  4322. */
  4323. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4324. /**
  4325. * Stores an array into a matrix after having multiplied each component by a given factor
  4326. * @param array defines the source array
  4327. * @param offset defines the offset in the source array
  4328. * @param scale defines the scaling factor
  4329. * @param result defines the target matrix
  4330. */
  4331. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4332. /**
  4333. * Gets an identity matrix that must not be updated
  4334. */
  4335. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4336. /**
  4337. * Stores a list of values (16) inside a given matrix
  4338. * @param initialM11 defines 1st value of 1st row
  4339. * @param initialM12 defines 2nd value of 1st row
  4340. * @param initialM13 defines 3rd value of 1st row
  4341. * @param initialM14 defines 4th value of 1st row
  4342. * @param initialM21 defines 1st value of 2nd row
  4343. * @param initialM22 defines 2nd value of 2nd row
  4344. * @param initialM23 defines 3rd value of 2nd row
  4345. * @param initialM24 defines 4th value of 2nd row
  4346. * @param initialM31 defines 1st value of 3rd row
  4347. * @param initialM32 defines 2nd value of 3rd row
  4348. * @param initialM33 defines 3rd value of 3rd row
  4349. * @param initialM34 defines 4th value of 3rd row
  4350. * @param initialM41 defines 1st value of 4th row
  4351. * @param initialM42 defines 2nd value of 4th row
  4352. * @param initialM43 defines 3rd value of 4th row
  4353. * @param initialM44 defines 4th value of 4th row
  4354. * @param result defines the target matrix
  4355. */
  4356. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4357. /**
  4358. * Creates new matrix from a list of values (16)
  4359. * @param initialM11 defines 1st value of 1st row
  4360. * @param initialM12 defines 2nd value of 1st row
  4361. * @param initialM13 defines 3rd value of 1st row
  4362. * @param initialM14 defines 4th value of 1st row
  4363. * @param initialM21 defines 1st value of 2nd row
  4364. * @param initialM22 defines 2nd value of 2nd row
  4365. * @param initialM23 defines 3rd value of 2nd row
  4366. * @param initialM24 defines 4th value of 2nd row
  4367. * @param initialM31 defines 1st value of 3rd row
  4368. * @param initialM32 defines 2nd value of 3rd row
  4369. * @param initialM33 defines 3rd value of 3rd row
  4370. * @param initialM34 defines 4th value of 3rd row
  4371. * @param initialM41 defines 1st value of 4th row
  4372. * @param initialM42 defines 2nd value of 4th row
  4373. * @param initialM43 defines 3rd value of 4th row
  4374. * @param initialM44 defines 4th value of 4th row
  4375. * @returns the new matrix
  4376. */
  4377. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4378. /**
  4379. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4380. * @param scale defines the scale vector3
  4381. * @param rotation defines the rotation quaternion
  4382. * @param translation defines the translation vector3
  4383. * @returns a new matrix
  4384. */
  4385. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4386. /**
  4387. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4388. * @param scale defines the scale vector3
  4389. * @param rotation defines the rotation quaternion
  4390. * @param translation defines the translation vector3
  4391. * @param result defines the target matrix
  4392. */
  4393. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4394. /**
  4395. * Creates a new identity matrix
  4396. * @returns a new identity matrix
  4397. */
  4398. static Identity(): Matrix;
  4399. /**
  4400. * Creates a new identity matrix and stores the result in a given matrix
  4401. * @param result defines the target matrix
  4402. */
  4403. static IdentityToRef(result: Matrix): void;
  4404. /**
  4405. * Creates a new zero matrix
  4406. * @returns a new zero matrix
  4407. */
  4408. static Zero(): Matrix;
  4409. /**
  4410. * Creates a new rotation matrix for "angle" radians around the X axis
  4411. * @param angle defines the angle (in radians) to use
  4412. * @return the new matrix
  4413. */
  4414. static RotationX(angle: number): Matrix;
  4415. /**
  4416. * Creates a new matrix as the invert of a given matrix
  4417. * @param source defines the source matrix
  4418. * @returns the new matrix
  4419. */
  4420. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4421. /**
  4422. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4423. * @param angle defines the angle (in radians) to use
  4424. * @param result defines the target matrix
  4425. */
  4426. static RotationXToRef(angle: number, result: Matrix): void;
  4427. /**
  4428. * Creates a new rotation matrix for "angle" radians around the Y axis
  4429. * @param angle defines the angle (in radians) to use
  4430. * @return the new matrix
  4431. */
  4432. static RotationY(angle: number): Matrix;
  4433. /**
  4434. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4435. * @param angle defines the angle (in radians) to use
  4436. * @param result defines the target matrix
  4437. */
  4438. static RotationYToRef(angle: number, result: Matrix): void;
  4439. /**
  4440. * Creates a new rotation matrix for "angle" radians around the Z axis
  4441. * @param angle defines the angle (in radians) to use
  4442. * @return the new matrix
  4443. */
  4444. static RotationZ(angle: number): Matrix;
  4445. /**
  4446. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4447. * @param angle defines the angle (in radians) to use
  4448. * @param result defines the target matrix
  4449. */
  4450. static RotationZToRef(angle: number, result: Matrix): void;
  4451. /**
  4452. * Creates a new rotation matrix for "angle" radians around the given axis
  4453. * @param axis defines the axis to use
  4454. * @param angle defines the angle (in radians) to use
  4455. * @return the new matrix
  4456. */
  4457. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4458. /**
  4459. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4460. * @param axis defines the axis to use
  4461. * @param angle defines the angle (in radians) to use
  4462. * @param result defines the target matrix
  4463. */
  4464. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4465. /**
  4466. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4467. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4468. * @param from defines the vector to align
  4469. * @param to defines the vector to align to
  4470. * @param result defines the target matrix
  4471. */
  4472. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4473. /**
  4474. * Creates a rotation matrix
  4475. * @param yaw defines the yaw angle in radians (Y axis)
  4476. * @param pitch defines the pitch angle in radians (X axis)
  4477. * @param roll defines the roll angle in radians (X axis)
  4478. * @returns the new rotation matrix
  4479. */
  4480. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4481. /**
  4482. * Creates a rotation matrix and stores it in a given matrix
  4483. * @param yaw defines the yaw angle in radians (Y axis)
  4484. * @param pitch defines the pitch angle in radians (X axis)
  4485. * @param roll defines the roll angle in radians (X axis)
  4486. * @param result defines the target matrix
  4487. */
  4488. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4489. /**
  4490. * Creates a scaling matrix
  4491. * @param x defines the scale factor on X axis
  4492. * @param y defines the scale factor on Y axis
  4493. * @param z defines the scale factor on Z axis
  4494. * @returns the new matrix
  4495. */
  4496. static Scaling(x: number, y: number, z: number): Matrix;
  4497. /**
  4498. * Creates a scaling matrix and stores it in a given matrix
  4499. * @param x defines the scale factor on X axis
  4500. * @param y defines the scale factor on Y axis
  4501. * @param z defines the scale factor on Z axis
  4502. * @param result defines the target matrix
  4503. */
  4504. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4505. /**
  4506. * Creates a translation matrix
  4507. * @param x defines the translation on X axis
  4508. * @param y defines the translation on Y axis
  4509. * @param z defines the translationon Z axis
  4510. * @returns the new matrix
  4511. */
  4512. static Translation(x: number, y: number, z: number): Matrix;
  4513. /**
  4514. * Creates a translation matrix and stores it in a given matrix
  4515. * @param x defines the translation on X axis
  4516. * @param y defines the translation on Y axis
  4517. * @param z defines the translationon Z axis
  4518. * @param result defines the target matrix
  4519. */
  4520. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4521. /**
  4522. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4523. * @param startValue defines the start value
  4524. * @param endValue defines the end value
  4525. * @param gradient defines the gradient factor
  4526. * @returns the new matrix
  4527. */
  4528. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4529. /**
  4530. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4531. * @param startValue defines the start value
  4532. * @param endValue defines the end value
  4533. * @param gradient defines the gradient factor
  4534. * @param result defines the Matrix object where to store data
  4535. */
  4536. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4537. /**
  4538. * Builds a new matrix whose values are computed by:
  4539. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4540. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4541. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4542. * @param startValue defines the first matrix
  4543. * @param endValue defines the second matrix
  4544. * @param gradient defines the gradient between the two matrices
  4545. * @returns the new matrix
  4546. */
  4547. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4548. /**
  4549. * Update a matrix to values which are computed by:
  4550. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4551. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4552. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4553. * @param startValue defines the first matrix
  4554. * @param endValue defines the second matrix
  4555. * @param gradient defines the gradient between the two matrices
  4556. * @param result defines the target matrix
  4557. */
  4558. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4559. /**
  4560. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4561. * This function works in left handed mode
  4562. * @param eye defines the final position of the entity
  4563. * @param target defines where the entity should look at
  4564. * @param up defines the up vector for the entity
  4565. * @returns the new matrix
  4566. */
  4567. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4568. /**
  4569. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4570. * This function works in left handed mode
  4571. * @param eye defines the final position of the entity
  4572. * @param target defines where the entity should look at
  4573. * @param up defines the up vector for the entity
  4574. * @param result defines the target matrix
  4575. */
  4576. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4577. /**
  4578. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4579. * This function works in right handed mode
  4580. * @param eye defines the final position of the entity
  4581. * @param target defines where the entity should look at
  4582. * @param up defines the up vector for the entity
  4583. * @returns the new matrix
  4584. */
  4585. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4586. /**
  4587. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4588. * This function works in right handed mode
  4589. * @param eye defines the final position of the entity
  4590. * @param target defines where the entity should look at
  4591. * @param up defines the up vector for the entity
  4592. * @param result defines the target matrix
  4593. */
  4594. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4595. /**
  4596. * Create a left-handed orthographic projection matrix
  4597. * @param width defines the viewport width
  4598. * @param height defines the viewport height
  4599. * @param znear defines the near clip plane
  4600. * @param zfar defines the far clip plane
  4601. * @returns a new matrix as a left-handed orthographic projection matrix
  4602. */
  4603. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4604. /**
  4605. * Store a left-handed orthographic projection to a given matrix
  4606. * @param width defines the viewport width
  4607. * @param height defines the viewport height
  4608. * @param znear defines the near clip plane
  4609. * @param zfar defines the far clip plane
  4610. * @param result defines the target matrix
  4611. */
  4612. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4613. /**
  4614. * Create a left-handed orthographic projection matrix
  4615. * @param left defines the viewport left coordinate
  4616. * @param right defines the viewport right coordinate
  4617. * @param bottom defines the viewport bottom coordinate
  4618. * @param top defines the viewport top coordinate
  4619. * @param znear defines the near clip plane
  4620. * @param zfar defines the far clip plane
  4621. * @returns a new matrix as a left-handed orthographic projection matrix
  4622. */
  4623. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4624. /**
  4625. * Stores a left-handed orthographic projection into a given matrix
  4626. * @param left defines the viewport left coordinate
  4627. * @param right defines the viewport right coordinate
  4628. * @param bottom defines the viewport bottom coordinate
  4629. * @param top defines the viewport top coordinate
  4630. * @param znear defines the near clip plane
  4631. * @param zfar defines the far clip plane
  4632. * @param result defines the target matrix
  4633. */
  4634. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4635. /**
  4636. * Creates a right-handed orthographic projection matrix
  4637. * @param left defines the viewport left coordinate
  4638. * @param right defines the viewport right coordinate
  4639. * @param bottom defines the viewport bottom coordinate
  4640. * @param top defines the viewport top coordinate
  4641. * @param znear defines the near clip plane
  4642. * @param zfar defines the far clip plane
  4643. * @returns a new matrix as a right-handed orthographic projection matrix
  4644. */
  4645. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4646. /**
  4647. * Stores a right-handed orthographic projection into a given matrix
  4648. * @param left defines the viewport left coordinate
  4649. * @param right defines the viewport right coordinate
  4650. * @param bottom defines the viewport bottom coordinate
  4651. * @param top defines the viewport top coordinate
  4652. * @param znear defines the near clip plane
  4653. * @param zfar defines the far clip plane
  4654. * @param result defines the target matrix
  4655. */
  4656. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4657. /**
  4658. * Creates a left-handed perspective projection matrix
  4659. * @param width defines the viewport width
  4660. * @param height defines the viewport height
  4661. * @param znear defines the near clip plane
  4662. * @param zfar defines the far clip plane
  4663. * @returns a new matrix as a left-handed perspective projection matrix
  4664. */
  4665. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4666. /**
  4667. * Creates a left-handed perspective projection matrix
  4668. * @param fov defines the horizontal field of view
  4669. * @param aspect defines the aspect ratio
  4670. * @param znear defines the near clip plane
  4671. * @param zfar defines the far clip plane
  4672. * @returns a new matrix as a left-handed perspective projection matrix
  4673. */
  4674. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4675. /**
  4676. * Stores a left-handed perspective projection into a given matrix
  4677. * @param fov defines the horizontal field of view
  4678. * @param aspect defines the aspect ratio
  4679. * @param znear defines the near clip plane
  4680. * @param zfar defines the far clip plane
  4681. * @param result defines the target matrix
  4682. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4683. */
  4684. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4685. /**
  4686. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4687. * @param fov defines the horizontal field of view
  4688. * @param aspect defines the aspect ratio
  4689. * @param znear defines the near clip plane
  4690. * @param zfar not used as infinity is used as far clip
  4691. * @param result defines the target matrix
  4692. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4693. */
  4694. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4695. /**
  4696. * Creates a right-handed perspective projection matrix
  4697. * @param fov defines the horizontal field of view
  4698. * @param aspect defines the aspect ratio
  4699. * @param znear defines the near clip plane
  4700. * @param zfar defines the far clip plane
  4701. * @returns a new matrix as a right-handed perspective projection matrix
  4702. */
  4703. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4704. /**
  4705. * Stores a right-handed perspective projection into a given matrix
  4706. * @param fov defines the horizontal field of view
  4707. * @param aspect defines the aspect ratio
  4708. * @param znear defines the near clip plane
  4709. * @param zfar defines the far clip plane
  4710. * @param result defines the target matrix
  4711. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4712. */
  4713. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4714. /**
  4715. * Stores a right-handed perspective projection into a given matrix
  4716. * @param fov defines the horizontal field of view
  4717. * @param aspect defines the aspect ratio
  4718. * @param znear defines the near clip plane
  4719. * @param zfar not used as infinity is used as far clip
  4720. * @param result defines the target matrix
  4721. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4722. */
  4723. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4724. /**
  4725. * Stores a perspective projection for WebVR info a given matrix
  4726. * @param fov defines the field of view
  4727. * @param znear defines the near clip plane
  4728. * @param zfar defines the far clip plane
  4729. * @param result defines the target matrix
  4730. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4731. */
  4732. static PerspectiveFovWebVRToRef(fov: {
  4733. upDegrees: number;
  4734. downDegrees: number;
  4735. leftDegrees: number;
  4736. rightDegrees: number;
  4737. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4738. /**
  4739. * Computes a complete transformation matrix
  4740. * @param viewport defines the viewport to use
  4741. * @param world defines the world matrix
  4742. * @param view defines the view matrix
  4743. * @param projection defines the projection matrix
  4744. * @param zmin defines the near clip plane
  4745. * @param zmax defines the far clip plane
  4746. * @returns the transformation matrix
  4747. */
  4748. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4749. /**
  4750. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4751. * @param matrix defines the matrix to use
  4752. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4753. */
  4754. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4755. /**
  4756. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4757. * @param matrix defines the matrix to use
  4758. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4759. */
  4760. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4761. /**
  4762. * Compute the transpose of a given matrix
  4763. * @param matrix defines the matrix to transpose
  4764. * @returns the new matrix
  4765. */
  4766. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4767. /**
  4768. * Compute the transpose of a matrix and store it in a target matrix
  4769. * @param matrix defines the matrix to transpose
  4770. * @param result defines the target matrix
  4771. */
  4772. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4773. /**
  4774. * Computes a reflection matrix from a plane
  4775. * @param plane defines the reflection plane
  4776. * @returns a new matrix
  4777. */
  4778. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4779. /**
  4780. * Computes a reflection matrix from a plane
  4781. * @param plane defines the reflection plane
  4782. * @param result defines the target matrix
  4783. */
  4784. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4785. /**
  4786. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4787. * @param xaxis defines the value of the 1st axis
  4788. * @param yaxis defines the value of the 2nd axis
  4789. * @param zaxis defines the value of the 3rd axis
  4790. * @param result defines the target matrix
  4791. */
  4792. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4793. /**
  4794. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4795. * @param quat defines the quaternion to use
  4796. * @param result defines the target matrix
  4797. */
  4798. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4799. }
  4800. /**
  4801. * @hidden
  4802. */
  4803. export class TmpVectors {
  4804. static Vector2: Vector2[];
  4805. static Vector3: Vector3[];
  4806. static Vector4: Vector4[];
  4807. static Quaternion: Quaternion[];
  4808. static Matrix: Matrix[];
  4809. }
  4810. }
  4811. declare module "babylonjs/Maths/math.path" {
  4812. import { DeepImmutable, Nullable } from "babylonjs/types";
  4813. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4814. /**
  4815. * Defines potential orientation for back face culling
  4816. */
  4817. export enum Orientation {
  4818. /**
  4819. * Clockwise
  4820. */
  4821. CW = 0,
  4822. /** Counter clockwise */
  4823. CCW = 1
  4824. }
  4825. /** Class used to represent a Bezier curve */
  4826. export class BezierCurve {
  4827. /**
  4828. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4829. * @param t defines the time
  4830. * @param x1 defines the left coordinate on X axis
  4831. * @param y1 defines the left coordinate on Y axis
  4832. * @param x2 defines the right coordinate on X axis
  4833. * @param y2 defines the right coordinate on Y axis
  4834. * @returns the interpolated value
  4835. */
  4836. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4837. }
  4838. /**
  4839. * Defines angle representation
  4840. */
  4841. export class Angle {
  4842. private _radians;
  4843. /**
  4844. * Creates an Angle object of "radians" radians (float).
  4845. * @param radians the angle in radians
  4846. */
  4847. constructor(radians: number);
  4848. /**
  4849. * Get value in degrees
  4850. * @returns the Angle value in degrees (float)
  4851. */
  4852. degrees(): number;
  4853. /**
  4854. * Get value in radians
  4855. * @returns the Angle value in radians (float)
  4856. */
  4857. radians(): number;
  4858. /**
  4859. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4860. * @param a defines first vector
  4861. * @param b defines second vector
  4862. * @returns a new Angle
  4863. */
  4864. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4865. /**
  4866. * Gets a new Angle object from the given float in radians
  4867. * @param radians defines the angle value in radians
  4868. * @returns a new Angle
  4869. */
  4870. static FromRadians(radians: number): Angle;
  4871. /**
  4872. * Gets a new Angle object from the given float in degrees
  4873. * @param degrees defines the angle value in degrees
  4874. * @returns a new Angle
  4875. */
  4876. static FromDegrees(degrees: number): Angle;
  4877. }
  4878. /**
  4879. * This represents an arc in a 2d space.
  4880. */
  4881. export class Arc2 {
  4882. /** Defines the start point of the arc */
  4883. startPoint: Vector2;
  4884. /** Defines the mid point of the arc */
  4885. midPoint: Vector2;
  4886. /** Defines the end point of the arc */
  4887. endPoint: Vector2;
  4888. /**
  4889. * Defines the center point of the arc.
  4890. */
  4891. centerPoint: Vector2;
  4892. /**
  4893. * Defines the radius of the arc.
  4894. */
  4895. radius: number;
  4896. /**
  4897. * Defines the angle of the arc (from mid point to end point).
  4898. */
  4899. angle: Angle;
  4900. /**
  4901. * Defines the start angle of the arc (from start point to middle point).
  4902. */
  4903. startAngle: Angle;
  4904. /**
  4905. * Defines the orientation of the arc (clock wise/counter clock wise).
  4906. */
  4907. orientation: Orientation;
  4908. /**
  4909. * Creates an Arc object from the three given points : start, middle and end.
  4910. * @param startPoint Defines the start point of the arc
  4911. * @param midPoint Defines the midlle point of the arc
  4912. * @param endPoint Defines the end point of the arc
  4913. */
  4914. constructor(
  4915. /** Defines the start point of the arc */
  4916. startPoint: Vector2,
  4917. /** Defines the mid point of the arc */
  4918. midPoint: Vector2,
  4919. /** Defines the end point of the arc */
  4920. endPoint: Vector2);
  4921. }
  4922. /**
  4923. * Represents a 2D path made up of multiple 2D points
  4924. */
  4925. export class Path2 {
  4926. private _points;
  4927. private _length;
  4928. /**
  4929. * If the path start and end point are the same
  4930. */
  4931. closed: boolean;
  4932. /**
  4933. * Creates a Path2 object from the starting 2D coordinates x and y.
  4934. * @param x the starting points x value
  4935. * @param y the starting points y value
  4936. */
  4937. constructor(x: number, y: number);
  4938. /**
  4939. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4940. * @param x the added points x value
  4941. * @param y the added points y value
  4942. * @returns the updated Path2.
  4943. */
  4944. addLineTo(x: number, y: number): Path2;
  4945. /**
  4946. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4947. * @param midX middle point x value
  4948. * @param midY middle point y value
  4949. * @param endX end point x value
  4950. * @param endY end point y value
  4951. * @param numberOfSegments (default: 36)
  4952. * @returns the updated Path2.
  4953. */
  4954. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4955. /**
  4956. * Closes the Path2.
  4957. * @returns the Path2.
  4958. */
  4959. close(): Path2;
  4960. /**
  4961. * Gets the sum of the distance between each sequential point in the path
  4962. * @returns the Path2 total length (float).
  4963. */
  4964. length(): number;
  4965. /**
  4966. * Gets the points which construct the path
  4967. * @returns the Path2 internal array of points.
  4968. */
  4969. getPoints(): Vector2[];
  4970. /**
  4971. * Retreives the point at the distance aways from the starting point
  4972. * @param normalizedLengthPosition the length along the path to retreive the point from
  4973. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4974. */
  4975. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4976. /**
  4977. * Creates a new path starting from an x and y position
  4978. * @param x starting x value
  4979. * @param y starting y value
  4980. * @returns a new Path2 starting at the coordinates (x, y).
  4981. */
  4982. static StartingAt(x: number, y: number): Path2;
  4983. }
  4984. /**
  4985. * Represents a 3D path made up of multiple 3D points
  4986. */
  4987. export class Path3D {
  4988. /**
  4989. * an array of Vector3, the curve axis of the Path3D
  4990. */
  4991. path: Vector3[];
  4992. private _curve;
  4993. private _distances;
  4994. private _tangents;
  4995. private _normals;
  4996. private _binormals;
  4997. private _raw;
  4998. private _alignTangentsWithPath;
  4999. private readonly _pointAtData;
  5000. /**
  5001. * new Path3D(path, normal, raw)
  5002. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5003. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5004. * @param path an array of Vector3, the curve axis of the Path3D
  5005. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5006. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5007. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5008. */
  5009. constructor(
  5010. /**
  5011. * an array of Vector3, the curve axis of the Path3D
  5012. */
  5013. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5014. /**
  5015. * Returns the Path3D array of successive Vector3 designing its curve.
  5016. * @returns the Path3D array of successive Vector3 designing its curve.
  5017. */
  5018. getCurve(): Vector3[];
  5019. /**
  5020. * Returns the Path3D array of successive Vector3 designing its curve.
  5021. * @returns the Path3D array of successive Vector3 designing its curve.
  5022. */
  5023. getPoints(): Vector3[];
  5024. /**
  5025. * @returns the computed length (float) of the path.
  5026. */
  5027. length(): number;
  5028. /**
  5029. * Returns an array populated with tangent vectors on each Path3D curve point.
  5030. * @returns an array populated with tangent vectors on each Path3D curve point.
  5031. */
  5032. getTangents(): Vector3[];
  5033. /**
  5034. * Returns an array populated with normal vectors on each Path3D curve point.
  5035. * @returns an array populated with normal vectors on each Path3D curve point.
  5036. */
  5037. getNormals(): Vector3[];
  5038. /**
  5039. * Returns an array populated with binormal vectors on each Path3D curve point.
  5040. * @returns an array populated with binormal vectors on each Path3D curve point.
  5041. */
  5042. getBinormals(): Vector3[];
  5043. /**
  5044. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5045. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5046. */
  5047. getDistances(): number[];
  5048. /**
  5049. * Returns an interpolated point along this path
  5050. * @param position the position of the point along this path, from 0.0 to 1.0
  5051. * @returns a new Vector3 as the point
  5052. */
  5053. getPointAt(position: number): Vector3;
  5054. /**
  5055. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5056. * @param position the position of the point along this path, from 0.0 to 1.0
  5057. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5058. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5059. */
  5060. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5061. /**
  5062. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5063. * @param position the position of the point along this path, from 0.0 to 1.0
  5064. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5065. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5066. */
  5067. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5068. /**
  5069. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5070. * @param position the position of the point along this path, from 0.0 to 1.0
  5071. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5072. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5073. */
  5074. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5075. /**
  5076. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5077. * @param position the position of the point along this path, from 0.0 to 1.0
  5078. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5079. */
  5080. getDistanceAt(position: number): number;
  5081. /**
  5082. * Returns the array index of the previous point of an interpolated point along this path
  5083. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5084. * @returns the array index
  5085. */
  5086. getPreviousPointIndexAt(position: number): number;
  5087. /**
  5088. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5089. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5090. * @returns the sub position
  5091. */
  5092. getSubPositionAt(position: number): number;
  5093. /**
  5094. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5095. * @param target the vector of which to get the closest position to
  5096. * @returns the position of the closest virtual point on this path to the target vector
  5097. */
  5098. getClosestPositionTo(target: Vector3): number;
  5099. /**
  5100. * Returns a sub path (slice) of this path
  5101. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5102. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5103. * @returns a sub path (slice) of this path
  5104. */
  5105. slice(start?: number, end?: number): Path3D;
  5106. /**
  5107. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5108. * @param path path which all values are copied into the curves points
  5109. * @param firstNormal which should be projected onto the curve
  5110. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5111. * @returns the same object updated.
  5112. */
  5113. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5114. private _compute;
  5115. private _getFirstNonNullVector;
  5116. private _getLastNonNullVector;
  5117. private _normalVector;
  5118. /**
  5119. * Updates the point at data for an interpolated point along this curve
  5120. * @param position the position of the point along this curve, from 0.0 to 1.0
  5121. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5122. * @returns the (updated) point at data
  5123. */
  5124. private _updatePointAtData;
  5125. /**
  5126. * Updates the point at data from the specified parameters
  5127. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5128. * @param point the interpolated point
  5129. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5130. */
  5131. private _setPointAtData;
  5132. /**
  5133. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5134. */
  5135. private _updateInterpolationMatrix;
  5136. }
  5137. /**
  5138. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5139. * A Curve3 is designed from a series of successive Vector3.
  5140. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5141. */
  5142. export class Curve3 {
  5143. private _points;
  5144. private _length;
  5145. /**
  5146. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5147. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5148. * @param v1 (Vector3) the control point
  5149. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5150. * @param nbPoints (integer) the wanted number of points in the curve
  5151. * @returns the created Curve3
  5152. */
  5153. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5154. /**
  5155. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5156. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5157. * @param v1 (Vector3) the first control point
  5158. * @param v2 (Vector3) the second control point
  5159. * @param v3 (Vector3) the end point of the Cubic Bezier
  5160. * @param nbPoints (integer) the wanted number of points in the curve
  5161. * @returns the created Curve3
  5162. */
  5163. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5164. /**
  5165. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5166. * @param p1 (Vector3) the origin point of the Hermite Spline
  5167. * @param t1 (Vector3) the tangent vector at the origin point
  5168. * @param p2 (Vector3) the end point of the Hermite Spline
  5169. * @param t2 (Vector3) the tangent vector at the end point
  5170. * @param nbPoints (integer) the wanted number of points in the curve
  5171. * @returns the created Curve3
  5172. */
  5173. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5174. /**
  5175. * Returns a Curve3 object along a CatmullRom Spline curve :
  5176. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5177. * @param nbPoints (integer) the wanted number of points between each curve control points
  5178. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5179. * @returns the created Curve3
  5180. */
  5181. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5182. /**
  5183. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5184. * A Curve3 is designed from a series of successive Vector3.
  5185. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5186. * @param points points which make up the curve
  5187. */
  5188. constructor(points: Vector3[]);
  5189. /**
  5190. * @returns the Curve3 stored array of successive Vector3
  5191. */
  5192. getPoints(): Vector3[];
  5193. /**
  5194. * @returns the computed length (float) of the curve.
  5195. */
  5196. length(): number;
  5197. /**
  5198. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5199. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5200. * curveA and curveB keep unchanged.
  5201. * @param curve the curve to continue from this curve
  5202. * @returns the newly constructed curve
  5203. */
  5204. continue(curve: DeepImmutable<Curve3>): Curve3;
  5205. private _computeLength;
  5206. }
  5207. }
  5208. declare module "babylonjs/Animations/easing" {
  5209. /**
  5210. * This represents the main contract an easing function should follow.
  5211. * Easing functions are used throughout the animation system.
  5212. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export interface IEasingFunction {
  5215. /**
  5216. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5217. * of the easing function.
  5218. * The link below provides some of the most common examples of easing functions.
  5219. * @see https://easings.net/
  5220. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5221. * @returns the corresponding value on the curve defined by the easing function
  5222. */
  5223. ease(gradient: number): number;
  5224. }
  5225. /**
  5226. * Base class used for every default easing function.
  5227. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5228. */
  5229. export class EasingFunction implements IEasingFunction {
  5230. /**
  5231. * Interpolation follows the mathematical formula associated with the easing function.
  5232. */
  5233. static readonly EASINGMODE_EASEIN: number;
  5234. /**
  5235. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5236. */
  5237. static readonly EASINGMODE_EASEOUT: number;
  5238. /**
  5239. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5240. */
  5241. static readonly EASINGMODE_EASEINOUT: number;
  5242. private _easingMode;
  5243. /**
  5244. * Sets the easing mode of the current function.
  5245. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5246. */
  5247. setEasingMode(easingMode: number): void;
  5248. /**
  5249. * Gets the current easing mode.
  5250. * @returns the easing mode
  5251. */
  5252. getEasingMode(): number;
  5253. /**
  5254. * @hidden
  5255. */
  5256. easeInCore(gradient: number): number;
  5257. /**
  5258. * Given an input gradient between 0 and 1, this returns the corresponding value
  5259. * of the easing function.
  5260. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5261. * @returns the corresponding value on the curve defined by the easing function
  5262. */
  5263. ease(gradient: number): number;
  5264. }
  5265. /**
  5266. * Easing function with a circle shape (see link below).
  5267. * @see https://easings.net/#easeInCirc
  5268. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5269. */
  5270. export class CircleEase extends EasingFunction implements IEasingFunction {
  5271. /** @hidden */
  5272. easeInCore(gradient: number): number;
  5273. }
  5274. /**
  5275. * Easing function with a ease back shape (see link below).
  5276. * @see https://easings.net/#easeInBack
  5277. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5278. */
  5279. export class BackEase extends EasingFunction implements IEasingFunction {
  5280. /** Defines the amplitude of the function */
  5281. amplitude: number;
  5282. /**
  5283. * Instantiates a back ease easing
  5284. * @see https://easings.net/#easeInBack
  5285. * @param amplitude Defines the amplitude of the function
  5286. */
  5287. constructor(
  5288. /** Defines the amplitude of the function */
  5289. amplitude?: number);
  5290. /** @hidden */
  5291. easeInCore(gradient: number): number;
  5292. }
  5293. /**
  5294. * Easing function with a bouncing shape (see link below).
  5295. * @see https://easings.net/#easeInBounce
  5296. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5297. */
  5298. export class BounceEase extends EasingFunction implements IEasingFunction {
  5299. /** Defines the number of bounces */
  5300. bounces: number;
  5301. /** Defines the amplitude of the bounce */
  5302. bounciness: number;
  5303. /**
  5304. * Instantiates a bounce easing
  5305. * @see https://easings.net/#easeInBounce
  5306. * @param bounces Defines the number of bounces
  5307. * @param bounciness Defines the amplitude of the bounce
  5308. */
  5309. constructor(
  5310. /** Defines the number of bounces */
  5311. bounces?: number,
  5312. /** Defines the amplitude of the bounce */
  5313. bounciness?: number);
  5314. /** @hidden */
  5315. easeInCore(gradient: number): number;
  5316. }
  5317. /**
  5318. * Easing function with a power of 3 shape (see link below).
  5319. * @see https://easings.net/#easeInCubic
  5320. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5321. */
  5322. export class CubicEase extends EasingFunction implements IEasingFunction {
  5323. /** @hidden */
  5324. easeInCore(gradient: number): number;
  5325. }
  5326. /**
  5327. * Easing function with an elastic shape (see link below).
  5328. * @see https://easings.net/#easeInElastic
  5329. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5330. */
  5331. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5332. /** Defines the number of oscillations*/
  5333. oscillations: number;
  5334. /** Defines the amplitude of the oscillations*/
  5335. springiness: number;
  5336. /**
  5337. * Instantiates an elastic easing function
  5338. * @see https://easings.net/#easeInElastic
  5339. * @param oscillations Defines the number of oscillations
  5340. * @param springiness Defines the amplitude of the oscillations
  5341. */
  5342. constructor(
  5343. /** Defines the number of oscillations*/
  5344. oscillations?: number,
  5345. /** Defines the amplitude of the oscillations*/
  5346. springiness?: number);
  5347. /** @hidden */
  5348. easeInCore(gradient: number): number;
  5349. }
  5350. /**
  5351. * Easing function with an exponential shape (see link below).
  5352. * @see https://easings.net/#easeInExpo
  5353. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5354. */
  5355. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5356. /** Defines the exponent of the function */
  5357. exponent: number;
  5358. /**
  5359. * Instantiates an exponential easing function
  5360. * @see https://easings.net/#easeInExpo
  5361. * @param exponent Defines the exponent of the function
  5362. */
  5363. constructor(
  5364. /** Defines the exponent of the function */
  5365. exponent?: number);
  5366. /** @hidden */
  5367. easeInCore(gradient: number): number;
  5368. }
  5369. /**
  5370. * Easing function with a power shape (see link below).
  5371. * @see https://easings.net/#easeInQuad
  5372. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5373. */
  5374. export class PowerEase extends EasingFunction implements IEasingFunction {
  5375. /** Defines the power of the function */
  5376. power: number;
  5377. /**
  5378. * Instantiates an power base easing function
  5379. * @see https://easings.net/#easeInQuad
  5380. * @param power Defines the power of the function
  5381. */
  5382. constructor(
  5383. /** Defines the power of the function */
  5384. power?: number);
  5385. /** @hidden */
  5386. easeInCore(gradient: number): number;
  5387. }
  5388. /**
  5389. * Easing function with a power of 2 shape (see link below).
  5390. * @see https://easings.net/#easeInQuad
  5391. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5392. */
  5393. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5394. /** @hidden */
  5395. easeInCore(gradient: number): number;
  5396. }
  5397. /**
  5398. * Easing function with a power of 4 shape (see link below).
  5399. * @see https://easings.net/#easeInQuart
  5400. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5401. */
  5402. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with a power of 5 shape (see link below).
  5408. * @see https://easings.net/#easeInQuint
  5409. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5412. /** @hidden */
  5413. easeInCore(gradient: number): number;
  5414. }
  5415. /**
  5416. * Easing function with a sin shape (see link below).
  5417. * @see https://easings.net/#easeInSine
  5418. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5419. */
  5420. export class SineEase extends EasingFunction implements IEasingFunction {
  5421. /** @hidden */
  5422. easeInCore(gradient: number): number;
  5423. }
  5424. /**
  5425. * Easing function with a bezier shape (see link below).
  5426. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5427. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5428. */
  5429. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5430. /** Defines the x component of the start tangent in the bezier curve */
  5431. x1: number;
  5432. /** Defines the y component of the start tangent in the bezier curve */
  5433. y1: number;
  5434. /** Defines the x component of the end tangent in the bezier curve */
  5435. x2: number;
  5436. /** Defines the y component of the end tangent in the bezier curve */
  5437. y2: number;
  5438. /**
  5439. * Instantiates a bezier function
  5440. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5441. * @param x1 Defines the x component of the start tangent in the bezier curve
  5442. * @param y1 Defines the y component of the start tangent in the bezier curve
  5443. * @param x2 Defines the x component of the end tangent in the bezier curve
  5444. * @param y2 Defines the y component of the end tangent in the bezier curve
  5445. */
  5446. constructor(
  5447. /** Defines the x component of the start tangent in the bezier curve */
  5448. x1?: number,
  5449. /** Defines the y component of the start tangent in the bezier curve */
  5450. y1?: number,
  5451. /** Defines the x component of the end tangent in the bezier curve */
  5452. x2?: number,
  5453. /** Defines the y component of the end tangent in the bezier curve */
  5454. y2?: number);
  5455. /** @hidden */
  5456. easeInCore(gradient: number): number;
  5457. }
  5458. }
  5459. declare module "babylonjs/Maths/math.color" {
  5460. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5461. /**
  5462. * Class used to hold a RBG color
  5463. */
  5464. export class Color3 {
  5465. /**
  5466. * Defines the red component (between 0 and 1, default is 0)
  5467. */
  5468. r: number;
  5469. /**
  5470. * Defines the green component (between 0 and 1, default is 0)
  5471. */
  5472. g: number;
  5473. /**
  5474. * Defines the blue component (between 0 and 1, default is 0)
  5475. */
  5476. b: number;
  5477. /**
  5478. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5479. * @param r defines the red component (between 0 and 1, default is 0)
  5480. * @param g defines the green component (between 0 and 1, default is 0)
  5481. * @param b defines the blue component (between 0 and 1, default is 0)
  5482. */
  5483. constructor(
  5484. /**
  5485. * Defines the red component (between 0 and 1, default is 0)
  5486. */
  5487. r?: number,
  5488. /**
  5489. * Defines the green component (between 0 and 1, default is 0)
  5490. */
  5491. g?: number,
  5492. /**
  5493. * Defines the blue component (between 0 and 1, default is 0)
  5494. */
  5495. b?: number);
  5496. /**
  5497. * Creates a string with the Color3 current values
  5498. * @returns the string representation of the Color3 object
  5499. */
  5500. toString(): string;
  5501. /**
  5502. * Returns the string "Color3"
  5503. * @returns "Color3"
  5504. */
  5505. getClassName(): string;
  5506. /**
  5507. * Compute the Color3 hash code
  5508. * @returns an unique number that can be used to hash Color3 objects
  5509. */
  5510. getHashCode(): number;
  5511. /**
  5512. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5513. * @param array defines the array where to store the r,g,b components
  5514. * @param index defines an optional index in the target array to define where to start storing values
  5515. * @returns the current Color3 object
  5516. */
  5517. toArray(array: FloatArray, index?: number): Color3;
  5518. /**
  5519. * Returns a new Color4 object from the current Color3 and the given alpha
  5520. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5521. * @returns a new Color4 object
  5522. */
  5523. toColor4(alpha?: number): Color4;
  5524. /**
  5525. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5526. * @returns the new array
  5527. */
  5528. asArray(): number[];
  5529. /**
  5530. * Returns the luminance value
  5531. * @returns a float value
  5532. */
  5533. toLuminance(): number;
  5534. /**
  5535. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5536. * @param otherColor defines the second operand
  5537. * @returns the new Color3 object
  5538. */
  5539. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5540. /**
  5541. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5542. * @param otherColor defines the second operand
  5543. * @param result defines the Color3 object where to store the result
  5544. * @returns the current Color3
  5545. */
  5546. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5547. /**
  5548. * Determines equality between Color3 objects
  5549. * @param otherColor defines the second operand
  5550. * @returns true if the rgb values are equal to the given ones
  5551. */
  5552. equals(otherColor: DeepImmutable<Color3>): boolean;
  5553. /**
  5554. * Determines equality between the current Color3 object and a set of r,b,g values
  5555. * @param r defines the red component to check
  5556. * @param g defines the green component to check
  5557. * @param b defines the blue component to check
  5558. * @returns true if the rgb values are equal to the given ones
  5559. */
  5560. equalsFloats(r: number, g: number, b: number): boolean;
  5561. /**
  5562. * Multiplies in place each rgb value by scale
  5563. * @param scale defines the scaling factor
  5564. * @returns the updated Color3
  5565. */
  5566. scale(scale: number): Color3;
  5567. /**
  5568. * Multiplies the rgb values by scale and stores the result into "result"
  5569. * @param scale defines the scaling factor
  5570. * @param result defines the Color3 object where to store the result
  5571. * @returns the unmodified current Color3
  5572. */
  5573. scaleToRef(scale: number, result: Color3): Color3;
  5574. /**
  5575. * Scale the current Color3 values by a factor and add the result to a given Color3
  5576. * @param scale defines the scale factor
  5577. * @param result defines color to store the result into
  5578. * @returns the unmodified current Color3
  5579. */
  5580. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5581. /**
  5582. * Clamps the rgb values by the min and max values and stores the result into "result"
  5583. * @param min defines minimum clamping value (default is 0)
  5584. * @param max defines maximum clamping value (default is 1)
  5585. * @param result defines color to store the result into
  5586. * @returns the original Color3
  5587. */
  5588. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5589. /**
  5590. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5591. * @param otherColor defines the second operand
  5592. * @returns the new Color3
  5593. */
  5594. add(otherColor: DeepImmutable<Color3>): Color3;
  5595. /**
  5596. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5597. * @param otherColor defines the second operand
  5598. * @param result defines Color3 object to store the result into
  5599. * @returns the unmodified current Color3
  5600. */
  5601. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5602. /**
  5603. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5604. * @param otherColor defines the second operand
  5605. * @returns the new Color3
  5606. */
  5607. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5608. /**
  5609. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5610. * @param otherColor defines the second operand
  5611. * @param result defines Color3 object to store the result into
  5612. * @returns the unmodified current Color3
  5613. */
  5614. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5615. /**
  5616. * Copy the current object
  5617. * @returns a new Color3 copied the current one
  5618. */
  5619. clone(): Color3;
  5620. /**
  5621. * Copies the rgb values from the source in the current Color3
  5622. * @param source defines the source Color3 object
  5623. * @returns the updated Color3 object
  5624. */
  5625. copyFrom(source: DeepImmutable<Color3>): Color3;
  5626. /**
  5627. * Updates the Color3 rgb values from the given floats
  5628. * @param r defines the red component to read from
  5629. * @param g defines the green component to read from
  5630. * @param b defines the blue component to read from
  5631. * @returns the current Color3 object
  5632. */
  5633. copyFromFloats(r: number, g: number, b: number): Color3;
  5634. /**
  5635. * Updates the Color3 rgb values from the given floats
  5636. * @param r defines the red component to read from
  5637. * @param g defines the green component to read from
  5638. * @param b defines the blue component to read from
  5639. * @returns the current Color3 object
  5640. */
  5641. set(r: number, g: number, b: number): Color3;
  5642. /**
  5643. * Compute the Color3 hexadecimal code as a string
  5644. * @returns a string containing the hexadecimal representation of the Color3 object
  5645. */
  5646. toHexString(): string;
  5647. /**
  5648. * Computes a new Color3 converted from the current one to linear space
  5649. * @returns a new Color3 object
  5650. */
  5651. toLinearSpace(): Color3;
  5652. /**
  5653. * Converts current color in rgb space to HSV values
  5654. * @returns a new color3 representing the HSV values
  5655. */
  5656. toHSV(): Color3;
  5657. /**
  5658. * Converts current color in rgb space to HSV values
  5659. * @param result defines the Color3 where to store the HSV values
  5660. */
  5661. toHSVToRef(result: Color3): void;
  5662. /**
  5663. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5664. * @param convertedColor defines the Color3 object where to store the linear space version
  5665. * @returns the unmodified Color3
  5666. */
  5667. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5668. /**
  5669. * Computes a new Color3 converted from the current one to gamma space
  5670. * @returns a new Color3 object
  5671. */
  5672. toGammaSpace(): Color3;
  5673. /**
  5674. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5675. * @param convertedColor defines the Color3 object where to store the gamma space version
  5676. * @returns the unmodified Color3
  5677. */
  5678. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5679. private static _BlackReadOnly;
  5680. /**
  5681. * Convert Hue, saturation and value to a Color3 (RGB)
  5682. * @param hue defines the hue
  5683. * @param saturation defines the saturation
  5684. * @param value defines the value
  5685. * @param result defines the Color3 where to store the RGB values
  5686. */
  5687. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5688. /**
  5689. * Creates a new Color3 from the string containing valid hexadecimal values
  5690. * @param hex defines a string containing valid hexadecimal values
  5691. * @returns a new Color3 object
  5692. */
  5693. static FromHexString(hex: string): Color3;
  5694. /**
  5695. * Creates a new Color3 from the starting index of the given array
  5696. * @param array defines the source array
  5697. * @param offset defines an offset in the source array
  5698. * @returns a new Color3 object
  5699. */
  5700. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5701. /**
  5702. * Creates a new Color3 from integer values (< 256)
  5703. * @param r defines the red component to read from (value between 0 and 255)
  5704. * @param g defines the green component to read from (value between 0 and 255)
  5705. * @param b defines the blue component to read from (value between 0 and 255)
  5706. * @returns a new Color3 object
  5707. */
  5708. static FromInts(r: number, g: number, b: number): Color3;
  5709. /**
  5710. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5711. * @param start defines the start Color3 value
  5712. * @param end defines the end Color3 value
  5713. * @param amount defines the gradient value between start and end
  5714. * @returns a new Color3 object
  5715. */
  5716. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5717. /**
  5718. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5719. * @param left defines the start value
  5720. * @param right defines the end value
  5721. * @param amount defines the gradient factor
  5722. * @param result defines the Color3 object where to store the result
  5723. */
  5724. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5725. /**
  5726. * Returns a Color3 value containing a red color
  5727. * @returns a new Color3 object
  5728. */
  5729. static Red(): Color3;
  5730. /**
  5731. * Returns a Color3 value containing a green color
  5732. * @returns a new Color3 object
  5733. */
  5734. static Green(): Color3;
  5735. /**
  5736. * Returns a Color3 value containing a blue color
  5737. * @returns a new Color3 object
  5738. */
  5739. static Blue(): Color3;
  5740. /**
  5741. * Returns a Color3 value containing a black color
  5742. * @returns a new Color3 object
  5743. */
  5744. static Black(): Color3;
  5745. /**
  5746. * Gets a Color3 value containing a black color that must not be updated
  5747. */
  5748. static get BlackReadOnly(): DeepImmutable<Color3>;
  5749. /**
  5750. * Returns a Color3 value containing a white color
  5751. * @returns a new Color3 object
  5752. */
  5753. static White(): Color3;
  5754. /**
  5755. * Returns a Color3 value containing a purple color
  5756. * @returns a new Color3 object
  5757. */
  5758. static Purple(): Color3;
  5759. /**
  5760. * Returns a Color3 value containing a magenta color
  5761. * @returns a new Color3 object
  5762. */
  5763. static Magenta(): Color3;
  5764. /**
  5765. * Returns a Color3 value containing a yellow color
  5766. * @returns a new Color3 object
  5767. */
  5768. static Yellow(): Color3;
  5769. /**
  5770. * Returns a Color3 value containing a gray color
  5771. * @returns a new Color3 object
  5772. */
  5773. static Gray(): Color3;
  5774. /**
  5775. * Returns a Color3 value containing a teal color
  5776. * @returns a new Color3 object
  5777. */
  5778. static Teal(): Color3;
  5779. /**
  5780. * Returns a Color3 value containing a random color
  5781. * @returns a new Color3 object
  5782. */
  5783. static Random(): Color3;
  5784. }
  5785. /**
  5786. * Class used to hold a RBGA color
  5787. */
  5788. export class Color4 {
  5789. /**
  5790. * Defines the red component (between 0 and 1, default is 0)
  5791. */
  5792. r: number;
  5793. /**
  5794. * Defines the green component (between 0 and 1, default is 0)
  5795. */
  5796. g: number;
  5797. /**
  5798. * Defines the blue component (between 0 and 1, default is 0)
  5799. */
  5800. b: number;
  5801. /**
  5802. * Defines the alpha component (between 0 and 1, default is 1)
  5803. */
  5804. a: number;
  5805. /**
  5806. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5807. * @param r defines the red component (between 0 and 1, default is 0)
  5808. * @param g defines the green component (between 0 and 1, default is 0)
  5809. * @param b defines the blue component (between 0 and 1, default is 0)
  5810. * @param a defines the alpha component (between 0 and 1, default is 1)
  5811. */
  5812. constructor(
  5813. /**
  5814. * Defines the red component (between 0 and 1, default is 0)
  5815. */
  5816. r?: number,
  5817. /**
  5818. * Defines the green component (between 0 and 1, default is 0)
  5819. */
  5820. g?: number,
  5821. /**
  5822. * Defines the blue component (between 0 and 1, default is 0)
  5823. */
  5824. b?: number,
  5825. /**
  5826. * Defines the alpha component (between 0 and 1, default is 1)
  5827. */
  5828. a?: number);
  5829. /**
  5830. * Adds in place the given Color4 values to the current Color4 object
  5831. * @param right defines the second operand
  5832. * @returns the current updated Color4 object
  5833. */
  5834. addInPlace(right: DeepImmutable<Color4>): Color4;
  5835. /**
  5836. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5837. * @returns the new array
  5838. */
  5839. asArray(): number[];
  5840. /**
  5841. * Stores from the starting index in the given array the Color4 successive values
  5842. * @param array defines the array where to store the r,g,b components
  5843. * @param index defines an optional index in the target array to define where to start storing values
  5844. * @returns the current Color4 object
  5845. */
  5846. toArray(array: number[], index?: number): Color4;
  5847. /**
  5848. * Determines equality between Color4 objects
  5849. * @param otherColor defines the second operand
  5850. * @returns true if the rgba values are equal to the given ones
  5851. */
  5852. equals(otherColor: DeepImmutable<Color4>): boolean;
  5853. /**
  5854. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5855. * @param right defines the second operand
  5856. * @returns a new Color4 object
  5857. */
  5858. add(right: DeepImmutable<Color4>): Color4;
  5859. /**
  5860. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5861. * @param right defines the second operand
  5862. * @returns a new Color4 object
  5863. */
  5864. subtract(right: DeepImmutable<Color4>): Color4;
  5865. /**
  5866. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5867. * @param right defines the second operand
  5868. * @param result defines the Color4 object where to store the result
  5869. * @returns the current Color4 object
  5870. */
  5871. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5872. /**
  5873. * Creates a new Color4 with the current Color4 values multiplied by scale
  5874. * @param scale defines the scaling factor to apply
  5875. * @returns a new Color4 object
  5876. */
  5877. scale(scale: number): Color4;
  5878. /**
  5879. * Multiplies the current Color4 values by scale and stores the result in "result"
  5880. * @param scale defines the scaling factor to apply
  5881. * @param result defines the Color4 object where to store the result
  5882. * @returns the current unmodified Color4
  5883. */
  5884. scaleToRef(scale: number, result: Color4): Color4;
  5885. /**
  5886. * Scale the current Color4 values by a factor and add the result to a given Color4
  5887. * @param scale defines the scale factor
  5888. * @param result defines the Color4 object where to store the result
  5889. * @returns the unmodified current Color4
  5890. */
  5891. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5892. /**
  5893. * Clamps the rgb values by the min and max values and stores the result into "result"
  5894. * @param min defines minimum clamping value (default is 0)
  5895. * @param max defines maximum clamping value (default is 1)
  5896. * @param result defines color to store the result into.
  5897. * @returns the cuurent Color4
  5898. */
  5899. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5900. /**
  5901. * Multipy an Color4 value by another and return a new Color4 object
  5902. * @param color defines the Color4 value to multiply by
  5903. * @returns a new Color4 object
  5904. */
  5905. multiply(color: Color4): Color4;
  5906. /**
  5907. * Multipy a Color4 value by another and push the result in a reference value
  5908. * @param color defines the Color4 value to multiply by
  5909. * @param result defines the Color4 to fill the result in
  5910. * @returns the result Color4
  5911. */
  5912. multiplyToRef(color: Color4, result: Color4): Color4;
  5913. /**
  5914. * Creates a string with the Color4 current values
  5915. * @returns the string representation of the Color4 object
  5916. */
  5917. toString(): string;
  5918. /**
  5919. * Returns the string "Color4"
  5920. * @returns "Color4"
  5921. */
  5922. getClassName(): string;
  5923. /**
  5924. * Compute the Color4 hash code
  5925. * @returns an unique number that can be used to hash Color4 objects
  5926. */
  5927. getHashCode(): number;
  5928. /**
  5929. * Creates a new Color4 copied from the current one
  5930. * @returns a new Color4 object
  5931. */
  5932. clone(): Color4;
  5933. /**
  5934. * Copies the given Color4 values into the current one
  5935. * @param source defines the source Color4 object
  5936. * @returns the current updated Color4 object
  5937. */
  5938. copyFrom(source: Color4): Color4;
  5939. /**
  5940. * Copies the given float values into the current one
  5941. * @param r defines the red component to read from
  5942. * @param g defines the green component to read from
  5943. * @param b defines the blue component to read from
  5944. * @param a defines the alpha component to read from
  5945. * @returns the current updated Color4 object
  5946. */
  5947. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5948. /**
  5949. * Copies the given float values into the current one
  5950. * @param r defines the red component to read from
  5951. * @param g defines the green component to read from
  5952. * @param b defines the blue component to read from
  5953. * @param a defines the alpha component to read from
  5954. * @returns the current updated Color4 object
  5955. */
  5956. set(r: number, g: number, b: number, a: number): Color4;
  5957. /**
  5958. * Compute the Color4 hexadecimal code as a string
  5959. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5960. * @returns a string containing the hexadecimal representation of the Color4 object
  5961. */
  5962. toHexString(returnAsColor3?: boolean): string;
  5963. /**
  5964. * Computes a new Color4 converted from the current one to linear space
  5965. * @returns a new Color4 object
  5966. */
  5967. toLinearSpace(): Color4;
  5968. /**
  5969. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5970. * @param convertedColor defines the Color4 object where to store the linear space version
  5971. * @returns the unmodified Color4
  5972. */
  5973. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5974. /**
  5975. * Computes a new Color4 converted from the current one to gamma space
  5976. * @returns a new Color4 object
  5977. */
  5978. toGammaSpace(): Color4;
  5979. /**
  5980. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5981. * @param convertedColor defines the Color4 object where to store the gamma space version
  5982. * @returns the unmodified Color4
  5983. */
  5984. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5985. /**
  5986. * Creates a new Color4 from the string containing valid hexadecimal values
  5987. * @param hex defines a string containing valid hexadecimal values
  5988. * @returns a new Color4 object
  5989. */
  5990. static FromHexString(hex: string): Color4;
  5991. /**
  5992. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5993. * @param left defines the start value
  5994. * @param right defines the end value
  5995. * @param amount defines the gradient factor
  5996. * @returns a new Color4 object
  5997. */
  5998. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5999. /**
  6000. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6001. * @param left defines the start value
  6002. * @param right defines the end value
  6003. * @param amount defines the gradient factor
  6004. * @param result defines the Color4 object where to store data
  6005. */
  6006. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6007. /**
  6008. * Creates a new Color4 from a Color3 and an alpha value
  6009. * @param color3 defines the source Color3 to read from
  6010. * @param alpha defines the alpha component (1.0 by default)
  6011. * @returns a new Color4 object
  6012. */
  6013. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6014. /**
  6015. * Creates a new Color4 from the starting index element of the given array
  6016. * @param array defines the source array to read from
  6017. * @param offset defines the offset in the source array
  6018. * @returns a new Color4 object
  6019. */
  6020. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6021. /**
  6022. * Creates a new Color3 from integer values (< 256)
  6023. * @param r defines the red component to read from (value between 0 and 255)
  6024. * @param g defines the green component to read from (value between 0 and 255)
  6025. * @param b defines the blue component to read from (value between 0 and 255)
  6026. * @param a defines the alpha component to read from (value between 0 and 255)
  6027. * @returns a new Color3 object
  6028. */
  6029. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6030. /**
  6031. * Check the content of a given array and convert it to an array containing RGBA data
  6032. * If the original array was already containing count * 4 values then it is returned directly
  6033. * @param colors defines the array to check
  6034. * @param count defines the number of RGBA data to expect
  6035. * @returns an array containing count * 4 values (RGBA)
  6036. */
  6037. static CheckColors4(colors: number[], count: number): number[];
  6038. }
  6039. /**
  6040. * @hidden
  6041. */
  6042. export class TmpColors {
  6043. static Color3: Color3[];
  6044. static Color4: Color4[];
  6045. }
  6046. }
  6047. declare module "babylonjs/Animations/animationKey" {
  6048. /**
  6049. * Defines an interface which represents an animation key frame
  6050. */
  6051. export interface IAnimationKey {
  6052. /**
  6053. * Frame of the key frame
  6054. */
  6055. frame: number;
  6056. /**
  6057. * Value at the specifies key frame
  6058. */
  6059. value: any;
  6060. /**
  6061. * The input tangent for the cubic hermite spline
  6062. */
  6063. inTangent?: any;
  6064. /**
  6065. * The output tangent for the cubic hermite spline
  6066. */
  6067. outTangent?: any;
  6068. /**
  6069. * The animation interpolation type
  6070. */
  6071. interpolation?: AnimationKeyInterpolation;
  6072. }
  6073. /**
  6074. * Enum for the animation key frame interpolation type
  6075. */
  6076. export enum AnimationKeyInterpolation {
  6077. /**
  6078. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6079. */
  6080. STEP = 1
  6081. }
  6082. }
  6083. declare module "babylonjs/Animations/animationRange" {
  6084. /**
  6085. * Represents the range of an animation
  6086. */
  6087. export class AnimationRange {
  6088. /**The name of the animation range**/
  6089. name: string;
  6090. /**The starting frame of the animation */
  6091. from: number;
  6092. /**The ending frame of the animation*/
  6093. to: number;
  6094. /**
  6095. * Initializes the range of an animation
  6096. * @param name The name of the animation range
  6097. * @param from The starting frame of the animation
  6098. * @param to The ending frame of the animation
  6099. */
  6100. constructor(
  6101. /**The name of the animation range**/
  6102. name: string,
  6103. /**The starting frame of the animation */
  6104. from: number,
  6105. /**The ending frame of the animation*/
  6106. to: number);
  6107. /**
  6108. * Makes a copy of the animation range
  6109. * @returns A copy of the animation range
  6110. */
  6111. clone(): AnimationRange;
  6112. }
  6113. }
  6114. declare module "babylonjs/Animations/animationEvent" {
  6115. /**
  6116. * Composed of a frame, and an action function
  6117. */
  6118. export class AnimationEvent {
  6119. /** The frame for which the event is triggered **/
  6120. frame: number;
  6121. /** The event to perform when triggered **/
  6122. action: (currentFrame: number) => void;
  6123. /** Specifies if the event should be triggered only once**/
  6124. onlyOnce?: boolean | undefined;
  6125. /**
  6126. * Specifies if the animation event is done
  6127. */
  6128. isDone: boolean;
  6129. /**
  6130. * Initializes the animation event
  6131. * @param frame The frame for which the event is triggered
  6132. * @param action The event to perform when triggered
  6133. * @param onlyOnce Specifies if the event should be triggered only once
  6134. */
  6135. constructor(
  6136. /** The frame for which the event is triggered **/
  6137. frame: number,
  6138. /** The event to perform when triggered **/
  6139. action: (currentFrame: number) => void,
  6140. /** Specifies if the event should be triggered only once**/
  6141. onlyOnce?: boolean | undefined);
  6142. /** @hidden */
  6143. _clone(): AnimationEvent;
  6144. }
  6145. }
  6146. declare module "babylonjs/Behaviors/behavior" {
  6147. import { Nullable } from "babylonjs/types";
  6148. /**
  6149. * Interface used to define a behavior
  6150. */
  6151. export interface Behavior<T> {
  6152. /** gets or sets behavior's name */
  6153. name: string;
  6154. /**
  6155. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6156. */
  6157. init(): void;
  6158. /**
  6159. * Called when the behavior is attached to a target
  6160. * @param target defines the target where the behavior is attached to
  6161. */
  6162. attach(target: T): void;
  6163. /**
  6164. * Called when the behavior is detached from its target
  6165. */
  6166. detach(): void;
  6167. }
  6168. /**
  6169. * Interface implemented by classes supporting behaviors
  6170. */
  6171. export interface IBehaviorAware<T> {
  6172. /**
  6173. * Attach a behavior
  6174. * @param behavior defines the behavior to attach
  6175. * @returns the current host
  6176. */
  6177. addBehavior(behavior: Behavior<T>): T;
  6178. /**
  6179. * Remove a behavior from the current object
  6180. * @param behavior defines the behavior to detach
  6181. * @returns the current host
  6182. */
  6183. removeBehavior(behavior: Behavior<T>): T;
  6184. /**
  6185. * Gets a behavior using its name to search
  6186. * @param name defines the name to search
  6187. * @returns the behavior or null if not found
  6188. */
  6189. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6190. }
  6191. }
  6192. declare module "babylonjs/Misc/smartArray" {
  6193. /**
  6194. * Defines an array and its length.
  6195. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6196. */
  6197. export interface ISmartArrayLike<T> {
  6198. /**
  6199. * The data of the array.
  6200. */
  6201. data: Array<T>;
  6202. /**
  6203. * The active length of the array.
  6204. */
  6205. length: number;
  6206. }
  6207. /**
  6208. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6209. */
  6210. export class SmartArray<T> implements ISmartArrayLike<T> {
  6211. /**
  6212. * The full set of data from the array.
  6213. */
  6214. data: Array<T>;
  6215. /**
  6216. * The active length of the array.
  6217. */
  6218. length: number;
  6219. protected _id: number;
  6220. /**
  6221. * Instantiates a Smart Array.
  6222. * @param capacity defines the default capacity of the array.
  6223. */
  6224. constructor(capacity: number);
  6225. /**
  6226. * Pushes a value at the end of the active data.
  6227. * @param value defines the object to push in the array.
  6228. */
  6229. push(value: T): void;
  6230. /**
  6231. * Iterates over the active data and apply the lambda to them.
  6232. * @param func defines the action to apply on each value.
  6233. */
  6234. forEach(func: (content: T) => void): void;
  6235. /**
  6236. * Sorts the full sets of data.
  6237. * @param compareFn defines the comparison function to apply.
  6238. */
  6239. sort(compareFn: (a: T, b: T) => number): void;
  6240. /**
  6241. * Resets the active data to an empty array.
  6242. */
  6243. reset(): void;
  6244. /**
  6245. * Releases all the data from the array as well as the array.
  6246. */
  6247. dispose(): void;
  6248. /**
  6249. * Concats the active data with a given array.
  6250. * @param array defines the data to concatenate with.
  6251. */
  6252. concat(array: any): void;
  6253. /**
  6254. * Returns the position of a value in the active data.
  6255. * @param value defines the value to find the index for
  6256. * @returns the index if found in the active data otherwise -1
  6257. */
  6258. indexOf(value: T): number;
  6259. /**
  6260. * Returns whether an element is part of the active data.
  6261. * @param value defines the value to look for
  6262. * @returns true if found in the active data otherwise false
  6263. */
  6264. contains(value: T): boolean;
  6265. private static _GlobalId;
  6266. }
  6267. /**
  6268. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6269. * The data in this array can only be present once
  6270. */
  6271. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6272. private _duplicateId;
  6273. /**
  6274. * Pushes a value at the end of the active data.
  6275. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6276. * @param value defines the object to push in the array.
  6277. */
  6278. push(value: T): void;
  6279. /**
  6280. * Pushes a value at the end of the active data.
  6281. * If the data is already present, it won t be added again
  6282. * @param value defines the object to push in the array.
  6283. * @returns true if added false if it was already present
  6284. */
  6285. pushNoDuplicate(value: T): boolean;
  6286. /**
  6287. * Resets the active data to an empty array.
  6288. */
  6289. reset(): void;
  6290. /**
  6291. * Concats the active data with a given array.
  6292. * This ensures no dupplicate will be present in the result.
  6293. * @param array defines the data to concatenate with.
  6294. */
  6295. concatWithNoDuplicate(array: any): void;
  6296. }
  6297. }
  6298. declare module "babylonjs/Cameras/cameraInputsManager" {
  6299. import { Nullable } from "babylonjs/types";
  6300. import { Camera } from "babylonjs/Cameras/camera";
  6301. /**
  6302. * @ignore
  6303. * This is a list of all the different input types that are available in the application.
  6304. * Fo instance: ArcRotateCameraGamepadInput...
  6305. */
  6306. export var CameraInputTypes: {};
  6307. /**
  6308. * This is the contract to implement in order to create a new input class.
  6309. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6310. */
  6311. export interface ICameraInput<TCamera extends Camera> {
  6312. /**
  6313. * Defines the camera the input is attached to.
  6314. */
  6315. camera: Nullable<TCamera>;
  6316. /**
  6317. * Gets the class name of the current intput.
  6318. * @returns the class name
  6319. */
  6320. getClassName(): string;
  6321. /**
  6322. * Get the friendly name associated with the input class.
  6323. * @returns the input friendly name
  6324. */
  6325. getSimpleName(): string;
  6326. /**
  6327. * Attach the input controls to a specific dom element to get the input from.
  6328. * @param element Defines the element the controls should be listened from
  6329. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6330. */
  6331. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6332. /**
  6333. * Detach the current controls from the specified dom element.
  6334. * @param element Defines the element to stop listening the inputs from
  6335. */
  6336. detachControl(element: Nullable<HTMLElement>): void;
  6337. /**
  6338. * Update the current camera state depending on the inputs that have been used this frame.
  6339. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6340. */
  6341. checkInputs?: () => void;
  6342. }
  6343. /**
  6344. * Represents a map of input types to input instance or input index to input instance.
  6345. */
  6346. export interface CameraInputsMap<TCamera extends Camera> {
  6347. /**
  6348. * Accessor to the input by input type.
  6349. */
  6350. [name: string]: ICameraInput<TCamera>;
  6351. /**
  6352. * Accessor to the input by input index.
  6353. */
  6354. [idx: number]: ICameraInput<TCamera>;
  6355. }
  6356. /**
  6357. * This represents the input manager used within a camera.
  6358. * It helps dealing with all the different kind of input attached to a camera.
  6359. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6360. */
  6361. export class CameraInputsManager<TCamera extends Camera> {
  6362. /**
  6363. * Defines the list of inputs attahed to the camera.
  6364. */
  6365. attached: CameraInputsMap<TCamera>;
  6366. /**
  6367. * Defines the dom element the camera is collecting inputs from.
  6368. * This is null if the controls have not been attached.
  6369. */
  6370. attachedElement: Nullable<HTMLElement>;
  6371. /**
  6372. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6373. */
  6374. noPreventDefault: boolean;
  6375. /**
  6376. * Defined the camera the input manager belongs to.
  6377. */
  6378. camera: TCamera;
  6379. /**
  6380. * Update the current camera state depending on the inputs that have been used this frame.
  6381. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6382. */
  6383. checkInputs: () => void;
  6384. /**
  6385. * Instantiate a new Camera Input Manager.
  6386. * @param camera Defines the camera the input manager blongs to
  6387. */
  6388. constructor(camera: TCamera);
  6389. /**
  6390. * Add an input method to a camera
  6391. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6392. * @param input camera input method
  6393. */
  6394. add(input: ICameraInput<TCamera>): void;
  6395. /**
  6396. * Remove a specific input method from a camera
  6397. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6398. * @param inputToRemove camera input method
  6399. */
  6400. remove(inputToRemove: ICameraInput<TCamera>): void;
  6401. /**
  6402. * Remove a specific input type from a camera
  6403. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6404. * @param inputType the type of the input to remove
  6405. */
  6406. removeByType(inputType: string): void;
  6407. private _addCheckInputs;
  6408. /**
  6409. * Attach the input controls to the currently attached dom element to listen the events from.
  6410. * @param input Defines the input to attach
  6411. */
  6412. attachInput(input: ICameraInput<TCamera>): void;
  6413. /**
  6414. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6415. * @param element Defines the dom element to collect the events from
  6416. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6417. */
  6418. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6419. /**
  6420. * Detach the current manager inputs controls from a specific dom element.
  6421. * @param element Defines the dom element to collect the events from
  6422. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6423. */
  6424. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6425. /**
  6426. * Rebuild the dynamic inputCheck function from the current list of
  6427. * defined inputs in the manager.
  6428. */
  6429. rebuildInputCheck(): void;
  6430. /**
  6431. * Remove all attached input methods from a camera
  6432. */
  6433. clear(): void;
  6434. /**
  6435. * Serialize the current input manager attached to a camera.
  6436. * This ensures than once parsed,
  6437. * the input associated to the camera will be identical to the current ones
  6438. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6439. */
  6440. serialize(serializedCamera: any): void;
  6441. /**
  6442. * Parses an input manager serialized JSON to restore the previous list of inputs
  6443. * and states associated to a camera.
  6444. * @param parsedCamera Defines the JSON to parse
  6445. */
  6446. parse(parsedCamera: any): void;
  6447. }
  6448. }
  6449. declare module "babylonjs/Meshes/buffer" {
  6450. import { Nullable, DataArray } from "babylonjs/types";
  6451. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6452. /**
  6453. * Class used to store data that will be store in GPU memory
  6454. */
  6455. export class Buffer {
  6456. private _engine;
  6457. private _buffer;
  6458. /** @hidden */
  6459. _data: Nullable<DataArray>;
  6460. private _updatable;
  6461. private _instanced;
  6462. private _divisor;
  6463. /**
  6464. * Gets the byte stride.
  6465. */
  6466. readonly byteStride: number;
  6467. /**
  6468. * Constructor
  6469. * @param engine the engine
  6470. * @param data the data to use for this buffer
  6471. * @param updatable whether the data is updatable
  6472. * @param stride the stride (optional)
  6473. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6474. * @param instanced whether the buffer is instanced (optional)
  6475. * @param useBytes set to true if the stride in in bytes (optional)
  6476. * @param divisor sets an optional divisor for instances (1 by default)
  6477. */
  6478. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6479. /**
  6480. * Create a new VertexBuffer based on the current buffer
  6481. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6482. * @param offset defines offset in the buffer (0 by default)
  6483. * @param size defines the size in floats of attributes (position is 3 for instance)
  6484. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6485. * @param instanced defines if the vertex buffer contains indexed data
  6486. * @param useBytes defines if the offset and stride are in bytes *
  6487. * @param divisor sets an optional divisor for instances (1 by default)
  6488. * @returns the new vertex buffer
  6489. */
  6490. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6491. /**
  6492. * Gets a boolean indicating if the Buffer is updatable?
  6493. * @returns true if the buffer is updatable
  6494. */
  6495. isUpdatable(): boolean;
  6496. /**
  6497. * Gets current buffer's data
  6498. * @returns a DataArray or null
  6499. */
  6500. getData(): Nullable<DataArray>;
  6501. /**
  6502. * Gets underlying native buffer
  6503. * @returns underlying native buffer
  6504. */
  6505. getBuffer(): Nullable<DataBuffer>;
  6506. /**
  6507. * Gets the stride in float32 units (i.e. byte stride / 4).
  6508. * May not be an integer if the byte stride is not divisible by 4.
  6509. * @returns the stride in float32 units
  6510. * @deprecated Please use byteStride instead.
  6511. */
  6512. getStrideSize(): number;
  6513. /**
  6514. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6515. * @param data defines the data to store
  6516. */
  6517. create(data?: Nullable<DataArray>): void;
  6518. /** @hidden */
  6519. _rebuild(): void;
  6520. /**
  6521. * Update current buffer data
  6522. * @param data defines the data to store
  6523. */
  6524. update(data: DataArray): void;
  6525. /**
  6526. * Updates the data directly.
  6527. * @param data the new data
  6528. * @param offset the new offset
  6529. * @param vertexCount the vertex count (optional)
  6530. * @param useBytes set to true if the offset is in bytes
  6531. */
  6532. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6533. /**
  6534. * Release all resources
  6535. */
  6536. dispose(): void;
  6537. }
  6538. /**
  6539. * Specialized buffer used to store vertex data
  6540. */
  6541. export class VertexBuffer {
  6542. /** @hidden */
  6543. _buffer: Buffer;
  6544. private _kind;
  6545. private _size;
  6546. private _ownsBuffer;
  6547. private _instanced;
  6548. private _instanceDivisor;
  6549. /**
  6550. * The byte type.
  6551. */
  6552. static readonly BYTE: number;
  6553. /**
  6554. * The unsigned byte type.
  6555. */
  6556. static readonly UNSIGNED_BYTE: number;
  6557. /**
  6558. * The short type.
  6559. */
  6560. static readonly SHORT: number;
  6561. /**
  6562. * The unsigned short type.
  6563. */
  6564. static readonly UNSIGNED_SHORT: number;
  6565. /**
  6566. * The integer type.
  6567. */
  6568. static readonly INT: number;
  6569. /**
  6570. * The unsigned integer type.
  6571. */
  6572. static readonly UNSIGNED_INT: number;
  6573. /**
  6574. * The float type.
  6575. */
  6576. static readonly FLOAT: number;
  6577. /**
  6578. * Gets or sets the instance divisor when in instanced mode
  6579. */
  6580. get instanceDivisor(): number;
  6581. set instanceDivisor(value: number);
  6582. /**
  6583. * Gets the byte stride.
  6584. */
  6585. readonly byteStride: number;
  6586. /**
  6587. * Gets the byte offset.
  6588. */
  6589. readonly byteOffset: number;
  6590. /**
  6591. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6592. */
  6593. readonly normalized: boolean;
  6594. /**
  6595. * Gets the data type of each component in the array.
  6596. */
  6597. readonly type: number;
  6598. /**
  6599. * Constructor
  6600. * @param engine the engine
  6601. * @param data the data to use for this vertex buffer
  6602. * @param kind the vertex buffer kind
  6603. * @param updatable whether the data is updatable
  6604. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6605. * @param stride the stride (optional)
  6606. * @param instanced whether the buffer is instanced (optional)
  6607. * @param offset the offset of the data (optional)
  6608. * @param size the number of components (optional)
  6609. * @param type the type of the component (optional)
  6610. * @param normalized whether the data contains normalized data (optional)
  6611. * @param useBytes set to true if stride and offset are in bytes (optional)
  6612. * @param divisor defines the instance divisor to use (1 by default)
  6613. */
  6614. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6615. /** @hidden */
  6616. _rebuild(): void;
  6617. /**
  6618. * Returns the kind of the VertexBuffer (string)
  6619. * @returns a string
  6620. */
  6621. getKind(): string;
  6622. /**
  6623. * Gets a boolean indicating if the VertexBuffer is updatable?
  6624. * @returns true if the buffer is updatable
  6625. */
  6626. isUpdatable(): boolean;
  6627. /**
  6628. * Gets current buffer's data
  6629. * @returns a DataArray or null
  6630. */
  6631. getData(): Nullable<DataArray>;
  6632. /**
  6633. * Gets underlying native buffer
  6634. * @returns underlying native buffer
  6635. */
  6636. getBuffer(): Nullable<DataBuffer>;
  6637. /**
  6638. * Gets the stride in float32 units (i.e. byte stride / 4).
  6639. * May not be an integer if the byte stride is not divisible by 4.
  6640. * @returns the stride in float32 units
  6641. * @deprecated Please use byteStride instead.
  6642. */
  6643. getStrideSize(): number;
  6644. /**
  6645. * Returns the offset as a multiple of the type byte length.
  6646. * @returns the offset in bytes
  6647. * @deprecated Please use byteOffset instead.
  6648. */
  6649. getOffset(): number;
  6650. /**
  6651. * Returns the number of components per vertex attribute (integer)
  6652. * @returns the size in float
  6653. */
  6654. getSize(): number;
  6655. /**
  6656. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6657. * @returns true if this buffer is instanced
  6658. */
  6659. getIsInstanced(): boolean;
  6660. /**
  6661. * Returns the instancing divisor, zero for non-instanced (integer).
  6662. * @returns a number
  6663. */
  6664. getInstanceDivisor(): number;
  6665. /**
  6666. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6667. * @param data defines the data to store
  6668. */
  6669. create(data?: DataArray): void;
  6670. /**
  6671. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6672. * This function will create a new buffer if the current one is not updatable
  6673. * @param data defines the data to store
  6674. */
  6675. update(data: DataArray): void;
  6676. /**
  6677. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6678. * Returns the directly updated WebGLBuffer.
  6679. * @param data the new data
  6680. * @param offset the new offset
  6681. * @param useBytes set to true if the offset is in bytes
  6682. */
  6683. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6684. /**
  6685. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6686. */
  6687. dispose(): void;
  6688. /**
  6689. * Enumerates each value of this vertex buffer as numbers.
  6690. * @param count the number of values to enumerate
  6691. * @param callback the callback function called for each value
  6692. */
  6693. forEach(count: number, callback: (value: number, index: number) => void): void;
  6694. /**
  6695. * Positions
  6696. */
  6697. static readonly PositionKind: string;
  6698. /**
  6699. * Normals
  6700. */
  6701. static readonly NormalKind: string;
  6702. /**
  6703. * Tangents
  6704. */
  6705. static readonly TangentKind: string;
  6706. /**
  6707. * Texture coordinates
  6708. */
  6709. static readonly UVKind: string;
  6710. /**
  6711. * Texture coordinates 2
  6712. */
  6713. static readonly UV2Kind: string;
  6714. /**
  6715. * Texture coordinates 3
  6716. */
  6717. static readonly UV3Kind: string;
  6718. /**
  6719. * Texture coordinates 4
  6720. */
  6721. static readonly UV4Kind: string;
  6722. /**
  6723. * Texture coordinates 5
  6724. */
  6725. static readonly UV5Kind: string;
  6726. /**
  6727. * Texture coordinates 6
  6728. */
  6729. static readonly UV6Kind: string;
  6730. /**
  6731. * Colors
  6732. */
  6733. static readonly ColorKind: string;
  6734. /**
  6735. * Matrix indices (for bones)
  6736. */
  6737. static readonly MatricesIndicesKind: string;
  6738. /**
  6739. * Matrix weights (for bones)
  6740. */
  6741. static readonly MatricesWeightsKind: string;
  6742. /**
  6743. * Additional matrix indices (for bones)
  6744. */
  6745. static readonly MatricesIndicesExtraKind: string;
  6746. /**
  6747. * Additional matrix weights (for bones)
  6748. */
  6749. static readonly MatricesWeightsExtraKind: string;
  6750. /**
  6751. * Deduces the stride given a kind.
  6752. * @param kind The kind string to deduce
  6753. * @returns The deduced stride
  6754. */
  6755. static DeduceStride(kind: string): number;
  6756. /**
  6757. * Gets the byte length of the given type.
  6758. * @param type the type
  6759. * @returns the number of bytes
  6760. */
  6761. static GetTypeByteLength(type: number): number;
  6762. /**
  6763. * Enumerates each value of the given parameters as numbers.
  6764. * @param data the data to enumerate
  6765. * @param byteOffset the byte offset of the data
  6766. * @param byteStride the byte stride of the data
  6767. * @param componentCount the number of components per element
  6768. * @param componentType the type of the component
  6769. * @param count the number of values to enumerate
  6770. * @param normalized whether the data is normalized
  6771. * @param callback the callback function called for each value
  6772. */
  6773. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6774. private static _GetFloatValue;
  6775. }
  6776. }
  6777. declare module "babylonjs/Collisions/intersectionInfo" {
  6778. import { Nullable } from "babylonjs/types";
  6779. /**
  6780. * @hidden
  6781. */
  6782. export class IntersectionInfo {
  6783. bu: Nullable<number>;
  6784. bv: Nullable<number>;
  6785. distance: number;
  6786. faceId: number;
  6787. subMeshId: number;
  6788. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6789. }
  6790. }
  6791. declare module "babylonjs/Culling/boundingSphere" {
  6792. import { DeepImmutable } from "babylonjs/types";
  6793. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6794. import { Plane } from "babylonjs/Maths/math.plane";
  6795. /**
  6796. * Class used to store bounding sphere information
  6797. */
  6798. export class BoundingSphere {
  6799. /**
  6800. * Gets the center of the bounding sphere in local space
  6801. */
  6802. readonly center: Vector3;
  6803. /**
  6804. * Radius of the bounding sphere in local space
  6805. */
  6806. radius: number;
  6807. /**
  6808. * Gets the center of the bounding sphere in world space
  6809. */
  6810. readonly centerWorld: Vector3;
  6811. /**
  6812. * Radius of the bounding sphere in world space
  6813. */
  6814. radiusWorld: number;
  6815. /**
  6816. * Gets the minimum vector in local space
  6817. */
  6818. readonly minimum: Vector3;
  6819. /**
  6820. * Gets the maximum vector in local space
  6821. */
  6822. readonly maximum: Vector3;
  6823. private _worldMatrix;
  6824. private static readonly TmpVector3;
  6825. /**
  6826. * Creates a new bounding sphere
  6827. * @param min defines the minimum vector (in local space)
  6828. * @param max defines the maximum vector (in local space)
  6829. * @param worldMatrix defines the new world matrix
  6830. */
  6831. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6832. /**
  6833. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6834. * @param min defines the new minimum vector (in local space)
  6835. * @param max defines the new maximum vector (in local space)
  6836. * @param worldMatrix defines the new world matrix
  6837. */
  6838. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6839. /**
  6840. * Scale the current bounding sphere by applying a scale factor
  6841. * @param factor defines the scale factor to apply
  6842. * @returns the current bounding box
  6843. */
  6844. scale(factor: number): BoundingSphere;
  6845. /**
  6846. * Gets the world matrix of the bounding box
  6847. * @returns a matrix
  6848. */
  6849. getWorldMatrix(): DeepImmutable<Matrix>;
  6850. /** @hidden */
  6851. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6852. /**
  6853. * Tests if the bounding sphere is intersecting the frustum planes
  6854. * @param frustumPlanes defines the frustum planes to test
  6855. * @returns true if there is an intersection
  6856. */
  6857. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6858. /**
  6859. * Tests if the bounding sphere center is in between the frustum planes.
  6860. * Used for optimistic fast inclusion.
  6861. * @param frustumPlanes defines the frustum planes to test
  6862. * @returns true if the sphere center is in between the frustum planes
  6863. */
  6864. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6865. /**
  6866. * Tests if a point is inside the bounding sphere
  6867. * @param point defines the point to test
  6868. * @returns true if the point is inside the bounding sphere
  6869. */
  6870. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6871. /**
  6872. * Checks if two sphere intersct
  6873. * @param sphere0 sphere 0
  6874. * @param sphere1 sphere 1
  6875. * @returns true if the speres intersect
  6876. */
  6877. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6878. }
  6879. }
  6880. declare module "babylonjs/Culling/boundingBox" {
  6881. import { DeepImmutable } from "babylonjs/types";
  6882. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6883. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6884. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6885. import { Plane } from "babylonjs/Maths/math.plane";
  6886. /**
  6887. * Class used to store bounding box information
  6888. */
  6889. export class BoundingBox implements ICullable {
  6890. /**
  6891. * Gets the 8 vectors representing the bounding box in local space
  6892. */
  6893. readonly vectors: Vector3[];
  6894. /**
  6895. * Gets the center of the bounding box in local space
  6896. */
  6897. readonly center: Vector3;
  6898. /**
  6899. * Gets the center of the bounding box in world space
  6900. */
  6901. readonly centerWorld: Vector3;
  6902. /**
  6903. * Gets the extend size in local space
  6904. */
  6905. readonly extendSize: Vector3;
  6906. /**
  6907. * Gets the extend size in world space
  6908. */
  6909. readonly extendSizeWorld: Vector3;
  6910. /**
  6911. * Gets the OBB (object bounding box) directions
  6912. */
  6913. readonly directions: Vector3[];
  6914. /**
  6915. * Gets the 8 vectors representing the bounding box in world space
  6916. */
  6917. readonly vectorsWorld: Vector3[];
  6918. /**
  6919. * Gets the minimum vector in world space
  6920. */
  6921. readonly minimumWorld: Vector3;
  6922. /**
  6923. * Gets the maximum vector in world space
  6924. */
  6925. readonly maximumWorld: Vector3;
  6926. /**
  6927. * Gets the minimum vector in local space
  6928. */
  6929. readonly minimum: Vector3;
  6930. /**
  6931. * Gets the maximum vector in local space
  6932. */
  6933. readonly maximum: Vector3;
  6934. private _worldMatrix;
  6935. private static readonly TmpVector3;
  6936. /**
  6937. * @hidden
  6938. */
  6939. _tag: number;
  6940. /**
  6941. * Creates a new bounding box
  6942. * @param min defines the minimum vector (in local space)
  6943. * @param max defines the maximum vector (in local space)
  6944. * @param worldMatrix defines the new world matrix
  6945. */
  6946. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6947. /**
  6948. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6949. * @param min defines the new minimum vector (in local space)
  6950. * @param max defines the new maximum vector (in local space)
  6951. * @param worldMatrix defines the new world matrix
  6952. */
  6953. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6954. /**
  6955. * Scale the current bounding box by applying a scale factor
  6956. * @param factor defines the scale factor to apply
  6957. * @returns the current bounding box
  6958. */
  6959. scale(factor: number): BoundingBox;
  6960. /**
  6961. * Gets the world matrix of the bounding box
  6962. * @returns a matrix
  6963. */
  6964. getWorldMatrix(): DeepImmutable<Matrix>;
  6965. /** @hidden */
  6966. _update(world: DeepImmutable<Matrix>): void;
  6967. /**
  6968. * Tests if the bounding box is intersecting the frustum planes
  6969. * @param frustumPlanes defines the frustum planes to test
  6970. * @returns true if there is an intersection
  6971. */
  6972. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6973. /**
  6974. * Tests if the bounding box is entirely inside the frustum planes
  6975. * @param frustumPlanes defines the frustum planes to test
  6976. * @returns true if there is an inclusion
  6977. */
  6978. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6979. /**
  6980. * Tests if a point is inside the bounding box
  6981. * @param point defines the point to test
  6982. * @returns true if the point is inside the bounding box
  6983. */
  6984. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6985. /**
  6986. * Tests if the bounding box intersects with a bounding sphere
  6987. * @param sphere defines the sphere to test
  6988. * @returns true if there is an intersection
  6989. */
  6990. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6991. /**
  6992. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6993. * @param min defines the min vector to use
  6994. * @param max defines the max vector to use
  6995. * @returns true if there is an intersection
  6996. */
  6997. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6998. /**
  6999. * Tests if two bounding boxes are intersections
  7000. * @param box0 defines the first box to test
  7001. * @param box1 defines the second box to test
  7002. * @returns true if there is an intersection
  7003. */
  7004. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7005. /**
  7006. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7007. * @param minPoint defines the minimum vector of the bounding box
  7008. * @param maxPoint defines the maximum vector of the bounding box
  7009. * @param sphereCenter defines the sphere center
  7010. * @param sphereRadius defines the sphere radius
  7011. * @returns true if there is an intersection
  7012. */
  7013. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7014. /**
  7015. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7016. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7017. * @param frustumPlanes defines the frustum planes to test
  7018. * @return true if there is an inclusion
  7019. */
  7020. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7021. /**
  7022. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7023. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7024. * @param frustumPlanes defines the frustum planes to test
  7025. * @return true if there is an intersection
  7026. */
  7027. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7028. }
  7029. }
  7030. declare module "babylonjs/Collisions/collider" {
  7031. import { Nullable, IndicesArray } from "babylonjs/types";
  7032. import { Vector3 } from "babylonjs/Maths/math.vector";
  7033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7034. import { Plane } from "babylonjs/Maths/math.plane";
  7035. /** @hidden */
  7036. export class Collider {
  7037. /** Define if a collision was found */
  7038. collisionFound: boolean;
  7039. /**
  7040. * Define last intersection point in local space
  7041. */
  7042. intersectionPoint: Vector3;
  7043. /**
  7044. * Define last collided mesh
  7045. */
  7046. collidedMesh: Nullable<AbstractMesh>;
  7047. private _collisionPoint;
  7048. private _planeIntersectionPoint;
  7049. private _tempVector;
  7050. private _tempVector2;
  7051. private _tempVector3;
  7052. private _tempVector4;
  7053. private _edge;
  7054. private _baseToVertex;
  7055. private _destinationPoint;
  7056. private _slidePlaneNormal;
  7057. private _displacementVector;
  7058. /** @hidden */
  7059. _radius: Vector3;
  7060. /** @hidden */
  7061. _retry: number;
  7062. private _velocity;
  7063. private _basePoint;
  7064. private _epsilon;
  7065. /** @hidden */
  7066. _velocityWorldLength: number;
  7067. /** @hidden */
  7068. _basePointWorld: Vector3;
  7069. private _velocityWorld;
  7070. private _normalizedVelocity;
  7071. /** @hidden */
  7072. _initialVelocity: Vector3;
  7073. /** @hidden */
  7074. _initialPosition: Vector3;
  7075. private _nearestDistance;
  7076. private _collisionMask;
  7077. get collisionMask(): number;
  7078. set collisionMask(mask: number);
  7079. /**
  7080. * Gets the plane normal used to compute the sliding response (in local space)
  7081. */
  7082. get slidePlaneNormal(): Vector3;
  7083. /** @hidden */
  7084. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7085. /** @hidden */
  7086. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7087. /** @hidden */
  7088. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7089. /** @hidden */
  7090. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7091. /** @hidden */
  7092. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7093. /** @hidden */
  7094. _getResponse(pos: Vector3, vel: Vector3): void;
  7095. }
  7096. }
  7097. declare module "babylonjs/Culling/boundingInfo" {
  7098. import { DeepImmutable } from "babylonjs/types";
  7099. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7100. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7101. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7102. import { Plane } from "babylonjs/Maths/math.plane";
  7103. import { Collider } from "babylonjs/Collisions/collider";
  7104. /**
  7105. * Interface for cullable objects
  7106. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7107. */
  7108. export interface ICullable {
  7109. /**
  7110. * Checks if the object or part of the object is in the frustum
  7111. * @param frustumPlanes Camera near/planes
  7112. * @returns true if the object is in frustum otherwise false
  7113. */
  7114. isInFrustum(frustumPlanes: Plane[]): boolean;
  7115. /**
  7116. * Checks if a cullable object (mesh...) is in the camera frustum
  7117. * Unlike isInFrustum this cheks the full bounding box
  7118. * @param frustumPlanes Camera near/planes
  7119. * @returns true if the object is in frustum otherwise false
  7120. */
  7121. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7122. }
  7123. /**
  7124. * Info for a bounding data of a mesh
  7125. */
  7126. export class BoundingInfo implements ICullable {
  7127. /**
  7128. * Bounding box for the mesh
  7129. */
  7130. readonly boundingBox: BoundingBox;
  7131. /**
  7132. * Bounding sphere for the mesh
  7133. */
  7134. readonly boundingSphere: BoundingSphere;
  7135. private _isLocked;
  7136. private static readonly TmpVector3;
  7137. /**
  7138. * Constructs bounding info
  7139. * @param minimum min vector of the bounding box/sphere
  7140. * @param maximum max vector of the bounding box/sphere
  7141. * @param worldMatrix defines the new world matrix
  7142. */
  7143. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7144. /**
  7145. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7146. * @param min defines the new minimum vector (in local space)
  7147. * @param max defines the new maximum vector (in local space)
  7148. * @param worldMatrix defines the new world matrix
  7149. */
  7150. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7151. /**
  7152. * min vector of the bounding box/sphere
  7153. */
  7154. get minimum(): Vector3;
  7155. /**
  7156. * max vector of the bounding box/sphere
  7157. */
  7158. get maximum(): Vector3;
  7159. /**
  7160. * If the info is locked and won't be updated to avoid perf overhead
  7161. */
  7162. get isLocked(): boolean;
  7163. set isLocked(value: boolean);
  7164. /**
  7165. * Updates the bounding sphere and box
  7166. * @param world world matrix to be used to update
  7167. */
  7168. update(world: DeepImmutable<Matrix>): void;
  7169. /**
  7170. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7171. * @param center New center of the bounding info
  7172. * @param extend New extend of the bounding info
  7173. * @returns the current bounding info
  7174. */
  7175. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7176. /**
  7177. * Scale the current bounding info by applying a scale factor
  7178. * @param factor defines the scale factor to apply
  7179. * @returns the current bounding info
  7180. */
  7181. scale(factor: number): BoundingInfo;
  7182. /**
  7183. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7184. * @param frustumPlanes defines the frustum to test
  7185. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7186. * @returns true if the bounding info is in the frustum planes
  7187. */
  7188. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7189. /**
  7190. * Gets the world distance between the min and max points of the bounding box
  7191. */
  7192. get diagonalLength(): number;
  7193. /**
  7194. * Checks if a cullable object (mesh...) is in the camera frustum
  7195. * Unlike isInFrustum this cheks the full bounding box
  7196. * @param frustumPlanes Camera near/planes
  7197. * @returns true if the object is in frustum otherwise false
  7198. */
  7199. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7200. /** @hidden */
  7201. _checkCollision(collider: Collider): boolean;
  7202. /**
  7203. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7204. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7205. * @param point the point to check intersection with
  7206. * @returns if the point intersects
  7207. */
  7208. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7209. /**
  7210. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7211. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7212. * @param boundingInfo the bounding info to check intersection with
  7213. * @param precise if the intersection should be done using OBB
  7214. * @returns if the bounding info intersects
  7215. */
  7216. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7217. }
  7218. }
  7219. declare module "babylonjs/Maths/math.functions" {
  7220. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7221. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7222. /**
  7223. * Extracts minimum and maximum values from a list of indexed positions
  7224. * @param positions defines the positions to use
  7225. * @param indices defines the indices to the positions
  7226. * @param indexStart defines the start index
  7227. * @param indexCount defines the end index
  7228. * @param bias defines bias value to add to the result
  7229. * @return minimum and maximum values
  7230. */
  7231. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7232. minimum: Vector3;
  7233. maximum: Vector3;
  7234. };
  7235. /**
  7236. * Extracts minimum and maximum values from a list of positions
  7237. * @param positions defines the positions to use
  7238. * @param start defines the start index in the positions array
  7239. * @param count defines the number of positions to handle
  7240. * @param bias defines bias value to add to the result
  7241. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7242. * @return minimum and maximum values
  7243. */
  7244. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7245. minimum: Vector3;
  7246. maximum: Vector3;
  7247. };
  7248. }
  7249. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7250. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7251. /** @hidden */
  7252. export class WebGLDataBuffer extends DataBuffer {
  7253. private _buffer;
  7254. constructor(resource: WebGLBuffer);
  7255. get underlyingResource(): any;
  7256. }
  7257. }
  7258. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7259. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7260. import { Nullable } from "babylonjs/types";
  7261. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7262. /** @hidden */
  7263. export class WebGLPipelineContext implements IPipelineContext {
  7264. engine: ThinEngine;
  7265. program: Nullable<WebGLProgram>;
  7266. context?: WebGLRenderingContext;
  7267. vertexShader?: WebGLShader;
  7268. fragmentShader?: WebGLShader;
  7269. isParallelCompiled: boolean;
  7270. onCompiled?: () => void;
  7271. transformFeedback?: WebGLTransformFeedback | null;
  7272. vertexCompilationError: Nullable<string>;
  7273. fragmentCompilationError: Nullable<string>;
  7274. programLinkError: Nullable<string>;
  7275. programValidationError: Nullable<string>;
  7276. get isAsync(): boolean;
  7277. get isReady(): boolean;
  7278. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7279. _getVertexShaderCode(): string | null;
  7280. _getFragmentShaderCode(): string | null;
  7281. }
  7282. }
  7283. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7284. import { FloatArray, Nullable } from "babylonjs/types";
  7285. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7286. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7287. module "babylonjs/Engines/thinEngine" {
  7288. interface ThinEngine {
  7289. /**
  7290. * Create an uniform buffer
  7291. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7292. * @param elements defines the content of the uniform buffer
  7293. * @returns the webGL uniform buffer
  7294. */
  7295. createUniformBuffer(elements: FloatArray): DataBuffer;
  7296. /**
  7297. * Create a dynamic uniform buffer
  7298. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7299. * @param elements defines the content of the uniform buffer
  7300. * @returns the webGL uniform buffer
  7301. */
  7302. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7303. /**
  7304. * Update an existing uniform buffer
  7305. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7306. * @param uniformBuffer defines the target uniform buffer
  7307. * @param elements defines the content to update
  7308. * @param offset defines the offset in the uniform buffer where update should start
  7309. * @param count defines the size of the data to update
  7310. */
  7311. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7312. /**
  7313. * Bind an uniform buffer to the current webGL context
  7314. * @param buffer defines the buffer to bind
  7315. */
  7316. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7317. /**
  7318. * Bind a buffer to the current webGL context at a given location
  7319. * @param buffer defines the buffer to bind
  7320. * @param location defines the index where to bind the buffer
  7321. */
  7322. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7323. /**
  7324. * Bind a specific block at a given index in a specific shader program
  7325. * @param pipelineContext defines the pipeline context to use
  7326. * @param blockName defines the block name
  7327. * @param index defines the index where to bind the block
  7328. */
  7329. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7330. }
  7331. }
  7332. }
  7333. declare module "babylonjs/Materials/uniformBuffer" {
  7334. import { Nullable, FloatArray } from "babylonjs/types";
  7335. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7336. import { Engine } from "babylonjs/Engines/engine";
  7337. import { Effect } from "babylonjs/Materials/effect";
  7338. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7339. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7340. import { Color3 } from "babylonjs/Maths/math.color";
  7341. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7342. /**
  7343. * Uniform buffer objects.
  7344. *
  7345. * Handles blocks of uniform on the GPU.
  7346. *
  7347. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7348. *
  7349. * For more information, please refer to :
  7350. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7351. */
  7352. export class UniformBuffer {
  7353. private _engine;
  7354. private _buffer;
  7355. private _data;
  7356. private _bufferData;
  7357. private _dynamic?;
  7358. private _uniformLocations;
  7359. private _uniformSizes;
  7360. private _uniformLocationPointer;
  7361. private _needSync;
  7362. private _noUBO;
  7363. private _currentEffect;
  7364. /** @hidden */
  7365. _alreadyBound: boolean;
  7366. private static _MAX_UNIFORM_SIZE;
  7367. private static _tempBuffer;
  7368. /**
  7369. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7370. * This is dynamic to allow compat with webgl 1 and 2.
  7371. * You will need to pass the name of the uniform as well as the value.
  7372. */
  7373. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7374. /**
  7375. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7376. * This is dynamic to allow compat with webgl 1 and 2.
  7377. * You will need to pass the name of the uniform as well as the value.
  7378. */
  7379. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7380. /**
  7381. * Lambda to Update a single float in a uniform buffer.
  7382. * This is dynamic to allow compat with webgl 1 and 2.
  7383. * You will need to pass the name of the uniform as well as the value.
  7384. */
  7385. updateFloat: (name: string, x: number) => void;
  7386. /**
  7387. * Lambda to Update a vec2 of float in a uniform buffer.
  7388. * This is dynamic to allow compat with webgl 1 and 2.
  7389. * You will need to pass the name of the uniform as well as the value.
  7390. */
  7391. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7392. /**
  7393. * Lambda to Update a vec3 of float in a uniform buffer.
  7394. * This is dynamic to allow compat with webgl 1 and 2.
  7395. * You will need to pass the name of the uniform as well as the value.
  7396. */
  7397. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7398. /**
  7399. * Lambda to Update a vec4 of float in a uniform buffer.
  7400. * This is dynamic to allow compat with webgl 1 and 2.
  7401. * You will need to pass the name of the uniform as well as the value.
  7402. */
  7403. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7404. /**
  7405. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7406. * This is dynamic to allow compat with webgl 1 and 2.
  7407. * You will need to pass the name of the uniform as well as the value.
  7408. */
  7409. updateMatrix: (name: string, mat: Matrix) => void;
  7410. /**
  7411. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7412. * This is dynamic to allow compat with webgl 1 and 2.
  7413. * You will need to pass the name of the uniform as well as the value.
  7414. */
  7415. updateVector3: (name: string, vector: Vector3) => void;
  7416. /**
  7417. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7418. * This is dynamic to allow compat with webgl 1 and 2.
  7419. * You will need to pass the name of the uniform as well as the value.
  7420. */
  7421. updateVector4: (name: string, vector: Vector4) => void;
  7422. /**
  7423. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7424. * This is dynamic to allow compat with webgl 1 and 2.
  7425. * You will need to pass the name of the uniform as well as the value.
  7426. */
  7427. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7428. /**
  7429. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7430. * This is dynamic to allow compat with webgl 1 and 2.
  7431. * You will need to pass the name of the uniform as well as the value.
  7432. */
  7433. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7434. /**
  7435. * Instantiates a new Uniform buffer objects.
  7436. *
  7437. * Handles blocks of uniform on the GPU.
  7438. *
  7439. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7440. *
  7441. * For more information, please refer to :
  7442. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7443. * @param engine Define the engine the buffer is associated with
  7444. * @param data Define the data contained in the buffer
  7445. * @param dynamic Define if the buffer is updatable
  7446. */
  7447. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7448. /**
  7449. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7450. * or just falling back on setUniformXXX calls.
  7451. */
  7452. get useUbo(): boolean;
  7453. /**
  7454. * Indicates if the WebGL underlying uniform buffer is in sync
  7455. * with the javascript cache data.
  7456. */
  7457. get isSync(): boolean;
  7458. /**
  7459. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7460. * Also, a dynamic UniformBuffer will disable cache verification and always
  7461. * update the underlying WebGL uniform buffer to the GPU.
  7462. * @returns if Dynamic, otherwise false
  7463. */
  7464. isDynamic(): boolean;
  7465. /**
  7466. * The data cache on JS side.
  7467. * @returns the underlying data as a float array
  7468. */
  7469. getData(): Float32Array;
  7470. /**
  7471. * The underlying WebGL Uniform buffer.
  7472. * @returns the webgl buffer
  7473. */
  7474. getBuffer(): Nullable<DataBuffer>;
  7475. /**
  7476. * std140 layout specifies how to align data within an UBO structure.
  7477. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7478. * for specs.
  7479. */
  7480. private _fillAlignment;
  7481. /**
  7482. * Adds an uniform in the buffer.
  7483. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7484. * for the layout to be correct !
  7485. * @param name Name of the uniform, as used in the uniform block in the shader.
  7486. * @param size Data size, or data directly.
  7487. */
  7488. addUniform(name: string, size: number | number[]): void;
  7489. /**
  7490. * Adds a Matrix 4x4 to the uniform buffer.
  7491. * @param name Name of the uniform, as used in the uniform block in the shader.
  7492. * @param mat A 4x4 matrix.
  7493. */
  7494. addMatrix(name: string, mat: Matrix): void;
  7495. /**
  7496. * Adds a vec2 to the uniform buffer.
  7497. * @param name Name of the uniform, as used in the uniform block in the shader.
  7498. * @param x Define the x component value of the vec2
  7499. * @param y Define the y component value of the vec2
  7500. */
  7501. addFloat2(name: string, x: number, y: number): void;
  7502. /**
  7503. * Adds a vec3 to the uniform buffer.
  7504. * @param name Name of the uniform, as used in the uniform block in the shader.
  7505. * @param x Define the x component value of the vec3
  7506. * @param y Define the y component value of the vec3
  7507. * @param z Define the z component value of the vec3
  7508. */
  7509. addFloat3(name: string, x: number, y: number, z: number): void;
  7510. /**
  7511. * Adds a vec3 to the uniform buffer.
  7512. * @param name Name of the uniform, as used in the uniform block in the shader.
  7513. * @param color Define the vec3 from a Color
  7514. */
  7515. addColor3(name: string, color: Color3): void;
  7516. /**
  7517. * Adds a vec4 to the uniform buffer.
  7518. * @param name Name of the uniform, as used in the uniform block in the shader.
  7519. * @param color Define the rgb components from a Color
  7520. * @param alpha Define the a component of the vec4
  7521. */
  7522. addColor4(name: string, color: Color3, alpha: number): void;
  7523. /**
  7524. * Adds a vec3 to the uniform buffer.
  7525. * @param name Name of the uniform, as used in the uniform block in the shader.
  7526. * @param vector Define the vec3 components from a Vector
  7527. */
  7528. addVector3(name: string, vector: Vector3): void;
  7529. /**
  7530. * Adds a Matrix 3x3 to the uniform buffer.
  7531. * @param name Name of the uniform, as used in the uniform block in the shader.
  7532. */
  7533. addMatrix3x3(name: string): void;
  7534. /**
  7535. * Adds a Matrix 2x2 to the uniform buffer.
  7536. * @param name Name of the uniform, as used in the uniform block in the shader.
  7537. */
  7538. addMatrix2x2(name: string): void;
  7539. /**
  7540. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7541. */
  7542. create(): void;
  7543. /** @hidden */
  7544. _rebuild(): void;
  7545. /**
  7546. * Updates the WebGL Uniform Buffer on the GPU.
  7547. * If the `dynamic` flag is set to true, no cache comparison is done.
  7548. * Otherwise, the buffer will be updated only if the cache differs.
  7549. */
  7550. update(): void;
  7551. /**
  7552. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7553. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7554. * @param data Define the flattened data
  7555. * @param size Define the size of the data.
  7556. */
  7557. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7558. private _valueCache;
  7559. private _cacheMatrix;
  7560. private _updateMatrix3x3ForUniform;
  7561. private _updateMatrix3x3ForEffect;
  7562. private _updateMatrix2x2ForEffect;
  7563. private _updateMatrix2x2ForUniform;
  7564. private _updateFloatForEffect;
  7565. private _updateFloatForUniform;
  7566. private _updateFloat2ForEffect;
  7567. private _updateFloat2ForUniform;
  7568. private _updateFloat3ForEffect;
  7569. private _updateFloat3ForUniform;
  7570. private _updateFloat4ForEffect;
  7571. private _updateFloat4ForUniform;
  7572. private _updateMatrixForEffect;
  7573. private _updateMatrixForUniform;
  7574. private _updateVector3ForEffect;
  7575. private _updateVector3ForUniform;
  7576. private _updateVector4ForEffect;
  7577. private _updateVector4ForUniform;
  7578. private _updateColor3ForEffect;
  7579. private _updateColor3ForUniform;
  7580. private _updateColor4ForEffect;
  7581. private _updateColor4ForUniform;
  7582. /**
  7583. * Sets a sampler uniform on the effect.
  7584. * @param name Define the name of the sampler.
  7585. * @param texture Define the texture to set in the sampler
  7586. */
  7587. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7588. /**
  7589. * Directly updates the value of the uniform in the cache AND on the GPU.
  7590. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7591. * @param data Define the flattened data
  7592. */
  7593. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7594. /**
  7595. * Binds this uniform buffer to an effect.
  7596. * @param effect Define the effect to bind the buffer to
  7597. * @param name Name of the uniform block in the shader.
  7598. */
  7599. bindToEffect(effect: Effect, name: string): void;
  7600. /**
  7601. * Disposes the uniform buffer.
  7602. */
  7603. dispose(): void;
  7604. }
  7605. }
  7606. declare module "babylonjs/Misc/iInspectable" {
  7607. /**
  7608. * Enum that determines the text-wrapping mode to use.
  7609. */
  7610. export enum InspectableType {
  7611. /**
  7612. * Checkbox for booleans
  7613. */
  7614. Checkbox = 0,
  7615. /**
  7616. * Sliders for numbers
  7617. */
  7618. Slider = 1,
  7619. /**
  7620. * Vector3
  7621. */
  7622. Vector3 = 2,
  7623. /**
  7624. * Quaternions
  7625. */
  7626. Quaternion = 3,
  7627. /**
  7628. * Color3
  7629. */
  7630. Color3 = 4,
  7631. /**
  7632. * String
  7633. */
  7634. String = 5
  7635. }
  7636. /**
  7637. * Interface used to define custom inspectable properties.
  7638. * This interface is used by the inspector to display custom property grids
  7639. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7640. */
  7641. export interface IInspectable {
  7642. /**
  7643. * Gets the label to display
  7644. */
  7645. label: string;
  7646. /**
  7647. * Gets the name of the property to edit
  7648. */
  7649. propertyName: string;
  7650. /**
  7651. * Gets the type of the editor to use
  7652. */
  7653. type: InspectableType;
  7654. /**
  7655. * Gets the minimum value of the property when using in "slider" mode
  7656. */
  7657. min?: number;
  7658. /**
  7659. * Gets the maximum value of the property when using in "slider" mode
  7660. */
  7661. max?: number;
  7662. /**
  7663. * Gets the setp to use when using in "slider" mode
  7664. */
  7665. step?: number;
  7666. }
  7667. }
  7668. declare module "babylonjs/Misc/timingTools" {
  7669. /**
  7670. * Class used to provide helper for timing
  7671. */
  7672. export class TimingTools {
  7673. /**
  7674. * Polyfill for setImmediate
  7675. * @param action defines the action to execute after the current execution block
  7676. */
  7677. static SetImmediate(action: () => void): void;
  7678. }
  7679. }
  7680. declare module "babylonjs/Misc/instantiationTools" {
  7681. /**
  7682. * Class used to enable instatition of objects by class name
  7683. */
  7684. export class InstantiationTools {
  7685. /**
  7686. * Use this object to register external classes like custom textures or material
  7687. * to allow the laoders to instantiate them
  7688. */
  7689. static RegisteredExternalClasses: {
  7690. [key: string]: Object;
  7691. };
  7692. /**
  7693. * Tries to instantiate a new object from a given class name
  7694. * @param className defines the class name to instantiate
  7695. * @returns the new object or null if the system was not able to do the instantiation
  7696. */
  7697. static Instantiate(className: string): any;
  7698. }
  7699. }
  7700. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7701. /**
  7702. * Define options used to create a depth texture
  7703. */
  7704. export class DepthTextureCreationOptions {
  7705. /** Specifies whether or not a stencil should be allocated in the texture */
  7706. generateStencil?: boolean;
  7707. /** Specifies whether or not bilinear filtering is enable on the texture */
  7708. bilinearFiltering?: boolean;
  7709. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7710. comparisonFunction?: number;
  7711. /** Specifies if the created texture is a cube texture */
  7712. isCube?: boolean;
  7713. }
  7714. }
  7715. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7716. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7717. import { Nullable } from "babylonjs/types";
  7718. import { Scene } from "babylonjs/scene";
  7719. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7720. module "babylonjs/Engines/thinEngine" {
  7721. interface ThinEngine {
  7722. /**
  7723. * Creates a depth stencil cube texture.
  7724. * This is only available in WebGL 2.
  7725. * @param size The size of face edge in the cube texture.
  7726. * @param options The options defining the cube texture.
  7727. * @returns The cube texture
  7728. */
  7729. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7730. /**
  7731. * Creates a cube texture
  7732. * @param rootUrl defines the url where the files to load is located
  7733. * @param scene defines the current scene
  7734. * @param files defines the list of files to load (1 per face)
  7735. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7736. * @param onLoad defines an optional callback raised when the texture is loaded
  7737. * @param onError defines an optional callback raised if there is an issue to load the texture
  7738. * @param format defines the format of the data
  7739. * @param forcedExtension defines the extension to use to pick the right loader
  7740. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7741. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7742. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7743. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7744. * @returns the cube texture as an InternalTexture
  7745. */
  7746. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7747. /**
  7748. * Creates a cube texture
  7749. * @param rootUrl defines the url where the files to load is located
  7750. * @param scene defines the current scene
  7751. * @param files defines the list of files to load (1 per face)
  7752. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7753. * @param onLoad defines an optional callback raised when the texture is loaded
  7754. * @param onError defines an optional callback raised if there is an issue to load the texture
  7755. * @param format defines the format of the data
  7756. * @param forcedExtension defines the extension to use to pick the right loader
  7757. * @returns the cube texture as an InternalTexture
  7758. */
  7759. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7760. /**
  7761. * Creates a cube texture
  7762. * @param rootUrl defines the url where the files to load is located
  7763. * @param scene defines the current scene
  7764. * @param files defines the list of files to load (1 per face)
  7765. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7766. * @param onLoad defines an optional callback raised when the texture is loaded
  7767. * @param onError defines an optional callback raised if there is an issue to load the texture
  7768. * @param format defines the format of the data
  7769. * @param forcedExtension defines the extension to use to pick the right loader
  7770. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7771. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7772. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7773. * @returns the cube texture as an InternalTexture
  7774. */
  7775. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7776. /** @hidden */
  7777. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7778. /** @hidden */
  7779. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7780. /** @hidden */
  7781. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7782. /** @hidden */
  7783. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7784. /**
  7785. * @hidden
  7786. */
  7787. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7788. }
  7789. }
  7790. }
  7791. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7792. import { Nullable } from "babylonjs/types";
  7793. import { Scene } from "babylonjs/scene";
  7794. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7795. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7796. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7797. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7798. import { Observable } from "babylonjs/Misc/observable";
  7799. /**
  7800. * Class for creating a cube texture
  7801. */
  7802. export class CubeTexture extends BaseTexture {
  7803. private _delayedOnLoad;
  7804. /**
  7805. * Observable triggered once the texture has been loaded.
  7806. */
  7807. onLoadObservable: Observable<CubeTexture>;
  7808. /**
  7809. * The url of the texture
  7810. */
  7811. url: string;
  7812. /**
  7813. * Gets or sets the center of the bounding box associated with the cube texture.
  7814. * It must define where the camera used to render the texture was set
  7815. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7816. */
  7817. boundingBoxPosition: Vector3;
  7818. private _boundingBoxSize;
  7819. /**
  7820. * Gets or sets the size of the bounding box associated with the cube texture
  7821. * When defined, the cubemap will switch to local mode
  7822. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7823. * @example https://www.babylonjs-playground.com/#RNASML
  7824. */
  7825. set boundingBoxSize(value: Vector3);
  7826. /**
  7827. * Returns the bounding box size
  7828. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7829. */
  7830. get boundingBoxSize(): Vector3;
  7831. protected _rotationY: number;
  7832. /**
  7833. * Sets texture matrix rotation angle around Y axis in radians.
  7834. */
  7835. set rotationY(value: number);
  7836. /**
  7837. * Gets texture matrix rotation angle around Y axis radians.
  7838. */
  7839. get rotationY(): number;
  7840. /**
  7841. * Are mip maps generated for this texture or not.
  7842. */
  7843. get noMipmap(): boolean;
  7844. private _noMipmap;
  7845. private _files;
  7846. protected _forcedExtension: Nullable<string>;
  7847. private _extensions;
  7848. private _textureMatrix;
  7849. private _format;
  7850. private _createPolynomials;
  7851. /**
  7852. * Creates a cube texture from an array of image urls
  7853. * @param files defines an array of image urls
  7854. * @param scene defines the hosting scene
  7855. * @param noMipmap specifies if mip maps are not used
  7856. * @returns a cube texture
  7857. */
  7858. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7859. /**
  7860. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7861. * @param url defines the url of the prefiltered texture
  7862. * @param scene defines the scene the texture is attached to
  7863. * @param forcedExtension defines the extension of the file if different from the url
  7864. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7865. * @return the prefiltered texture
  7866. */
  7867. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7868. /**
  7869. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7870. * as prefiltered data.
  7871. * @param rootUrl defines the url of the texture or the root name of the six images
  7872. * @param null defines the scene or engine the texture is attached to
  7873. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7874. * @param noMipmap defines if mipmaps should be created or not
  7875. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7876. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7877. * @param onError defines a callback triggered in case of error during load
  7878. * @param format defines the internal format to use for the texture once loaded
  7879. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7880. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7881. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7882. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7883. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7884. * @return the cube texture
  7885. */
  7886. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7887. /**
  7888. * Get the current class name of the texture useful for serialization or dynamic coding.
  7889. * @returns "CubeTexture"
  7890. */
  7891. getClassName(): string;
  7892. /**
  7893. * Update the url (and optional buffer) of this texture if url was null during construction.
  7894. * @param url the url of the texture
  7895. * @param forcedExtension defines the extension to use
  7896. * @param onLoad callback called when the texture is loaded (defaults to null)
  7897. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7898. */
  7899. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7900. /**
  7901. * Delays loading of the cube texture
  7902. * @param forcedExtension defines the extension to use
  7903. */
  7904. delayLoad(forcedExtension?: string): void;
  7905. /**
  7906. * Returns the reflection texture matrix
  7907. * @returns the reflection texture matrix
  7908. */
  7909. getReflectionTextureMatrix(): Matrix;
  7910. /**
  7911. * Sets the reflection texture matrix
  7912. * @param value Reflection texture matrix
  7913. */
  7914. setReflectionTextureMatrix(value: Matrix): void;
  7915. /**
  7916. * Parses text to create a cube texture
  7917. * @param parsedTexture define the serialized text to read from
  7918. * @param scene defines the hosting scene
  7919. * @param rootUrl defines the root url of the cube texture
  7920. * @returns a cube texture
  7921. */
  7922. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7923. /**
  7924. * Makes a clone, or deep copy, of the cube texture
  7925. * @returns a new cube texture
  7926. */
  7927. clone(): CubeTexture;
  7928. }
  7929. }
  7930. declare module "babylonjs/Materials/materialDefines" {
  7931. /**
  7932. * Manages the defines for the Material
  7933. */
  7934. export class MaterialDefines {
  7935. /** @hidden */
  7936. protected _keys: string[];
  7937. private _isDirty;
  7938. /** @hidden */
  7939. _renderId: number;
  7940. /** @hidden */
  7941. _areLightsDirty: boolean;
  7942. /** @hidden */
  7943. _areLightsDisposed: boolean;
  7944. /** @hidden */
  7945. _areAttributesDirty: boolean;
  7946. /** @hidden */
  7947. _areTexturesDirty: boolean;
  7948. /** @hidden */
  7949. _areFresnelDirty: boolean;
  7950. /** @hidden */
  7951. _areMiscDirty: boolean;
  7952. /** @hidden */
  7953. _areImageProcessingDirty: boolean;
  7954. /** @hidden */
  7955. _normals: boolean;
  7956. /** @hidden */
  7957. _uvs: boolean;
  7958. /** @hidden */
  7959. _needNormals: boolean;
  7960. /** @hidden */
  7961. _needUVs: boolean;
  7962. [id: string]: any;
  7963. /**
  7964. * Specifies if the material needs to be re-calculated
  7965. */
  7966. get isDirty(): boolean;
  7967. /**
  7968. * Marks the material to indicate that it has been re-calculated
  7969. */
  7970. markAsProcessed(): void;
  7971. /**
  7972. * Marks the material to indicate that it needs to be re-calculated
  7973. */
  7974. markAsUnprocessed(): void;
  7975. /**
  7976. * Marks the material to indicate all of its defines need to be re-calculated
  7977. */
  7978. markAllAsDirty(): void;
  7979. /**
  7980. * Marks the material to indicate that image processing needs to be re-calculated
  7981. */
  7982. markAsImageProcessingDirty(): void;
  7983. /**
  7984. * Marks the material to indicate the lights need to be re-calculated
  7985. * @param disposed Defines whether the light is dirty due to dispose or not
  7986. */
  7987. markAsLightDirty(disposed?: boolean): void;
  7988. /**
  7989. * Marks the attribute state as changed
  7990. */
  7991. markAsAttributesDirty(): void;
  7992. /**
  7993. * Marks the texture state as changed
  7994. */
  7995. markAsTexturesDirty(): void;
  7996. /**
  7997. * Marks the fresnel state as changed
  7998. */
  7999. markAsFresnelDirty(): void;
  8000. /**
  8001. * Marks the misc state as changed
  8002. */
  8003. markAsMiscDirty(): void;
  8004. /**
  8005. * Rebuilds the material defines
  8006. */
  8007. rebuild(): void;
  8008. /**
  8009. * Specifies if two material defines are equal
  8010. * @param other - A material define instance to compare to
  8011. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8012. */
  8013. isEqual(other: MaterialDefines): boolean;
  8014. /**
  8015. * Clones this instance's defines to another instance
  8016. * @param other - material defines to clone values to
  8017. */
  8018. cloneTo(other: MaterialDefines): void;
  8019. /**
  8020. * Resets the material define values
  8021. */
  8022. reset(): void;
  8023. /**
  8024. * Converts the material define values to a string
  8025. * @returns - String of material define information
  8026. */
  8027. toString(): string;
  8028. }
  8029. }
  8030. declare module "babylonjs/Materials/colorCurves" {
  8031. import { Effect } from "babylonjs/Materials/effect";
  8032. /**
  8033. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8034. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8035. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  8036. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8037. */
  8038. export class ColorCurves {
  8039. private _dirty;
  8040. private _tempColor;
  8041. private _globalCurve;
  8042. private _highlightsCurve;
  8043. private _midtonesCurve;
  8044. private _shadowsCurve;
  8045. private _positiveCurve;
  8046. private _negativeCurve;
  8047. private _globalHue;
  8048. private _globalDensity;
  8049. private _globalSaturation;
  8050. private _globalExposure;
  8051. /**
  8052. * Gets the global Hue value.
  8053. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8054. */
  8055. get globalHue(): number;
  8056. /**
  8057. * Sets the global Hue value.
  8058. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8059. */
  8060. set globalHue(value: number);
  8061. /**
  8062. * Gets the global Density value.
  8063. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8064. * Values less than zero provide a filter of opposite hue.
  8065. */
  8066. get globalDensity(): number;
  8067. /**
  8068. * Sets the global Density value.
  8069. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8070. * Values less than zero provide a filter of opposite hue.
  8071. */
  8072. set globalDensity(value: number);
  8073. /**
  8074. * Gets the global Saturation value.
  8075. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8076. */
  8077. get globalSaturation(): number;
  8078. /**
  8079. * Sets the global Saturation value.
  8080. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8081. */
  8082. set globalSaturation(value: number);
  8083. /**
  8084. * Gets the global Exposure value.
  8085. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8086. */
  8087. get globalExposure(): number;
  8088. /**
  8089. * Sets the global Exposure value.
  8090. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8091. */
  8092. set globalExposure(value: number);
  8093. private _highlightsHue;
  8094. private _highlightsDensity;
  8095. private _highlightsSaturation;
  8096. private _highlightsExposure;
  8097. /**
  8098. * Gets the highlights Hue value.
  8099. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8100. */
  8101. get highlightsHue(): number;
  8102. /**
  8103. * Sets the highlights Hue value.
  8104. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8105. */
  8106. set highlightsHue(value: number);
  8107. /**
  8108. * Gets the highlights Density value.
  8109. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8110. * Values less than zero provide a filter of opposite hue.
  8111. */
  8112. get highlightsDensity(): number;
  8113. /**
  8114. * Sets the highlights Density value.
  8115. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8116. * Values less than zero provide a filter of opposite hue.
  8117. */
  8118. set highlightsDensity(value: number);
  8119. /**
  8120. * Gets the highlights Saturation value.
  8121. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8122. */
  8123. get highlightsSaturation(): number;
  8124. /**
  8125. * Sets the highlights Saturation value.
  8126. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8127. */
  8128. set highlightsSaturation(value: number);
  8129. /**
  8130. * Gets the highlights Exposure value.
  8131. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8132. */
  8133. get highlightsExposure(): number;
  8134. /**
  8135. * Sets the highlights Exposure value.
  8136. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8137. */
  8138. set highlightsExposure(value: number);
  8139. private _midtonesHue;
  8140. private _midtonesDensity;
  8141. private _midtonesSaturation;
  8142. private _midtonesExposure;
  8143. /**
  8144. * Gets the midtones Hue value.
  8145. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8146. */
  8147. get midtonesHue(): number;
  8148. /**
  8149. * Sets the midtones Hue value.
  8150. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8151. */
  8152. set midtonesHue(value: number);
  8153. /**
  8154. * Gets the midtones Density value.
  8155. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8156. * Values less than zero provide a filter of opposite hue.
  8157. */
  8158. get midtonesDensity(): number;
  8159. /**
  8160. * Sets the midtones Density value.
  8161. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8162. * Values less than zero provide a filter of opposite hue.
  8163. */
  8164. set midtonesDensity(value: number);
  8165. /**
  8166. * Gets the midtones Saturation value.
  8167. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8168. */
  8169. get midtonesSaturation(): number;
  8170. /**
  8171. * Sets the midtones Saturation value.
  8172. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8173. */
  8174. set midtonesSaturation(value: number);
  8175. /**
  8176. * Gets the midtones Exposure value.
  8177. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8178. */
  8179. get midtonesExposure(): number;
  8180. /**
  8181. * Sets the midtones Exposure value.
  8182. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8183. */
  8184. set midtonesExposure(value: number);
  8185. private _shadowsHue;
  8186. private _shadowsDensity;
  8187. private _shadowsSaturation;
  8188. private _shadowsExposure;
  8189. /**
  8190. * Gets the shadows Hue value.
  8191. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8192. */
  8193. get shadowsHue(): number;
  8194. /**
  8195. * Sets the shadows Hue value.
  8196. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8197. */
  8198. set shadowsHue(value: number);
  8199. /**
  8200. * Gets the shadows Density value.
  8201. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8202. * Values less than zero provide a filter of opposite hue.
  8203. */
  8204. get shadowsDensity(): number;
  8205. /**
  8206. * Sets the shadows Density value.
  8207. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8208. * Values less than zero provide a filter of opposite hue.
  8209. */
  8210. set shadowsDensity(value: number);
  8211. /**
  8212. * Gets the shadows Saturation value.
  8213. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8214. */
  8215. get shadowsSaturation(): number;
  8216. /**
  8217. * Sets the shadows Saturation value.
  8218. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8219. */
  8220. set shadowsSaturation(value: number);
  8221. /**
  8222. * Gets the shadows Exposure value.
  8223. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8224. */
  8225. get shadowsExposure(): number;
  8226. /**
  8227. * Sets the shadows Exposure value.
  8228. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8229. */
  8230. set shadowsExposure(value: number);
  8231. /**
  8232. * Returns the class name
  8233. * @returns The class name
  8234. */
  8235. getClassName(): string;
  8236. /**
  8237. * Binds the color curves to the shader.
  8238. * @param colorCurves The color curve to bind
  8239. * @param effect The effect to bind to
  8240. * @param positiveUniform The positive uniform shader parameter
  8241. * @param neutralUniform The neutral uniform shader parameter
  8242. * @param negativeUniform The negative uniform shader parameter
  8243. */
  8244. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8245. /**
  8246. * Prepare the list of uniforms associated with the ColorCurves effects.
  8247. * @param uniformsList The list of uniforms used in the effect
  8248. */
  8249. static PrepareUniforms(uniformsList: string[]): void;
  8250. /**
  8251. * Returns color grading data based on a hue, density, saturation and exposure value.
  8252. * @param filterHue The hue of the color filter.
  8253. * @param filterDensity The density of the color filter.
  8254. * @param saturation The saturation.
  8255. * @param exposure The exposure.
  8256. * @param result The result data container.
  8257. */
  8258. private getColorGradingDataToRef;
  8259. /**
  8260. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8261. * @param value The input slider value in range [-100,100].
  8262. * @returns Adjusted value.
  8263. */
  8264. private static applyColorGradingSliderNonlinear;
  8265. /**
  8266. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8267. * @param hue The hue (H) input.
  8268. * @param saturation The saturation (S) input.
  8269. * @param brightness The brightness (B) input.
  8270. * @result An RGBA color represented as Vector4.
  8271. */
  8272. private static fromHSBToRef;
  8273. /**
  8274. * Returns a value clamped between min and max
  8275. * @param value The value to clamp
  8276. * @param min The minimum of value
  8277. * @param max The maximum of value
  8278. * @returns The clamped value.
  8279. */
  8280. private static clamp;
  8281. /**
  8282. * Clones the current color curve instance.
  8283. * @return The cloned curves
  8284. */
  8285. clone(): ColorCurves;
  8286. /**
  8287. * Serializes the current color curve instance to a json representation.
  8288. * @return a JSON representation
  8289. */
  8290. serialize(): any;
  8291. /**
  8292. * Parses the color curve from a json representation.
  8293. * @param source the JSON source to parse
  8294. * @return The parsed curves
  8295. */
  8296. static Parse(source: any): ColorCurves;
  8297. }
  8298. }
  8299. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8300. import { Observable } from "babylonjs/Misc/observable";
  8301. import { Nullable } from "babylonjs/types";
  8302. import { Color4 } from "babylonjs/Maths/math.color";
  8303. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8304. import { Effect } from "babylonjs/Materials/effect";
  8305. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8306. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8307. /**
  8308. * Interface to follow in your material defines to integrate easily the
  8309. * Image proccessing functions.
  8310. * @hidden
  8311. */
  8312. export interface IImageProcessingConfigurationDefines {
  8313. IMAGEPROCESSING: boolean;
  8314. VIGNETTE: boolean;
  8315. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8316. VIGNETTEBLENDMODEOPAQUE: boolean;
  8317. TONEMAPPING: boolean;
  8318. TONEMAPPING_ACES: boolean;
  8319. CONTRAST: boolean;
  8320. EXPOSURE: boolean;
  8321. COLORCURVES: boolean;
  8322. COLORGRADING: boolean;
  8323. COLORGRADING3D: boolean;
  8324. SAMPLER3DGREENDEPTH: boolean;
  8325. SAMPLER3DBGRMAP: boolean;
  8326. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8327. }
  8328. /**
  8329. * @hidden
  8330. */
  8331. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8332. IMAGEPROCESSING: boolean;
  8333. VIGNETTE: boolean;
  8334. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8335. VIGNETTEBLENDMODEOPAQUE: boolean;
  8336. TONEMAPPING: boolean;
  8337. TONEMAPPING_ACES: boolean;
  8338. CONTRAST: boolean;
  8339. COLORCURVES: boolean;
  8340. COLORGRADING: boolean;
  8341. COLORGRADING3D: boolean;
  8342. SAMPLER3DGREENDEPTH: boolean;
  8343. SAMPLER3DBGRMAP: boolean;
  8344. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8345. EXPOSURE: boolean;
  8346. constructor();
  8347. }
  8348. /**
  8349. * This groups together the common properties used for image processing either in direct forward pass
  8350. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8351. * or not.
  8352. */
  8353. export class ImageProcessingConfiguration {
  8354. /**
  8355. * Default tone mapping applied in BabylonJS.
  8356. */
  8357. static readonly TONEMAPPING_STANDARD: number;
  8358. /**
  8359. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8360. * to other engines rendering to increase portability.
  8361. */
  8362. static readonly TONEMAPPING_ACES: number;
  8363. /**
  8364. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8365. */
  8366. colorCurves: Nullable<ColorCurves>;
  8367. private _colorCurvesEnabled;
  8368. /**
  8369. * Gets wether the color curves effect is enabled.
  8370. */
  8371. get colorCurvesEnabled(): boolean;
  8372. /**
  8373. * Sets wether the color curves effect is enabled.
  8374. */
  8375. set colorCurvesEnabled(value: boolean);
  8376. private _colorGradingTexture;
  8377. /**
  8378. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8379. */
  8380. get colorGradingTexture(): Nullable<BaseTexture>;
  8381. /**
  8382. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8383. */
  8384. set colorGradingTexture(value: Nullable<BaseTexture>);
  8385. private _colorGradingEnabled;
  8386. /**
  8387. * Gets wether the color grading effect is enabled.
  8388. */
  8389. get colorGradingEnabled(): boolean;
  8390. /**
  8391. * Sets wether the color grading effect is enabled.
  8392. */
  8393. set colorGradingEnabled(value: boolean);
  8394. private _colorGradingWithGreenDepth;
  8395. /**
  8396. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8397. */
  8398. get colorGradingWithGreenDepth(): boolean;
  8399. /**
  8400. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8401. */
  8402. set colorGradingWithGreenDepth(value: boolean);
  8403. private _colorGradingBGR;
  8404. /**
  8405. * Gets wether the color grading texture contains BGR values.
  8406. */
  8407. get colorGradingBGR(): boolean;
  8408. /**
  8409. * Sets wether the color grading texture contains BGR values.
  8410. */
  8411. set colorGradingBGR(value: boolean);
  8412. /** @hidden */
  8413. _exposure: number;
  8414. /**
  8415. * Gets the Exposure used in the effect.
  8416. */
  8417. get exposure(): number;
  8418. /**
  8419. * Sets the Exposure used in the effect.
  8420. */
  8421. set exposure(value: number);
  8422. private _toneMappingEnabled;
  8423. /**
  8424. * Gets wether the tone mapping effect is enabled.
  8425. */
  8426. get toneMappingEnabled(): boolean;
  8427. /**
  8428. * Sets wether the tone mapping effect is enabled.
  8429. */
  8430. set toneMappingEnabled(value: boolean);
  8431. private _toneMappingType;
  8432. /**
  8433. * Gets the type of tone mapping effect.
  8434. */
  8435. get toneMappingType(): number;
  8436. /**
  8437. * Sets the type of tone mapping effect used in BabylonJS.
  8438. */
  8439. set toneMappingType(value: number);
  8440. protected _contrast: number;
  8441. /**
  8442. * Gets the contrast used in the effect.
  8443. */
  8444. get contrast(): number;
  8445. /**
  8446. * Sets the contrast used in the effect.
  8447. */
  8448. set contrast(value: number);
  8449. /**
  8450. * Vignette stretch size.
  8451. */
  8452. vignetteStretch: number;
  8453. /**
  8454. * Vignette centre X Offset.
  8455. */
  8456. vignetteCentreX: number;
  8457. /**
  8458. * Vignette centre Y Offset.
  8459. */
  8460. vignetteCentreY: number;
  8461. /**
  8462. * Vignette weight or intensity of the vignette effect.
  8463. */
  8464. vignetteWeight: number;
  8465. /**
  8466. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8467. * if vignetteEnabled is set to true.
  8468. */
  8469. vignetteColor: Color4;
  8470. /**
  8471. * Camera field of view used by the Vignette effect.
  8472. */
  8473. vignetteCameraFov: number;
  8474. private _vignetteBlendMode;
  8475. /**
  8476. * Gets the vignette blend mode allowing different kind of effect.
  8477. */
  8478. get vignetteBlendMode(): number;
  8479. /**
  8480. * Sets the vignette blend mode allowing different kind of effect.
  8481. */
  8482. set vignetteBlendMode(value: number);
  8483. private _vignetteEnabled;
  8484. /**
  8485. * Gets wether the vignette effect is enabled.
  8486. */
  8487. get vignetteEnabled(): boolean;
  8488. /**
  8489. * Sets wether the vignette effect is enabled.
  8490. */
  8491. set vignetteEnabled(value: boolean);
  8492. private _applyByPostProcess;
  8493. /**
  8494. * Gets wether the image processing is applied through a post process or not.
  8495. */
  8496. get applyByPostProcess(): boolean;
  8497. /**
  8498. * Sets wether the image processing is applied through a post process or not.
  8499. */
  8500. set applyByPostProcess(value: boolean);
  8501. private _isEnabled;
  8502. /**
  8503. * Gets wether the image processing is enabled or not.
  8504. */
  8505. get isEnabled(): boolean;
  8506. /**
  8507. * Sets wether the image processing is enabled or not.
  8508. */
  8509. set isEnabled(value: boolean);
  8510. /**
  8511. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8512. */
  8513. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8514. /**
  8515. * Method called each time the image processing information changes requires to recompile the effect.
  8516. */
  8517. protected _updateParameters(): void;
  8518. /**
  8519. * Gets the current class name.
  8520. * @return "ImageProcessingConfiguration"
  8521. */
  8522. getClassName(): string;
  8523. /**
  8524. * Prepare the list of uniforms associated with the Image Processing effects.
  8525. * @param uniforms The list of uniforms used in the effect
  8526. * @param defines the list of defines currently in use
  8527. */
  8528. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8529. /**
  8530. * Prepare the list of samplers associated with the Image Processing effects.
  8531. * @param samplersList The list of uniforms used in the effect
  8532. * @param defines the list of defines currently in use
  8533. */
  8534. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8535. /**
  8536. * Prepare the list of defines associated to the shader.
  8537. * @param defines the list of defines to complete
  8538. * @param forPostProcess Define if we are currently in post process mode or not
  8539. */
  8540. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8541. /**
  8542. * Returns true if all the image processing information are ready.
  8543. * @returns True if ready, otherwise, false
  8544. */
  8545. isReady(): boolean;
  8546. /**
  8547. * Binds the image processing to the shader.
  8548. * @param effect The effect to bind to
  8549. * @param overrideAspectRatio Override the aspect ratio of the effect
  8550. */
  8551. bind(effect: Effect, overrideAspectRatio?: number): void;
  8552. /**
  8553. * Clones the current image processing instance.
  8554. * @return The cloned image processing
  8555. */
  8556. clone(): ImageProcessingConfiguration;
  8557. /**
  8558. * Serializes the current image processing instance to a json representation.
  8559. * @return a JSON representation
  8560. */
  8561. serialize(): any;
  8562. /**
  8563. * Parses the image processing from a json representation.
  8564. * @param source the JSON source to parse
  8565. * @return The parsed image processing
  8566. */
  8567. static Parse(source: any): ImageProcessingConfiguration;
  8568. private static _VIGNETTEMODE_MULTIPLY;
  8569. private static _VIGNETTEMODE_OPAQUE;
  8570. /**
  8571. * Used to apply the vignette as a mix with the pixel color.
  8572. */
  8573. static get VIGNETTEMODE_MULTIPLY(): number;
  8574. /**
  8575. * Used to apply the vignette as a replacement of the pixel color.
  8576. */
  8577. static get VIGNETTEMODE_OPAQUE(): number;
  8578. }
  8579. }
  8580. declare module "babylonjs/Shaders/postprocess.vertex" {
  8581. /** @hidden */
  8582. export var postprocessVertexShader: {
  8583. name: string;
  8584. shader: string;
  8585. };
  8586. }
  8587. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8588. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8589. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8590. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8591. module "babylonjs/Engines/thinEngine" {
  8592. interface ThinEngine {
  8593. /**
  8594. * Creates a new render target texture
  8595. * @param size defines the size of the texture
  8596. * @param options defines the options used to create the texture
  8597. * @returns a new render target texture stored in an InternalTexture
  8598. */
  8599. createRenderTargetTexture(size: number | {
  8600. width: number;
  8601. height: number;
  8602. layers?: number;
  8603. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8604. /**
  8605. * Creates a depth stencil texture.
  8606. * This is only available in WebGL 2 or with the depth texture extension available.
  8607. * @param size The size of face edge in the texture.
  8608. * @param options The options defining the texture.
  8609. * @returns The texture
  8610. */
  8611. createDepthStencilTexture(size: number | {
  8612. width: number;
  8613. height: number;
  8614. layers?: number;
  8615. }, options: DepthTextureCreationOptions): InternalTexture;
  8616. /** @hidden */
  8617. _createDepthStencilTexture(size: number | {
  8618. width: number;
  8619. height: number;
  8620. layers?: number;
  8621. }, options: DepthTextureCreationOptions): InternalTexture;
  8622. }
  8623. }
  8624. }
  8625. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8626. /**
  8627. * Defines the kind of connection point for node based material
  8628. */
  8629. export enum NodeMaterialBlockConnectionPointTypes {
  8630. /** Float */
  8631. Float = 1,
  8632. /** Int */
  8633. Int = 2,
  8634. /** Vector2 */
  8635. Vector2 = 4,
  8636. /** Vector3 */
  8637. Vector3 = 8,
  8638. /** Vector4 */
  8639. Vector4 = 16,
  8640. /** Color3 */
  8641. Color3 = 32,
  8642. /** Color4 */
  8643. Color4 = 64,
  8644. /** Matrix */
  8645. Matrix = 128,
  8646. /** Custom object */
  8647. Object = 256,
  8648. /** Detect type based on connection */
  8649. AutoDetect = 1024,
  8650. /** Output type that will be defined by input type */
  8651. BasedOnInput = 2048
  8652. }
  8653. }
  8654. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8655. /**
  8656. * Enum used to define the target of a block
  8657. */
  8658. export enum NodeMaterialBlockTargets {
  8659. /** Vertex shader */
  8660. Vertex = 1,
  8661. /** Fragment shader */
  8662. Fragment = 2,
  8663. /** Neutral */
  8664. Neutral = 4,
  8665. /** Vertex and Fragment */
  8666. VertexAndFragment = 3
  8667. }
  8668. }
  8669. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8670. /**
  8671. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8672. */
  8673. export enum NodeMaterialBlockConnectionPointMode {
  8674. /** Value is an uniform */
  8675. Uniform = 0,
  8676. /** Value is a mesh attribute */
  8677. Attribute = 1,
  8678. /** Value is a varying between vertex and fragment shaders */
  8679. Varying = 2,
  8680. /** Mode is undefined */
  8681. Undefined = 3
  8682. }
  8683. }
  8684. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8685. /**
  8686. * Enum used to define system values e.g. values automatically provided by the system
  8687. */
  8688. export enum NodeMaterialSystemValues {
  8689. /** World */
  8690. World = 1,
  8691. /** View */
  8692. View = 2,
  8693. /** Projection */
  8694. Projection = 3,
  8695. /** ViewProjection */
  8696. ViewProjection = 4,
  8697. /** WorldView */
  8698. WorldView = 5,
  8699. /** WorldViewProjection */
  8700. WorldViewProjection = 6,
  8701. /** CameraPosition */
  8702. CameraPosition = 7,
  8703. /** Fog Color */
  8704. FogColor = 8,
  8705. /** Delta time */
  8706. DeltaTime = 9
  8707. }
  8708. }
  8709. declare module "babylonjs/Maths/math.axis" {
  8710. import { Vector3 } from "babylonjs/Maths/math.vector";
  8711. /** Defines supported spaces */
  8712. export enum Space {
  8713. /** Local (object) space */
  8714. LOCAL = 0,
  8715. /** World space */
  8716. WORLD = 1,
  8717. /** Bone space */
  8718. BONE = 2
  8719. }
  8720. /** Defines the 3 main axes */
  8721. export class Axis {
  8722. /** X axis */
  8723. static X: Vector3;
  8724. /** Y axis */
  8725. static Y: Vector3;
  8726. /** Z axis */
  8727. static Z: Vector3;
  8728. }
  8729. }
  8730. declare module "babylonjs/Maths/math.frustum" {
  8731. import { Matrix } from "babylonjs/Maths/math.vector";
  8732. import { DeepImmutable } from "babylonjs/types";
  8733. import { Plane } from "babylonjs/Maths/math.plane";
  8734. /**
  8735. * Represents a camera frustum
  8736. */
  8737. export class Frustum {
  8738. /**
  8739. * Gets the planes representing the frustum
  8740. * @param transform matrix to be applied to the returned planes
  8741. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8742. */
  8743. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8744. /**
  8745. * Gets the near frustum plane transformed by the transform matrix
  8746. * @param transform transformation matrix to be applied to the resulting frustum plane
  8747. * @param frustumPlane the resuling frustum plane
  8748. */
  8749. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8750. /**
  8751. * Gets the far frustum plane transformed by the transform matrix
  8752. * @param transform transformation matrix to be applied to the resulting frustum plane
  8753. * @param frustumPlane the resuling frustum plane
  8754. */
  8755. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8756. /**
  8757. * Gets the left frustum plane transformed by the transform matrix
  8758. * @param transform transformation matrix to be applied to the resulting frustum plane
  8759. * @param frustumPlane the resuling frustum plane
  8760. */
  8761. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8762. /**
  8763. * Gets the right frustum plane transformed by the transform matrix
  8764. * @param transform transformation matrix to be applied to the resulting frustum plane
  8765. * @param frustumPlane the resuling frustum plane
  8766. */
  8767. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8768. /**
  8769. * Gets the top frustum plane transformed by the transform matrix
  8770. * @param transform transformation matrix to be applied to the resulting frustum plane
  8771. * @param frustumPlane the resuling frustum plane
  8772. */
  8773. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8774. /**
  8775. * Gets the bottom frustum plane transformed by the transform matrix
  8776. * @param transform transformation matrix to be applied to the resulting frustum plane
  8777. * @param frustumPlane the resuling frustum plane
  8778. */
  8779. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8780. /**
  8781. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8782. * @param transform transformation matrix to be applied to the resulting frustum planes
  8783. * @param frustumPlanes the resuling frustum planes
  8784. */
  8785. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8786. }
  8787. }
  8788. declare module "babylonjs/Maths/math.size" {
  8789. /**
  8790. * Interface for the size containing width and height
  8791. */
  8792. export interface ISize {
  8793. /**
  8794. * Width
  8795. */
  8796. width: number;
  8797. /**
  8798. * Heighht
  8799. */
  8800. height: number;
  8801. }
  8802. /**
  8803. * Size containing widht and height
  8804. */
  8805. export class Size implements ISize {
  8806. /**
  8807. * Width
  8808. */
  8809. width: number;
  8810. /**
  8811. * Height
  8812. */
  8813. height: number;
  8814. /**
  8815. * Creates a Size object from the given width and height (floats).
  8816. * @param width width of the new size
  8817. * @param height height of the new size
  8818. */
  8819. constructor(width: number, height: number);
  8820. /**
  8821. * Returns a string with the Size width and height
  8822. * @returns a string with the Size width and height
  8823. */
  8824. toString(): string;
  8825. /**
  8826. * "Size"
  8827. * @returns the string "Size"
  8828. */
  8829. getClassName(): string;
  8830. /**
  8831. * Returns the Size hash code.
  8832. * @returns a hash code for a unique width and height
  8833. */
  8834. getHashCode(): number;
  8835. /**
  8836. * Updates the current size from the given one.
  8837. * @param src the given size
  8838. */
  8839. copyFrom(src: Size): void;
  8840. /**
  8841. * Updates in place the current Size from the given floats.
  8842. * @param width width of the new size
  8843. * @param height height of the new size
  8844. * @returns the updated Size.
  8845. */
  8846. copyFromFloats(width: number, height: number): Size;
  8847. /**
  8848. * Updates in place the current Size from the given floats.
  8849. * @param width width to set
  8850. * @param height height to set
  8851. * @returns the updated Size.
  8852. */
  8853. set(width: number, height: number): Size;
  8854. /**
  8855. * Multiplies the width and height by numbers
  8856. * @param w factor to multiple the width by
  8857. * @param h factor to multiple the height by
  8858. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8859. */
  8860. multiplyByFloats(w: number, h: number): Size;
  8861. /**
  8862. * Clones the size
  8863. * @returns a new Size copied from the given one.
  8864. */
  8865. clone(): Size;
  8866. /**
  8867. * True if the current Size and the given one width and height are strictly equal.
  8868. * @param other the other size to compare against
  8869. * @returns True if the current Size and the given one width and height are strictly equal.
  8870. */
  8871. equals(other: Size): boolean;
  8872. /**
  8873. * The surface of the Size : width * height (float).
  8874. */
  8875. get surface(): number;
  8876. /**
  8877. * Create a new size of zero
  8878. * @returns a new Size set to (0.0, 0.0)
  8879. */
  8880. static Zero(): Size;
  8881. /**
  8882. * Sums the width and height of two sizes
  8883. * @param otherSize size to add to this size
  8884. * @returns a new Size set as the addition result of the current Size and the given one.
  8885. */
  8886. add(otherSize: Size): Size;
  8887. /**
  8888. * Subtracts the width and height of two
  8889. * @param otherSize size to subtract to this size
  8890. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8891. */
  8892. subtract(otherSize: Size): Size;
  8893. /**
  8894. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8895. * @param start starting size to lerp between
  8896. * @param end end size to lerp between
  8897. * @param amount amount to lerp between the start and end values
  8898. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8899. */
  8900. static Lerp(start: Size, end: Size, amount: number): Size;
  8901. }
  8902. }
  8903. declare module "babylonjs/Maths/math.vertexFormat" {
  8904. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8905. /**
  8906. * Contains position and normal vectors for a vertex
  8907. */
  8908. export class PositionNormalVertex {
  8909. /** the position of the vertex (defaut: 0,0,0) */
  8910. position: Vector3;
  8911. /** the normal of the vertex (defaut: 0,1,0) */
  8912. normal: Vector3;
  8913. /**
  8914. * Creates a PositionNormalVertex
  8915. * @param position the position of the vertex (defaut: 0,0,0)
  8916. * @param normal the normal of the vertex (defaut: 0,1,0)
  8917. */
  8918. constructor(
  8919. /** the position of the vertex (defaut: 0,0,0) */
  8920. position?: Vector3,
  8921. /** the normal of the vertex (defaut: 0,1,0) */
  8922. normal?: Vector3);
  8923. /**
  8924. * Clones the PositionNormalVertex
  8925. * @returns the cloned PositionNormalVertex
  8926. */
  8927. clone(): PositionNormalVertex;
  8928. }
  8929. /**
  8930. * Contains position, normal and uv vectors for a vertex
  8931. */
  8932. export class PositionNormalTextureVertex {
  8933. /** the position of the vertex (defaut: 0,0,0) */
  8934. position: Vector3;
  8935. /** the normal of the vertex (defaut: 0,1,0) */
  8936. normal: Vector3;
  8937. /** the uv of the vertex (default: 0,0) */
  8938. uv: Vector2;
  8939. /**
  8940. * Creates a PositionNormalTextureVertex
  8941. * @param position the position of the vertex (defaut: 0,0,0)
  8942. * @param normal the normal of the vertex (defaut: 0,1,0)
  8943. * @param uv the uv of the vertex (default: 0,0)
  8944. */
  8945. constructor(
  8946. /** the position of the vertex (defaut: 0,0,0) */
  8947. position?: Vector3,
  8948. /** the normal of the vertex (defaut: 0,1,0) */
  8949. normal?: Vector3,
  8950. /** the uv of the vertex (default: 0,0) */
  8951. uv?: Vector2);
  8952. /**
  8953. * Clones the PositionNormalTextureVertex
  8954. * @returns the cloned PositionNormalTextureVertex
  8955. */
  8956. clone(): PositionNormalTextureVertex;
  8957. }
  8958. }
  8959. declare module "babylonjs/Maths/math" {
  8960. export * from "babylonjs/Maths/math.axis";
  8961. export * from "babylonjs/Maths/math.color";
  8962. export * from "babylonjs/Maths/math.constants";
  8963. export * from "babylonjs/Maths/math.frustum";
  8964. export * from "babylonjs/Maths/math.path";
  8965. export * from "babylonjs/Maths/math.plane";
  8966. export * from "babylonjs/Maths/math.size";
  8967. export * from "babylonjs/Maths/math.vector";
  8968. export * from "babylonjs/Maths/math.vertexFormat";
  8969. export * from "babylonjs/Maths/math.viewport";
  8970. }
  8971. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  8972. /**
  8973. * Enum defining the type of animations supported by InputBlock
  8974. */
  8975. export enum AnimatedInputBlockTypes {
  8976. /** No animation */
  8977. None = 0,
  8978. /** Time based animation. Will only work for floats */
  8979. Time = 1
  8980. }
  8981. }
  8982. declare module "babylonjs/Lights/shadowLight" {
  8983. import { Camera } from "babylonjs/Cameras/camera";
  8984. import { Scene } from "babylonjs/scene";
  8985. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8987. import { Light } from "babylonjs/Lights/light";
  8988. /**
  8989. * Interface describing all the common properties and methods a shadow light needs to implement.
  8990. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8991. * as well as binding the different shadow properties to the effects.
  8992. */
  8993. export interface IShadowLight extends Light {
  8994. /**
  8995. * The light id in the scene (used in scene.findLighById for instance)
  8996. */
  8997. id: string;
  8998. /**
  8999. * The position the shdow will be casted from.
  9000. */
  9001. position: Vector3;
  9002. /**
  9003. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9004. */
  9005. direction: Vector3;
  9006. /**
  9007. * The transformed position. Position of the light in world space taking parenting in account.
  9008. */
  9009. transformedPosition: Vector3;
  9010. /**
  9011. * The transformed direction. Direction of the light in world space taking parenting in account.
  9012. */
  9013. transformedDirection: Vector3;
  9014. /**
  9015. * The friendly name of the light in the scene.
  9016. */
  9017. name: string;
  9018. /**
  9019. * Defines the shadow projection clipping minimum z value.
  9020. */
  9021. shadowMinZ: number;
  9022. /**
  9023. * Defines the shadow projection clipping maximum z value.
  9024. */
  9025. shadowMaxZ: number;
  9026. /**
  9027. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9028. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9029. */
  9030. computeTransformedInformation(): boolean;
  9031. /**
  9032. * Gets the scene the light belongs to.
  9033. * @returns The scene
  9034. */
  9035. getScene(): Scene;
  9036. /**
  9037. * Callback defining a custom Projection Matrix Builder.
  9038. * This can be used to override the default projection matrix computation.
  9039. */
  9040. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9041. /**
  9042. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9043. * @param matrix The materix to updated with the projection information
  9044. * @param viewMatrix The transform matrix of the light
  9045. * @param renderList The list of mesh to render in the map
  9046. * @returns The current light
  9047. */
  9048. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9049. /**
  9050. * Gets the current depth scale used in ESM.
  9051. * @returns The scale
  9052. */
  9053. getDepthScale(): number;
  9054. /**
  9055. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9056. * @returns true if a cube texture needs to be use
  9057. */
  9058. needCube(): boolean;
  9059. /**
  9060. * Detects if the projection matrix requires to be recomputed this frame.
  9061. * @returns true if it requires to be recomputed otherwise, false.
  9062. */
  9063. needProjectionMatrixCompute(): boolean;
  9064. /**
  9065. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9066. */
  9067. forceProjectionMatrixCompute(): void;
  9068. /**
  9069. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9070. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9071. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9072. */
  9073. getShadowDirection(faceIndex?: number): Vector3;
  9074. /**
  9075. * Gets the minZ used for shadow according to both the scene and the light.
  9076. * @param activeCamera The camera we are returning the min for
  9077. * @returns the depth min z
  9078. */
  9079. getDepthMinZ(activeCamera: Camera): number;
  9080. /**
  9081. * Gets the maxZ used for shadow according to both the scene and the light.
  9082. * @param activeCamera The camera we are returning the max for
  9083. * @returns the depth max z
  9084. */
  9085. getDepthMaxZ(activeCamera: Camera): number;
  9086. }
  9087. /**
  9088. * Base implementation IShadowLight
  9089. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9090. */
  9091. export abstract class ShadowLight extends Light implements IShadowLight {
  9092. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9093. protected _position: Vector3;
  9094. protected _setPosition(value: Vector3): void;
  9095. /**
  9096. * Sets the position the shadow will be casted from. Also use as the light position for both
  9097. * point and spot lights.
  9098. */
  9099. get position(): Vector3;
  9100. /**
  9101. * Sets the position the shadow will be casted from. Also use as the light position for both
  9102. * point and spot lights.
  9103. */
  9104. set position(value: Vector3);
  9105. protected _direction: Vector3;
  9106. protected _setDirection(value: Vector3): void;
  9107. /**
  9108. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9109. * Also use as the light direction on spot and directional lights.
  9110. */
  9111. get direction(): Vector3;
  9112. /**
  9113. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9114. * Also use as the light direction on spot and directional lights.
  9115. */
  9116. set direction(value: Vector3);
  9117. protected _shadowMinZ: number;
  9118. /**
  9119. * Gets the shadow projection clipping minimum z value.
  9120. */
  9121. get shadowMinZ(): number;
  9122. /**
  9123. * Sets the shadow projection clipping minimum z value.
  9124. */
  9125. set shadowMinZ(value: number);
  9126. protected _shadowMaxZ: number;
  9127. /**
  9128. * Sets the shadow projection clipping maximum z value.
  9129. */
  9130. get shadowMaxZ(): number;
  9131. /**
  9132. * Gets the shadow projection clipping maximum z value.
  9133. */
  9134. set shadowMaxZ(value: number);
  9135. /**
  9136. * Callback defining a custom Projection Matrix Builder.
  9137. * This can be used to override the default projection matrix computation.
  9138. */
  9139. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9140. /**
  9141. * The transformed position. Position of the light in world space taking parenting in account.
  9142. */
  9143. transformedPosition: Vector3;
  9144. /**
  9145. * The transformed direction. Direction of the light in world space taking parenting in account.
  9146. */
  9147. transformedDirection: Vector3;
  9148. private _needProjectionMatrixCompute;
  9149. /**
  9150. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9151. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9152. */
  9153. computeTransformedInformation(): boolean;
  9154. /**
  9155. * Return the depth scale used for the shadow map.
  9156. * @returns the depth scale.
  9157. */
  9158. getDepthScale(): number;
  9159. /**
  9160. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9161. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9162. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9163. */
  9164. getShadowDirection(faceIndex?: number): Vector3;
  9165. /**
  9166. * Returns the ShadowLight absolute position in the World.
  9167. * @returns the position vector in world space
  9168. */
  9169. getAbsolutePosition(): Vector3;
  9170. /**
  9171. * Sets the ShadowLight direction toward the passed target.
  9172. * @param target The point to target in local space
  9173. * @returns the updated ShadowLight direction
  9174. */
  9175. setDirectionToTarget(target: Vector3): Vector3;
  9176. /**
  9177. * Returns the light rotation in euler definition.
  9178. * @returns the x y z rotation in local space.
  9179. */
  9180. getRotation(): Vector3;
  9181. /**
  9182. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9183. * @returns true if a cube texture needs to be use
  9184. */
  9185. needCube(): boolean;
  9186. /**
  9187. * Detects if the projection matrix requires to be recomputed this frame.
  9188. * @returns true if it requires to be recomputed otherwise, false.
  9189. */
  9190. needProjectionMatrixCompute(): boolean;
  9191. /**
  9192. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9193. */
  9194. forceProjectionMatrixCompute(): void;
  9195. /** @hidden */
  9196. _initCache(): void;
  9197. /** @hidden */
  9198. _isSynchronized(): boolean;
  9199. /**
  9200. * Computes the world matrix of the node
  9201. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9202. * @returns the world matrix
  9203. */
  9204. computeWorldMatrix(force?: boolean): Matrix;
  9205. /**
  9206. * Gets the minZ used for shadow according to both the scene and the light.
  9207. * @param activeCamera The camera we are returning the min for
  9208. * @returns the depth min z
  9209. */
  9210. getDepthMinZ(activeCamera: Camera): number;
  9211. /**
  9212. * Gets the maxZ used for shadow according to both the scene and the light.
  9213. * @param activeCamera The camera we are returning the max for
  9214. * @returns the depth max z
  9215. */
  9216. getDepthMaxZ(activeCamera: Camera): number;
  9217. /**
  9218. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9219. * @param matrix The materix to updated with the projection information
  9220. * @param viewMatrix The transform matrix of the light
  9221. * @param renderList The list of mesh to render in the map
  9222. * @returns The current light
  9223. */
  9224. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9225. }
  9226. }
  9227. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9228. /** @hidden */
  9229. export var packingFunctions: {
  9230. name: string;
  9231. shader: string;
  9232. };
  9233. }
  9234. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9235. /** @hidden */
  9236. export var bayerDitherFunctions: {
  9237. name: string;
  9238. shader: string;
  9239. };
  9240. }
  9241. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9242. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9243. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9244. /** @hidden */
  9245. export var shadowMapFragmentDeclaration: {
  9246. name: string;
  9247. shader: string;
  9248. };
  9249. }
  9250. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9251. /** @hidden */
  9252. export var clipPlaneFragmentDeclaration: {
  9253. name: string;
  9254. shader: string;
  9255. };
  9256. }
  9257. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9258. /** @hidden */
  9259. export var clipPlaneFragment: {
  9260. name: string;
  9261. shader: string;
  9262. };
  9263. }
  9264. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9265. /** @hidden */
  9266. export var shadowMapFragment: {
  9267. name: string;
  9268. shader: string;
  9269. };
  9270. }
  9271. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9272. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9273. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9274. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9275. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9276. /** @hidden */
  9277. export var shadowMapPixelShader: {
  9278. name: string;
  9279. shader: string;
  9280. };
  9281. }
  9282. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9283. /** @hidden */
  9284. export var bonesDeclaration: {
  9285. name: string;
  9286. shader: string;
  9287. };
  9288. }
  9289. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9290. /** @hidden */
  9291. export var morphTargetsVertexGlobalDeclaration: {
  9292. name: string;
  9293. shader: string;
  9294. };
  9295. }
  9296. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9297. /** @hidden */
  9298. export var morphTargetsVertexDeclaration: {
  9299. name: string;
  9300. shader: string;
  9301. };
  9302. }
  9303. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9304. /** @hidden */
  9305. export var instancesDeclaration: {
  9306. name: string;
  9307. shader: string;
  9308. };
  9309. }
  9310. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9311. /** @hidden */
  9312. export var helperFunctions: {
  9313. name: string;
  9314. shader: string;
  9315. };
  9316. }
  9317. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9318. /** @hidden */
  9319. export var shadowMapVertexDeclaration: {
  9320. name: string;
  9321. shader: string;
  9322. };
  9323. }
  9324. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9325. /** @hidden */
  9326. export var clipPlaneVertexDeclaration: {
  9327. name: string;
  9328. shader: string;
  9329. };
  9330. }
  9331. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9332. /** @hidden */
  9333. export var morphTargetsVertex: {
  9334. name: string;
  9335. shader: string;
  9336. };
  9337. }
  9338. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9339. /** @hidden */
  9340. export var instancesVertex: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9346. /** @hidden */
  9347. export var bonesVertex: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9353. /** @hidden */
  9354. export var shadowMapVertexNormalBias: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9360. /** @hidden */
  9361. export var shadowMapVertexMetric: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9367. /** @hidden */
  9368. export var clipPlaneVertex: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9374. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9375. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9376. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9377. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9378. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9379. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9380. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9381. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9382. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9383. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9384. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9385. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9386. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9387. /** @hidden */
  9388. export var shadowMapVertexShader: {
  9389. name: string;
  9390. shader: string;
  9391. };
  9392. }
  9393. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9394. /** @hidden */
  9395. export var depthBoxBlurPixelShader: {
  9396. name: string;
  9397. shader: string;
  9398. };
  9399. }
  9400. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9401. /** @hidden */
  9402. export var shadowMapFragmentSoftTransparentShadow: {
  9403. name: string;
  9404. shader: string;
  9405. };
  9406. }
  9407. declare module "babylonjs/Materials/effectFallbacks" {
  9408. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9409. import { Effect } from "babylonjs/Materials/effect";
  9410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9411. /**
  9412. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9413. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9414. */
  9415. export class EffectFallbacks implements IEffectFallbacks {
  9416. private _defines;
  9417. private _currentRank;
  9418. private _maxRank;
  9419. private _mesh;
  9420. /**
  9421. * Removes the fallback from the bound mesh.
  9422. */
  9423. unBindMesh(): void;
  9424. /**
  9425. * Adds a fallback on the specified property.
  9426. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9427. * @param define The name of the define in the shader
  9428. */
  9429. addFallback(rank: number, define: string): void;
  9430. /**
  9431. * Sets the mesh to use CPU skinning when needing to fallback.
  9432. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9433. * @param mesh The mesh to use the fallbacks.
  9434. */
  9435. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9436. /**
  9437. * Checks to see if more fallbacks are still availible.
  9438. */
  9439. get hasMoreFallbacks(): boolean;
  9440. /**
  9441. * Removes the defines that should be removed when falling back.
  9442. * @param currentDefines defines the current define statements for the shader.
  9443. * @param effect defines the current effect we try to compile
  9444. * @returns The resulting defines with defines of the current rank removed.
  9445. */
  9446. reduce(currentDefines: string, effect: Effect): string;
  9447. }
  9448. }
  9449. declare module "babylonjs/Actions/action" {
  9450. import { Observable } from "babylonjs/Misc/observable";
  9451. import { Condition } from "babylonjs/Actions/condition";
  9452. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9453. import { Scene } from "babylonjs/scene";
  9454. import { ActionManager } from "babylonjs/Actions/actionManager";
  9455. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9456. import { Node } from "babylonjs/node";
  9457. /**
  9458. * Interface used to define Action
  9459. */
  9460. export interface IAction {
  9461. /**
  9462. * Trigger for the action
  9463. */
  9464. trigger: number;
  9465. /** Options of the trigger */
  9466. triggerOptions: any;
  9467. /**
  9468. * Gets the trigger parameters
  9469. * @returns the trigger parameters
  9470. */
  9471. getTriggerParameter(): any;
  9472. /**
  9473. * Internal only - executes current action event
  9474. * @hidden
  9475. */
  9476. _executeCurrent(evt?: ActionEvent): void;
  9477. /**
  9478. * Serialize placeholder for child classes
  9479. * @param parent of child
  9480. * @returns the serialized object
  9481. */
  9482. serialize(parent: any): any;
  9483. /**
  9484. * Internal only
  9485. * @hidden
  9486. */
  9487. _prepare(): void;
  9488. /**
  9489. * Internal only - manager for action
  9490. * @hidden
  9491. */
  9492. _actionManager: AbstractActionManager;
  9493. /**
  9494. * Adds action to chain of actions, may be a DoNothingAction
  9495. * @param action defines the next action to execute
  9496. * @returns The action passed in
  9497. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9498. */
  9499. then(action: IAction): IAction;
  9500. }
  9501. /**
  9502. * The action to be carried out following a trigger
  9503. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9504. */
  9505. export class Action implements IAction {
  9506. /** the trigger, with or without parameters, for the action */
  9507. triggerOptions: any;
  9508. /**
  9509. * Trigger for the action
  9510. */
  9511. trigger: number;
  9512. /**
  9513. * Internal only - manager for action
  9514. * @hidden
  9515. */
  9516. _actionManager: ActionManager;
  9517. private _nextActiveAction;
  9518. private _child;
  9519. private _condition?;
  9520. private _triggerParameter;
  9521. /**
  9522. * An event triggered prior to action being executed.
  9523. */
  9524. onBeforeExecuteObservable: Observable<Action>;
  9525. /**
  9526. * Creates a new Action
  9527. * @param triggerOptions the trigger, with or without parameters, for the action
  9528. * @param condition an optional determinant of action
  9529. */
  9530. constructor(
  9531. /** the trigger, with or without parameters, for the action */
  9532. triggerOptions: any, condition?: Condition);
  9533. /**
  9534. * Internal only
  9535. * @hidden
  9536. */
  9537. _prepare(): void;
  9538. /**
  9539. * Gets the trigger parameters
  9540. * @returns the trigger parameters
  9541. */
  9542. getTriggerParameter(): any;
  9543. /**
  9544. * Internal only - executes current action event
  9545. * @hidden
  9546. */
  9547. _executeCurrent(evt?: ActionEvent): void;
  9548. /**
  9549. * Execute placeholder for child classes
  9550. * @param evt optional action event
  9551. */
  9552. execute(evt?: ActionEvent): void;
  9553. /**
  9554. * Skips to next active action
  9555. */
  9556. skipToNextActiveAction(): void;
  9557. /**
  9558. * Adds action to chain of actions, may be a DoNothingAction
  9559. * @param action defines the next action to execute
  9560. * @returns The action passed in
  9561. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9562. */
  9563. then(action: Action): Action;
  9564. /**
  9565. * Internal only
  9566. * @hidden
  9567. */
  9568. _getProperty(propertyPath: string): string;
  9569. /**
  9570. * Internal only
  9571. * @hidden
  9572. */
  9573. _getEffectiveTarget(target: any, propertyPath: string): any;
  9574. /**
  9575. * Serialize placeholder for child classes
  9576. * @param parent of child
  9577. * @returns the serialized object
  9578. */
  9579. serialize(parent: any): any;
  9580. /**
  9581. * Internal only called by serialize
  9582. * @hidden
  9583. */
  9584. protected _serialize(serializedAction: any, parent?: any): any;
  9585. /**
  9586. * Internal only
  9587. * @hidden
  9588. */
  9589. static _SerializeValueAsString: (value: any) => string;
  9590. /**
  9591. * Internal only
  9592. * @hidden
  9593. */
  9594. static _GetTargetProperty: (target: Scene | Node) => {
  9595. name: string;
  9596. targetType: string;
  9597. value: string;
  9598. };
  9599. }
  9600. }
  9601. declare module "babylonjs/Actions/condition" {
  9602. import { ActionManager } from "babylonjs/Actions/actionManager";
  9603. /**
  9604. * A Condition applied to an Action
  9605. */
  9606. export class Condition {
  9607. /**
  9608. * Internal only - manager for action
  9609. * @hidden
  9610. */
  9611. _actionManager: ActionManager;
  9612. /**
  9613. * Internal only
  9614. * @hidden
  9615. */
  9616. _evaluationId: number;
  9617. /**
  9618. * Internal only
  9619. * @hidden
  9620. */
  9621. _currentResult: boolean;
  9622. /**
  9623. * Creates a new Condition
  9624. * @param actionManager the manager of the action the condition is applied to
  9625. */
  9626. constructor(actionManager: ActionManager);
  9627. /**
  9628. * Check if the current condition is valid
  9629. * @returns a boolean
  9630. */
  9631. isValid(): boolean;
  9632. /**
  9633. * Internal only
  9634. * @hidden
  9635. */
  9636. _getProperty(propertyPath: string): string;
  9637. /**
  9638. * Internal only
  9639. * @hidden
  9640. */
  9641. _getEffectiveTarget(target: any, propertyPath: string): any;
  9642. /**
  9643. * Serialize placeholder for child classes
  9644. * @returns the serialized object
  9645. */
  9646. serialize(): any;
  9647. /**
  9648. * Internal only
  9649. * @hidden
  9650. */
  9651. protected _serialize(serializedCondition: any): any;
  9652. }
  9653. /**
  9654. * Defines specific conditional operators as extensions of Condition
  9655. */
  9656. export class ValueCondition extends Condition {
  9657. /** path to specify the property of the target the conditional operator uses */
  9658. propertyPath: string;
  9659. /** the value compared by the conditional operator against the current value of the property */
  9660. value: any;
  9661. /** the conditional operator, default ValueCondition.IsEqual */
  9662. operator: number;
  9663. /**
  9664. * Internal only
  9665. * @hidden
  9666. */
  9667. private static _IsEqual;
  9668. /**
  9669. * Internal only
  9670. * @hidden
  9671. */
  9672. private static _IsDifferent;
  9673. /**
  9674. * Internal only
  9675. * @hidden
  9676. */
  9677. private static _IsGreater;
  9678. /**
  9679. * Internal only
  9680. * @hidden
  9681. */
  9682. private static _IsLesser;
  9683. /**
  9684. * returns the number for IsEqual
  9685. */
  9686. static get IsEqual(): number;
  9687. /**
  9688. * Returns the number for IsDifferent
  9689. */
  9690. static get IsDifferent(): number;
  9691. /**
  9692. * Returns the number for IsGreater
  9693. */
  9694. static get IsGreater(): number;
  9695. /**
  9696. * Returns the number for IsLesser
  9697. */
  9698. static get IsLesser(): number;
  9699. /**
  9700. * Internal only The action manager for the condition
  9701. * @hidden
  9702. */
  9703. _actionManager: ActionManager;
  9704. /**
  9705. * Internal only
  9706. * @hidden
  9707. */
  9708. private _target;
  9709. /**
  9710. * Internal only
  9711. * @hidden
  9712. */
  9713. private _effectiveTarget;
  9714. /**
  9715. * Internal only
  9716. * @hidden
  9717. */
  9718. private _property;
  9719. /**
  9720. * Creates a new ValueCondition
  9721. * @param actionManager manager for the action the condition applies to
  9722. * @param target for the action
  9723. * @param propertyPath path to specify the property of the target the conditional operator uses
  9724. * @param value the value compared by the conditional operator against the current value of the property
  9725. * @param operator the conditional operator, default ValueCondition.IsEqual
  9726. */
  9727. constructor(actionManager: ActionManager, target: any,
  9728. /** path to specify the property of the target the conditional operator uses */
  9729. propertyPath: string,
  9730. /** the value compared by the conditional operator against the current value of the property */
  9731. value: any,
  9732. /** the conditional operator, default ValueCondition.IsEqual */
  9733. operator?: number);
  9734. /**
  9735. * Compares the given value with the property value for the specified conditional operator
  9736. * @returns the result of the comparison
  9737. */
  9738. isValid(): boolean;
  9739. /**
  9740. * Serialize the ValueCondition into a JSON compatible object
  9741. * @returns serialization object
  9742. */
  9743. serialize(): any;
  9744. /**
  9745. * Gets the name of the conditional operator for the ValueCondition
  9746. * @param operator the conditional operator
  9747. * @returns the name
  9748. */
  9749. static GetOperatorName(operator: number): string;
  9750. }
  9751. /**
  9752. * Defines a predicate condition as an extension of Condition
  9753. */
  9754. export class PredicateCondition extends Condition {
  9755. /** defines the predicate function used to validate the condition */
  9756. predicate: () => boolean;
  9757. /**
  9758. * Internal only - manager for action
  9759. * @hidden
  9760. */
  9761. _actionManager: ActionManager;
  9762. /**
  9763. * Creates a new PredicateCondition
  9764. * @param actionManager manager for the action the condition applies to
  9765. * @param predicate defines the predicate function used to validate the condition
  9766. */
  9767. constructor(actionManager: ActionManager,
  9768. /** defines the predicate function used to validate the condition */
  9769. predicate: () => boolean);
  9770. /**
  9771. * @returns the validity of the predicate condition
  9772. */
  9773. isValid(): boolean;
  9774. }
  9775. /**
  9776. * Defines a state condition as an extension of Condition
  9777. */
  9778. export class StateCondition extends Condition {
  9779. /** Value to compare with target state */
  9780. value: string;
  9781. /**
  9782. * Internal only - manager for action
  9783. * @hidden
  9784. */
  9785. _actionManager: ActionManager;
  9786. /**
  9787. * Internal only
  9788. * @hidden
  9789. */
  9790. private _target;
  9791. /**
  9792. * Creates a new StateCondition
  9793. * @param actionManager manager for the action the condition applies to
  9794. * @param target of the condition
  9795. * @param value to compare with target state
  9796. */
  9797. constructor(actionManager: ActionManager, target: any,
  9798. /** Value to compare with target state */
  9799. value: string);
  9800. /**
  9801. * Gets a boolean indicating if the current condition is met
  9802. * @returns the validity of the state
  9803. */
  9804. isValid(): boolean;
  9805. /**
  9806. * Serialize the StateCondition into a JSON compatible object
  9807. * @returns serialization object
  9808. */
  9809. serialize(): any;
  9810. }
  9811. }
  9812. declare module "babylonjs/Actions/directActions" {
  9813. import { Action } from "babylonjs/Actions/action";
  9814. import { Condition } from "babylonjs/Actions/condition";
  9815. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9816. /**
  9817. * This defines an action responsible to toggle a boolean once triggered.
  9818. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9819. */
  9820. export class SwitchBooleanAction extends Action {
  9821. /**
  9822. * The path to the boolean property in the target object
  9823. */
  9824. propertyPath: string;
  9825. private _target;
  9826. private _effectiveTarget;
  9827. private _property;
  9828. /**
  9829. * Instantiate the action
  9830. * @param triggerOptions defines the trigger options
  9831. * @param target defines the object containing the boolean
  9832. * @param propertyPath defines the path to the boolean property in the target object
  9833. * @param condition defines the trigger related conditions
  9834. */
  9835. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9836. /** @hidden */
  9837. _prepare(): void;
  9838. /**
  9839. * Execute the action toggle the boolean value.
  9840. */
  9841. execute(): void;
  9842. /**
  9843. * Serializes the actions and its related information.
  9844. * @param parent defines the object to serialize in
  9845. * @returns the serialized object
  9846. */
  9847. serialize(parent: any): any;
  9848. }
  9849. /**
  9850. * This defines an action responsible to set a the state field of the target
  9851. * to a desired value once triggered.
  9852. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9853. */
  9854. export class SetStateAction extends Action {
  9855. /**
  9856. * The value to store in the state field.
  9857. */
  9858. value: string;
  9859. private _target;
  9860. /**
  9861. * Instantiate the action
  9862. * @param triggerOptions defines the trigger options
  9863. * @param target defines the object containing the state property
  9864. * @param value defines the value to store in the state field
  9865. * @param condition defines the trigger related conditions
  9866. */
  9867. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9868. /**
  9869. * Execute the action and store the value on the target state property.
  9870. */
  9871. execute(): void;
  9872. /**
  9873. * Serializes the actions and its related information.
  9874. * @param parent defines the object to serialize in
  9875. * @returns the serialized object
  9876. */
  9877. serialize(parent: any): any;
  9878. }
  9879. /**
  9880. * This defines an action responsible to set a property of the target
  9881. * to a desired value once triggered.
  9882. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9883. */
  9884. export class SetValueAction extends Action {
  9885. /**
  9886. * The path of the property to set in the target.
  9887. */
  9888. propertyPath: string;
  9889. /**
  9890. * The value to set in the property
  9891. */
  9892. value: any;
  9893. private _target;
  9894. private _effectiveTarget;
  9895. private _property;
  9896. /**
  9897. * Instantiate the action
  9898. * @param triggerOptions defines the trigger options
  9899. * @param target defines the object containing the property
  9900. * @param propertyPath defines the path of the property to set in the target
  9901. * @param value defines the value to set in the property
  9902. * @param condition defines the trigger related conditions
  9903. */
  9904. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9905. /** @hidden */
  9906. _prepare(): void;
  9907. /**
  9908. * Execute the action and set the targetted property to the desired value.
  9909. */
  9910. execute(): void;
  9911. /**
  9912. * Serializes the actions and its related information.
  9913. * @param parent defines the object to serialize in
  9914. * @returns the serialized object
  9915. */
  9916. serialize(parent: any): any;
  9917. }
  9918. /**
  9919. * This defines an action responsible to increment the target value
  9920. * to a desired value once triggered.
  9921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9922. */
  9923. export class IncrementValueAction extends Action {
  9924. /**
  9925. * The path of the property to increment in the target.
  9926. */
  9927. propertyPath: string;
  9928. /**
  9929. * The value we should increment the property by.
  9930. */
  9931. value: any;
  9932. private _target;
  9933. private _effectiveTarget;
  9934. private _property;
  9935. /**
  9936. * Instantiate the action
  9937. * @param triggerOptions defines the trigger options
  9938. * @param target defines the object containing the property
  9939. * @param propertyPath defines the path of the property to increment in the target
  9940. * @param value defines the value value we should increment the property by
  9941. * @param condition defines the trigger related conditions
  9942. */
  9943. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9944. /** @hidden */
  9945. _prepare(): void;
  9946. /**
  9947. * Execute the action and increment the target of the value amount.
  9948. */
  9949. execute(): void;
  9950. /**
  9951. * Serializes the actions and its related information.
  9952. * @param parent defines the object to serialize in
  9953. * @returns the serialized object
  9954. */
  9955. serialize(parent: any): any;
  9956. }
  9957. /**
  9958. * This defines an action responsible to start an animation once triggered.
  9959. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9960. */
  9961. export class PlayAnimationAction extends Action {
  9962. /**
  9963. * Where the animation should start (animation frame)
  9964. */
  9965. from: number;
  9966. /**
  9967. * Where the animation should stop (animation frame)
  9968. */
  9969. to: number;
  9970. /**
  9971. * Define if the animation should loop or stop after the first play.
  9972. */
  9973. loop?: boolean;
  9974. private _target;
  9975. /**
  9976. * Instantiate the action
  9977. * @param triggerOptions defines the trigger options
  9978. * @param target defines the target animation or animation name
  9979. * @param from defines from where the animation should start (animation frame)
  9980. * @param end defines where the animation should stop (animation frame)
  9981. * @param loop defines if the animation should loop or stop after the first play
  9982. * @param condition defines the trigger related conditions
  9983. */
  9984. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9985. /** @hidden */
  9986. _prepare(): void;
  9987. /**
  9988. * Execute the action and play the animation.
  9989. */
  9990. execute(): void;
  9991. /**
  9992. * Serializes the actions and its related information.
  9993. * @param parent defines the object to serialize in
  9994. * @returns the serialized object
  9995. */
  9996. serialize(parent: any): any;
  9997. }
  9998. /**
  9999. * This defines an action responsible to stop an animation once triggered.
  10000. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10001. */
  10002. export class StopAnimationAction extends Action {
  10003. private _target;
  10004. /**
  10005. * Instantiate the action
  10006. * @param triggerOptions defines the trigger options
  10007. * @param target defines the target animation or animation name
  10008. * @param condition defines the trigger related conditions
  10009. */
  10010. constructor(triggerOptions: any, target: any, condition?: Condition);
  10011. /** @hidden */
  10012. _prepare(): void;
  10013. /**
  10014. * Execute the action and stop the animation.
  10015. */
  10016. execute(): void;
  10017. /**
  10018. * Serializes the actions and its related information.
  10019. * @param parent defines the object to serialize in
  10020. * @returns the serialized object
  10021. */
  10022. serialize(parent: any): any;
  10023. }
  10024. /**
  10025. * This defines an action responsible that does nothing once triggered.
  10026. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10027. */
  10028. export class DoNothingAction extends Action {
  10029. /**
  10030. * Instantiate the action
  10031. * @param triggerOptions defines the trigger options
  10032. * @param condition defines the trigger related conditions
  10033. */
  10034. constructor(triggerOptions?: any, condition?: Condition);
  10035. /**
  10036. * Execute the action and do nothing.
  10037. */
  10038. execute(): void;
  10039. /**
  10040. * Serializes the actions and its related information.
  10041. * @param parent defines the object to serialize in
  10042. * @returns the serialized object
  10043. */
  10044. serialize(parent: any): any;
  10045. }
  10046. /**
  10047. * This defines an action responsible to trigger several actions once triggered.
  10048. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10049. */
  10050. export class CombineAction extends Action {
  10051. /**
  10052. * The list of aggregated animations to run.
  10053. */
  10054. children: Action[];
  10055. /**
  10056. * Instantiate the action
  10057. * @param triggerOptions defines the trigger options
  10058. * @param children defines the list of aggregated animations to run
  10059. * @param condition defines the trigger related conditions
  10060. */
  10061. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10062. /** @hidden */
  10063. _prepare(): void;
  10064. /**
  10065. * Execute the action and executes all the aggregated actions.
  10066. */
  10067. execute(evt: ActionEvent): void;
  10068. /**
  10069. * Serializes the actions and its related information.
  10070. * @param parent defines the object to serialize in
  10071. * @returns the serialized object
  10072. */
  10073. serialize(parent: any): any;
  10074. }
  10075. /**
  10076. * This defines an action responsible to run code (external event) once triggered.
  10077. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10078. */
  10079. export class ExecuteCodeAction extends Action {
  10080. /**
  10081. * The callback function to run.
  10082. */
  10083. func: (evt: ActionEvent) => void;
  10084. /**
  10085. * Instantiate the action
  10086. * @param triggerOptions defines the trigger options
  10087. * @param func defines the callback function to run
  10088. * @param condition defines the trigger related conditions
  10089. */
  10090. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10091. /**
  10092. * Execute the action and run the attached code.
  10093. */
  10094. execute(evt: ActionEvent): void;
  10095. }
  10096. /**
  10097. * This defines an action responsible to set the parent property of the target once triggered.
  10098. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10099. */
  10100. export class SetParentAction extends Action {
  10101. private _parent;
  10102. private _target;
  10103. /**
  10104. * Instantiate the action
  10105. * @param triggerOptions defines the trigger options
  10106. * @param target defines the target containing the parent property
  10107. * @param parent defines from where the animation should start (animation frame)
  10108. * @param condition defines the trigger related conditions
  10109. */
  10110. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10111. /** @hidden */
  10112. _prepare(): void;
  10113. /**
  10114. * Execute the action and set the parent property.
  10115. */
  10116. execute(): void;
  10117. /**
  10118. * Serializes the actions and its related information.
  10119. * @param parent defines the object to serialize in
  10120. * @returns the serialized object
  10121. */
  10122. serialize(parent: any): any;
  10123. }
  10124. }
  10125. declare module "babylonjs/Actions/actionManager" {
  10126. import { Nullable } from "babylonjs/types";
  10127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10128. import { Scene } from "babylonjs/scene";
  10129. import { IAction } from "babylonjs/Actions/action";
  10130. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10131. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10132. /**
  10133. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10134. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10135. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10136. */
  10137. export class ActionManager extends AbstractActionManager {
  10138. /**
  10139. * Nothing
  10140. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10141. */
  10142. static readonly NothingTrigger: number;
  10143. /**
  10144. * On pick
  10145. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10146. */
  10147. static readonly OnPickTrigger: number;
  10148. /**
  10149. * On left pick
  10150. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10151. */
  10152. static readonly OnLeftPickTrigger: number;
  10153. /**
  10154. * On right pick
  10155. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10156. */
  10157. static readonly OnRightPickTrigger: number;
  10158. /**
  10159. * On center pick
  10160. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10161. */
  10162. static readonly OnCenterPickTrigger: number;
  10163. /**
  10164. * On pick down
  10165. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10166. */
  10167. static readonly OnPickDownTrigger: number;
  10168. /**
  10169. * On double pick
  10170. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10171. */
  10172. static readonly OnDoublePickTrigger: number;
  10173. /**
  10174. * On pick up
  10175. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10176. */
  10177. static readonly OnPickUpTrigger: number;
  10178. /**
  10179. * On pick out.
  10180. * This trigger will only be raised if you also declared a OnPickDown
  10181. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10182. */
  10183. static readonly OnPickOutTrigger: number;
  10184. /**
  10185. * On long press
  10186. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10187. */
  10188. static readonly OnLongPressTrigger: number;
  10189. /**
  10190. * On pointer over
  10191. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10192. */
  10193. static readonly OnPointerOverTrigger: number;
  10194. /**
  10195. * On pointer out
  10196. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10197. */
  10198. static readonly OnPointerOutTrigger: number;
  10199. /**
  10200. * On every frame
  10201. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10202. */
  10203. static readonly OnEveryFrameTrigger: number;
  10204. /**
  10205. * On intersection enter
  10206. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10207. */
  10208. static readonly OnIntersectionEnterTrigger: number;
  10209. /**
  10210. * On intersection exit
  10211. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10212. */
  10213. static readonly OnIntersectionExitTrigger: number;
  10214. /**
  10215. * On key down
  10216. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10217. */
  10218. static readonly OnKeyDownTrigger: number;
  10219. /**
  10220. * On key up
  10221. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10222. */
  10223. static readonly OnKeyUpTrigger: number;
  10224. private _scene;
  10225. /**
  10226. * Creates a new action manager
  10227. * @param scene defines the hosting scene
  10228. */
  10229. constructor(scene: Scene);
  10230. /**
  10231. * Releases all associated resources
  10232. */
  10233. dispose(): void;
  10234. /**
  10235. * Gets hosting scene
  10236. * @returns the hosting scene
  10237. */
  10238. getScene(): Scene;
  10239. /**
  10240. * Does this action manager handles actions of any of the given triggers
  10241. * @param triggers defines the triggers to be tested
  10242. * @return a boolean indicating whether one (or more) of the triggers is handled
  10243. */
  10244. hasSpecificTriggers(triggers: number[]): boolean;
  10245. /**
  10246. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10247. * speed.
  10248. * @param triggerA defines the trigger to be tested
  10249. * @param triggerB defines the trigger to be tested
  10250. * @return a boolean indicating whether one (or more) of the triggers is handled
  10251. */
  10252. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10253. /**
  10254. * Does this action manager handles actions of a given trigger
  10255. * @param trigger defines the trigger to be tested
  10256. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10257. * @return whether the trigger is handled
  10258. */
  10259. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10260. /**
  10261. * Does this action manager has pointer triggers
  10262. */
  10263. get hasPointerTriggers(): boolean;
  10264. /**
  10265. * Does this action manager has pick triggers
  10266. */
  10267. get hasPickTriggers(): boolean;
  10268. /**
  10269. * Registers an action to this action manager
  10270. * @param action defines the action to be registered
  10271. * @return the action amended (prepared) after registration
  10272. */
  10273. registerAction(action: IAction): Nullable<IAction>;
  10274. /**
  10275. * Unregisters an action to this action manager
  10276. * @param action defines the action to be unregistered
  10277. * @return a boolean indicating whether the action has been unregistered
  10278. */
  10279. unregisterAction(action: IAction): Boolean;
  10280. /**
  10281. * Process a specific trigger
  10282. * @param trigger defines the trigger to process
  10283. * @param evt defines the event details to be processed
  10284. */
  10285. processTrigger(trigger: number, evt?: IActionEvent): void;
  10286. /** @hidden */
  10287. _getEffectiveTarget(target: any, propertyPath: string): any;
  10288. /** @hidden */
  10289. _getProperty(propertyPath: string): string;
  10290. /**
  10291. * Serialize this manager to a JSON object
  10292. * @param name defines the property name to store this manager
  10293. * @returns a JSON representation of this manager
  10294. */
  10295. serialize(name: string): any;
  10296. /**
  10297. * Creates a new ActionManager from a JSON data
  10298. * @param parsedActions defines the JSON data to read from
  10299. * @param object defines the hosting mesh
  10300. * @param scene defines the hosting scene
  10301. */
  10302. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10303. /**
  10304. * Get a trigger name by index
  10305. * @param trigger defines the trigger index
  10306. * @returns a trigger name
  10307. */
  10308. static GetTriggerName(trigger: number): string;
  10309. }
  10310. }
  10311. declare module "babylonjs/Sprites/sprite" {
  10312. import { Vector3 } from "babylonjs/Maths/math.vector";
  10313. import { Nullable } from "babylonjs/types";
  10314. import { ActionManager } from "babylonjs/Actions/actionManager";
  10315. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10316. import { Color4 } from "babylonjs/Maths/math.color";
  10317. import { Observable } from "babylonjs/Misc/observable";
  10318. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10319. import { Animation } from "babylonjs/Animations/animation";
  10320. /**
  10321. * Class used to represent a sprite
  10322. * @see https://doc.babylonjs.com/babylon101/sprites
  10323. */
  10324. export class Sprite implements IAnimatable {
  10325. /** defines the name */
  10326. name: string;
  10327. /** Gets or sets the current world position */
  10328. position: Vector3;
  10329. /** Gets or sets the main color */
  10330. color: Color4;
  10331. /** Gets or sets the width */
  10332. width: number;
  10333. /** Gets or sets the height */
  10334. height: number;
  10335. /** Gets or sets rotation angle */
  10336. angle: number;
  10337. /** Gets or sets the cell index in the sprite sheet */
  10338. cellIndex: number;
  10339. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10340. cellRef: string;
  10341. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10342. invertU: boolean;
  10343. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10344. invertV: boolean;
  10345. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10346. disposeWhenFinishedAnimating: boolean;
  10347. /** Gets the list of attached animations */
  10348. animations: Nullable<Array<Animation>>;
  10349. /** Gets or sets a boolean indicating if the sprite can be picked */
  10350. isPickable: boolean;
  10351. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10352. useAlphaForPicking: boolean;
  10353. /** @hidden */
  10354. _xOffset: number;
  10355. /** @hidden */
  10356. _yOffset: number;
  10357. /** @hidden */
  10358. _xSize: number;
  10359. /** @hidden */
  10360. _ySize: number;
  10361. /**
  10362. * Gets or sets the associated action manager
  10363. */
  10364. actionManager: Nullable<ActionManager>;
  10365. /**
  10366. * An event triggered when the control has been disposed
  10367. */
  10368. onDisposeObservable: Observable<Sprite>;
  10369. private _animationStarted;
  10370. private _loopAnimation;
  10371. private _fromIndex;
  10372. private _toIndex;
  10373. private _delay;
  10374. private _direction;
  10375. private _manager;
  10376. private _time;
  10377. private _onAnimationEnd;
  10378. /**
  10379. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10380. */
  10381. isVisible: boolean;
  10382. /**
  10383. * Gets or sets the sprite size
  10384. */
  10385. get size(): number;
  10386. set size(value: number);
  10387. /**
  10388. * Returns a boolean indicating if the animation is started
  10389. */
  10390. get animationStarted(): boolean;
  10391. /**
  10392. * Gets or sets the unique id of the sprite
  10393. */
  10394. uniqueId: number;
  10395. /**
  10396. * Gets the manager of this sprite
  10397. */
  10398. get manager(): ISpriteManager;
  10399. /**
  10400. * Creates a new Sprite
  10401. * @param name defines the name
  10402. * @param manager defines the manager
  10403. */
  10404. constructor(
  10405. /** defines the name */
  10406. name: string, manager: ISpriteManager);
  10407. /**
  10408. * Returns the string "Sprite"
  10409. * @returns "Sprite"
  10410. */
  10411. getClassName(): string;
  10412. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10413. get fromIndex(): number;
  10414. set fromIndex(value: number);
  10415. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10416. get toIndex(): number;
  10417. set toIndex(value: number);
  10418. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10419. get loopAnimation(): boolean;
  10420. set loopAnimation(value: boolean);
  10421. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10422. get delay(): number;
  10423. set delay(value: number);
  10424. /**
  10425. * Starts an animation
  10426. * @param from defines the initial key
  10427. * @param to defines the end key
  10428. * @param loop defines if the animation must loop
  10429. * @param delay defines the start delay (in ms)
  10430. * @param onAnimationEnd defines a callback to call when animation ends
  10431. */
  10432. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10433. /** Stops current animation (if any) */
  10434. stopAnimation(): void;
  10435. /** @hidden */
  10436. _animate(deltaTime: number): void;
  10437. /** Release associated resources */
  10438. dispose(): void;
  10439. /**
  10440. * Serializes the sprite to a JSON object
  10441. * @returns the JSON object
  10442. */
  10443. serialize(): any;
  10444. /**
  10445. * Parses a JSON object to create a new sprite
  10446. * @param parsedSprite The JSON object to parse
  10447. * @param manager defines the hosting manager
  10448. * @returns the new sprite
  10449. */
  10450. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10451. }
  10452. }
  10453. declare module "babylonjs/Collisions/pickingInfo" {
  10454. import { Nullable } from "babylonjs/types";
  10455. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10456. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10457. import { Sprite } from "babylonjs/Sprites/sprite";
  10458. import { Ray } from "babylonjs/Culling/ray";
  10459. /**
  10460. * Information about the result of picking within a scene
  10461. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10462. */
  10463. export class PickingInfo {
  10464. /** @hidden */
  10465. _pickingUnavailable: boolean;
  10466. /**
  10467. * If the pick collided with an object
  10468. */
  10469. hit: boolean;
  10470. /**
  10471. * Distance away where the pick collided
  10472. */
  10473. distance: number;
  10474. /**
  10475. * The location of pick collision
  10476. */
  10477. pickedPoint: Nullable<Vector3>;
  10478. /**
  10479. * The mesh corresponding the the pick collision
  10480. */
  10481. pickedMesh: Nullable<AbstractMesh>;
  10482. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10483. bu: number;
  10484. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10485. bv: number;
  10486. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10487. faceId: number;
  10488. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10489. subMeshFaceId: number;
  10490. /** Id of the the submesh that was picked */
  10491. subMeshId: number;
  10492. /** If a sprite was picked, this will be the sprite the pick collided with */
  10493. pickedSprite: Nullable<Sprite>;
  10494. /**
  10495. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10496. */
  10497. originMesh: Nullable<AbstractMesh>;
  10498. /**
  10499. * The ray that was used to perform the picking.
  10500. */
  10501. ray: Nullable<Ray>;
  10502. /**
  10503. * Gets the normal correspodning to the face the pick collided with
  10504. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10505. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10506. * @returns The normal correspodning to the face the pick collided with
  10507. */
  10508. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10509. /**
  10510. * Gets the texture coordinates of where the pick occured
  10511. * @returns the vector containing the coordnates of the texture
  10512. */
  10513. getTextureCoordinates(): Nullable<Vector2>;
  10514. }
  10515. }
  10516. declare module "babylonjs/Culling/ray" {
  10517. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10518. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10520. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10521. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10522. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10523. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10524. import { Plane } from "babylonjs/Maths/math.plane";
  10525. /**
  10526. * Class representing a ray with position and direction
  10527. */
  10528. export class Ray {
  10529. /** origin point */
  10530. origin: Vector3;
  10531. /** direction */
  10532. direction: Vector3;
  10533. /** length of the ray */
  10534. length: number;
  10535. private static readonly TmpVector3;
  10536. private _tmpRay;
  10537. /**
  10538. * Creates a new ray
  10539. * @param origin origin point
  10540. * @param direction direction
  10541. * @param length length of the ray
  10542. */
  10543. constructor(
  10544. /** origin point */
  10545. origin: Vector3,
  10546. /** direction */
  10547. direction: Vector3,
  10548. /** length of the ray */
  10549. length?: number);
  10550. /**
  10551. * Checks if the ray intersects a box
  10552. * This does not account for the ray lenght by design to improve perfs.
  10553. * @param minimum bound of the box
  10554. * @param maximum bound of the box
  10555. * @param intersectionTreshold extra extend to be added to the box in all direction
  10556. * @returns if the box was hit
  10557. */
  10558. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10559. /**
  10560. * Checks if the ray intersects a box
  10561. * This does not account for the ray lenght by design to improve perfs.
  10562. * @param box the bounding box to check
  10563. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10564. * @returns if the box was hit
  10565. */
  10566. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10567. /**
  10568. * If the ray hits a sphere
  10569. * @param sphere the bounding sphere to check
  10570. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10571. * @returns true if it hits the sphere
  10572. */
  10573. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10574. /**
  10575. * If the ray hits a triange
  10576. * @param vertex0 triangle vertex
  10577. * @param vertex1 triangle vertex
  10578. * @param vertex2 triangle vertex
  10579. * @returns intersection information if hit
  10580. */
  10581. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10582. /**
  10583. * Checks if ray intersects a plane
  10584. * @param plane the plane to check
  10585. * @returns the distance away it was hit
  10586. */
  10587. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10588. /**
  10589. * Calculate the intercept of a ray on a given axis
  10590. * @param axis to check 'x' | 'y' | 'z'
  10591. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10592. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10593. */
  10594. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10595. /**
  10596. * Checks if ray intersects a mesh
  10597. * @param mesh the mesh to check
  10598. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10599. * @returns picking info of the intersecton
  10600. */
  10601. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10602. /**
  10603. * Checks if ray intersects a mesh
  10604. * @param meshes the meshes to check
  10605. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10606. * @param results array to store result in
  10607. * @returns Array of picking infos
  10608. */
  10609. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10610. private _comparePickingInfo;
  10611. private static smallnum;
  10612. private static rayl;
  10613. /**
  10614. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10615. * @param sega the first point of the segment to test the intersection against
  10616. * @param segb the second point of the segment to test the intersection against
  10617. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10618. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10619. */
  10620. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10621. /**
  10622. * Update the ray from viewport position
  10623. * @param x position
  10624. * @param y y position
  10625. * @param viewportWidth viewport width
  10626. * @param viewportHeight viewport height
  10627. * @param world world matrix
  10628. * @param view view matrix
  10629. * @param projection projection matrix
  10630. * @returns this ray updated
  10631. */
  10632. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10633. /**
  10634. * Creates a ray with origin and direction of 0,0,0
  10635. * @returns the new ray
  10636. */
  10637. static Zero(): Ray;
  10638. /**
  10639. * Creates a new ray from screen space and viewport
  10640. * @param x position
  10641. * @param y y position
  10642. * @param viewportWidth viewport width
  10643. * @param viewportHeight viewport height
  10644. * @param world world matrix
  10645. * @param view view matrix
  10646. * @param projection projection matrix
  10647. * @returns new ray
  10648. */
  10649. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10650. /**
  10651. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  10652. * transformed to the given world matrix.
  10653. * @param origin The origin point
  10654. * @param end The end point
  10655. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10656. * @returns the new ray
  10657. */
  10658. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10659. /**
  10660. * Transforms a ray by a matrix
  10661. * @param ray ray to transform
  10662. * @param matrix matrix to apply
  10663. * @returns the resulting new ray
  10664. */
  10665. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10666. /**
  10667. * Transforms a ray by a matrix
  10668. * @param ray ray to transform
  10669. * @param matrix matrix to apply
  10670. * @param result ray to store result in
  10671. */
  10672. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10673. /**
  10674. * Unproject a ray from screen space to object space
  10675. * @param sourceX defines the screen space x coordinate to use
  10676. * @param sourceY defines the screen space y coordinate to use
  10677. * @param viewportWidth defines the current width of the viewport
  10678. * @param viewportHeight defines the current height of the viewport
  10679. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10680. * @param view defines the view matrix to use
  10681. * @param projection defines the projection matrix to use
  10682. */
  10683. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10684. }
  10685. /**
  10686. * Type used to define predicate used to select faces when a mesh intersection is detected
  10687. */
  10688. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10689. module "babylonjs/scene" {
  10690. interface Scene {
  10691. /** @hidden */
  10692. _tempPickingRay: Nullable<Ray>;
  10693. /** @hidden */
  10694. _cachedRayForTransform: Ray;
  10695. /** @hidden */
  10696. _pickWithRayInverseMatrix: Matrix;
  10697. /** @hidden */
  10698. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10699. /** @hidden */
  10700. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10701. }
  10702. }
  10703. }
  10704. declare module "babylonjs/sceneComponent" {
  10705. import { Scene } from "babylonjs/scene";
  10706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10707. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10708. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10709. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10710. import { Nullable } from "babylonjs/types";
  10711. import { Camera } from "babylonjs/Cameras/camera";
  10712. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10713. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10714. import { AbstractScene } from "babylonjs/abstractScene";
  10715. import { Mesh } from "babylonjs/Meshes/mesh";
  10716. /**
  10717. * Groups all the scene component constants in one place to ease maintenance.
  10718. * @hidden
  10719. */
  10720. export class SceneComponentConstants {
  10721. static readonly NAME_EFFECTLAYER: string;
  10722. static readonly NAME_LAYER: string;
  10723. static readonly NAME_LENSFLARESYSTEM: string;
  10724. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10725. static readonly NAME_PARTICLESYSTEM: string;
  10726. static readonly NAME_GAMEPAD: string;
  10727. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10728. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10729. static readonly NAME_PREPASSRENDERER: string;
  10730. static readonly NAME_DEPTHRENDERER: string;
  10731. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10732. static readonly NAME_SPRITE: string;
  10733. static readonly NAME_OUTLINERENDERER: string;
  10734. static readonly NAME_PROCEDURALTEXTURE: string;
  10735. static readonly NAME_SHADOWGENERATOR: string;
  10736. static readonly NAME_OCTREE: string;
  10737. static readonly NAME_PHYSICSENGINE: string;
  10738. static readonly NAME_AUDIO: string;
  10739. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10740. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10741. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10742. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10743. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10744. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10745. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10746. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10747. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10748. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10749. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10750. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10751. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10752. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10753. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10754. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10755. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10756. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10757. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10758. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10759. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10760. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10761. static readonly STEP_AFTERRENDER_AUDIO: number;
  10762. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10763. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10764. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10765. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10766. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10767. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10768. static readonly STEP_POINTERMOVE_SPRITE: number;
  10769. static readonly STEP_POINTERDOWN_SPRITE: number;
  10770. static readonly STEP_POINTERUP_SPRITE: number;
  10771. }
  10772. /**
  10773. * This represents a scene component.
  10774. *
  10775. * This is used to decouple the dependency the scene is having on the different workloads like
  10776. * layers, post processes...
  10777. */
  10778. export interface ISceneComponent {
  10779. /**
  10780. * The name of the component. Each component must have a unique name.
  10781. */
  10782. name: string;
  10783. /**
  10784. * The scene the component belongs to.
  10785. */
  10786. scene: Scene;
  10787. /**
  10788. * Register the component to one instance of a scene.
  10789. */
  10790. register(): void;
  10791. /**
  10792. * Rebuilds the elements related to this component in case of
  10793. * context lost for instance.
  10794. */
  10795. rebuild(): void;
  10796. /**
  10797. * Disposes the component and the associated ressources.
  10798. */
  10799. dispose(): void;
  10800. }
  10801. /**
  10802. * This represents a SERIALIZABLE scene component.
  10803. *
  10804. * This extends Scene Component to add Serialization methods on top.
  10805. */
  10806. export interface ISceneSerializableComponent extends ISceneComponent {
  10807. /**
  10808. * Adds all the elements from the container to the scene
  10809. * @param container the container holding the elements
  10810. */
  10811. addFromContainer(container: AbstractScene): void;
  10812. /**
  10813. * Removes all the elements in the container from the scene
  10814. * @param container contains the elements to remove
  10815. * @param dispose if the removed element should be disposed (default: false)
  10816. */
  10817. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10818. /**
  10819. * Serializes the component data to the specified json object
  10820. * @param serializationObject The object to serialize to
  10821. */
  10822. serialize(serializationObject: any): void;
  10823. }
  10824. /**
  10825. * Strong typing of a Mesh related stage step action
  10826. */
  10827. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10828. /**
  10829. * Strong typing of a Evaluate Sub Mesh related stage step action
  10830. */
  10831. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10832. /**
  10833. * Strong typing of a Active Mesh related stage step action
  10834. */
  10835. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10836. /**
  10837. * Strong typing of a Camera related stage step action
  10838. */
  10839. export type CameraStageAction = (camera: Camera) => void;
  10840. /**
  10841. * Strong typing of a Camera Frame buffer related stage step action
  10842. */
  10843. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10844. /**
  10845. * Strong typing of a Render Target related stage step action
  10846. */
  10847. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10848. /**
  10849. * Strong typing of a RenderingGroup related stage step action
  10850. */
  10851. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10852. /**
  10853. * Strong typing of a Mesh Render related stage step action
  10854. */
  10855. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10856. /**
  10857. * Strong typing of a simple stage step action
  10858. */
  10859. export type SimpleStageAction = () => void;
  10860. /**
  10861. * Strong typing of a render target action.
  10862. */
  10863. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10864. /**
  10865. * Strong typing of a pointer move action.
  10866. */
  10867. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10868. /**
  10869. * Strong typing of a pointer up/down action.
  10870. */
  10871. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10872. /**
  10873. * Representation of a stage in the scene (Basically a list of ordered steps)
  10874. * @hidden
  10875. */
  10876. export class Stage<T extends Function> extends Array<{
  10877. index: number;
  10878. component: ISceneComponent;
  10879. action: T;
  10880. }> {
  10881. /**
  10882. * Hide ctor from the rest of the world.
  10883. * @param items The items to add.
  10884. */
  10885. private constructor();
  10886. /**
  10887. * Creates a new Stage.
  10888. * @returns A new instance of a Stage
  10889. */
  10890. static Create<T extends Function>(): Stage<T>;
  10891. /**
  10892. * Registers a step in an ordered way in the targeted stage.
  10893. * @param index Defines the position to register the step in
  10894. * @param component Defines the component attached to the step
  10895. * @param action Defines the action to launch during the step
  10896. */
  10897. registerStep(index: number, component: ISceneComponent, action: T): void;
  10898. /**
  10899. * Clears all the steps from the stage.
  10900. */
  10901. clear(): void;
  10902. }
  10903. }
  10904. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10905. import { Nullable } from "babylonjs/types";
  10906. import { Observable } from "babylonjs/Misc/observable";
  10907. import { Scene } from "babylonjs/scene";
  10908. import { Sprite } from "babylonjs/Sprites/sprite";
  10909. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10910. import { Ray } from "babylonjs/Culling/ray";
  10911. import { Camera } from "babylonjs/Cameras/camera";
  10912. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10913. import { ISceneComponent } from "babylonjs/sceneComponent";
  10914. module "babylonjs/scene" {
  10915. interface Scene {
  10916. /** @hidden */
  10917. _pointerOverSprite: Nullable<Sprite>;
  10918. /** @hidden */
  10919. _pickedDownSprite: Nullable<Sprite>;
  10920. /** @hidden */
  10921. _tempSpritePickingRay: Nullable<Ray>;
  10922. /**
  10923. * All of the sprite managers added to this scene
  10924. * @see https://doc.babylonjs.com/babylon101/sprites
  10925. */
  10926. spriteManagers: Array<ISpriteManager>;
  10927. /**
  10928. * An event triggered when sprites rendering is about to start
  10929. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10930. */
  10931. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10932. /**
  10933. * An event triggered when sprites rendering is done
  10934. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10935. */
  10936. onAfterSpritesRenderingObservable: Observable<Scene>;
  10937. /** @hidden */
  10938. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10939. /** Launch a ray to try to pick a sprite in the scene
  10940. * @param x position on screen
  10941. * @param y position on screen
  10942. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10943. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10944. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10945. * @returns a PickingInfo
  10946. */
  10947. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10948. /** Use the given ray to pick a sprite in the scene
  10949. * @param ray The ray (in world space) to use to pick meshes
  10950. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10951. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10952. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10953. * @returns a PickingInfo
  10954. */
  10955. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10956. /** @hidden */
  10957. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10958. /** Launch a ray to try to pick sprites in the scene
  10959. * @param x position on screen
  10960. * @param y position on screen
  10961. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10962. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10963. * @returns a PickingInfo array
  10964. */
  10965. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10966. /** Use the given ray to pick sprites in the scene
  10967. * @param ray The ray (in world space) to use to pick meshes
  10968. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10969. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10970. * @returns a PickingInfo array
  10971. */
  10972. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10973. /**
  10974. * Force the sprite under the pointer
  10975. * @param sprite defines the sprite to use
  10976. */
  10977. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10978. /**
  10979. * Gets the sprite under the pointer
  10980. * @returns a Sprite or null if no sprite is under the pointer
  10981. */
  10982. getPointerOverSprite(): Nullable<Sprite>;
  10983. }
  10984. }
  10985. /**
  10986. * Defines the sprite scene component responsible to manage sprites
  10987. * in a given scene.
  10988. */
  10989. export class SpriteSceneComponent implements ISceneComponent {
  10990. /**
  10991. * The component name helpfull to identify the component in the list of scene components.
  10992. */
  10993. readonly name: string;
  10994. /**
  10995. * The scene the component belongs to.
  10996. */
  10997. scene: Scene;
  10998. /** @hidden */
  10999. private _spritePredicate;
  11000. /**
  11001. * Creates a new instance of the component for the given scene
  11002. * @param scene Defines the scene to register the component in
  11003. */
  11004. constructor(scene: Scene);
  11005. /**
  11006. * Registers the component in a given scene
  11007. */
  11008. register(): void;
  11009. /**
  11010. * Rebuilds the elements related to this component in case of
  11011. * context lost for instance.
  11012. */
  11013. rebuild(): void;
  11014. /**
  11015. * Disposes the component and the associated ressources.
  11016. */
  11017. dispose(): void;
  11018. private _pickSpriteButKeepRay;
  11019. private _pointerMove;
  11020. private _pointerDown;
  11021. private _pointerUp;
  11022. }
  11023. }
  11024. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11025. /** @hidden */
  11026. export var fogFragmentDeclaration: {
  11027. name: string;
  11028. shader: string;
  11029. };
  11030. }
  11031. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11032. /** @hidden */
  11033. export var fogFragment: {
  11034. name: string;
  11035. shader: string;
  11036. };
  11037. }
  11038. declare module "babylonjs/Shaders/sprites.fragment" {
  11039. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11040. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11041. /** @hidden */
  11042. export var spritesPixelShader: {
  11043. name: string;
  11044. shader: string;
  11045. };
  11046. }
  11047. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11048. /** @hidden */
  11049. export var fogVertexDeclaration: {
  11050. name: string;
  11051. shader: string;
  11052. };
  11053. }
  11054. declare module "babylonjs/Shaders/sprites.vertex" {
  11055. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11056. /** @hidden */
  11057. export var spritesVertexShader: {
  11058. name: string;
  11059. shader: string;
  11060. };
  11061. }
  11062. declare module "babylonjs/Sprites/spriteManager" {
  11063. import { IDisposable, Scene } from "babylonjs/scene";
  11064. import { Nullable } from "babylonjs/types";
  11065. import { Observable } from "babylonjs/Misc/observable";
  11066. import { Sprite } from "babylonjs/Sprites/sprite";
  11067. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11068. import { Camera } from "babylonjs/Cameras/camera";
  11069. import { Texture } from "babylonjs/Materials/Textures/texture";
  11070. import "babylonjs/Shaders/sprites.fragment";
  11071. import "babylonjs/Shaders/sprites.vertex";
  11072. import { Ray } from "babylonjs/Culling/ray";
  11073. /**
  11074. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11075. */
  11076. export interface ISpriteManager extends IDisposable {
  11077. /**
  11078. * Gets manager's name
  11079. */
  11080. name: string;
  11081. /**
  11082. * Restricts the camera to viewing objects with the same layerMask.
  11083. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11084. */
  11085. layerMask: number;
  11086. /**
  11087. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11088. */
  11089. isPickable: boolean;
  11090. /**
  11091. * Gets the hosting scene
  11092. */
  11093. scene: Scene;
  11094. /**
  11095. * Specifies the rendering group id for this mesh (0 by default)
  11096. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11097. */
  11098. renderingGroupId: number;
  11099. /**
  11100. * Defines the list of sprites managed by the manager.
  11101. */
  11102. sprites: Array<Sprite>;
  11103. /**
  11104. * Gets or sets the spritesheet texture
  11105. */
  11106. texture: Texture;
  11107. /** Defines the default width of a cell in the spritesheet */
  11108. cellWidth: number;
  11109. /** Defines the default height of a cell in the spritesheet */
  11110. cellHeight: number;
  11111. /**
  11112. * Tests the intersection of a sprite with a specific ray.
  11113. * @param ray The ray we are sending to test the collision
  11114. * @param camera The camera space we are sending rays in
  11115. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11116. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11117. * @returns picking info or null.
  11118. */
  11119. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11120. /**
  11121. * Intersects the sprites with a ray
  11122. * @param ray defines the ray to intersect with
  11123. * @param camera defines the current active camera
  11124. * @param predicate defines a predicate used to select candidate sprites
  11125. * @returns null if no hit or a PickingInfo array
  11126. */
  11127. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11128. /**
  11129. * Renders the list of sprites on screen.
  11130. */
  11131. render(): void;
  11132. }
  11133. /**
  11134. * Class used to manage multiple sprites on the same spritesheet
  11135. * @see https://doc.babylonjs.com/babylon101/sprites
  11136. */
  11137. export class SpriteManager implements ISpriteManager {
  11138. /** defines the manager's name */
  11139. name: string;
  11140. /** Define the Url to load snippets */
  11141. static SnippetUrl: string;
  11142. /** Snippet ID if the manager was created from the snippet server */
  11143. snippetId: string;
  11144. /** Gets the list of sprites */
  11145. sprites: Sprite[];
  11146. /** Gets or sets the rendering group id (0 by default) */
  11147. renderingGroupId: number;
  11148. /** Gets or sets camera layer mask */
  11149. layerMask: number;
  11150. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11151. fogEnabled: boolean;
  11152. /** Gets or sets a boolean indicating if the sprites are pickable */
  11153. isPickable: boolean;
  11154. /** Defines the default width of a cell in the spritesheet */
  11155. cellWidth: number;
  11156. /** Defines the default height of a cell in the spritesheet */
  11157. cellHeight: number;
  11158. /** Associative array from JSON sprite data file */
  11159. private _cellData;
  11160. /** Array of sprite names from JSON sprite data file */
  11161. private _spriteMap;
  11162. /** True when packed cell data from JSON file is ready*/
  11163. private _packedAndReady;
  11164. private _textureContent;
  11165. /**
  11166. * An event triggered when the manager is disposed.
  11167. */
  11168. onDisposeObservable: Observable<SpriteManager>;
  11169. private _onDisposeObserver;
  11170. /**
  11171. * Callback called when the manager is disposed
  11172. */
  11173. set onDispose(callback: () => void);
  11174. private _capacity;
  11175. private _fromPacked;
  11176. private _spriteTexture;
  11177. private _epsilon;
  11178. private _scene;
  11179. private _vertexData;
  11180. private _buffer;
  11181. private _vertexBuffers;
  11182. private _indexBuffer;
  11183. private _effectBase;
  11184. private _effectFog;
  11185. /**
  11186. * Gets or sets the unique id of the sprite
  11187. */
  11188. uniqueId: number;
  11189. /**
  11190. * Gets the array of sprites
  11191. */
  11192. get children(): Sprite[];
  11193. /**
  11194. * Gets the hosting scene
  11195. */
  11196. get scene(): Scene;
  11197. /**
  11198. * Gets the capacity of the manager
  11199. */
  11200. get capacity(): number;
  11201. /**
  11202. * Gets or sets the spritesheet texture
  11203. */
  11204. get texture(): Texture;
  11205. set texture(value: Texture);
  11206. private _blendMode;
  11207. /**
  11208. * Blend mode use to render the particle, it can be any of
  11209. * the static Constants.ALPHA_x properties provided in this class.
  11210. * Default value is Constants.ALPHA_COMBINE
  11211. */
  11212. get blendMode(): number;
  11213. set blendMode(blendMode: number);
  11214. /** Disables writing to the depth buffer when rendering the sprites.
  11215. * It can be handy to disable depth writing when using textures without alpha channel
  11216. * and setting some specific blend modes.
  11217. */
  11218. disableDepthWrite: boolean;
  11219. /**
  11220. * Creates a new sprite manager
  11221. * @param name defines the manager's name
  11222. * @param imgUrl defines the sprite sheet url
  11223. * @param capacity defines the maximum allowed number of sprites
  11224. * @param cellSize defines the size of a sprite cell
  11225. * @param scene defines the hosting scene
  11226. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11227. * @param samplingMode defines the smapling mode to use with spritesheet
  11228. * @param fromPacked set to false; do not alter
  11229. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11230. */
  11231. constructor(
  11232. /** defines the manager's name */
  11233. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11234. /**
  11235. * Returns the string "SpriteManager"
  11236. * @returns "SpriteManager"
  11237. */
  11238. getClassName(): string;
  11239. private _makePacked;
  11240. private _appendSpriteVertex;
  11241. private _checkTextureAlpha;
  11242. /**
  11243. * Intersects the sprites with a ray
  11244. * @param ray defines the ray to intersect with
  11245. * @param camera defines the current active camera
  11246. * @param predicate defines a predicate used to select candidate sprites
  11247. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11248. * @returns null if no hit or a PickingInfo
  11249. */
  11250. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11251. /**
  11252. * Intersects the sprites with a ray
  11253. * @param ray defines the ray to intersect with
  11254. * @param camera defines the current active camera
  11255. * @param predicate defines a predicate used to select candidate sprites
  11256. * @returns null if no hit or a PickingInfo array
  11257. */
  11258. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11259. /**
  11260. * Render all child sprites
  11261. */
  11262. render(): void;
  11263. /**
  11264. * Release associated resources
  11265. */
  11266. dispose(): void;
  11267. /**
  11268. * Serializes the sprite manager to a JSON object
  11269. * @param serializeTexture defines if the texture must be serialized as well
  11270. * @returns the JSON object
  11271. */
  11272. serialize(serializeTexture?: boolean): any;
  11273. /**
  11274. * Parses a JSON object to create a new sprite manager.
  11275. * @param parsedManager The JSON object to parse
  11276. * @param scene The scene to create the sprite managerin
  11277. * @param rootUrl The root url to use to load external dependencies like texture
  11278. * @returns the new sprite manager
  11279. */
  11280. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11281. /**
  11282. * Creates a sprite manager from a snippet saved in a remote file
  11283. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11284. * @param url defines the url to load from
  11285. * @param scene defines the hosting scene
  11286. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11287. * @returns a promise that will resolve to the new sprite manager
  11288. */
  11289. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11290. /**
  11291. * Creates a sprite manager from a snippet saved by the sprite editor
  11292. * @param snippetId defines the snippet to load
  11293. * @param scene defines the hosting scene
  11294. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11295. * @returns a promise that will resolve to the new sprite manager
  11296. */
  11297. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11298. }
  11299. }
  11300. declare module "babylonjs/Misc/gradients" {
  11301. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11302. /** Interface used by value gradients (color, factor, ...) */
  11303. export interface IValueGradient {
  11304. /**
  11305. * Gets or sets the gradient value (between 0 and 1)
  11306. */
  11307. gradient: number;
  11308. }
  11309. /** Class used to store color4 gradient */
  11310. export class ColorGradient implements IValueGradient {
  11311. /**
  11312. * Gets or sets the gradient value (between 0 and 1)
  11313. */
  11314. gradient: number;
  11315. /**
  11316. * Gets or sets first associated color
  11317. */
  11318. color1: Color4;
  11319. /**
  11320. * Gets or sets second associated color
  11321. */
  11322. color2?: Color4 | undefined;
  11323. /**
  11324. * Creates a new color4 gradient
  11325. * @param gradient gets or sets the gradient value (between 0 and 1)
  11326. * @param color1 gets or sets first associated color
  11327. * @param color2 gets or sets first second color
  11328. */
  11329. constructor(
  11330. /**
  11331. * Gets or sets the gradient value (between 0 and 1)
  11332. */
  11333. gradient: number,
  11334. /**
  11335. * Gets or sets first associated color
  11336. */
  11337. color1: Color4,
  11338. /**
  11339. * Gets or sets second associated color
  11340. */
  11341. color2?: Color4 | undefined);
  11342. /**
  11343. * Will get a color picked randomly between color1 and color2.
  11344. * If color2 is undefined then color1 will be used
  11345. * @param result defines the target Color4 to store the result in
  11346. */
  11347. getColorToRef(result: Color4): void;
  11348. }
  11349. /** Class used to store color 3 gradient */
  11350. export class Color3Gradient implements IValueGradient {
  11351. /**
  11352. * Gets or sets the gradient value (between 0 and 1)
  11353. */
  11354. gradient: number;
  11355. /**
  11356. * Gets or sets the associated color
  11357. */
  11358. color: Color3;
  11359. /**
  11360. * Creates a new color3 gradient
  11361. * @param gradient gets or sets the gradient value (between 0 and 1)
  11362. * @param color gets or sets associated color
  11363. */
  11364. constructor(
  11365. /**
  11366. * Gets or sets the gradient value (between 0 and 1)
  11367. */
  11368. gradient: number,
  11369. /**
  11370. * Gets or sets the associated color
  11371. */
  11372. color: Color3);
  11373. }
  11374. /** Class used to store factor gradient */
  11375. export class FactorGradient implements IValueGradient {
  11376. /**
  11377. * Gets or sets the gradient value (between 0 and 1)
  11378. */
  11379. gradient: number;
  11380. /**
  11381. * Gets or sets first associated factor
  11382. */
  11383. factor1: number;
  11384. /**
  11385. * Gets or sets second associated factor
  11386. */
  11387. factor2?: number | undefined;
  11388. /**
  11389. * Creates a new factor gradient
  11390. * @param gradient gets or sets the gradient value (between 0 and 1)
  11391. * @param factor1 gets or sets first associated factor
  11392. * @param factor2 gets or sets second associated factor
  11393. */
  11394. constructor(
  11395. /**
  11396. * Gets or sets the gradient value (between 0 and 1)
  11397. */
  11398. gradient: number,
  11399. /**
  11400. * Gets or sets first associated factor
  11401. */
  11402. factor1: number,
  11403. /**
  11404. * Gets or sets second associated factor
  11405. */
  11406. factor2?: number | undefined);
  11407. /**
  11408. * Will get a number picked randomly between factor1 and factor2.
  11409. * If factor2 is undefined then factor1 will be used
  11410. * @returns the picked number
  11411. */
  11412. getFactor(): number;
  11413. }
  11414. /**
  11415. * Helper used to simplify some generic gradient tasks
  11416. */
  11417. export class GradientHelper {
  11418. /**
  11419. * Gets the current gradient from an array of IValueGradient
  11420. * @param ratio defines the current ratio to get
  11421. * @param gradients defines the array of IValueGradient
  11422. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11423. */
  11424. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11425. }
  11426. }
  11427. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11428. import { Nullable } from "babylonjs/types";
  11429. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11430. import { Scene } from "babylonjs/scene";
  11431. module "babylonjs/Engines/thinEngine" {
  11432. interface ThinEngine {
  11433. /**
  11434. * Creates a raw texture
  11435. * @param data defines the data to store in the texture
  11436. * @param width defines the width of the texture
  11437. * @param height defines the height of the texture
  11438. * @param format defines the format of the data
  11439. * @param generateMipMaps defines if the engine should generate the mip levels
  11440. * @param invertY defines if data must be stored with Y axis inverted
  11441. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11442. * @param compression defines the compression used (null by default)
  11443. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11444. * @returns the raw texture inside an InternalTexture
  11445. */
  11446. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11447. /**
  11448. * Update a raw texture
  11449. * @param texture defines the texture to update
  11450. * @param data defines the data to store in the texture
  11451. * @param format defines the format of the data
  11452. * @param invertY defines if data must be stored with Y axis inverted
  11453. */
  11454. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11455. /**
  11456. * Update a raw texture
  11457. * @param texture defines the texture to update
  11458. * @param data defines the data to store in the texture
  11459. * @param format defines the format of the data
  11460. * @param invertY defines if data must be stored with Y axis inverted
  11461. * @param compression defines the compression used (null by default)
  11462. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11463. */
  11464. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11465. /**
  11466. * Creates a new raw cube texture
  11467. * @param data defines the array of data to use to create each face
  11468. * @param size defines the size of the textures
  11469. * @param format defines the format of the data
  11470. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11471. * @param generateMipMaps defines if the engine should generate the mip levels
  11472. * @param invertY defines if data must be stored with Y axis inverted
  11473. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11474. * @param compression defines the compression used (null by default)
  11475. * @returns the cube texture as an InternalTexture
  11476. */
  11477. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11478. /**
  11479. * Update a raw cube texture
  11480. * @param texture defines the texture to udpdate
  11481. * @param data defines the data to store
  11482. * @param format defines the data format
  11483. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11484. * @param invertY defines if data must be stored with Y axis inverted
  11485. */
  11486. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11487. /**
  11488. * Update a raw cube texture
  11489. * @param texture defines the texture to udpdate
  11490. * @param data defines the data to store
  11491. * @param format defines the data format
  11492. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11493. * @param invertY defines if data must be stored with Y axis inverted
  11494. * @param compression defines the compression used (null by default)
  11495. */
  11496. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11497. /**
  11498. * Update a raw cube texture
  11499. * @param texture defines the texture to udpdate
  11500. * @param data defines the data to store
  11501. * @param format defines the data format
  11502. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11503. * @param invertY defines if data must be stored with Y axis inverted
  11504. * @param compression defines the compression used (null by default)
  11505. * @param level defines which level of the texture to update
  11506. */
  11507. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11508. /**
  11509. * Creates a new raw cube texture from a specified url
  11510. * @param url defines the url where the data is located
  11511. * @param scene defines the current scene
  11512. * @param size defines the size of the textures
  11513. * @param format defines the format of the data
  11514. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11515. * @param noMipmap defines if the engine should avoid generating the mip levels
  11516. * @param callback defines a callback used to extract texture data from loaded data
  11517. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11518. * @param onLoad defines a callback called when texture is loaded
  11519. * @param onError defines a callback called if there is an error
  11520. * @returns the cube texture as an InternalTexture
  11521. */
  11522. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  11523. /**
  11524. * Creates a new raw cube texture from a specified url
  11525. * @param url defines the url where the data is located
  11526. * @param scene defines the current scene
  11527. * @param size defines the size of the textures
  11528. * @param format defines the format of the data
  11529. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11530. * @param noMipmap defines if the engine should avoid generating the mip levels
  11531. * @param callback defines a callback used to extract texture data from loaded data
  11532. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11533. * @param onLoad defines a callback called when texture is loaded
  11534. * @param onError defines a callback called if there is an error
  11535. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11536. * @param invertY defines if data must be stored with Y axis inverted
  11537. * @returns the cube texture as an InternalTexture
  11538. */
  11539. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  11540. /**
  11541. * Creates a new raw 3D texture
  11542. * @param data defines the data used to create the texture
  11543. * @param width defines the width of the texture
  11544. * @param height defines the height of the texture
  11545. * @param depth defines the depth of the texture
  11546. * @param format defines the format of the texture
  11547. * @param generateMipMaps defines if the engine must generate mip levels
  11548. * @param invertY defines if data must be stored with Y axis inverted
  11549. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11550. * @param compression defines the compressed used (can be null)
  11551. * @param textureType defines the compressed used (can be null)
  11552. * @returns a new raw 3D texture (stored in an InternalTexture)
  11553. */
  11554. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11555. /**
  11556. * Update a raw 3D texture
  11557. * @param texture defines the texture to update
  11558. * @param data defines the data to store
  11559. * @param format defines the data format
  11560. * @param invertY defines if data must be stored with Y axis inverted
  11561. */
  11562. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11563. /**
  11564. * Update a raw 3D texture
  11565. * @param texture defines the texture to update
  11566. * @param data defines the data to store
  11567. * @param format defines the data format
  11568. * @param invertY defines if data must be stored with Y axis inverted
  11569. * @param compression defines the used compression (can be null)
  11570. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11571. */
  11572. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11573. /**
  11574. * Creates a new raw 2D array texture
  11575. * @param data defines the data used to create the texture
  11576. * @param width defines the width of the texture
  11577. * @param height defines the height of the texture
  11578. * @param depth defines the number of layers of the texture
  11579. * @param format defines the format of the texture
  11580. * @param generateMipMaps defines if the engine must generate mip levels
  11581. * @param invertY defines if data must be stored with Y axis inverted
  11582. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11583. * @param compression defines the compressed used (can be null)
  11584. * @param textureType defines the compressed used (can be null)
  11585. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11586. */
  11587. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11588. /**
  11589. * Update a raw 2D array texture
  11590. * @param texture defines the texture to update
  11591. * @param data defines the data to store
  11592. * @param format defines the data format
  11593. * @param invertY defines if data must be stored with Y axis inverted
  11594. */
  11595. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11596. /**
  11597. * Update a raw 2D array texture
  11598. * @param texture defines the texture to update
  11599. * @param data defines the data to store
  11600. * @param format defines the data format
  11601. * @param invertY defines if data must be stored with Y axis inverted
  11602. * @param compression defines the used compression (can be null)
  11603. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11604. */
  11605. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11606. }
  11607. }
  11608. }
  11609. declare module "babylonjs/Materials/Textures/rawTexture" {
  11610. import { Scene } from "babylonjs/scene";
  11611. import { Texture } from "babylonjs/Materials/Textures/texture";
  11612. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11613. /**
  11614. * Raw texture can help creating a texture directly from an array of data.
  11615. * This can be super useful if you either get the data from an uncompressed source or
  11616. * if you wish to create your texture pixel by pixel.
  11617. */
  11618. export class RawTexture extends Texture {
  11619. /**
  11620. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11621. */
  11622. format: number;
  11623. /**
  11624. * Instantiates a new RawTexture.
  11625. * Raw texture can help creating a texture directly from an array of data.
  11626. * This can be super useful if you either get the data from an uncompressed source or
  11627. * if you wish to create your texture pixel by pixel.
  11628. * @param data define the array of data to use to create the texture
  11629. * @param width define the width of the texture
  11630. * @param height define the height of the texture
  11631. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11632. * @param scene define the scene the texture belongs to
  11633. * @param generateMipMaps define whether mip maps should be generated or not
  11634. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11635. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11636. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11637. */
  11638. constructor(data: ArrayBufferView, width: number, height: number,
  11639. /**
  11640. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11641. */
  11642. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11643. /**
  11644. * Updates the texture underlying data.
  11645. * @param data Define the new data of the texture
  11646. */
  11647. update(data: ArrayBufferView): void;
  11648. /**
  11649. * Creates a luminance texture from some data.
  11650. * @param data Define the texture data
  11651. * @param width Define the width of the texture
  11652. * @param height Define the height of the texture
  11653. * @param scene Define the scene the texture belongs to
  11654. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11655. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11656. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11657. * @returns the luminance texture
  11658. */
  11659. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11660. /**
  11661. * Creates a luminance alpha texture from some data.
  11662. * @param data Define the texture data
  11663. * @param width Define the width of the texture
  11664. * @param height Define the height of the texture
  11665. * @param scene Define the scene the texture belongs to
  11666. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11667. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11668. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11669. * @returns the luminance alpha texture
  11670. */
  11671. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11672. /**
  11673. * Creates an alpha texture from some data.
  11674. * @param data Define the texture data
  11675. * @param width Define the width of the texture
  11676. * @param height Define the height of the texture
  11677. * @param scene Define the scene the texture belongs to
  11678. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11679. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11680. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11681. * @returns the alpha texture
  11682. */
  11683. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11684. /**
  11685. * Creates a RGB texture from some data.
  11686. * @param data Define the texture data
  11687. * @param width Define the width of the texture
  11688. * @param height Define the height of the texture
  11689. * @param scene Define the scene the texture belongs to
  11690. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11691. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11692. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11693. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11694. * @returns the RGB alpha texture
  11695. */
  11696. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11697. /**
  11698. * Creates a RGBA texture from some data.
  11699. * @param data Define the texture data
  11700. * @param width Define the width of the texture
  11701. * @param height Define the height of the texture
  11702. * @param scene Define the scene the texture belongs to
  11703. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11704. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11705. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11706. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11707. * @returns the RGBA texture
  11708. */
  11709. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11710. /**
  11711. * Creates a R texture from some data.
  11712. * @param data Define the texture data
  11713. * @param width Define the width of the texture
  11714. * @param height Define the height of the texture
  11715. * @param scene Define the scene the texture belongs to
  11716. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11717. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11718. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11719. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11720. * @returns the R texture
  11721. */
  11722. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11723. }
  11724. }
  11725. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11726. import { Scene } from "babylonjs/scene";
  11727. import { ISceneComponent } from "babylonjs/sceneComponent";
  11728. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11729. module "babylonjs/abstractScene" {
  11730. interface AbstractScene {
  11731. /**
  11732. * The list of procedural textures added to the scene
  11733. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11734. */
  11735. proceduralTextures: Array<ProceduralTexture>;
  11736. }
  11737. }
  11738. /**
  11739. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11740. * in a given scene.
  11741. */
  11742. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11743. /**
  11744. * The component name helpfull to identify the component in the list of scene components.
  11745. */
  11746. readonly name: string;
  11747. /**
  11748. * The scene the component belongs to.
  11749. */
  11750. scene: Scene;
  11751. /**
  11752. * Creates a new instance of the component for the given scene
  11753. * @param scene Defines the scene to register the component in
  11754. */
  11755. constructor(scene: Scene);
  11756. /**
  11757. * Registers the component in a given scene
  11758. */
  11759. register(): void;
  11760. /**
  11761. * Rebuilds the elements related to this component in case of
  11762. * context lost for instance.
  11763. */
  11764. rebuild(): void;
  11765. /**
  11766. * Disposes the component and the associated ressources.
  11767. */
  11768. dispose(): void;
  11769. private _beforeClear;
  11770. }
  11771. }
  11772. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11773. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11774. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11775. module "babylonjs/Engines/thinEngine" {
  11776. interface ThinEngine {
  11777. /**
  11778. * Creates a new render target cube texture
  11779. * @param size defines the size of the texture
  11780. * @param options defines the options used to create the texture
  11781. * @returns a new render target cube texture stored in an InternalTexture
  11782. */
  11783. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11784. }
  11785. }
  11786. }
  11787. declare module "babylonjs/Shaders/procedural.vertex" {
  11788. /** @hidden */
  11789. export var proceduralVertexShader: {
  11790. name: string;
  11791. shader: string;
  11792. };
  11793. }
  11794. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11795. import { Observable } from "babylonjs/Misc/observable";
  11796. import { Nullable } from "babylonjs/types";
  11797. import { Scene } from "babylonjs/scene";
  11798. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11799. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11800. import { Effect } from "babylonjs/Materials/effect";
  11801. import { Texture } from "babylonjs/Materials/Textures/texture";
  11802. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11803. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11804. import "babylonjs/Shaders/procedural.vertex";
  11805. /**
  11806. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  11807. * This is the base class of any Procedural texture and contains most of the shareable code.
  11808. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11809. */
  11810. export class ProceduralTexture extends Texture {
  11811. isCube: boolean;
  11812. /**
  11813. * Define if the texture is enabled or not (disabled texture will not render)
  11814. */
  11815. isEnabled: boolean;
  11816. /**
  11817. * Define if the texture must be cleared before rendering (default is true)
  11818. */
  11819. autoClear: boolean;
  11820. /**
  11821. * Callback called when the texture is generated
  11822. */
  11823. onGenerated: () => void;
  11824. /**
  11825. * Event raised when the texture is generated
  11826. */
  11827. onGeneratedObservable: Observable<ProceduralTexture>;
  11828. /** @hidden */
  11829. _generateMipMaps: boolean;
  11830. /** @hidden **/
  11831. _effect: Effect;
  11832. /** @hidden */
  11833. _textures: {
  11834. [key: string]: Texture;
  11835. };
  11836. /** @hidden */
  11837. protected _fallbackTexture: Nullable<Texture>;
  11838. private _size;
  11839. private _currentRefreshId;
  11840. private _frameId;
  11841. private _refreshRate;
  11842. private _vertexBuffers;
  11843. private _indexBuffer;
  11844. private _uniforms;
  11845. private _samplers;
  11846. private _fragment;
  11847. private _floats;
  11848. private _ints;
  11849. private _floatsArrays;
  11850. private _colors3;
  11851. private _colors4;
  11852. private _vectors2;
  11853. private _vectors3;
  11854. private _matrices;
  11855. private _fallbackTextureUsed;
  11856. private _fullEngine;
  11857. private _cachedDefines;
  11858. private _contentUpdateId;
  11859. private _contentData;
  11860. /**
  11861. * Instantiates a new procedural texture.
  11862. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  11863. * This is the base class of any Procedural texture and contains most of the shareable code.
  11864. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11865. * @param name Define the name of the texture
  11866. * @param size Define the size of the texture to create
  11867. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11868. * @param scene Define the scene the texture belongs to
  11869. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11870. * @param generateMipMaps Define if the texture should creates mip maps or not
  11871. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11872. */
  11873. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11874. /**
  11875. * The effect that is created when initializing the post process.
  11876. * @returns The created effect corresponding the the postprocess.
  11877. */
  11878. getEffect(): Effect;
  11879. /**
  11880. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11881. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11882. */
  11883. getContent(): Nullable<ArrayBufferView>;
  11884. private _createIndexBuffer;
  11885. /** @hidden */
  11886. _rebuild(): void;
  11887. /**
  11888. * Resets the texture in order to recreate its associated resources.
  11889. * This can be called in case of context loss
  11890. */
  11891. reset(): void;
  11892. protected _getDefines(): string;
  11893. /**
  11894. * Is the texture ready to be used ? (rendered at least once)
  11895. * @returns true if ready, otherwise, false.
  11896. */
  11897. isReady(): boolean;
  11898. /**
  11899. * Resets the refresh counter of the texture and start bak from scratch.
  11900. * Could be useful to regenerate the texture if it is setup to render only once.
  11901. */
  11902. resetRefreshCounter(): void;
  11903. /**
  11904. * Set the fragment shader to use in order to render the texture.
  11905. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11906. */
  11907. setFragment(fragment: any): void;
  11908. /**
  11909. * Define the refresh rate of the texture or the rendering frequency.
  11910. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11911. */
  11912. get refreshRate(): number;
  11913. set refreshRate(value: number);
  11914. /** @hidden */
  11915. _shouldRender(): boolean;
  11916. /**
  11917. * Get the size the texture is rendering at.
  11918. * @returns the size (texture is always squared)
  11919. */
  11920. getRenderSize(): number;
  11921. /**
  11922. * Resize the texture to new value.
  11923. * @param size Define the new size the texture should have
  11924. * @param generateMipMaps Define whether the new texture should create mip maps
  11925. */
  11926. resize(size: number, generateMipMaps: boolean): void;
  11927. private _checkUniform;
  11928. /**
  11929. * Set a texture in the shader program used to render.
  11930. * @param name Define the name of the uniform samplers as defined in the shader
  11931. * @param texture Define the texture to bind to this sampler
  11932. * @return the texture itself allowing "fluent" like uniform updates
  11933. */
  11934. setTexture(name: string, texture: Texture): ProceduralTexture;
  11935. /**
  11936. * Set a float in the shader.
  11937. * @param name Define the name of the uniform as defined in the shader
  11938. * @param value Define the value to give to the uniform
  11939. * @return the texture itself allowing "fluent" like uniform updates
  11940. */
  11941. setFloat(name: string, value: number): ProceduralTexture;
  11942. /**
  11943. * Set a int in the shader.
  11944. * @param name Define the name of the uniform as defined in the shader
  11945. * @param value Define the value to give to the uniform
  11946. * @return the texture itself allowing "fluent" like uniform updates
  11947. */
  11948. setInt(name: string, value: number): ProceduralTexture;
  11949. /**
  11950. * Set an array of floats in the shader.
  11951. * @param name Define the name of the uniform as defined in the shader
  11952. * @param value Define the value to give to the uniform
  11953. * @return the texture itself allowing "fluent" like uniform updates
  11954. */
  11955. setFloats(name: string, value: number[]): ProceduralTexture;
  11956. /**
  11957. * Set a vec3 in the shader from a Color3.
  11958. * @param name Define the name of the uniform as defined in the shader
  11959. * @param value Define the value to give to the uniform
  11960. * @return the texture itself allowing "fluent" like uniform updates
  11961. */
  11962. setColor3(name: string, value: Color3): ProceduralTexture;
  11963. /**
  11964. * Set a vec4 in the shader from a Color4.
  11965. * @param name Define the name of the uniform as defined in the shader
  11966. * @param value Define the value to give to the uniform
  11967. * @return the texture itself allowing "fluent" like uniform updates
  11968. */
  11969. setColor4(name: string, value: Color4): ProceduralTexture;
  11970. /**
  11971. * Set a vec2 in the shader from a Vector2.
  11972. * @param name Define the name of the uniform as defined in the shader
  11973. * @param value Define the value to give to the uniform
  11974. * @return the texture itself allowing "fluent" like uniform updates
  11975. */
  11976. setVector2(name: string, value: Vector2): ProceduralTexture;
  11977. /**
  11978. * Set a vec3 in the shader from a Vector3.
  11979. * @param name Define the name of the uniform as defined in the shader
  11980. * @param value Define the value to give to the uniform
  11981. * @return the texture itself allowing "fluent" like uniform updates
  11982. */
  11983. setVector3(name: string, value: Vector3): ProceduralTexture;
  11984. /**
  11985. * Set a mat4 in the shader from a MAtrix.
  11986. * @param name Define the name of the uniform as defined in the shader
  11987. * @param value Define the value to give to the uniform
  11988. * @return the texture itself allowing "fluent" like uniform updates
  11989. */
  11990. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11991. /**
  11992. * Render the texture to its associated render target.
  11993. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11994. */
  11995. render(useCameraPostProcess?: boolean): void;
  11996. /**
  11997. * Clone the texture.
  11998. * @returns the cloned texture
  11999. */
  12000. clone(): ProceduralTexture;
  12001. /**
  12002. * Dispose the texture and release its asoociated resources.
  12003. */
  12004. dispose(): void;
  12005. }
  12006. }
  12007. declare module "babylonjs/Particles/baseParticleSystem" {
  12008. import { Nullable } from "babylonjs/types";
  12009. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12010. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12011. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12012. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12013. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12014. import { Scene } from "babylonjs/scene";
  12015. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12016. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12017. import { Texture } from "babylonjs/Materials/Textures/texture";
  12018. import { Color4 } from "babylonjs/Maths/math.color";
  12019. import { Animation } from "babylonjs/Animations/animation";
  12020. /**
  12021. * This represents the base class for particle system in Babylon.
  12022. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12023. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12024. * @example https://doc.babylonjs.com/babylon101/particles
  12025. */
  12026. export class BaseParticleSystem {
  12027. /**
  12028. * Source color is added to the destination color without alpha affecting the result
  12029. */
  12030. static BLENDMODE_ONEONE: number;
  12031. /**
  12032. * Blend current color and particle color using particle’s alpha
  12033. */
  12034. static BLENDMODE_STANDARD: number;
  12035. /**
  12036. * Add current color and particle color multiplied by particle’s alpha
  12037. */
  12038. static BLENDMODE_ADD: number;
  12039. /**
  12040. * Multiply current color with particle color
  12041. */
  12042. static BLENDMODE_MULTIPLY: number;
  12043. /**
  12044. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12045. */
  12046. static BLENDMODE_MULTIPLYADD: number;
  12047. /**
  12048. * List of animations used by the particle system.
  12049. */
  12050. animations: Animation[];
  12051. /**
  12052. * Gets or sets the unique id of the particle system
  12053. */
  12054. uniqueId: number;
  12055. /**
  12056. * The id of the Particle system.
  12057. */
  12058. id: string;
  12059. /**
  12060. * The friendly name of the Particle system.
  12061. */
  12062. name: string;
  12063. /**
  12064. * Snippet ID if the particle system was created from the snippet server
  12065. */
  12066. snippetId: string;
  12067. /**
  12068. * The rendering group used by the Particle system to chose when to render.
  12069. */
  12070. renderingGroupId: number;
  12071. /**
  12072. * The emitter represents the Mesh or position we are attaching the particle system to.
  12073. */
  12074. emitter: Nullable<AbstractMesh | Vector3>;
  12075. /**
  12076. * The maximum number of particles to emit per frame
  12077. */
  12078. emitRate: number;
  12079. /**
  12080. * If you want to launch only a few particles at once, that can be done, as well.
  12081. */
  12082. manualEmitCount: number;
  12083. /**
  12084. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12085. */
  12086. updateSpeed: number;
  12087. /**
  12088. * The amount of time the particle system is running (depends of the overall update speed).
  12089. */
  12090. targetStopDuration: number;
  12091. /**
  12092. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12093. */
  12094. disposeOnStop: boolean;
  12095. /**
  12096. * Minimum power of emitting particles.
  12097. */
  12098. minEmitPower: number;
  12099. /**
  12100. * Maximum power of emitting particles.
  12101. */
  12102. maxEmitPower: number;
  12103. /**
  12104. * Minimum life time of emitting particles.
  12105. */
  12106. minLifeTime: number;
  12107. /**
  12108. * Maximum life time of emitting particles.
  12109. */
  12110. maxLifeTime: number;
  12111. /**
  12112. * Minimum Size of emitting particles.
  12113. */
  12114. minSize: number;
  12115. /**
  12116. * Maximum Size of emitting particles.
  12117. */
  12118. maxSize: number;
  12119. /**
  12120. * Minimum scale of emitting particles on X axis.
  12121. */
  12122. minScaleX: number;
  12123. /**
  12124. * Maximum scale of emitting particles on X axis.
  12125. */
  12126. maxScaleX: number;
  12127. /**
  12128. * Minimum scale of emitting particles on Y axis.
  12129. */
  12130. minScaleY: number;
  12131. /**
  12132. * Maximum scale of emitting particles on Y axis.
  12133. */
  12134. maxScaleY: number;
  12135. /**
  12136. * Gets or sets the minimal initial rotation in radians.
  12137. */
  12138. minInitialRotation: number;
  12139. /**
  12140. * Gets or sets the maximal initial rotation in radians.
  12141. */
  12142. maxInitialRotation: number;
  12143. /**
  12144. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12145. */
  12146. minAngularSpeed: number;
  12147. /**
  12148. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12149. */
  12150. maxAngularSpeed: number;
  12151. /**
  12152. * The texture used to render each particle. (this can be a spritesheet)
  12153. */
  12154. particleTexture: Nullable<Texture>;
  12155. /**
  12156. * The layer mask we are rendering the particles through.
  12157. */
  12158. layerMask: number;
  12159. /**
  12160. * This can help using your own shader to render the particle system.
  12161. * The according effect will be created
  12162. */
  12163. customShader: any;
  12164. /**
  12165. * By default particle system starts as soon as they are created. This prevents the
  12166. * automatic start to happen and let you decide when to start emitting particles.
  12167. */
  12168. preventAutoStart: boolean;
  12169. private _noiseTexture;
  12170. /**
  12171. * Gets or sets a texture used to add random noise to particle positions
  12172. */
  12173. get noiseTexture(): Nullable<ProceduralTexture>;
  12174. set noiseTexture(value: Nullable<ProceduralTexture>);
  12175. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12176. noiseStrength: Vector3;
  12177. /**
  12178. * Callback triggered when the particle animation is ending.
  12179. */
  12180. onAnimationEnd: Nullable<() => void>;
  12181. /**
  12182. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12183. */
  12184. blendMode: number;
  12185. /**
  12186. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12187. * to override the particles.
  12188. */
  12189. forceDepthWrite: boolean;
  12190. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  12191. preWarmCycles: number;
  12192. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12193. preWarmStepOffset: number;
  12194. /**
  12195. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  12196. */
  12197. spriteCellChangeSpeed: number;
  12198. /**
  12199. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12200. */
  12201. startSpriteCellID: number;
  12202. /**
  12203. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12204. */
  12205. endSpriteCellID: number;
  12206. /**
  12207. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12208. */
  12209. spriteCellWidth: number;
  12210. /**
  12211. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12212. */
  12213. spriteCellHeight: number;
  12214. /**
  12215. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12216. */
  12217. spriteRandomStartCell: boolean;
  12218. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12219. translationPivot: Vector2;
  12220. /** @hidden */
  12221. protected _isAnimationSheetEnabled: boolean;
  12222. /**
  12223. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12224. */
  12225. beginAnimationOnStart: boolean;
  12226. /**
  12227. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12228. */
  12229. beginAnimationFrom: number;
  12230. /**
  12231. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12232. */
  12233. beginAnimationTo: number;
  12234. /**
  12235. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12236. */
  12237. beginAnimationLoop: boolean;
  12238. /**
  12239. * Gets or sets a world offset applied to all particles
  12240. */
  12241. worldOffset: Vector3;
  12242. /**
  12243. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12244. */
  12245. get isAnimationSheetEnabled(): boolean;
  12246. set isAnimationSheetEnabled(value: boolean);
  12247. /**
  12248. * Get hosting scene
  12249. * @returns the scene
  12250. */
  12251. getScene(): Scene;
  12252. /**
  12253. * You can use gravity if you want to give an orientation to your particles.
  12254. */
  12255. gravity: Vector3;
  12256. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12257. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12258. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12259. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12260. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12261. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12262. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12263. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12264. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12265. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12266. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12267. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12268. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12269. /**
  12270. * Defines the delay in milliseconds before starting the system (0 by default)
  12271. */
  12272. startDelay: number;
  12273. /**
  12274. * Gets the current list of drag gradients.
  12275. * You must use addDragGradient and removeDragGradient to udpate this list
  12276. * @returns the list of drag gradients
  12277. */
  12278. getDragGradients(): Nullable<Array<FactorGradient>>;
  12279. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12280. limitVelocityDamping: number;
  12281. /**
  12282. * Gets the current list of limit velocity gradients.
  12283. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12284. * @returns the list of limit velocity gradients
  12285. */
  12286. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12287. /**
  12288. * Gets the current list of color gradients.
  12289. * You must use addColorGradient and removeColorGradient to udpate this list
  12290. * @returns the list of color gradients
  12291. */
  12292. getColorGradients(): Nullable<Array<ColorGradient>>;
  12293. /**
  12294. * Gets the current list of size gradients.
  12295. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12296. * @returns the list of size gradients
  12297. */
  12298. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12299. /**
  12300. * Gets the current list of color remap gradients.
  12301. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12302. * @returns the list of color remap gradients
  12303. */
  12304. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12305. /**
  12306. * Gets the current list of alpha remap gradients.
  12307. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12308. * @returns the list of alpha remap gradients
  12309. */
  12310. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12311. /**
  12312. * Gets the current list of life time gradients.
  12313. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12314. * @returns the list of life time gradients
  12315. */
  12316. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12317. /**
  12318. * Gets the current list of angular speed gradients.
  12319. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12320. * @returns the list of angular speed gradients
  12321. */
  12322. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12323. /**
  12324. * Gets the current list of velocity gradients.
  12325. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12326. * @returns the list of velocity gradients
  12327. */
  12328. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12329. /**
  12330. * Gets the current list of start size gradients.
  12331. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12332. * @returns the list of start size gradients
  12333. */
  12334. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12335. /**
  12336. * Gets the current list of emit rate gradients.
  12337. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12338. * @returns the list of emit rate gradients
  12339. */
  12340. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12341. /**
  12342. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12343. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12344. */
  12345. get direction1(): Vector3;
  12346. set direction1(value: Vector3);
  12347. /**
  12348. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12349. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12350. */
  12351. get direction2(): Vector3;
  12352. set direction2(value: Vector3);
  12353. /**
  12354. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12355. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12356. */
  12357. get minEmitBox(): Vector3;
  12358. set minEmitBox(value: Vector3);
  12359. /**
  12360. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12361. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12362. */
  12363. get maxEmitBox(): Vector3;
  12364. set maxEmitBox(value: Vector3);
  12365. /**
  12366. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12367. */
  12368. color1: Color4;
  12369. /**
  12370. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12371. */
  12372. color2: Color4;
  12373. /**
  12374. * Color the particle will have at the end of its lifetime
  12375. */
  12376. colorDead: Color4;
  12377. /**
  12378. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12379. */
  12380. textureMask: Color4;
  12381. /**
  12382. * The particle emitter type defines the emitter used by the particle system.
  12383. * It can be for example box, sphere, or cone...
  12384. */
  12385. particleEmitterType: IParticleEmitterType;
  12386. /** @hidden */
  12387. _isSubEmitter: boolean;
  12388. /**
  12389. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12390. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12391. */
  12392. billboardMode: number;
  12393. protected _isBillboardBased: boolean;
  12394. /**
  12395. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12396. */
  12397. get isBillboardBased(): boolean;
  12398. set isBillboardBased(value: boolean);
  12399. /**
  12400. * The scene the particle system belongs to.
  12401. */
  12402. protected _scene: Scene;
  12403. /**
  12404. * Local cache of defines for image processing.
  12405. */
  12406. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12407. /**
  12408. * Default configuration related to image processing available in the standard Material.
  12409. */
  12410. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12411. /**
  12412. * Gets the image processing configuration used either in this material.
  12413. */
  12414. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12415. /**
  12416. * Sets the Default image processing configuration used either in the this material.
  12417. *
  12418. * If sets to null, the scene one is in use.
  12419. */
  12420. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12421. /**
  12422. * Attaches a new image processing configuration to the Standard Material.
  12423. * @param configuration
  12424. */
  12425. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12426. /** @hidden */
  12427. protected _reset(): void;
  12428. /** @hidden */
  12429. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12430. /**
  12431. * Instantiates a particle system.
  12432. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12433. * @param name The name of the particle system
  12434. */
  12435. constructor(name: string);
  12436. /**
  12437. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12438. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12439. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12440. * @returns the emitter
  12441. */
  12442. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12443. /**
  12444. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12445. * @param radius The radius of the hemisphere to emit from
  12446. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12447. * @returns the emitter
  12448. */
  12449. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12450. /**
  12451. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12452. * @param radius The radius of the sphere to emit from
  12453. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12454. * @returns the emitter
  12455. */
  12456. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12457. /**
  12458. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12459. * @param radius The radius of the sphere to emit from
  12460. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12461. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12462. * @returns the emitter
  12463. */
  12464. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12465. /**
  12466. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12467. * @param radius The radius of the emission cylinder
  12468. * @param height The height of the emission cylinder
  12469. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12470. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12471. * @returns the emitter
  12472. */
  12473. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12474. /**
  12475. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12476. * @param radius The radius of the cylinder to emit from
  12477. * @param height The height of the emission cylinder
  12478. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12479. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12480. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12481. * @returns the emitter
  12482. */
  12483. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12484. /**
  12485. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12486. * @param radius The radius of the cone to emit from
  12487. * @param angle The base angle of the cone
  12488. * @returns the emitter
  12489. */
  12490. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12491. /**
  12492. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12493. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12494. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12495. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12496. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12497. * @returns the emitter
  12498. */
  12499. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12500. }
  12501. }
  12502. declare module "babylonjs/Particles/subEmitter" {
  12503. import { Scene } from "babylonjs/scene";
  12504. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12505. /**
  12506. * Type of sub emitter
  12507. */
  12508. export enum SubEmitterType {
  12509. /**
  12510. * Attached to the particle over it's lifetime
  12511. */
  12512. ATTACHED = 0,
  12513. /**
  12514. * Created when the particle dies
  12515. */
  12516. END = 1
  12517. }
  12518. /**
  12519. * Sub emitter class used to emit particles from an existing particle
  12520. */
  12521. export class SubEmitter {
  12522. /**
  12523. * the particle system to be used by the sub emitter
  12524. */
  12525. particleSystem: ParticleSystem;
  12526. /**
  12527. * Type of the submitter (Default: END)
  12528. */
  12529. type: SubEmitterType;
  12530. /**
  12531. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  12532. * Note: This only is supported when using an emitter of type Mesh
  12533. */
  12534. inheritDirection: boolean;
  12535. /**
  12536. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12537. */
  12538. inheritedVelocityAmount: number;
  12539. /**
  12540. * Creates a sub emitter
  12541. * @param particleSystem the particle system to be used by the sub emitter
  12542. */
  12543. constructor(
  12544. /**
  12545. * the particle system to be used by the sub emitter
  12546. */
  12547. particleSystem: ParticleSystem);
  12548. /**
  12549. * Clones the sub emitter
  12550. * @returns the cloned sub emitter
  12551. */
  12552. clone(): SubEmitter;
  12553. /**
  12554. * Serialize current object to a JSON object
  12555. * @returns the serialized object
  12556. */
  12557. serialize(): any;
  12558. /** @hidden */
  12559. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12560. /**
  12561. * Creates a new SubEmitter from a serialized JSON version
  12562. * @param serializationObject defines the JSON object to read from
  12563. * @param scene defines the hosting scene
  12564. * @param rootUrl defines the rootUrl for data loading
  12565. * @returns a new SubEmitter
  12566. */
  12567. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12568. /** Release associated resources */
  12569. dispose(): void;
  12570. }
  12571. }
  12572. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12573. /** @hidden */
  12574. export var imageProcessingDeclaration: {
  12575. name: string;
  12576. shader: string;
  12577. };
  12578. }
  12579. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12580. /** @hidden */
  12581. export var imageProcessingFunctions: {
  12582. name: string;
  12583. shader: string;
  12584. };
  12585. }
  12586. declare module "babylonjs/Shaders/particles.fragment" {
  12587. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12588. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12589. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12590. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12591. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12592. /** @hidden */
  12593. export var particlesPixelShader: {
  12594. name: string;
  12595. shader: string;
  12596. };
  12597. }
  12598. declare module "babylonjs/Shaders/particles.vertex" {
  12599. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12600. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12601. /** @hidden */
  12602. export var particlesVertexShader: {
  12603. name: string;
  12604. shader: string;
  12605. };
  12606. }
  12607. declare module "babylonjs/Particles/particleSystem" {
  12608. import { Nullable } from "babylonjs/types";
  12609. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12610. import { Observable } from "babylonjs/Misc/observable";
  12611. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12612. import { Effect } from "babylonjs/Materials/effect";
  12613. import { Scene, IDisposable } from "babylonjs/scene";
  12614. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12615. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12616. import { Particle } from "babylonjs/Particles/particle";
  12617. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12618. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12619. import "babylonjs/Shaders/particles.fragment";
  12620. import "babylonjs/Shaders/particles.vertex";
  12621. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12622. /**
  12623. * This represents a particle system in Babylon.
  12624. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12625. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12626. * @example https://doc.babylonjs.com/babylon101/particles
  12627. */
  12628. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12629. /**
  12630. * Billboard mode will only apply to Y axis
  12631. */
  12632. static readonly BILLBOARDMODE_Y: number;
  12633. /**
  12634. * Billboard mode will apply to all axes
  12635. */
  12636. static readonly BILLBOARDMODE_ALL: number;
  12637. /**
  12638. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12639. */
  12640. static readonly BILLBOARDMODE_STRETCHED: number;
  12641. /**
  12642. * This function can be defined to provide custom update for active particles.
  12643. * This function will be called instead of regular update (age, position, color, etc.).
  12644. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12645. */
  12646. updateFunction: (particles: Particle[]) => void;
  12647. private _emitterWorldMatrix;
  12648. /**
  12649. * This function can be defined to specify initial direction for every new particle.
  12650. * It by default use the emitterType defined function
  12651. */
  12652. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12653. /**
  12654. * This function can be defined to specify initial position for every new particle.
  12655. * It by default use the emitterType defined function
  12656. */
  12657. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12658. /**
  12659. * @hidden
  12660. */
  12661. _inheritedVelocityOffset: Vector3;
  12662. /**
  12663. * An event triggered when the system is disposed
  12664. */
  12665. onDisposeObservable: Observable<IParticleSystem>;
  12666. private _onDisposeObserver;
  12667. /**
  12668. * Sets a callback that will be triggered when the system is disposed
  12669. */
  12670. set onDispose(callback: () => void);
  12671. private _particles;
  12672. private _epsilon;
  12673. private _capacity;
  12674. private _stockParticles;
  12675. private _newPartsExcess;
  12676. private _vertexData;
  12677. private _vertexBuffer;
  12678. private _vertexBuffers;
  12679. private _spriteBuffer;
  12680. private _indexBuffer;
  12681. private _effect;
  12682. private _customEffect;
  12683. private _cachedDefines;
  12684. private _scaledColorStep;
  12685. private _colorDiff;
  12686. private _scaledDirection;
  12687. private _scaledGravity;
  12688. private _currentRenderId;
  12689. private _alive;
  12690. private _useInstancing;
  12691. private _started;
  12692. private _stopped;
  12693. private _actualFrame;
  12694. private _scaledUpdateSpeed;
  12695. private _vertexBufferSize;
  12696. /** @hidden */
  12697. _currentEmitRateGradient: Nullable<FactorGradient>;
  12698. /** @hidden */
  12699. _currentEmitRate1: number;
  12700. /** @hidden */
  12701. _currentEmitRate2: number;
  12702. /** @hidden */
  12703. _currentStartSizeGradient: Nullable<FactorGradient>;
  12704. /** @hidden */
  12705. _currentStartSize1: number;
  12706. /** @hidden */
  12707. _currentStartSize2: number;
  12708. private readonly _rawTextureWidth;
  12709. private _rampGradientsTexture;
  12710. private _useRampGradients;
  12711. /** Gets or sets a boolean indicating that ramp gradients must be used
  12712. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12713. */
  12714. get useRampGradients(): boolean;
  12715. set useRampGradients(value: boolean);
  12716. /**
  12717. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  12718. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  12719. */
  12720. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12721. private _subEmitters;
  12722. /**
  12723. * @hidden
  12724. * If the particle systems emitter should be disposed when the particle system is disposed
  12725. */
  12726. _disposeEmitterOnDispose: boolean;
  12727. /**
  12728. * The current active Sub-systems, this property is used by the root particle system only.
  12729. */
  12730. activeSubSystems: Array<ParticleSystem>;
  12731. /**
  12732. * Specifies if the particles are updated in emitter local space or world space
  12733. */
  12734. isLocal: boolean;
  12735. private _rootParticleSystem;
  12736. /**
  12737. * Gets the current list of active particles
  12738. */
  12739. get particles(): Particle[];
  12740. /**
  12741. * Gets the number of particles active at the same time.
  12742. * @returns The number of active particles.
  12743. */
  12744. getActiveCount(): number;
  12745. /**
  12746. * Returns the string "ParticleSystem"
  12747. * @returns a string containing the class name
  12748. */
  12749. getClassName(): string;
  12750. /**
  12751. * Gets a boolean indicating that the system is stopping
  12752. * @returns true if the system is currently stopping
  12753. */
  12754. isStopping(): boolean;
  12755. /**
  12756. * Gets the custom effect used to render the particles
  12757. * @param blendMode Blend mode for which the effect should be retrieved
  12758. * @returns The effect
  12759. */
  12760. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12761. /**
  12762. * Sets the custom effect used to render the particles
  12763. * @param effect The effect to set
  12764. * @param blendMode Blend mode for which the effect should be set
  12765. */
  12766. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12767. /** @hidden */
  12768. private _onBeforeDrawParticlesObservable;
  12769. /**
  12770. * Observable that will be called just before the particles are drawn
  12771. */
  12772. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12773. /**
  12774. * Gets the name of the particle vertex shader
  12775. */
  12776. get vertexShaderName(): string;
  12777. /**
  12778. * Instantiates a particle system.
  12779. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12780. * @param name The name of the particle system
  12781. * @param capacity The max number of particles alive at the same time
  12782. * @param scene The scene the particle system belongs to
  12783. * @param customEffect a custom effect used to change the way particles are rendered by default
  12784. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12785. * @param epsilon Offset used to render the particles
  12786. */
  12787. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12788. private _addFactorGradient;
  12789. private _removeFactorGradient;
  12790. /**
  12791. * Adds a new life time gradient
  12792. * @param gradient defines the gradient to use (between 0 and 1)
  12793. * @param factor defines the life time factor to affect to the specified gradient
  12794. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12795. * @returns the current particle system
  12796. */
  12797. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12798. /**
  12799. * Remove a specific life time gradient
  12800. * @param gradient defines the gradient to remove
  12801. * @returns the current particle system
  12802. */
  12803. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12804. /**
  12805. * Adds a new size gradient
  12806. * @param gradient defines the gradient to use (between 0 and 1)
  12807. * @param factor defines the size factor to affect to the specified gradient
  12808. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12809. * @returns the current particle system
  12810. */
  12811. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12812. /**
  12813. * Remove a specific size gradient
  12814. * @param gradient defines the gradient to remove
  12815. * @returns the current particle system
  12816. */
  12817. removeSizeGradient(gradient: number): IParticleSystem;
  12818. /**
  12819. * Adds a new color remap gradient
  12820. * @param gradient defines the gradient to use (between 0 and 1)
  12821. * @param min defines the color remap minimal range
  12822. * @param max defines the color remap maximal range
  12823. * @returns the current particle system
  12824. */
  12825. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12826. /**
  12827. * Remove a specific color remap gradient
  12828. * @param gradient defines the gradient to remove
  12829. * @returns the current particle system
  12830. */
  12831. removeColorRemapGradient(gradient: number): IParticleSystem;
  12832. /**
  12833. * Adds a new alpha remap gradient
  12834. * @param gradient defines the gradient to use (between 0 and 1)
  12835. * @param min defines the alpha remap minimal range
  12836. * @param max defines the alpha remap maximal range
  12837. * @returns the current particle system
  12838. */
  12839. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12840. /**
  12841. * Remove a specific alpha remap gradient
  12842. * @param gradient defines the gradient to remove
  12843. * @returns the current particle system
  12844. */
  12845. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12846. /**
  12847. * Adds a new angular speed gradient
  12848. * @param gradient defines the gradient to use (between 0 and 1)
  12849. * @param factor defines the angular speed to affect to the specified gradient
  12850. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12851. * @returns the current particle system
  12852. */
  12853. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12854. /**
  12855. * Remove a specific angular speed gradient
  12856. * @param gradient defines the gradient to remove
  12857. * @returns the current particle system
  12858. */
  12859. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12860. /**
  12861. * Adds a new velocity gradient
  12862. * @param gradient defines the gradient to use (between 0 and 1)
  12863. * @param factor defines the velocity to affect to the specified gradient
  12864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12865. * @returns the current particle system
  12866. */
  12867. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12868. /**
  12869. * Remove a specific velocity gradient
  12870. * @param gradient defines the gradient to remove
  12871. * @returns the current particle system
  12872. */
  12873. removeVelocityGradient(gradient: number): IParticleSystem;
  12874. /**
  12875. * Adds a new limit velocity gradient
  12876. * @param gradient defines the gradient to use (between 0 and 1)
  12877. * @param factor defines the limit velocity value to affect to the specified gradient
  12878. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12879. * @returns the current particle system
  12880. */
  12881. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12882. /**
  12883. * Remove a specific limit velocity gradient
  12884. * @param gradient defines the gradient to remove
  12885. * @returns the current particle system
  12886. */
  12887. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12888. /**
  12889. * Adds a new drag gradient
  12890. * @param gradient defines the gradient to use (between 0 and 1)
  12891. * @param factor defines the drag value to affect to the specified gradient
  12892. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12893. * @returns the current particle system
  12894. */
  12895. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12896. /**
  12897. * Remove a specific drag gradient
  12898. * @param gradient defines the gradient to remove
  12899. * @returns the current particle system
  12900. */
  12901. removeDragGradient(gradient: number): IParticleSystem;
  12902. /**
  12903. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12904. * @param gradient defines the gradient to use (between 0 and 1)
  12905. * @param factor defines the emit rate value to affect to the specified gradient
  12906. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12907. * @returns the current particle system
  12908. */
  12909. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12910. /**
  12911. * Remove a specific emit rate gradient
  12912. * @param gradient defines the gradient to remove
  12913. * @returns the current particle system
  12914. */
  12915. removeEmitRateGradient(gradient: number): IParticleSystem;
  12916. /**
  12917. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12918. * @param gradient defines the gradient to use (between 0 and 1)
  12919. * @param factor defines the start size value to affect to the specified gradient
  12920. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12921. * @returns the current particle system
  12922. */
  12923. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12924. /**
  12925. * Remove a specific start size gradient
  12926. * @param gradient defines the gradient to remove
  12927. * @returns the current particle system
  12928. */
  12929. removeStartSizeGradient(gradient: number): IParticleSystem;
  12930. private _createRampGradientTexture;
  12931. /**
  12932. * Gets the current list of ramp gradients.
  12933. * You must use addRampGradient and removeRampGradient to udpate this list
  12934. * @returns the list of ramp gradients
  12935. */
  12936. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12937. /** Force the system to rebuild all gradients that need to be resync */
  12938. forceRefreshGradients(): void;
  12939. private _syncRampGradientTexture;
  12940. /**
  12941. * Adds a new ramp gradient used to remap particle colors
  12942. * @param gradient defines the gradient to use (between 0 and 1)
  12943. * @param color defines the color to affect to the specified gradient
  12944. * @returns the current particle system
  12945. */
  12946. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12947. /**
  12948. * Remove a specific ramp gradient
  12949. * @param gradient defines the gradient to remove
  12950. * @returns the current particle system
  12951. */
  12952. removeRampGradient(gradient: number): ParticleSystem;
  12953. /**
  12954. * Adds a new color gradient
  12955. * @param gradient defines the gradient to use (between 0 and 1)
  12956. * @param color1 defines the color to affect to the specified gradient
  12957. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12958. * @returns this particle system
  12959. */
  12960. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12961. /**
  12962. * Remove a specific color gradient
  12963. * @param gradient defines the gradient to remove
  12964. * @returns this particle system
  12965. */
  12966. removeColorGradient(gradient: number): IParticleSystem;
  12967. private _fetchR;
  12968. protected _reset(): void;
  12969. private _resetEffect;
  12970. private _createVertexBuffers;
  12971. private _createIndexBuffer;
  12972. /**
  12973. * Gets the maximum number of particles active at the same time.
  12974. * @returns The max number of active particles.
  12975. */
  12976. getCapacity(): number;
  12977. /**
  12978. * Gets whether there are still active particles in the system.
  12979. * @returns True if it is alive, otherwise false.
  12980. */
  12981. isAlive(): boolean;
  12982. /**
  12983. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12984. * @returns True if it has been started, otherwise false.
  12985. */
  12986. isStarted(): boolean;
  12987. private _prepareSubEmitterInternalArray;
  12988. /**
  12989. * Starts the particle system and begins to emit
  12990. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12991. */
  12992. start(delay?: number): void;
  12993. /**
  12994. * Stops the particle system.
  12995. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  12996. */
  12997. stop(stopSubEmitters?: boolean): void;
  12998. /**
  12999. * Remove all active particles
  13000. */
  13001. reset(): void;
  13002. /**
  13003. * @hidden (for internal use only)
  13004. */
  13005. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13006. /**
  13007. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13008. * Its lifetime will start back at 0.
  13009. */
  13010. recycleParticle: (particle: Particle) => void;
  13011. private _stopSubEmitters;
  13012. private _createParticle;
  13013. private _removeFromRoot;
  13014. private _emitFromParticle;
  13015. private _update;
  13016. /** @hidden */
  13017. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13018. /** @hidden */
  13019. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13020. /**
  13021. * Fill the defines array according to the current settings of the particle system
  13022. * @param defines Array to be updated
  13023. * @param blendMode blend mode to take into account when updating the array
  13024. */
  13025. fillDefines(defines: Array<string>, blendMode: number): void;
  13026. /**
  13027. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13028. * @param uniforms Uniforms array to fill
  13029. * @param attributes Attributes array to fill
  13030. * @param samplers Samplers array to fill
  13031. */
  13032. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13033. /** @hidden */
  13034. private _getEffect;
  13035. /**
  13036. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13037. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13038. */
  13039. animate(preWarmOnly?: boolean): void;
  13040. private _appendParticleVertices;
  13041. /**
  13042. * Rebuilds the particle system.
  13043. */
  13044. rebuild(): void;
  13045. /**
  13046. * Is this system ready to be used/rendered
  13047. * @return true if the system is ready
  13048. */
  13049. isReady(): boolean;
  13050. private _render;
  13051. /**
  13052. * Renders the particle system in its current state.
  13053. * @returns the current number of particles
  13054. */
  13055. render(): number;
  13056. /**
  13057. * Disposes the particle system and free the associated resources
  13058. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13059. */
  13060. dispose(disposeTexture?: boolean): void;
  13061. /**
  13062. * Clones the particle system.
  13063. * @param name The name of the cloned object
  13064. * @param newEmitter The new emitter to use
  13065. * @returns the cloned particle system
  13066. */
  13067. clone(name: string, newEmitter: any): ParticleSystem;
  13068. /**
  13069. * Serializes the particle system to a JSON object
  13070. * @param serializeTexture defines if the texture must be serialized as well
  13071. * @returns the JSON object
  13072. */
  13073. serialize(serializeTexture?: boolean): any;
  13074. /** @hidden */
  13075. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13076. /** @hidden */
  13077. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  13078. /**
  13079. * Parses a JSON object to create a particle system.
  13080. * @param parsedParticleSystem The JSON object to parse
  13081. * @param scene The scene to create the particle system in
  13082. * @param rootUrl The root url to use to load external dependencies like texture
  13083. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13084. * @returns the Parsed particle system
  13085. */
  13086. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13087. }
  13088. }
  13089. declare module "babylonjs/Particles/particle" {
  13090. import { Nullable } from "babylonjs/types";
  13091. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13092. import { Color4 } from "babylonjs/Maths/math.color";
  13093. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13094. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13095. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13096. /**
  13097. * A particle represents one of the element emitted by a particle system.
  13098. * This is mainly define by its coordinates, direction, velocity and age.
  13099. */
  13100. export class Particle {
  13101. /**
  13102. * The particle system the particle belongs to.
  13103. */
  13104. particleSystem: ParticleSystem;
  13105. private static _Count;
  13106. /**
  13107. * Unique ID of the particle
  13108. */
  13109. id: number;
  13110. /**
  13111. * The world position of the particle in the scene.
  13112. */
  13113. position: Vector3;
  13114. /**
  13115. * The world direction of the particle in the scene.
  13116. */
  13117. direction: Vector3;
  13118. /**
  13119. * The color of the particle.
  13120. */
  13121. color: Color4;
  13122. /**
  13123. * The color change of the particle per step.
  13124. */
  13125. colorStep: Color4;
  13126. /**
  13127. * Defines how long will the life of the particle be.
  13128. */
  13129. lifeTime: number;
  13130. /**
  13131. * The current age of the particle.
  13132. */
  13133. age: number;
  13134. /**
  13135. * The current size of the particle.
  13136. */
  13137. size: number;
  13138. /**
  13139. * The current scale of the particle.
  13140. */
  13141. scale: Vector2;
  13142. /**
  13143. * The current angle of the particle.
  13144. */
  13145. angle: number;
  13146. /**
  13147. * Defines how fast is the angle changing.
  13148. */
  13149. angularSpeed: number;
  13150. /**
  13151. * Defines the cell index used by the particle to be rendered from a sprite.
  13152. */
  13153. cellIndex: number;
  13154. /**
  13155. * The information required to support color remapping
  13156. */
  13157. remapData: Vector4;
  13158. /** @hidden */
  13159. _randomCellOffset?: number;
  13160. /** @hidden */
  13161. _initialDirection: Nullable<Vector3>;
  13162. /** @hidden */
  13163. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13164. /** @hidden */
  13165. _initialStartSpriteCellID: number;
  13166. /** @hidden */
  13167. _initialEndSpriteCellID: number;
  13168. /** @hidden */
  13169. _currentColorGradient: Nullable<ColorGradient>;
  13170. /** @hidden */
  13171. _currentColor1: Color4;
  13172. /** @hidden */
  13173. _currentColor2: Color4;
  13174. /** @hidden */
  13175. _currentSizeGradient: Nullable<FactorGradient>;
  13176. /** @hidden */
  13177. _currentSize1: number;
  13178. /** @hidden */
  13179. _currentSize2: number;
  13180. /** @hidden */
  13181. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13182. /** @hidden */
  13183. _currentAngularSpeed1: number;
  13184. /** @hidden */
  13185. _currentAngularSpeed2: number;
  13186. /** @hidden */
  13187. _currentVelocityGradient: Nullable<FactorGradient>;
  13188. /** @hidden */
  13189. _currentVelocity1: number;
  13190. /** @hidden */
  13191. _currentVelocity2: number;
  13192. /** @hidden */
  13193. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13194. /** @hidden */
  13195. _currentLimitVelocity1: number;
  13196. /** @hidden */
  13197. _currentLimitVelocity2: number;
  13198. /** @hidden */
  13199. _currentDragGradient: Nullable<FactorGradient>;
  13200. /** @hidden */
  13201. _currentDrag1: number;
  13202. /** @hidden */
  13203. _currentDrag2: number;
  13204. /** @hidden */
  13205. _randomNoiseCoordinates1: Vector3;
  13206. /** @hidden */
  13207. _randomNoiseCoordinates2: Vector3;
  13208. /** @hidden */
  13209. _localPosition?: Vector3;
  13210. /**
  13211. * Creates a new instance Particle
  13212. * @param particleSystem the particle system the particle belongs to
  13213. */
  13214. constructor(
  13215. /**
  13216. * The particle system the particle belongs to.
  13217. */
  13218. particleSystem: ParticleSystem);
  13219. private updateCellInfoFromSystem;
  13220. /**
  13221. * Defines how the sprite cell index is updated for the particle
  13222. */
  13223. updateCellIndex(): void;
  13224. /** @hidden */
  13225. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13226. /** @hidden */
  13227. _inheritParticleInfoToSubEmitters(): void;
  13228. /** @hidden */
  13229. _reset(): void;
  13230. /**
  13231. * Copy the properties of particle to another one.
  13232. * @param other the particle to copy the information to.
  13233. */
  13234. copyTo(other: Particle): void;
  13235. }
  13236. }
  13237. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13238. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13239. import { Effect } from "babylonjs/Materials/effect";
  13240. import { Particle } from "babylonjs/Particles/particle";
  13241. import { Scene } from "babylonjs/scene";
  13242. /**
  13243. * Particle emitter represents a volume emitting particles.
  13244. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13245. */
  13246. export interface IParticleEmitterType {
  13247. /**
  13248. * Called by the particle System when the direction is computed for the created particle.
  13249. * @param worldMatrix is the world matrix of the particle system
  13250. * @param directionToUpdate is the direction vector to update with the result
  13251. * @param particle is the particle we are computed the direction for
  13252. * @param isLocal defines if the direction should be set in local space
  13253. */
  13254. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13255. /**
  13256. * Called by the particle System when the position is computed for the created particle.
  13257. * @param worldMatrix is the world matrix of the particle system
  13258. * @param positionToUpdate is the position vector to update with the result
  13259. * @param particle is the particle we are computed the position for
  13260. * @param isLocal defines if the position should be set in local space
  13261. */
  13262. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13263. /**
  13264. * Clones the current emitter and returns a copy of it
  13265. * @returns the new emitter
  13266. */
  13267. clone(): IParticleEmitterType;
  13268. /**
  13269. * Called by the GPUParticleSystem to setup the update shader
  13270. * @param effect defines the update shader
  13271. */
  13272. applyToShader(effect: Effect): void;
  13273. /**
  13274. * Returns a string to use to update the GPU particles update shader
  13275. * @returns the effect defines string
  13276. */
  13277. getEffectDefines(): string;
  13278. /**
  13279. * Returns a string representing the class name
  13280. * @returns a string containing the class name
  13281. */
  13282. getClassName(): string;
  13283. /**
  13284. * Serializes the particle system to a JSON object.
  13285. * @returns the JSON object
  13286. */
  13287. serialize(): any;
  13288. /**
  13289. * Parse properties from a JSON object
  13290. * @param serializationObject defines the JSON object
  13291. * @param scene defines the hosting scene
  13292. */
  13293. parse(serializationObject: any, scene: Scene): void;
  13294. }
  13295. }
  13296. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13297. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13298. import { Effect } from "babylonjs/Materials/effect";
  13299. import { Particle } from "babylonjs/Particles/particle";
  13300. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13301. /**
  13302. * Particle emitter emitting particles from the inside of a box.
  13303. * It emits the particles randomly between 2 given directions.
  13304. */
  13305. export class BoxParticleEmitter implements IParticleEmitterType {
  13306. /**
  13307. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13308. */
  13309. direction1: Vector3;
  13310. /**
  13311. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13312. */
  13313. direction2: Vector3;
  13314. /**
  13315. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  13316. */
  13317. minEmitBox: Vector3;
  13318. /**
  13319. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  13320. */
  13321. maxEmitBox: Vector3;
  13322. /**
  13323. * Creates a new instance BoxParticleEmitter
  13324. */
  13325. constructor();
  13326. /**
  13327. * Called by the particle System when the direction is computed for the created particle.
  13328. * @param worldMatrix is the world matrix of the particle system
  13329. * @param directionToUpdate is the direction vector to update with the result
  13330. * @param particle is the particle we are computed the direction for
  13331. * @param isLocal defines if the direction should be set in local space
  13332. */
  13333. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13334. /**
  13335. * Called by the particle System when the position is computed for the created particle.
  13336. * @param worldMatrix is the world matrix of the particle system
  13337. * @param positionToUpdate is the position vector to update with the result
  13338. * @param particle is the particle we are computed the position for
  13339. * @param isLocal defines if the position should be set in local space
  13340. */
  13341. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13342. /**
  13343. * Clones the current emitter and returns a copy of it
  13344. * @returns the new emitter
  13345. */
  13346. clone(): BoxParticleEmitter;
  13347. /**
  13348. * Called by the GPUParticleSystem to setup the update shader
  13349. * @param effect defines the update shader
  13350. */
  13351. applyToShader(effect: Effect): void;
  13352. /**
  13353. * Returns a string to use to update the GPU particles update shader
  13354. * @returns a string containng the defines string
  13355. */
  13356. getEffectDefines(): string;
  13357. /**
  13358. * Returns the string "BoxParticleEmitter"
  13359. * @returns a string containing the class name
  13360. */
  13361. getClassName(): string;
  13362. /**
  13363. * Serializes the particle system to a JSON object.
  13364. * @returns the JSON object
  13365. */
  13366. serialize(): any;
  13367. /**
  13368. * Parse properties from a JSON object
  13369. * @param serializationObject defines the JSON object
  13370. */
  13371. parse(serializationObject: any): void;
  13372. }
  13373. }
  13374. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13375. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13376. import { Effect } from "babylonjs/Materials/effect";
  13377. import { Particle } from "babylonjs/Particles/particle";
  13378. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13379. /**
  13380. * Particle emitter emitting particles from the inside of a cone.
  13381. * It emits the particles alongside the cone volume from the base to the particle.
  13382. * The emission direction might be randomized.
  13383. */
  13384. export class ConeParticleEmitter implements IParticleEmitterType {
  13385. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13386. directionRandomizer: number;
  13387. private _radius;
  13388. private _angle;
  13389. private _height;
  13390. /**
  13391. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13392. */
  13393. radiusRange: number;
  13394. /**
  13395. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13396. */
  13397. heightRange: number;
  13398. /**
  13399. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13400. */
  13401. emitFromSpawnPointOnly: boolean;
  13402. /**
  13403. * Gets or sets the radius of the emission cone
  13404. */
  13405. get radius(): number;
  13406. set radius(value: number);
  13407. /**
  13408. * Gets or sets the angle of the emission cone
  13409. */
  13410. get angle(): number;
  13411. set angle(value: number);
  13412. private _buildHeight;
  13413. /**
  13414. * Creates a new instance ConeParticleEmitter
  13415. * @param radius the radius of the emission cone (1 by default)
  13416. * @param angle the cone base angle (PI by default)
  13417. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13418. */
  13419. constructor(radius?: number, angle?: number,
  13420. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13421. directionRandomizer?: number);
  13422. /**
  13423. * Called by the particle System when the direction is computed for the created particle.
  13424. * @param worldMatrix is the world matrix of the particle system
  13425. * @param directionToUpdate is the direction vector to update with the result
  13426. * @param particle is the particle we are computed the direction for
  13427. * @param isLocal defines if the direction should be set in local space
  13428. */
  13429. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13430. /**
  13431. * Called by the particle System when the position is computed for the created particle.
  13432. * @param worldMatrix is the world matrix of the particle system
  13433. * @param positionToUpdate is the position vector to update with the result
  13434. * @param particle is the particle we are computed the position for
  13435. * @param isLocal defines if the position should be set in local space
  13436. */
  13437. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13438. /**
  13439. * Clones the current emitter and returns a copy of it
  13440. * @returns the new emitter
  13441. */
  13442. clone(): ConeParticleEmitter;
  13443. /**
  13444. * Called by the GPUParticleSystem to setup the update shader
  13445. * @param effect defines the update shader
  13446. */
  13447. applyToShader(effect: Effect): void;
  13448. /**
  13449. * Returns a string to use to update the GPU particles update shader
  13450. * @returns a string containng the defines string
  13451. */
  13452. getEffectDefines(): string;
  13453. /**
  13454. * Returns the string "ConeParticleEmitter"
  13455. * @returns a string containing the class name
  13456. */
  13457. getClassName(): string;
  13458. /**
  13459. * Serializes the particle system to a JSON object.
  13460. * @returns the JSON object
  13461. */
  13462. serialize(): any;
  13463. /**
  13464. * Parse properties from a JSON object
  13465. * @param serializationObject defines the JSON object
  13466. */
  13467. parse(serializationObject: any): void;
  13468. }
  13469. }
  13470. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13471. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13472. import { Effect } from "babylonjs/Materials/effect";
  13473. import { Particle } from "babylonjs/Particles/particle";
  13474. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13475. /**
  13476. * Particle emitter emitting particles from the inside of a cylinder.
  13477. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13478. */
  13479. export class CylinderParticleEmitter implements IParticleEmitterType {
  13480. /**
  13481. * The radius of the emission cylinder.
  13482. */
  13483. radius: number;
  13484. /**
  13485. * The height of the emission cylinder.
  13486. */
  13487. height: number;
  13488. /**
  13489. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13490. */
  13491. radiusRange: number;
  13492. /**
  13493. * How much to randomize the particle direction [0-1].
  13494. */
  13495. directionRandomizer: number;
  13496. /**
  13497. * Creates a new instance CylinderParticleEmitter
  13498. * @param radius the radius of the emission cylinder (1 by default)
  13499. * @param height the height of the emission cylinder (1 by default)
  13500. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13501. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13502. */
  13503. constructor(
  13504. /**
  13505. * The radius of the emission cylinder.
  13506. */
  13507. radius?: number,
  13508. /**
  13509. * The height of the emission cylinder.
  13510. */
  13511. height?: number,
  13512. /**
  13513. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13514. */
  13515. radiusRange?: number,
  13516. /**
  13517. * How much to randomize the particle direction [0-1].
  13518. */
  13519. directionRandomizer?: number);
  13520. /**
  13521. * Called by the particle System when the direction is computed for the created particle.
  13522. * @param worldMatrix is the world matrix of the particle system
  13523. * @param directionToUpdate is the direction vector to update with the result
  13524. * @param particle is the particle we are computed the direction for
  13525. * @param isLocal defines if the direction should be set in local space
  13526. */
  13527. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13528. /**
  13529. * Called by the particle System when the position is computed for the created particle.
  13530. * @param worldMatrix is the world matrix of the particle system
  13531. * @param positionToUpdate is the position vector to update with the result
  13532. * @param particle is the particle we are computed the position for
  13533. * @param isLocal defines if the position should be set in local space
  13534. */
  13535. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13536. /**
  13537. * Clones the current emitter and returns a copy of it
  13538. * @returns the new emitter
  13539. */
  13540. clone(): CylinderParticleEmitter;
  13541. /**
  13542. * Called by the GPUParticleSystem to setup the update shader
  13543. * @param effect defines the update shader
  13544. */
  13545. applyToShader(effect: Effect): void;
  13546. /**
  13547. * Returns a string to use to update the GPU particles update shader
  13548. * @returns a string containng the defines string
  13549. */
  13550. getEffectDefines(): string;
  13551. /**
  13552. * Returns the string "CylinderParticleEmitter"
  13553. * @returns a string containing the class name
  13554. */
  13555. getClassName(): string;
  13556. /**
  13557. * Serializes the particle system to a JSON object.
  13558. * @returns the JSON object
  13559. */
  13560. serialize(): any;
  13561. /**
  13562. * Parse properties from a JSON object
  13563. * @param serializationObject defines the JSON object
  13564. */
  13565. parse(serializationObject: any): void;
  13566. }
  13567. /**
  13568. * Particle emitter emitting particles from the inside of a cylinder.
  13569. * It emits the particles randomly between two vectors.
  13570. */
  13571. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13572. /**
  13573. * The min limit of the emission direction.
  13574. */
  13575. direction1: Vector3;
  13576. /**
  13577. * The max limit of the emission direction.
  13578. */
  13579. direction2: Vector3;
  13580. /**
  13581. * Creates a new instance CylinderDirectedParticleEmitter
  13582. * @param radius the radius of the emission cylinder (1 by default)
  13583. * @param height the height of the emission cylinder (1 by default)
  13584. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13585. * @param direction1 the min limit of the emission direction (up vector by default)
  13586. * @param direction2 the max limit of the emission direction (up vector by default)
  13587. */
  13588. constructor(radius?: number, height?: number, radiusRange?: number,
  13589. /**
  13590. * The min limit of the emission direction.
  13591. */
  13592. direction1?: Vector3,
  13593. /**
  13594. * The max limit of the emission direction.
  13595. */
  13596. direction2?: Vector3);
  13597. /**
  13598. * Called by the particle System when the direction is computed for the created particle.
  13599. * @param worldMatrix is the world matrix of the particle system
  13600. * @param directionToUpdate is the direction vector to update with the result
  13601. * @param particle is the particle we are computed the direction for
  13602. */
  13603. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13604. /**
  13605. * Clones the current emitter and returns a copy of it
  13606. * @returns the new emitter
  13607. */
  13608. clone(): CylinderDirectedParticleEmitter;
  13609. /**
  13610. * Called by the GPUParticleSystem to setup the update shader
  13611. * @param effect defines the update shader
  13612. */
  13613. applyToShader(effect: Effect): void;
  13614. /**
  13615. * Returns a string to use to update the GPU particles update shader
  13616. * @returns a string containng the defines string
  13617. */
  13618. getEffectDefines(): string;
  13619. /**
  13620. * Returns the string "CylinderDirectedParticleEmitter"
  13621. * @returns a string containing the class name
  13622. */
  13623. getClassName(): string;
  13624. /**
  13625. * Serializes the particle system to a JSON object.
  13626. * @returns the JSON object
  13627. */
  13628. serialize(): any;
  13629. /**
  13630. * Parse properties from a JSON object
  13631. * @param serializationObject defines the JSON object
  13632. */
  13633. parse(serializationObject: any): void;
  13634. }
  13635. }
  13636. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13637. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13638. import { Effect } from "babylonjs/Materials/effect";
  13639. import { Particle } from "babylonjs/Particles/particle";
  13640. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13641. /**
  13642. * Particle emitter emitting particles from the inside of a hemisphere.
  13643. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13644. */
  13645. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13646. /**
  13647. * The radius of the emission hemisphere.
  13648. */
  13649. radius: number;
  13650. /**
  13651. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13652. */
  13653. radiusRange: number;
  13654. /**
  13655. * How much to randomize the particle direction [0-1].
  13656. */
  13657. directionRandomizer: number;
  13658. /**
  13659. * Creates a new instance HemisphericParticleEmitter
  13660. * @param radius the radius of the emission hemisphere (1 by default)
  13661. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13662. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13663. */
  13664. constructor(
  13665. /**
  13666. * The radius of the emission hemisphere.
  13667. */
  13668. radius?: number,
  13669. /**
  13670. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13671. */
  13672. radiusRange?: number,
  13673. /**
  13674. * How much to randomize the particle direction [0-1].
  13675. */
  13676. directionRandomizer?: number);
  13677. /**
  13678. * Called by the particle System when the direction is computed for the created particle.
  13679. * @param worldMatrix is the world matrix of the particle system
  13680. * @param directionToUpdate is the direction vector to update with the result
  13681. * @param particle is the particle we are computed the direction for
  13682. * @param isLocal defines if the direction should be set in local space
  13683. */
  13684. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13685. /**
  13686. * Called by the particle System when the position is computed for the created particle.
  13687. * @param worldMatrix is the world matrix of the particle system
  13688. * @param positionToUpdate is the position vector to update with the result
  13689. * @param particle is the particle we are computed the position for
  13690. * @param isLocal defines if the position should be set in local space
  13691. */
  13692. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13693. /**
  13694. * Clones the current emitter and returns a copy of it
  13695. * @returns the new emitter
  13696. */
  13697. clone(): HemisphericParticleEmitter;
  13698. /**
  13699. * Called by the GPUParticleSystem to setup the update shader
  13700. * @param effect defines the update shader
  13701. */
  13702. applyToShader(effect: Effect): void;
  13703. /**
  13704. * Returns a string to use to update the GPU particles update shader
  13705. * @returns a string containng the defines string
  13706. */
  13707. getEffectDefines(): string;
  13708. /**
  13709. * Returns the string "HemisphericParticleEmitter"
  13710. * @returns a string containing the class name
  13711. */
  13712. getClassName(): string;
  13713. /**
  13714. * Serializes the particle system to a JSON object.
  13715. * @returns the JSON object
  13716. */
  13717. serialize(): any;
  13718. /**
  13719. * Parse properties from a JSON object
  13720. * @param serializationObject defines the JSON object
  13721. */
  13722. parse(serializationObject: any): void;
  13723. }
  13724. }
  13725. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13726. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13727. import { Effect } from "babylonjs/Materials/effect";
  13728. import { Particle } from "babylonjs/Particles/particle";
  13729. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13730. /**
  13731. * Particle emitter emitting particles from a point.
  13732. * It emits the particles randomly between 2 given directions.
  13733. */
  13734. export class PointParticleEmitter implements IParticleEmitterType {
  13735. /**
  13736. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13737. */
  13738. direction1: Vector3;
  13739. /**
  13740. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13741. */
  13742. direction2: Vector3;
  13743. /**
  13744. * Creates a new instance PointParticleEmitter
  13745. */
  13746. constructor();
  13747. /**
  13748. * Called by the particle System when the direction is computed for the created particle.
  13749. * @param worldMatrix is the world matrix of the particle system
  13750. * @param directionToUpdate is the direction vector to update with the result
  13751. * @param particle is the particle we are computed the direction for
  13752. * @param isLocal defines if the direction should be set in local space
  13753. */
  13754. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13755. /**
  13756. * Called by the particle System when the position is computed for the created particle.
  13757. * @param worldMatrix is the world matrix of the particle system
  13758. * @param positionToUpdate is the position vector to update with the result
  13759. * @param particle is the particle we are computed the position for
  13760. * @param isLocal defines if the position should be set in local space
  13761. */
  13762. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13763. /**
  13764. * Clones the current emitter and returns a copy of it
  13765. * @returns the new emitter
  13766. */
  13767. clone(): PointParticleEmitter;
  13768. /**
  13769. * Called by the GPUParticleSystem to setup the update shader
  13770. * @param effect defines the update shader
  13771. */
  13772. applyToShader(effect: Effect): void;
  13773. /**
  13774. * Returns a string to use to update the GPU particles update shader
  13775. * @returns a string containng the defines string
  13776. */
  13777. getEffectDefines(): string;
  13778. /**
  13779. * Returns the string "PointParticleEmitter"
  13780. * @returns a string containing the class name
  13781. */
  13782. getClassName(): string;
  13783. /**
  13784. * Serializes the particle system to a JSON object.
  13785. * @returns the JSON object
  13786. */
  13787. serialize(): any;
  13788. /**
  13789. * Parse properties from a JSON object
  13790. * @param serializationObject defines the JSON object
  13791. */
  13792. parse(serializationObject: any): void;
  13793. }
  13794. }
  13795. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  13796. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13797. import { Effect } from "babylonjs/Materials/effect";
  13798. import { Particle } from "babylonjs/Particles/particle";
  13799. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13800. /**
  13801. * Particle emitter emitting particles from the inside of a sphere.
  13802. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13803. */
  13804. export class SphereParticleEmitter implements IParticleEmitterType {
  13805. /**
  13806. * The radius of the emission sphere.
  13807. */
  13808. radius: number;
  13809. /**
  13810. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13811. */
  13812. radiusRange: number;
  13813. /**
  13814. * How much to randomize the particle direction [0-1].
  13815. */
  13816. directionRandomizer: number;
  13817. /**
  13818. * Creates a new instance SphereParticleEmitter
  13819. * @param radius the radius of the emission sphere (1 by default)
  13820. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13821. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13822. */
  13823. constructor(
  13824. /**
  13825. * The radius of the emission sphere.
  13826. */
  13827. radius?: number,
  13828. /**
  13829. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13830. */
  13831. radiusRange?: number,
  13832. /**
  13833. * How much to randomize the particle direction [0-1].
  13834. */
  13835. directionRandomizer?: number);
  13836. /**
  13837. * Called by the particle System when the direction is computed for the created particle.
  13838. * @param worldMatrix is the world matrix of the particle system
  13839. * @param directionToUpdate is the direction vector to update with the result
  13840. * @param particle is the particle we are computed the direction for
  13841. * @param isLocal defines if the direction should be set in local space
  13842. */
  13843. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13844. /**
  13845. * Called by the particle System when the position is computed for the created particle.
  13846. * @param worldMatrix is the world matrix of the particle system
  13847. * @param positionToUpdate is the position vector to update with the result
  13848. * @param particle is the particle we are computed the position for
  13849. * @param isLocal defines if the position should be set in local space
  13850. */
  13851. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13852. /**
  13853. * Clones the current emitter and returns a copy of it
  13854. * @returns the new emitter
  13855. */
  13856. clone(): SphereParticleEmitter;
  13857. /**
  13858. * Called by the GPUParticleSystem to setup the update shader
  13859. * @param effect defines the update shader
  13860. */
  13861. applyToShader(effect: Effect): void;
  13862. /**
  13863. * Returns a string to use to update the GPU particles update shader
  13864. * @returns a string containng the defines string
  13865. */
  13866. getEffectDefines(): string;
  13867. /**
  13868. * Returns the string "SphereParticleEmitter"
  13869. * @returns a string containing the class name
  13870. */
  13871. getClassName(): string;
  13872. /**
  13873. * Serializes the particle system to a JSON object.
  13874. * @returns the JSON object
  13875. */
  13876. serialize(): any;
  13877. /**
  13878. * Parse properties from a JSON object
  13879. * @param serializationObject defines the JSON object
  13880. */
  13881. parse(serializationObject: any): void;
  13882. }
  13883. /**
  13884. * Particle emitter emitting particles from the inside of a sphere.
  13885. * It emits the particles randomly between two vectors.
  13886. */
  13887. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13888. /**
  13889. * The min limit of the emission direction.
  13890. */
  13891. direction1: Vector3;
  13892. /**
  13893. * The max limit of the emission direction.
  13894. */
  13895. direction2: Vector3;
  13896. /**
  13897. * Creates a new instance SphereDirectedParticleEmitter
  13898. * @param radius the radius of the emission sphere (1 by default)
  13899. * @param direction1 the min limit of the emission direction (up vector by default)
  13900. * @param direction2 the max limit of the emission direction (up vector by default)
  13901. */
  13902. constructor(radius?: number,
  13903. /**
  13904. * The min limit of the emission direction.
  13905. */
  13906. direction1?: Vector3,
  13907. /**
  13908. * The max limit of the emission direction.
  13909. */
  13910. direction2?: Vector3);
  13911. /**
  13912. * Called by the particle System when the direction is computed for the created particle.
  13913. * @param worldMatrix is the world matrix of the particle system
  13914. * @param directionToUpdate is the direction vector to update with the result
  13915. * @param particle is the particle we are computed the direction for
  13916. */
  13917. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13918. /**
  13919. * Clones the current emitter and returns a copy of it
  13920. * @returns the new emitter
  13921. */
  13922. clone(): SphereDirectedParticleEmitter;
  13923. /**
  13924. * Called by the GPUParticleSystem to setup the update shader
  13925. * @param effect defines the update shader
  13926. */
  13927. applyToShader(effect: Effect): void;
  13928. /**
  13929. * Returns a string to use to update the GPU particles update shader
  13930. * @returns a string containng the defines string
  13931. */
  13932. getEffectDefines(): string;
  13933. /**
  13934. * Returns the string "SphereDirectedParticleEmitter"
  13935. * @returns a string containing the class name
  13936. */
  13937. getClassName(): string;
  13938. /**
  13939. * Serializes the particle system to a JSON object.
  13940. * @returns the JSON object
  13941. */
  13942. serialize(): any;
  13943. /**
  13944. * Parse properties from a JSON object
  13945. * @param serializationObject defines the JSON object
  13946. */
  13947. parse(serializationObject: any): void;
  13948. }
  13949. }
  13950. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13951. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13952. import { Effect } from "babylonjs/Materials/effect";
  13953. import { Particle } from "babylonjs/Particles/particle";
  13954. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13955. import { Nullable } from "babylonjs/types";
  13956. /**
  13957. * Particle emitter emitting particles from a custom list of positions.
  13958. */
  13959. export class CustomParticleEmitter implements IParticleEmitterType {
  13960. /**
  13961. * Gets or sets the position generator that will create the inital position of each particle.
  13962. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13963. */
  13964. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13965. /**
  13966. * Gets or sets the destination generator that will create the final destination of each particle.
  13967. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13968. */
  13969. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13970. /**
  13971. * Creates a new instance CustomParticleEmitter
  13972. */
  13973. constructor();
  13974. /**
  13975. * Called by the particle System when the direction is computed for the created particle.
  13976. * @param worldMatrix is the world matrix of the particle system
  13977. * @param directionToUpdate is the direction vector to update with the result
  13978. * @param particle is the particle we are computed the direction for
  13979. * @param isLocal defines if the direction should be set in local space
  13980. */
  13981. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13982. /**
  13983. * Called by the particle System when the position is computed for the created particle.
  13984. * @param worldMatrix is the world matrix of the particle system
  13985. * @param positionToUpdate is the position vector to update with the result
  13986. * @param particle is the particle we are computed the position for
  13987. * @param isLocal defines if the position should be set in local space
  13988. */
  13989. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13990. /**
  13991. * Clones the current emitter and returns a copy of it
  13992. * @returns the new emitter
  13993. */
  13994. clone(): CustomParticleEmitter;
  13995. /**
  13996. * Called by the GPUParticleSystem to setup the update shader
  13997. * @param effect defines the update shader
  13998. */
  13999. applyToShader(effect: Effect): void;
  14000. /**
  14001. * Returns a string to use to update the GPU particles update shader
  14002. * @returns a string containng the defines string
  14003. */
  14004. getEffectDefines(): string;
  14005. /**
  14006. * Returns the string "PointParticleEmitter"
  14007. * @returns a string containing the class name
  14008. */
  14009. getClassName(): string;
  14010. /**
  14011. * Serializes the particle system to a JSON object.
  14012. * @returns the JSON object
  14013. */
  14014. serialize(): any;
  14015. /**
  14016. * Parse properties from a JSON object
  14017. * @param serializationObject defines the JSON object
  14018. */
  14019. parse(serializationObject: any): void;
  14020. }
  14021. }
  14022. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14023. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14024. import { Effect } from "babylonjs/Materials/effect";
  14025. import { Particle } from "babylonjs/Particles/particle";
  14026. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14027. import { Nullable } from "babylonjs/types";
  14028. import { Scene } from "babylonjs/scene";
  14029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14030. /**
  14031. * Particle emitter emitting particles from the inside of a box.
  14032. * It emits the particles randomly between 2 given directions.
  14033. */
  14034. export class MeshParticleEmitter implements IParticleEmitterType {
  14035. private _indices;
  14036. private _positions;
  14037. private _normals;
  14038. private _storedNormal;
  14039. private _mesh;
  14040. /**
  14041. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14042. */
  14043. direction1: Vector3;
  14044. /**
  14045. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14046. */
  14047. direction2: Vector3;
  14048. /**
  14049. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14050. */
  14051. useMeshNormalsForDirection: boolean;
  14052. /** Defines the mesh to use as source */
  14053. get mesh(): Nullable<AbstractMesh>;
  14054. set mesh(value: Nullable<AbstractMesh>);
  14055. /**
  14056. * Creates a new instance MeshParticleEmitter
  14057. * @param mesh defines the mesh to use as source
  14058. */
  14059. constructor(mesh?: Nullable<AbstractMesh>);
  14060. /**
  14061. * Called by the particle System when the direction is computed for the created particle.
  14062. * @param worldMatrix is the world matrix of the particle system
  14063. * @param directionToUpdate is the direction vector to update with the result
  14064. * @param particle is the particle we are computed the direction for
  14065. * @param isLocal defines if the direction should be set in local space
  14066. */
  14067. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14068. /**
  14069. * Called by the particle System when the position is computed for the created particle.
  14070. * @param worldMatrix is the world matrix of the particle system
  14071. * @param positionToUpdate is the position vector to update with the result
  14072. * @param particle is the particle we are computed the position for
  14073. * @param isLocal defines if the position should be set in local space
  14074. */
  14075. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14076. /**
  14077. * Clones the current emitter and returns a copy of it
  14078. * @returns the new emitter
  14079. */
  14080. clone(): MeshParticleEmitter;
  14081. /**
  14082. * Called by the GPUParticleSystem to setup the update shader
  14083. * @param effect defines the update shader
  14084. */
  14085. applyToShader(effect: Effect): void;
  14086. /**
  14087. * Returns a string to use to update the GPU particles update shader
  14088. * @returns a string containng the defines string
  14089. */
  14090. getEffectDefines(): string;
  14091. /**
  14092. * Returns the string "BoxParticleEmitter"
  14093. * @returns a string containing the class name
  14094. */
  14095. getClassName(): string;
  14096. /**
  14097. * Serializes the particle system to a JSON object.
  14098. * @returns the JSON object
  14099. */
  14100. serialize(): any;
  14101. /**
  14102. * Parse properties from a JSON object
  14103. * @param serializationObject defines the JSON object
  14104. * @param scene defines the hosting scene
  14105. */
  14106. parse(serializationObject: any, scene: Scene): void;
  14107. }
  14108. }
  14109. declare module "babylonjs/Particles/EmitterTypes/index" {
  14110. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14111. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14112. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14113. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14114. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14115. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14116. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14117. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14118. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14119. }
  14120. declare module "babylonjs/Particles/IParticleSystem" {
  14121. import { Nullable } from "babylonjs/types";
  14122. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  14123. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14124. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14125. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14126. import { Texture } from "babylonjs/Materials/Textures/texture";
  14127. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14128. import { Scene } from "babylonjs/scene";
  14129. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14130. import { Effect } from "babylonjs/Materials/effect";
  14131. import { Observable } from "babylonjs/Misc/observable";
  14132. import { Animation } from "babylonjs/Animations/animation";
  14133. /**
  14134. * Interface representing a particle system in Babylon.js.
  14135. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14136. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14137. */
  14138. export interface IParticleSystem {
  14139. /**
  14140. * List of animations used by the particle system.
  14141. */
  14142. animations: Animation[];
  14143. /**
  14144. * The id of the Particle system.
  14145. */
  14146. id: string;
  14147. /**
  14148. * The name of the Particle system.
  14149. */
  14150. name: string;
  14151. /**
  14152. * The emitter represents the Mesh or position we are attaching the particle system to.
  14153. */
  14154. emitter: Nullable<AbstractMesh | Vector3>;
  14155. /**
  14156. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14157. */
  14158. isBillboardBased: boolean;
  14159. /**
  14160. * The rendering group used by the Particle system to chose when to render.
  14161. */
  14162. renderingGroupId: number;
  14163. /**
  14164. * The layer mask we are rendering the particles through.
  14165. */
  14166. layerMask: number;
  14167. /**
  14168. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14169. */
  14170. updateSpeed: number;
  14171. /**
  14172. * The amount of time the particle system is running (depends of the overall update speed).
  14173. */
  14174. targetStopDuration: number;
  14175. /**
  14176. * The texture used to render each particle. (this can be a spritesheet)
  14177. */
  14178. particleTexture: Nullable<Texture>;
  14179. /**
  14180. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14181. */
  14182. blendMode: number;
  14183. /**
  14184. * Minimum life time of emitting particles.
  14185. */
  14186. minLifeTime: number;
  14187. /**
  14188. * Maximum life time of emitting particles.
  14189. */
  14190. maxLifeTime: number;
  14191. /**
  14192. * Minimum Size of emitting particles.
  14193. */
  14194. minSize: number;
  14195. /**
  14196. * Maximum Size of emitting particles.
  14197. */
  14198. maxSize: number;
  14199. /**
  14200. * Minimum scale of emitting particles on X axis.
  14201. */
  14202. minScaleX: number;
  14203. /**
  14204. * Maximum scale of emitting particles on X axis.
  14205. */
  14206. maxScaleX: number;
  14207. /**
  14208. * Minimum scale of emitting particles on Y axis.
  14209. */
  14210. minScaleY: number;
  14211. /**
  14212. * Maximum scale of emitting particles on Y axis.
  14213. */
  14214. maxScaleY: number;
  14215. /**
  14216. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14217. */
  14218. color1: Color4;
  14219. /**
  14220. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14221. */
  14222. color2: Color4;
  14223. /**
  14224. * Color the particle will have at the end of its lifetime.
  14225. */
  14226. colorDead: Color4;
  14227. /**
  14228. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14229. */
  14230. emitRate: number;
  14231. /**
  14232. * You can use gravity if you want to give an orientation to your particles.
  14233. */
  14234. gravity: Vector3;
  14235. /**
  14236. * Minimum power of emitting particles.
  14237. */
  14238. minEmitPower: number;
  14239. /**
  14240. * Maximum power of emitting particles.
  14241. */
  14242. maxEmitPower: number;
  14243. /**
  14244. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14245. */
  14246. minAngularSpeed: number;
  14247. /**
  14248. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14249. */
  14250. maxAngularSpeed: number;
  14251. /**
  14252. * Gets or sets the minimal initial rotation in radians.
  14253. */
  14254. minInitialRotation: number;
  14255. /**
  14256. * Gets or sets the maximal initial rotation in radians.
  14257. */
  14258. maxInitialRotation: number;
  14259. /**
  14260. * The particle emitter type defines the emitter used by the particle system.
  14261. * It can be for example box, sphere, or cone...
  14262. */
  14263. particleEmitterType: Nullable<IParticleEmitterType>;
  14264. /**
  14265. * Defines the delay in milliseconds before starting the system (0 by default)
  14266. */
  14267. startDelay: number;
  14268. /**
  14269. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  14270. */
  14271. preWarmCycles: number;
  14272. /**
  14273. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14274. */
  14275. preWarmStepOffset: number;
  14276. /**
  14277. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  14278. */
  14279. spriteCellChangeSpeed: number;
  14280. /**
  14281. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14282. */
  14283. startSpriteCellID: number;
  14284. /**
  14285. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14286. */
  14287. endSpriteCellID: number;
  14288. /**
  14289. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14290. */
  14291. spriteCellWidth: number;
  14292. /**
  14293. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14294. */
  14295. spriteCellHeight: number;
  14296. /**
  14297. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14298. */
  14299. spriteRandomStartCell: boolean;
  14300. /**
  14301. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14302. */
  14303. isAnimationSheetEnabled: boolean;
  14304. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14305. translationPivot: Vector2;
  14306. /**
  14307. * Gets or sets a texture used to add random noise to particle positions
  14308. */
  14309. noiseTexture: Nullable<BaseTexture>;
  14310. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14311. noiseStrength: Vector3;
  14312. /**
  14313. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14314. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14315. */
  14316. billboardMode: number;
  14317. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14318. limitVelocityDamping: number;
  14319. /**
  14320. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14321. */
  14322. beginAnimationOnStart: boolean;
  14323. /**
  14324. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14325. */
  14326. beginAnimationFrom: number;
  14327. /**
  14328. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14329. */
  14330. beginAnimationTo: number;
  14331. /**
  14332. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14333. */
  14334. beginAnimationLoop: boolean;
  14335. /**
  14336. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14337. */
  14338. disposeOnStop: boolean;
  14339. /**
  14340. * Specifies if the particles are updated in emitter local space or world space
  14341. */
  14342. isLocal: boolean;
  14343. /** Snippet ID if the particle system was created from the snippet server */
  14344. snippetId: string;
  14345. /**
  14346. * Gets the maximum number of particles active at the same time.
  14347. * @returns The max number of active particles.
  14348. */
  14349. getCapacity(): number;
  14350. /**
  14351. * Gets the number of particles active at the same time.
  14352. * @returns The number of active particles.
  14353. */
  14354. getActiveCount(): number;
  14355. /**
  14356. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14357. * @returns True if it has been started, otherwise false.
  14358. */
  14359. isStarted(): boolean;
  14360. /**
  14361. * Animates the particle system for this frame.
  14362. */
  14363. animate(): void;
  14364. /**
  14365. * Renders the particle system in its current state.
  14366. * @returns the current number of particles
  14367. */
  14368. render(): number;
  14369. /**
  14370. * Dispose the particle system and frees its associated resources.
  14371. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14372. */
  14373. dispose(disposeTexture?: boolean): void;
  14374. /**
  14375. * An event triggered when the system is disposed
  14376. */
  14377. onDisposeObservable: Observable<IParticleSystem>;
  14378. /**
  14379. * Clones the particle system.
  14380. * @param name The name of the cloned object
  14381. * @param newEmitter The new emitter to use
  14382. * @returns the cloned particle system
  14383. */
  14384. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14385. /**
  14386. * Serializes the particle system to a JSON object
  14387. * @param serializeTexture defines if the texture must be serialized as well
  14388. * @returns the JSON object
  14389. */
  14390. serialize(serializeTexture: boolean): any;
  14391. /**
  14392. * Rebuild the particle system
  14393. */
  14394. rebuild(): void;
  14395. /** Force the system to rebuild all gradients that need to be resync */
  14396. forceRefreshGradients(): void;
  14397. /**
  14398. * Starts the particle system and begins to emit
  14399. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14400. */
  14401. start(delay?: number): void;
  14402. /**
  14403. * Stops the particle system.
  14404. */
  14405. stop(): void;
  14406. /**
  14407. * Remove all active particles
  14408. */
  14409. reset(): void;
  14410. /**
  14411. * Gets a boolean indicating that the system is stopping
  14412. * @returns true if the system is currently stopping
  14413. */
  14414. isStopping(): boolean;
  14415. /**
  14416. * Is this system ready to be used/rendered
  14417. * @return true if the system is ready
  14418. */
  14419. isReady(): boolean;
  14420. /**
  14421. * Returns the string "ParticleSystem"
  14422. * @returns a string containing the class name
  14423. */
  14424. getClassName(): string;
  14425. /**
  14426. * Gets the custom effect used to render the particles
  14427. * @param blendMode Blend mode for which the effect should be retrieved
  14428. * @returns The effect
  14429. */
  14430. getCustomEffect(blendMode: number): Nullable<Effect>;
  14431. /**
  14432. * Sets the custom effect used to render the particles
  14433. * @param effect The effect to set
  14434. * @param blendMode Blend mode for which the effect should be set
  14435. */
  14436. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14437. /**
  14438. * Fill the defines array according to the current settings of the particle system
  14439. * @param defines Array to be updated
  14440. * @param blendMode blend mode to take into account when updating the array
  14441. */
  14442. fillDefines(defines: Array<string>, blendMode: number): void;
  14443. /**
  14444. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14445. * @param uniforms Uniforms array to fill
  14446. * @param attributes Attributes array to fill
  14447. * @param samplers Samplers array to fill
  14448. */
  14449. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14450. /**
  14451. * Observable that will be called just before the particles are drawn
  14452. */
  14453. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14454. /**
  14455. * Gets the name of the particle vertex shader
  14456. */
  14457. vertexShaderName: string;
  14458. /**
  14459. * Adds a new color gradient
  14460. * @param gradient defines the gradient to use (between 0 and 1)
  14461. * @param color1 defines the color to affect to the specified gradient
  14462. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14463. * @returns the current particle system
  14464. */
  14465. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14466. /**
  14467. * Remove a specific color gradient
  14468. * @param gradient defines the gradient to remove
  14469. * @returns the current particle system
  14470. */
  14471. removeColorGradient(gradient: number): IParticleSystem;
  14472. /**
  14473. * Adds a new size gradient
  14474. * @param gradient defines the gradient to use (between 0 and 1)
  14475. * @param factor defines the size factor to affect to the specified gradient
  14476. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14477. * @returns the current particle system
  14478. */
  14479. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14480. /**
  14481. * Remove a specific size gradient
  14482. * @param gradient defines the gradient to remove
  14483. * @returns the current particle system
  14484. */
  14485. removeSizeGradient(gradient: number): IParticleSystem;
  14486. /**
  14487. * Gets the current list of color gradients.
  14488. * You must use addColorGradient and removeColorGradient to udpate this list
  14489. * @returns the list of color gradients
  14490. */
  14491. getColorGradients(): Nullable<Array<ColorGradient>>;
  14492. /**
  14493. * Gets the current list of size gradients.
  14494. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14495. * @returns the list of size gradients
  14496. */
  14497. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14498. /**
  14499. * Gets the current list of angular speed gradients.
  14500. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14501. * @returns the list of angular speed gradients
  14502. */
  14503. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14504. /**
  14505. * Adds a new angular speed gradient
  14506. * @param gradient defines the gradient to use (between 0 and 1)
  14507. * @param factor defines the angular speed to affect to the specified gradient
  14508. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14509. * @returns the current particle system
  14510. */
  14511. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14512. /**
  14513. * Remove a specific angular speed gradient
  14514. * @param gradient defines the gradient to remove
  14515. * @returns the current particle system
  14516. */
  14517. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14518. /**
  14519. * Gets the current list of velocity gradients.
  14520. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14521. * @returns the list of velocity gradients
  14522. */
  14523. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14524. /**
  14525. * Adds a new velocity gradient
  14526. * @param gradient defines the gradient to use (between 0 and 1)
  14527. * @param factor defines the velocity to affect to the specified gradient
  14528. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14529. * @returns the current particle system
  14530. */
  14531. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14532. /**
  14533. * Remove a specific velocity gradient
  14534. * @param gradient defines the gradient to remove
  14535. * @returns the current particle system
  14536. */
  14537. removeVelocityGradient(gradient: number): IParticleSystem;
  14538. /**
  14539. * Gets the current list of limit velocity gradients.
  14540. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14541. * @returns the list of limit velocity gradients
  14542. */
  14543. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14544. /**
  14545. * Adds a new limit velocity gradient
  14546. * @param gradient defines the gradient to use (between 0 and 1)
  14547. * @param factor defines the limit velocity to affect to the specified gradient
  14548. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14549. * @returns the current particle system
  14550. */
  14551. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14552. /**
  14553. * Remove a specific limit velocity gradient
  14554. * @param gradient defines the gradient to remove
  14555. * @returns the current particle system
  14556. */
  14557. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14558. /**
  14559. * Adds a new drag gradient
  14560. * @param gradient defines the gradient to use (between 0 and 1)
  14561. * @param factor defines the drag to affect to the specified gradient
  14562. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14563. * @returns the current particle system
  14564. */
  14565. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14566. /**
  14567. * Remove a specific drag gradient
  14568. * @param gradient defines the gradient to remove
  14569. * @returns the current particle system
  14570. */
  14571. removeDragGradient(gradient: number): IParticleSystem;
  14572. /**
  14573. * Gets the current list of drag gradients.
  14574. * You must use addDragGradient and removeDragGradient to udpate this list
  14575. * @returns the list of drag gradients
  14576. */
  14577. getDragGradients(): Nullable<Array<FactorGradient>>;
  14578. /**
  14579. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14580. * @param gradient defines the gradient to use (between 0 and 1)
  14581. * @param factor defines the emit rate to affect to the specified gradient
  14582. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14583. * @returns the current particle system
  14584. */
  14585. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14586. /**
  14587. * Remove a specific emit rate gradient
  14588. * @param gradient defines the gradient to remove
  14589. * @returns the current particle system
  14590. */
  14591. removeEmitRateGradient(gradient: number): IParticleSystem;
  14592. /**
  14593. * Gets the current list of emit rate gradients.
  14594. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14595. * @returns the list of emit rate gradients
  14596. */
  14597. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14598. /**
  14599. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14600. * @param gradient defines the gradient to use (between 0 and 1)
  14601. * @param factor defines the start size to affect to the specified gradient
  14602. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14603. * @returns the current particle system
  14604. */
  14605. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14606. /**
  14607. * Remove a specific start size gradient
  14608. * @param gradient defines the gradient to remove
  14609. * @returns the current particle system
  14610. */
  14611. removeStartSizeGradient(gradient: number): IParticleSystem;
  14612. /**
  14613. * Gets the current list of start size gradients.
  14614. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14615. * @returns the list of start size gradients
  14616. */
  14617. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14618. /**
  14619. * Adds a new life time gradient
  14620. * @param gradient defines the gradient to use (between 0 and 1)
  14621. * @param factor defines the life time factor to affect to the specified gradient
  14622. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14623. * @returns the current particle system
  14624. */
  14625. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14626. /**
  14627. * Remove a specific life time gradient
  14628. * @param gradient defines the gradient to remove
  14629. * @returns the current particle system
  14630. */
  14631. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14632. /**
  14633. * Gets the current list of life time gradients.
  14634. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14635. * @returns the list of life time gradients
  14636. */
  14637. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14638. /**
  14639. * Gets the current list of color gradients.
  14640. * You must use addColorGradient and removeColorGradient to udpate this list
  14641. * @returns the list of color gradients
  14642. */
  14643. getColorGradients(): Nullable<Array<ColorGradient>>;
  14644. /**
  14645. * Adds a new ramp gradient used to remap particle colors
  14646. * @param gradient defines the gradient to use (between 0 and 1)
  14647. * @param color defines the color to affect to the specified gradient
  14648. * @returns the current particle system
  14649. */
  14650. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14651. /**
  14652. * Gets the current list of ramp gradients.
  14653. * You must use addRampGradient and removeRampGradient to udpate this list
  14654. * @returns the list of ramp gradients
  14655. */
  14656. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14657. /** Gets or sets a boolean indicating that ramp gradients must be used
  14658. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14659. */
  14660. useRampGradients: boolean;
  14661. /**
  14662. * Adds a new color remap gradient
  14663. * @param gradient defines the gradient to use (between 0 and 1)
  14664. * @param min defines the color remap minimal range
  14665. * @param max defines the color remap maximal range
  14666. * @returns the current particle system
  14667. */
  14668. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14669. /**
  14670. * Gets the current list of color remap gradients.
  14671. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14672. * @returns the list of color remap gradients
  14673. */
  14674. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14675. /**
  14676. * Adds a new alpha remap gradient
  14677. * @param gradient defines the gradient to use (between 0 and 1)
  14678. * @param min defines the alpha remap minimal range
  14679. * @param max defines the alpha remap maximal range
  14680. * @returns the current particle system
  14681. */
  14682. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14683. /**
  14684. * Gets the current list of alpha remap gradients.
  14685. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14686. * @returns the list of alpha remap gradients
  14687. */
  14688. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14689. /**
  14690. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14691. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14692. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14693. * @returns the emitter
  14694. */
  14695. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14696. /**
  14697. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14698. * @param radius The radius of the hemisphere to emit from
  14699. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14700. * @returns the emitter
  14701. */
  14702. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14703. /**
  14704. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14705. * @param radius The radius of the sphere to emit from
  14706. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14707. * @returns the emitter
  14708. */
  14709. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14710. /**
  14711. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14712. * @param radius The radius of the sphere to emit from
  14713. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14714. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14715. * @returns the emitter
  14716. */
  14717. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14718. /**
  14719. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14720. * @param radius The radius of the emission cylinder
  14721. * @param height The height of the emission cylinder
  14722. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14723. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14724. * @returns the emitter
  14725. */
  14726. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14727. /**
  14728. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14729. * @param radius The radius of the cylinder to emit from
  14730. * @param height The height of the emission cylinder
  14731. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14732. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14733. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14734. * @returns the emitter
  14735. */
  14736. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14737. /**
  14738. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14739. * @param radius The radius of the cone to emit from
  14740. * @param angle The base angle of the cone
  14741. * @returns the emitter
  14742. */
  14743. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14744. /**
  14745. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14746. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14747. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14748. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14749. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14750. * @returns the emitter
  14751. */
  14752. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14753. /**
  14754. * Get hosting scene
  14755. * @returns the scene
  14756. */
  14757. getScene(): Scene;
  14758. }
  14759. }
  14760. declare module "babylonjs/Meshes/transformNode" {
  14761. import { DeepImmutable } from "babylonjs/types";
  14762. import { Observable } from "babylonjs/Misc/observable";
  14763. import { Nullable } from "babylonjs/types";
  14764. import { Camera } from "babylonjs/Cameras/camera";
  14765. import { Scene } from "babylonjs/scene";
  14766. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14767. import { Node } from "babylonjs/node";
  14768. import { Bone } from "babylonjs/Bones/bone";
  14769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14770. import { Space } from "babylonjs/Maths/math.axis";
  14771. /**
  14772. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  14773. * @see https://doc.babylonjs.com/how_to/transformnode
  14774. */
  14775. export class TransformNode extends Node {
  14776. /**
  14777. * Object will not rotate to face the camera
  14778. */
  14779. static BILLBOARDMODE_NONE: number;
  14780. /**
  14781. * Object will rotate to face the camera but only on the x axis
  14782. */
  14783. static BILLBOARDMODE_X: number;
  14784. /**
  14785. * Object will rotate to face the camera but only on the y axis
  14786. */
  14787. static BILLBOARDMODE_Y: number;
  14788. /**
  14789. * Object will rotate to face the camera but only on the z axis
  14790. */
  14791. static BILLBOARDMODE_Z: number;
  14792. /**
  14793. * Object will rotate to face the camera
  14794. */
  14795. static BILLBOARDMODE_ALL: number;
  14796. /**
  14797. * Object will rotate to face the camera's position instead of orientation
  14798. */
  14799. static BILLBOARDMODE_USE_POSITION: number;
  14800. private static _TmpRotation;
  14801. private static _TmpScaling;
  14802. private static _TmpTranslation;
  14803. private _forward;
  14804. private _forwardInverted;
  14805. private _up;
  14806. private _right;
  14807. private _rightInverted;
  14808. private _position;
  14809. private _rotation;
  14810. private _rotationQuaternion;
  14811. protected _scaling: Vector3;
  14812. protected _isDirty: boolean;
  14813. private _transformToBoneReferal;
  14814. private _isAbsoluteSynced;
  14815. private _billboardMode;
  14816. /**
  14817. * Gets or sets the billboard mode. Default is 0.
  14818. *
  14819. * | Value | Type | Description |
  14820. * | --- | --- | --- |
  14821. * | 0 | BILLBOARDMODE_NONE | |
  14822. * | 1 | BILLBOARDMODE_X | |
  14823. * | 2 | BILLBOARDMODE_Y | |
  14824. * | 4 | BILLBOARDMODE_Z | |
  14825. * | 7 | BILLBOARDMODE_ALL | |
  14826. *
  14827. */
  14828. get billboardMode(): number;
  14829. set billboardMode(value: number);
  14830. private _preserveParentRotationForBillboard;
  14831. /**
  14832. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14833. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14834. */
  14835. get preserveParentRotationForBillboard(): boolean;
  14836. set preserveParentRotationForBillboard(value: boolean);
  14837. /**
  14838. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  14839. */
  14840. scalingDeterminant: number;
  14841. private _infiniteDistance;
  14842. /**
  14843. * Gets or sets the distance of the object to max, often used by skybox
  14844. */
  14845. get infiniteDistance(): boolean;
  14846. set infiniteDistance(value: boolean);
  14847. /**
  14848. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14849. * By default the system will update normals to compensate
  14850. */
  14851. ignoreNonUniformScaling: boolean;
  14852. /**
  14853. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  14854. */
  14855. reIntegrateRotationIntoRotationQuaternion: boolean;
  14856. /** @hidden */
  14857. _poseMatrix: Nullable<Matrix>;
  14858. /** @hidden */
  14859. _localMatrix: Matrix;
  14860. private _usePivotMatrix;
  14861. private _absolutePosition;
  14862. private _absoluteScaling;
  14863. private _absoluteRotationQuaternion;
  14864. private _pivotMatrix;
  14865. private _pivotMatrixInverse;
  14866. protected _postMultiplyPivotMatrix: boolean;
  14867. protected _isWorldMatrixFrozen: boolean;
  14868. /** @hidden */
  14869. _indexInSceneTransformNodesArray: number;
  14870. /**
  14871. * An event triggered after the world matrix is updated
  14872. */
  14873. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14874. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14875. /**
  14876. * Gets a string identifying the name of the class
  14877. * @returns "TransformNode" string
  14878. */
  14879. getClassName(): string;
  14880. /**
  14881. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14882. */
  14883. get position(): Vector3;
  14884. set position(newPosition: Vector3);
  14885. /**
  14886. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14887. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14888. */
  14889. get rotation(): Vector3;
  14890. set rotation(newRotation: Vector3);
  14891. /**
  14892. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14893. */
  14894. get scaling(): Vector3;
  14895. set scaling(newScaling: Vector3);
  14896. /**
  14897. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  14898. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14899. */
  14900. get rotationQuaternion(): Nullable<Quaternion>;
  14901. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14902. /**
  14903. * The forward direction of that transform in world space.
  14904. */
  14905. get forward(): Vector3;
  14906. /**
  14907. * The up direction of that transform in world space.
  14908. */
  14909. get up(): Vector3;
  14910. /**
  14911. * The right direction of that transform in world space.
  14912. */
  14913. get right(): Vector3;
  14914. /**
  14915. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14916. * @param matrix the matrix to copy the pose from
  14917. * @returns this TransformNode.
  14918. */
  14919. updatePoseMatrix(matrix: Matrix): TransformNode;
  14920. /**
  14921. * Returns the mesh Pose matrix.
  14922. * @returns the pose matrix
  14923. */
  14924. getPoseMatrix(): Matrix;
  14925. /** @hidden */
  14926. _isSynchronized(): boolean;
  14927. /** @hidden */
  14928. _initCache(): void;
  14929. /**
  14930. * Flag the transform node as dirty (Forcing it to update everything)
  14931. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14932. * @returns this transform node
  14933. */
  14934. markAsDirty(property: string): TransformNode;
  14935. /**
  14936. * Returns the current mesh absolute position.
  14937. * Returns a Vector3.
  14938. */
  14939. get absolutePosition(): Vector3;
  14940. /**
  14941. * Returns the current mesh absolute scaling.
  14942. * Returns a Vector3.
  14943. */
  14944. get absoluteScaling(): Vector3;
  14945. /**
  14946. * Returns the current mesh absolute rotation.
  14947. * Returns a Quaternion.
  14948. */
  14949. get absoluteRotationQuaternion(): Quaternion;
  14950. /**
  14951. * Sets a new matrix to apply before all other transformation
  14952. * @param matrix defines the transform matrix
  14953. * @returns the current TransformNode
  14954. */
  14955. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14956. /**
  14957. * Sets a new pivot matrix to the current node
  14958. * @param matrix defines the new pivot matrix to use
  14959. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  14960. * @returns the current TransformNode
  14961. */
  14962. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14963. /**
  14964. * Returns the mesh pivot matrix.
  14965. * Default : Identity.
  14966. * @returns the matrix
  14967. */
  14968. getPivotMatrix(): Matrix;
  14969. /**
  14970. * Instantiate (when possible) or clone that node with its hierarchy
  14971. * @param newParent defines the new parent to use for the instance (or clone)
  14972. * @param options defines options to configure how copy is done
  14973. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14974. * @returns an instance (or a clone) of the current node with its hiearchy
  14975. */
  14976. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14977. doNotInstantiate: boolean;
  14978. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14979. /**
  14980. * Prevents the World matrix to be computed any longer
  14981. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14982. * @returns the TransformNode.
  14983. */
  14984. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14985. /**
  14986. * Allows back the World matrix computation.
  14987. * @returns the TransformNode.
  14988. */
  14989. unfreezeWorldMatrix(): this;
  14990. /**
  14991. * True if the World matrix has been frozen.
  14992. */
  14993. get isWorldMatrixFrozen(): boolean;
  14994. /**
  14995. * Retuns the mesh absolute position in the World.
  14996. * @returns a Vector3.
  14997. */
  14998. getAbsolutePosition(): Vector3;
  14999. /**
  15000. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15001. * @param absolutePosition the absolute position to set
  15002. * @returns the TransformNode.
  15003. */
  15004. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15005. /**
  15006. * Sets the mesh position in its local space.
  15007. * @param vector3 the position to set in localspace
  15008. * @returns the TransformNode.
  15009. */
  15010. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15011. /**
  15012. * Returns the mesh position in the local space from the current World matrix values.
  15013. * @returns a new Vector3.
  15014. */
  15015. getPositionExpressedInLocalSpace(): Vector3;
  15016. /**
  15017. * Translates the mesh along the passed Vector3 in its local space.
  15018. * @param vector3 the distance to translate in localspace
  15019. * @returns the TransformNode.
  15020. */
  15021. locallyTranslate(vector3: Vector3): TransformNode;
  15022. private static _lookAtVectorCache;
  15023. /**
  15024. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15025. * @param targetPoint the position (must be in same space as current mesh) to look at
  15026. * @param yawCor optional yaw (y-axis) correction in radians
  15027. * @param pitchCor optional pitch (x-axis) correction in radians
  15028. * @param rollCor optional roll (z-axis) correction in radians
  15029. * @param space the choosen space of the target
  15030. * @returns the TransformNode.
  15031. */
  15032. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15033. /**
  15034. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15035. * This Vector3 is expressed in the World space.
  15036. * @param localAxis axis to rotate
  15037. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15038. */
  15039. getDirection(localAxis: Vector3): Vector3;
  15040. /**
  15041. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15042. * localAxis is expressed in the mesh local space.
  15043. * result is computed in the Wordl space from the mesh World matrix.
  15044. * @param localAxis axis to rotate
  15045. * @param result the resulting transformnode
  15046. * @returns this TransformNode.
  15047. */
  15048. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15049. /**
  15050. * Sets this transform node rotation to the given local axis.
  15051. * @param localAxis the axis in local space
  15052. * @param yawCor optional yaw (y-axis) correction in radians
  15053. * @param pitchCor optional pitch (x-axis) correction in radians
  15054. * @param rollCor optional roll (z-axis) correction in radians
  15055. * @returns this TransformNode
  15056. */
  15057. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15058. /**
  15059. * Sets a new pivot point to the current node
  15060. * @param point defines the new pivot point to use
  15061. * @param space defines if the point is in world or local space (local by default)
  15062. * @returns the current TransformNode
  15063. */
  15064. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15065. /**
  15066. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15067. * @returns the pivot point
  15068. */
  15069. getPivotPoint(): Vector3;
  15070. /**
  15071. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15072. * @param result the vector3 to store the result
  15073. * @returns this TransformNode.
  15074. */
  15075. getPivotPointToRef(result: Vector3): TransformNode;
  15076. /**
  15077. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15078. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15079. */
  15080. getAbsolutePivotPoint(): Vector3;
  15081. /**
  15082. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15083. * @param result vector3 to store the result
  15084. * @returns this TransformNode.
  15085. */
  15086. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15087. /**
  15088. * Defines the passed node as the parent of the current node.
  15089. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15090. * @see https://doc.babylonjs.com/how_to/parenting
  15091. * @param node the node ot set as the parent
  15092. * @returns this TransformNode.
  15093. */
  15094. setParent(node: Nullable<Node>): TransformNode;
  15095. private _nonUniformScaling;
  15096. /**
  15097. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15098. */
  15099. get nonUniformScaling(): boolean;
  15100. /** @hidden */
  15101. _updateNonUniformScalingState(value: boolean): boolean;
  15102. /**
  15103. * Attach the current TransformNode to another TransformNode associated with a bone
  15104. * @param bone Bone affecting the TransformNode
  15105. * @param affectedTransformNode TransformNode associated with the bone
  15106. * @returns this object
  15107. */
  15108. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15109. /**
  15110. * Detach the transform node if its associated with a bone
  15111. * @returns this object
  15112. */
  15113. detachFromBone(): TransformNode;
  15114. private static _rotationAxisCache;
  15115. /**
  15116. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15117. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15118. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15119. * The passed axis is also normalized.
  15120. * @param axis the axis to rotate around
  15121. * @param amount the amount to rotate in radians
  15122. * @param space Space to rotate in (Default: local)
  15123. * @returns the TransformNode.
  15124. */
  15125. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15126. /**
  15127. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15128. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15129. * The passed axis is also normalized. .
  15130. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15131. * @param point the point to rotate around
  15132. * @param axis the axis to rotate around
  15133. * @param amount the amount to rotate in radians
  15134. * @returns the TransformNode
  15135. */
  15136. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15137. /**
  15138. * Translates the mesh along the axis vector for the passed distance in the given space.
  15139. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15140. * @param axis the axis to translate in
  15141. * @param distance the distance to translate
  15142. * @param space Space to rotate in (Default: local)
  15143. * @returns the TransformNode.
  15144. */
  15145. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15146. /**
  15147. * Adds a rotation step to the mesh current rotation.
  15148. * x, y, z are Euler angles expressed in radians.
  15149. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15150. * This means this rotation is made in the mesh local space only.
  15151. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15152. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15153. * ```javascript
  15154. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15155. * ```
  15156. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15157. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  15158. * @param x Rotation to add
  15159. * @param y Rotation to add
  15160. * @param z Rotation to add
  15161. * @returns the TransformNode.
  15162. */
  15163. addRotation(x: number, y: number, z: number): TransformNode;
  15164. /**
  15165. * @hidden
  15166. */
  15167. protected _getEffectiveParent(): Nullable<Node>;
  15168. /**
  15169. * Computes the world matrix of the node
  15170. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15171. * @returns the world matrix
  15172. */
  15173. computeWorldMatrix(force?: boolean): Matrix;
  15174. /**
  15175. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15176. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15177. */
  15178. resetLocalMatrix(independentOfChildren?: boolean): void;
  15179. protected _afterComputeWorldMatrix(): void;
  15180. /**
  15181. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15182. * @param func callback function to add
  15183. *
  15184. * @returns the TransformNode.
  15185. */
  15186. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15187. /**
  15188. * Removes a registered callback function.
  15189. * @param func callback function to remove
  15190. * @returns the TransformNode.
  15191. */
  15192. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15193. /**
  15194. * Gets the position of the current mesh in camera space
  15195. * @param camera defines the camera to use
  15196. * @returns a position
  15197. */
  15198. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15199. /**
  15200. * Returns the distance from the mesh to the active camera
  15201. * @param camera defines the camera to use
  15202. * @returns the distance
  15203. */
  15204. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15205. /**
  15206. * Clone the current transform node
  15207. * @param name Name of the new clone
  15208. * @param newParent New parent for the clone
  15209. * @param doNotCloneChildren Do not clone children hierarchy
  15210. * @returns the new transform node
  15211. */
  15212. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15213. /**
  15214. * Serializes the objects information.
  15215. * @param currentSerializationObject defines the object to serialize in
  15216. * @returns the serialized object
  15217. */
  15218. serialize(currentSerializationObject?: any): any;
  15219. /**
  15220. * Returns a new TransformNode object parsed from the source provided.
  15221. * @param parsedTransformNode is the source.
  15222. * @param scene the scne the object belongs to
  15223. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15224. * @returns a new TransformNode object parsed from the source provided.
  15225. */
  15226. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15227. /**
  15228. * Get all child-transformNodes of this node
  15229. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  15230. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  15231. * @returns an array of TransformNode
  15232. */
  15233. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15234. /**
  15235. * Releases resources associated with this transform node.
  15236. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15237. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15238. */
  15239. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15240. /**
  15241. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15242. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15243. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15244. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15245. * @returns the current mesh
  15246. */
  15247. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15248. private _syncAbsoluteScalingAndRotation;
  15249. }
  15250. }
  15251. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15252. /**
  15253. * Class used to override all child animations of a given target
  15254. */
  15255. export class AnimationPropertiesOverride {
  15256. /**
  15257. * Gets or sets a value indicating if animation blending must be used
  15258. */
  15259. enableBlending: boolean;
  15260. /**
  15261. * Gets or sets the blending speed to use when enableBlending is true
  15262. */
  15263. blendingSpeed: number;
  15264. /**
  15265. * Gets or sets the default loop mode to use
  15266. */
  15267. loopMode: number;
  15268. }
  15269. }
  15270. declare module "babylonjs/Bones/bone" {
  15271. import { Skeleton } from "babylonjs/Bones/skeleton";
  15272. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15273. import { Nullable } from "babylonjs/types";
  15274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15275. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15276. import { Node } from "babylonjs/node";
  15277. import { Space } from "babylonjs/Maths/math.axis";
  15278. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15279. /**
  15280. * Class used to store bone information
  15281. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15282. */
  15283. export class Bone extends Node {
  15284. /**
  15285. * defines the bone name
  15286. */
  15287. name: string;
  15288. private static _tmpVecs;
  15289. private static _tmpQuat;
  15290. private static _tmpMats;
  15291. /**
  15292. * Gets the list of child bones
  15293. */
  15294. children: Bone[];
  15295. /** Gets the animations associated with this bone */
  15296. animations: import("babylonjs/Animations/animation").Animation[];
  15297. /**
  15298. * Gets or sets bone length
  15299. */
  15300. length: number;
  15301. /**
  15302. * @hidden Internal only
  15303. * Set this value to map this bone to a different index in the transform matrices
  15304. * Set this value to -1 to exclude the bone from the transform matrices
  15305. */
  15306. _index: Nullable<number>;
  15307. private _skeleton;
  15308. private _localMatrix;
  15309. private _restPose;
  15310. private _baseMatrix;
  15311. private _absoluteTransform;
  15312. private _invertedAbsoluteTransform;
  15313. private _parent;
  15314. private _scalingDeterminant;
  15315. private _worldTransform;
  15316. private _localScaling;
  15317. private _localRotation;
  15318. private _localPosition;
  15319. private _needToDecompose;
  15320. private _needToCompose;
  15321. /** @hidden */
  15322. _linkedTransformNode: Nullable<TransformNode>;
  15323. /** @hidden */
  15324. _waitingTransformNodeId: Nullable<string>;
  15325. /** @hidden */
  15326. get _matrix(): Matrix;
  15327. /** @hidden */
  15328. set _matrix(value: Matrix);
  15329. /**
  15330. * Create a new bone
  15331. * @param name defines the bone name
  15332. * @param skeleton defines the parent skeleton
  15333. * @param parentBone defines the parent (can be null if the bone is the root)
  15334. * @param localMatrix defines the local matrix
  15335. * @param restPose defines the rest pose matrix
  15336. * @param baseMatrix defines the base matrix
  15337. * @param index defines index of the bone in the hiearchy
  15338. */
  15339. constructor(
  15340. /**
  15341. * defines the bone name
  15342. */
  15343. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15344. /**
  15345. * Gets the current object class name.
  15346. * @return the class name
  15347. */
  15348. getClassName(): string;
  15349. /**
  15350. * Gets the parent skeleton
  15351. * @returns a skeleton
  15352. */
  15353. getSkeleton(): Skeleton;
  15354. /**
  15355. * Gets parent bone
  15356. * @returns a bone or null if the bone is the root of the bone hierarchy
  15357. */
  15358. getParent(): Nullable<Bone>;
  15359. /**
  15360. * Returns an array containing the root bones
  15361. * @returns an array containing the root bones
  15362. */
  15363. getChildren(): Array<Bone>;
  15364. /**
  15365. * Gets the node index in matrix array generated for rendering
  15366. * @returns the node index
  15367. */
  15368. getIndex(): number;
  15369. /**
  15370. * Sets the parent bone
  15371. * @param parent defines the parent (can be null if the bone is the root)
  15372. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15373. */
  15374. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15375. /**
  15376. * Gets the local matrix
  15377. * @returns a matrix
  15378. */
  15379. getLocalMatrix(): Matrix;
  15380. /**
  15381. * Gets the base matrix (initial matrix which remains unchanged)
  15382. * @returns a matrix
  15383. */
  15384. getBaseMatrix(): Matrix;
  15385. /**
  15386. * Gets the rest pose matrix
  15387. * @returns a matrix
  15388. */
  15389. getRestPose(): Matrix;
  15390. /**
  15391. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15392. */
  15393. getWorldMatrix(): Matrix;
  15394. /**
  15395. * Sets the local matrix to rest pose matrix
  15396. */
  15397. returnToRest(): void;
  15398. /**
  15399. * Gets the inverse of the absolute transform matrix.
  15400. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15401. * @returns a matrix
  15402. */
  15403. getInvertedAbsoluteTransform(): Matrix;
  15404. /**
  15405. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15406. * @returns a matrix
  15407. */
  15408. getAbsoluteTransform(): Matrix;
  15409. /**
  15410. * Links with the given transform node.
  15411. * The local matrix of this bone is copied from the transform node every frame.
  15412. * @param transformNode defines the transform node to link to
  15413. */
  15414. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15415. /**
  15416. * Gets the node used to drive the bone's transformation
  15417. * @returns a transform node or null
  15418. */
  15419. getTransformNode(): Nullable<TransformNode>;
  15420. /** Gets or sets current position (in local space) */
  15421. get position(): Vector3;
  15422. set position(newPosition: Vector3);
  15423. /** Gets or sets current rotation (in local space) */
  15424. get rotation(): Vector3;
  15425. set rotation(newRotation: Vector3);
  15426. /** Gets or sets current rotation quaternion (in local space) */
  15427. get rotationQuaternion(): Quaternion;
  15428. set rotationQuaternion(newRotation: Quaternion);
  15429. /** Gets or sets current scaling (in local space) */
  15430. get scaling(): Vector3;
  15431. set scaling(newScaling: Vector3);
  15432. /**
  15433. * Gets the animation properties override
  15434. */
  15435. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15436. private _decompose;
  15437. private _compose;
  15438. /**
  15439. * Update the base and local matrices
  15440. * @param matrix defines the new base or local matrix
  15441. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15442. * @param updateLocalMatrix defines if the local matrix should be updated
  15443. */
  15444. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15445. /** @hidden */
  15446. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15447. /**
  15448. * Flag the bone as dirty (Forcing it to update everything)
  15449. */
  15450. markAsDirty(): void;
  15451. /** @hidden */
  15452. _markAsDirtyAndCompose(): void;
  15453. private _markAsDirtyAndDecompose;
  15454. /**
  15455. * Translate the bone in local or world space
  15456. * @param vec The amount to translate the bone
  15457. * @param space The space that the translation is in
  15458. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15459. */
  15460. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15461. /**
  15462. * Set the postion of the bone in local or world space
  15463. * @param position The position to set the bone
  15464. * @param space The space that the position is in
  15465. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15466. */
  15467. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15468. /**
  15469. * Set the absolute position of the bone (world space)
  15470. * @param position The position to set the bone
  15471. * @param mesh The mesh that this bone is attached to
  15472. */
  15473. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15474. /**
  15475. * Scale the bone on the x, y and z axes (in local space)
  15476. * @param x The amount to scale the bone on the x axis
  15477. * @param y The amount to scale the bone on the y axis
  15478. * @param z The amount to scale the bone on the z axis
  15479. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15480. */
  15481. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15482. /**
  15483. * Set the bone scaling in local space
  15484. * @param scale defines the scaling vector
  15485. */
  15486. setScale(scale: Vector3): void;
  15487. /**
  15488. * Gets the current scaling in local space
  15489. * @returns the current scaling vector
  15490. */
  15491. getScale(): Vector3;
  15492. /**
  15493. * Gets the current scaling in local space and stores it in a target vector
  15494. * @param result defines the target vector
  15495. */
  15496. getScaleToRef(result: Vector3): void;
  15497. /**
  15498. * Set the yaw, pitch, and roll of the bone in local or world space
  15499. * @param yaw The rotation of the bone on the y axis
  15500. * @param pitch The rotation of the bone on the x axis
  15501. * @param roll The rotation of the bone on the z axis
  15502. * @param space The space that the axes of rotation are in
  15503. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15504. */
  15505. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15506. /**
  15507. * Add a rotation to the bone on an axis in local or world space
  15508. * @param axis The axis to rotate the bone on
  15509. * @param amount The amount to rotate the bone
  15510. * @param space The space that the axis is in
  15511. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15512. */
  15513. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15514. /**
  15515. * Set the rotation of the bone to a particular axis angle in local or world space
  15516. * @param axis The axis to rotate the bone on
  15517. * @param angle The angle that the bone should be rotated to
  15518. * @param space The space that the axis is in
  15519. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15520. */
  15521. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15522. /**
  15523. * Set the euler rotation of the bone in local of world space
  15524. * @param rotation The euler rotation that the bone should be set to
  15525. * @param space The space that the rotation is in
  15526. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15527. */
  15528. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15529. /**
  15530. * Set the quaternion rotation of the bone in local of world space
  15531. * @param quat The quaternion rotation that the bone should be set to
  15532. * @param space The space that the rotation is in
  15533. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15534. */
  15535. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15536. /**
  15537. * Set the rotation matrix of the bone in local of world space
  15538. * @param rotMat The rotation matrix that the bone should be set to
  15539. * @param space The space that the rotation is in
  15540. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15541. */
  15542. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15543. private _rotateWithMatrix;
  15544. private _getNegativeRotationToRef;
  15545. /**
  15546. * Get the position of the bone in local or world space
  15547. * @param space The space that the returned position is in
  15548. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15549. * @returns The position of the bone
  15550. */
  15551. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15552. /**
  15553. * Copy the position of the bone to a vector3 in local or world space
  15554. * @param space The space that the returned position is in
  15555. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15556. * @param result The vector3 to copy the position to
  15557. */
  15558. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15559. /**
  15560. * Get the absolute position of the bone (world space)
  15561. * @param mesh The mesh that this bone is attached to
  15562. * @returns The absolute position of the bone
  15563. */
  15564. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15565. /**
  15566. * Copy the absolute position of the bone (world space) to the result param
  15567. * @param mesh The mesh that this bone is attached to
  15568. * @param result The vector3 to copy the absolute position to
  15569. */
  15570. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15571. /**
  15572. * Compute the absolute transforms of this bone and its children
  15573. */
  15574. computeAbsoluteTransforms(): void;
  15575. /**
  15576. * Get the world direction from an axis that is in the local space of the bone
  15577. * @param localAxis The local direction that is used to compute the world direction
  15578. * @param mesh The mesh that this bone is attached to
  15579. * @returns The world direction
  15580. */
  15581. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15582. /**
  15583. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15584. * @param localAxis The local direction that is used to compute the world direction
  15585. * @param mesh The mesh that this bone is attached to
  15586. * @param result The vector3 that the world direction will be copied to
  15587. */
  15588. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15589. /**
  15590. * Get the euler rotation of the bone in local or world space
  15591. * @param space The space that the rotation should be in
  15592. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15593. * @returns The euler rotation
  15594. */
  15595. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15596. /**
  15597. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15598. * @param space The space that the rotation should be in
  15599. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15600. * @param result The vector3 that the rotation should be copied to
  15601. */
  15602. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15603. /**
  15604. * Get the quaternion rotation of the bone in either local or world space
  15605. * @param space The space that the rotation should be in
  15606. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15607. * @returns The quaternion rotation
  15608. */
  15609. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15610. /**
  15611. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15612. * @param space The space that the rotation should be in
  15613. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15614. * @param result The quaternion that the rotation should be copied to
  15615. */
  15616. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15617. /**
  15618. * Get the rotation matrix of the bone in local or world space
  15619. * @param space The space that the rotation should be in
  15620. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15621. * @returns The rotation matrix
  15622. */
  15623. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15624. /**
  15625. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15626. * @param space The space that the rotation should be in
  15627. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15628. * @param result The quaternion that the rotation should be copied to
  15629. */
  15630. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15631. /**
  15632. * Get the world position of a point that is in the local space of the bone
  15633. * @param position The local position
  15634. * @param mesh The mesh that this bone is attached to
  15635. * @returns The world position
  15636. */
  15637. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15638. /**
  15639. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15640. * @param position The local position
  15641. * @param mesh The mesh that this bone is attached to
  15642. * @param result The vector3 that the world position should be copied to
  15643. */
  15644. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15645. /**
  15646. * Get the local position of a point that is in world space
  15647. * @param position The world position
  15648. * @param mesh The mesh that this bone is attached to
  15649. * @returns The local position
  15650. */
  15651. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15652. /**
  15653. * Get the local position of a point that is in world space and copy it to the result param
  15654. * @param position The world position
  15655. * @param mesh The mesh that this bone is attached to
  15656. * @param result The vector3 that the local position should be copied to
  15657. */
  15658. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15659. }
  15660. }
  15661. declare module "babylonjs/Animations/runtimeAnimation" {
  15662. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15663. import { Animatable } from "babylonjs/Animations/animatable";
  15664. import { Scene } from "babylonjs/scene";
  15665. /**
  15666. * Defines a runtime animation
  15667. */
  15668. export class RuntimeAnimation {
  15669. private _events;
  15670. /**
  15671. * The current frame of the runtime animation
  15672. */
  15673. private _currentFrame;
  15674. /**
  15675. * The animation used by the runtime animation
  15676. */
  15677. private _animation;
  15678. /**
  15679. * The target of the runtime animation
  15680. */
  15681. private _target;
  15682. /**
  15683. * The initiating animatable
  15684. */
  15685. private _host;
  15686. /**
  15687. * The original value of the runtime animation
  15688. */
  15689. private _originalValue;
  15690. /**
  15691. * The original blend value of the runtime animation
  15692. */
  15693. private _originalBlendValue;
  15694. /**
  15695. * The offsets cache of the runtime animation
  15696. */
  15697. private _offsetsCache;
  15698. /**
  15699. * The high limits cache of the runtime animation
  15700. */
  15701. private _highLimitsCache;
  15702. /**
  15703. * Specifies if the runtime animation has been stopped
  15704. */
  15705. private _stopped;
  15706. /**
  15707. * The blending factor of the runtime animation
  15708. */
  15709. private _blendingFactor;
  15710. /**
  15711. * The BabylonJS scene
  15712. */
  15713. private _scene;
  15714. /**
  15715. * The current value of the runtime animation
  15716. */
  15717. private _currentValue;
  15718. /** @hidden */
  15719. _animationState: _IAnimationState;
  15720. /**
  15721. * The active target of the runtime animation
  15722. */
  15723. private _activeTargets;
  15724. private _currentActiveTarget;
  15725. private _directTarget;
  15726. /**
  15727. * The target path of the runtime animation
  15728. */
  15729. private _targetPath;
  15730. /**
  15731. * The weight of the runtime animation
  15732. */
  15733. private _weight;
  15734. /**
  15735. * The ratio offset of the runtime animation
  15736. */
  15737. private _ratioOffset;
  15738. /**
  15739. * The previous delay of the runtime animation
  15740. */
  15741. private _previousDelay;
  15742. /**
  15743. * The previous ratio of the runtime animation
  15744. */
  15745. private _previousRatio;
  15746. private _enableBlending;
  15747. private _keys;
  15748. private _minFrame;
  15749. private _maxFrame;
  15750. private _minValue;
  15751. private _maxValue;
  15752. private _targetIsArray;
  15753. /**
  15754. * Gets the current frame of the runtime animation
  15755. */
  15756. get currentFrame(): number;
  15757. /**
  15758. * Gets the weight of the runtime animation
  15759. */
  15760. get weight(): number;
  15761. /**
  15762. * Gets the current value of the runtime animation
  15763. */
  15764. get currentValue(): any;
  15765. /**
  15766. * Gets the target path of the runtime animation
  15767. */
  15768. get targetPath(): string;
  15769. /**
  15770. * Gets the actual target of the runtime animation
  15771. */
  15772. get target(): any;
  15773. /**
  15774. * Gets the additive state of the runtime animation
  15775. */
  15776. get isAdditive(): boolean;
  15777. /** @hidden */
  15778. _onLoop: () => void;
  15779. /**
  15780. * Create a new RuntimeAnimation object
  15781. * @param target defines the target of the animation
  15782. * @param animation defines the source animation object
  15783. * @param scene defines the hosting scene
  15784. * @param host defines the initiating Animatable
  15785. */
  15786. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15787. private _preparePath;
  15788. /**
  15789. * Gets the animation from the runtime animation
  15790. */
  15791. get animation(): Animation;
  15792. /**
  15793. * Resets the runtime animation to the beginning
  15794. * @param restoreOriginal defines whether to restore the target property to the original value
  15795. */
  15796. reset(restoreOriginal?: boolean): void;
  15797. /**
  15798. * Specifies if the runtime animation is stopped
  15799. * @returns Boolean specifying if the runtime animation is stopped
  15800. */
  15801. isStopped(): boolean;
  15802. /**
  15803. * Disposes of the runtime animation
  15804. */
  15805. dispose(): void;
  15806. /**
  15807. * Apply the interpolated value to the target
  15808. * @param currentValue defines the value computed by the animation
  15809. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15810. */
  15811. setValue(currentValue: any, weight: number): void;
  15812. private _getOriginalValues;
  15813. private _setValue;
  15814. /**
  15815. * Gets the loop pmode of the runtime animation
  15816. * @returns Loop Mode
  15817. */
  15818. private _getCorrectLoopMode;
  15819. /**
  15820. * Move the current animation to a given frame
  15821. * @param frame defines the frame to move to
  15822. */
  15823. goToFrame(frame: number): void;
  15824. /**
  15825. * @hidden Internal use only
  15826. */
  15827. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15828. /**
  15829. * Execute the current animation
  15830. * @param delay defines the delay to add to the current frame
  15831. * @param from defines the lower bound of the animation range
  15832. * @param to defines the upper bound of the animation range
  15833. * @param loop defines if the current animation must loop
  15834. * @param speedRatio defines the current speed ratio
  15835. * @param weight defines the weight of the animation (default is -1 so no weight)
  15836. * @param onLoop optional callback called when animation loops
  15837. * @returns a boolean indicating if the animation is running
  15838. */
  15839. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15840. }
  15841. }
  15842. declare module "babylonjs/Animations/animatable" {
  15843. import { Animation } from "babylonjs/Animations/animation";
  15844. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  15845. import { Nullable } from "babylonjs/types";
  15846. import { Observable } from "babylonjs/Misc/observable";
  15847. import { Scene } from "babylonjs/scene";
  15848. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  15849. import { Node } from "babylonjs/node";
  15850. /**
  15851. * Class used to store an actual running animation
  15852. */
  15853. export class Animatable {
  15854. /** defines the target object */
  15855. target: any;
  15856. /** defines the starting frame number (default is 0) */
  15857. fromFrame: number;
  15858. /** defines the ending frame number (default is 100) */
  15859. toFrame: number;
  15860. /** defines if the animation must loop (default is false) */
  15861. loopAnimation: boolean;
  15862. /** defines a callback to call when animation ends if it is not looping */
  15863. onAnimationEnd?: (() => void) | null | undefined;
  15864. /** defines a callback to call when animation loops */
  15865. onAnimationLoop?: (() => void) | null | undefined;
  15866. /** defines whether the animation should be evaluated additively */
  15867. isAdditive: boolean;
  15868. private _localDelayOffset;
  15869. private _pausedDelay;
  15870. private _runtimeAnimations;
  15871. private _paused;
  15872. private _scene;
  15873. private _speedRatio;
  15874. private _weight;
  15875. private _syncRoot;
  15876. /**
  15877. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15878. * This will only apply for non looping animation (default is true)
  15879. */
  15880. disposeOnEnd: boolean;
  15881. /**
  15882. * Gets a boolean indicating if the animation has started
  15883. */
  15884. animationStarted: boolean;
  15885. /**
  15886. * Observer raised when the animation ends
  15887. */
  15888. onAnimationEndObservable: Observable<Animatable>;
  15889. /**
  15890. * Observer raised when the animation loops
  15891. */
  15892. onAnimationLoopObservable: Observable<Animatable>;
  15893. /**
  15894. * Gets the root Animatable used to synchronize and normalize animations
  15895. */
  15896. get syncRoot(): Nullable<Animatable>;
  15897. /**
  15898. * Gets the current frame of the first RuntimeAnimation
  15899. * Used to synchronize Animatables
  15900. */
  15901. get masterFrame(): number;
  15902. /**
  15903. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15904. */
  15905. get weight(): number;
  15906. set weight(value: number);
  15907. /**
  15908. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15909. */
  15910. get speedRatio(): number;
  15911. set speedRatio(value: number);
  15912. /**
  15913. * Creates a new Animatable
  15914. * @param scene defines the hosting scene
  15915. * @param target defines the target object
  15916. * @param fromFrame defines the starting frame number (default is 0)
  15917. * @param toFrame defines the ending frame number (default is 100)
  15918. * @param loopAnimation defines if the animation must loop (default is false)
  15919. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15920. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15921. * @param animations defines a group of animation to add to the new Animatable
  15922. * @param onAnimationLoop defines a callback to call when animation loops
  15923. * @param isAdditive defines whether the animation should be evaluated additively
  15924. */
  15925. constructor(scene: Scene,
  15926. /** defines the target object */
  15927. target: any,
  15928. /** defines the starting frame number (default is 0) */
  15929. fromFrame?: number,
  15930. /** defines the ending frame number (default is 100) */
  15931. toFrame?: number,
  15932. /** defines if the animation must loop (default is false) */
  15933. loopAnimation?: boolean, speedRatio?: number,
  15934. /** defines a callback to call when animation ends if it is not looping */
  15935. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15936. /** defines a callback to call when animation loops */
  15937. onAnimationLoop?: (() => void) | null | undefined,
  15938. /** defines whether the animation should be evaluated additively */
  15939. isAdditive?: boolean);
  15940. /**
  15941. * Synchronize and normalize current Animatable with a source Animatable
  15942. * This is useful when using animation weights and when animations are not of the same length
  15943. * @param root defines the root Animatable to synchronize with
  15944. * @returns the current Animatable
  15945. */
  15946. syncWith(root: Animatable): Animatable;
  15947. /**
  15948. * Gets the list of runtime animations
  15949. * @returns an array of RuntimeAnimation
  15950. */
  15951. getAnimations(): RuntimeAnimation[];
  15952. /**
  15953. * Adds more animations to the current animatable
  15954. * @param target defines the target of the animations
  15955. * @param animations defines the new animations to add
  15956. */
  15957. appendAnimations(target: any, animations: Animation[]): void;
  15958. /**
  15959. * Gets the source animation for a specific property
  15960. * @param property defines the propertyu to look for
  15961. * @returns null or the source animation for the given property
  15962. */
  15963. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15964. /**
  15965. * Gets the runtime animation for a specific property
  15966. * @param property defines the propertyu to look for
  15967. * @returns null or the runtime animation for the given property
  15968. */
  15969. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15970. /**
  15971. * Resets the animatable to its original state
  15972. */
  15973. reset(): void;
  15974. /**
  15975. * Allows the animatable to blend with current running animations
  15976. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15977. * @param blendingSpeed defines the blending speed to use
  15978. */
  15979. enableBlending(blendingSpeed: number): void;
  15980. /**
  15981. * Disable animation blending
  15982. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15983. */
  15984. disableBlending(): void;
  15985. /**
  15986. * Jump directly to a given frame
  15987. * @param frame defines the frame to jump to
  15988. */
  15989. goToFrame(frame: number): void;
  15990. /**
  15991. * Pause the animation
  15992. */
  15993. pause(): void;
  15994. /**
  15995. * Restart the animation
  15996. */
  15997. restart(): void;
  15998. private _raiseOnAnimationEnd;
  15999. /**
  16000. * Stop and delete the current animation
  16001. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16002. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  16003. */
  16004. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16005. /**
  16006. * Wait asynchronously for the animation to end
  16007. * @returns a promise which will be fullfilled when the animation ends
  16008. */
  16009. waitAsync(): Promise<Animatable>;
  16010. /** @hidden */
  16011. _animate(delay: number): boolean;
  16012. }
  16013. module "babylonjs/scene" {
  16014. interface Scene {
  16015. /** @hidden */
  16016. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16017. /** @hidden */
  16018. _processLateAnimationBindingsForMatrices(holder: {
  16019. totalWeight: number;
  16020. totalAdditiveWeight: number;
  16021. animations: RuntimeAnimation[];
  16022. additiveAnimations: RuntimeAnimation[];
  16023. originalValue: Matrix;
  16024. }): any;
  16025. /** @hidden */
  16026. _processLateAnimationBindingsForQuaternions(holder: {
  16027. totalWeight: number;
  16028. totalAdditiveWeight: number;
  16029. animations: RuntimeAnimation[];
  16030. additiveAnimations: RuntimeAnimation[];
  16031. originalValue: Quaternion;
  16032. }, refQuaternion: Quaternion): Quaternion;
  16033. /** @hidden */
  16034. _processLateAnimationBindings(): void;
  16035. /**
  16036. * Will start the animation sequence of a given target
  16037. * @param target defines the target
  16038. * @param from defines from which frame should animation start
  16039. * @param to defines until which frame should animation run.
  16040. * @param weight defines the weight to apply to the animation (1.0 by default)
  16041. * @param loop defines if the animation loops
  16042. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16043. * @param onAnimationEnd defines the function to be executed when the animation ends
  16044. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16045. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16046. * @param onAnimationLoop defines the callback to call when an animation loops
  16047. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16048. * @returns the animatable object created for this animation
  16049. */
  16050. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16051. /**
  16052. * Will start the animation sequence of a given target
  16053. * @param target defines the target
  16054. * @param from defines from which frame should animation start
  16055. * @param to defines until which frame should animation run.
  16056. * @param loop defines if the animation loops
  16057. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16058. * @param onAnimationEnd defines the function to be executed when the animation ends
  16059. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16060. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16061. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16062. * @param onAnimationLoop defines the callback to call when an animation loops
  16063. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16064. * @returns the animatable object created for this animation
  16065. */
  16066. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16067. /**
  16068. * Will start the animation sequence of a given target and its hierarchy
  16069. * @param target defines the target
  16070. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  16071. * @param from defines from which frame should animation start
  16072. * @param to defines until which frame should animation run.
  16073. * @param loop defines if the animation loops
  16074. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16075. * @param onAnimationEnd defines the function to be executed when the animation ends
  16076. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16077. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16078. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16079. * @param onAnimationLoop defines the callback to call when an animation loops
  16080. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16081. * @returns the list of created animatables
  16082. */
  16083. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16084. /**
  16085. * Begin a new animation on a given node
  16086. * @param target defines the target where the animation will take place
  16087. * @param animations defines the list of animations to start
  16088. * @param from defines the initial value
  16089. * @param to defines the final value
  16090. * @param loop defines if you want animation to loop (off by default)
  16091. * @param speedRatio defines the speed ratio to apply to all animations
  16092. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16093. * @param onAnimationLoop defines the callback to call when an animation loops
  16094. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16095. * @returns the list of created animatables
  16096. */
  16097. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16098. /**
  16099. * Begin a new animation on a given node and its hierarchy
  16100. * @param target defines the root node where the animation will take place
  16101. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  16102. * @param animations defines the list of animations to start
  16103. * @param from defines the initial value
  16104. * @param to defines the final value
  16105. * @param loop defines if you want animation to loop (off by default)
  16106. * @param speedRatio defines the speed ratio to apply to all animations
  16107. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16108. * @param onAnimationLoop defines the callback to call when an animation loops
  16109. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16110. * @returns the list of animatables created for all nodes
  16111. */
  16112. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16113. /**
  16114. * Gets the animatable associated with a specific target
  16115. * @param target defines the target of the animatable
  16116. * @returns the required animatable if found
  16117. */
  16118. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16119. /**
  16120. * Gets all animatables associated with a given target
  16121. * @param target defines the target to look animatables for
  16122. * @returns an array of Animatables
  16123. */
  16124. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16125. /**
  16126. * Stops and removes all animations that have been applied to the scene
  16127. */
  16128. stopAllAnimations(): void;
  16129. /**
  16130. * Gets the current delta time used by animation engine
  16131. */
  16132. deltaTime: number;
  16133. }
  16134. }
  16135. module "babylonjs/Bones/bone" {
  16136. interface Bone {
  16137. /**
  16138. * Copy an animation range from another bone
  16139. * @param source defines the source bone
  16140. * @param rangeName defines the range name to copy
  16141. * @param frameOffset defines the frame offset
  16142. * @param rescaleAsRequired defines if rescaling must be applied if required
  16143. * @param skelDimensionsRatio defines the scaling ratio
  16144. * @returns true if operation was successful
  16145. */
  16146. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16147. }
  16148. }
  16149. }
  16150. declare module "babylonjs/Bones/skeleton" {
  16151. import { Bone } from "babylonjs/Bones/bone";
  16152. import { Observable } from "babylonjs/Misc/observable";
  16153. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16154. import { Scene } from "babylonjs/scene";
  16155. import { Nullable } from "babylonjs/types";
  16156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16157. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16158. import { Animatable } from "babylonjs/Animations/animatable";
  16159. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16160. import { Animation } from "babylonjs/Animations/animation";
  16161. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16162. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16163. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16164. /**
  16165. * Class used to handle skinning animations
  16166. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16167. */
  16168. export class Skeleton implements IAnimatable {
  16169. /** defines the skeleton name */
  16170. name: string;
  16171. /** defines the skeleton Id */
  16172. id: string;
  16173. /**
  16174. * Defines the list of child bones
  16175. */
  16176. bones: Bone[];
  16177. /**
  16178. * Defines an estimate of the dimension of the skeleton at rest
  16179. */
  16180. dimensionsAtRest: Vector3;
  16181. /**
  16182. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16183. */
  16184. needInitialSkinMatrix: boolean;
  16185. /**
  16186. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16187. */
  16188. overrideMesh: Nullable<AbstractMesh>;
  16189. /**
  16190. * Gets the list of animations attached to this skeleton
  16191. */
  16192. animations: Array<Animation>;
  16193. private _scene;
  16194. private _isDirty;
  16195. private _transformMatrices;
  16196. private _transformMatrixTexture;
  16197. private _meshesWithPoseMatrix;
  16198. private _animatables;
  16199. private _identity;
  16200. private _synchronizedWithMesh;
  16201. private _ranges;
  16202. private _lastAbsoluteTransformsUpdateId;
  16203. private _canUseTextureForBones;
  16204. private _uniqueId;
  16205. /** @hidden */
  16206. _numBonesWithLinkedTransformNode: number;
  16207. /** @hidden */
  16208. _hasWaitingData: Nullable<boolean>;
  16209. /**
  16210. * Specifies if the skeleton should be serialized
  16211. */
  16212. doNotSerialize: boolean;
  16213. private _useTextureToStoreBoneMatrices;
  16214. /**
  16215. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16216. * Please note that this option is not available if the hardware does not support it
  16217. */
  16218. get useTextureToStoreBoneMatrices(): boolean;
  16219. set useTextureToStoreBoneMatrices(value: boolean);
  16220. private _animationPropertiesOverride;
  16221. /**
  16222. * Gets or sets the animation properties override
  16223. */
  16224. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16225. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16226. /**
  16227. * List of inspectable custom properties (used by the Inspector)
  16228. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16229. */
  16230. inspectableCustomProperties: IInspectable[];
  16231. /**
  16232. * An observable triggered before computing the skeleton's matrices
  16233. */
  16234. onBeforeComputeObservable: Observable<Skeleton>;
  16235. /**
  16236. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16237. */
  16238. get isUsingTextureForMatrices(): boolean;
  16239. /**
  16240. * Gets the unique ID of this skeleton
  16241. */
  16242. get uniqueId(): number;
  16243. /**
  16244. * Creates a new skeleton
  16245. * @param name defines the skeleton name
  16246. * @param id defines the skeleton Id
  16247. * @param scene defines the hosting scene
  16248. */
  16249. constructor(
  16250. /** defines the skeleton name */
  16251. name: string,
  16252. /** defines the skeleton Id */
  16253. id: string, scene: Scene);
  16254. /**
  16255. * Gets the current object class name.
  16256. * @return the class name
  16257. */
  16258. getClassName(): string;
  16259. /**
  16260. * Returns an array containing the root bones
  16261. * @returns an array containing the root bones
  16262. */
  16263. getChildren(): Array<Bone>;
  16264. /**
  16265. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16266. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16267. * @returns a Float32Array containing matrices data
  16268. */
  16269. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16270. /**
  16271. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16272. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16273. * @returns a raw texture containing the data
  16274. */
  16275. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16276. /**
  16277. * Gets the current hosting scene
  16278. * @returns a scene object
  16279. */
  16280. getScene(): Scene;
  16281. /**
  16282. * Gets a string representing the current skeleton data
  16283. * @param fullDetails defines a boolean indicating if we want a verbose version
  16284. * @returns a string representing the current skeleton data
  16285. */
  16286. toString(fullDetails?: boolean): string;
  16287. /**
  16288. * Get bone's index searching by name
  16289. * @param name defines bone's name to search for
  16290. * @return the indice of the bone. Returns -1 if not found
  16291. */
  16292. getBoneIndexByName(name: string): number;
  16293. /**
  16294. * Creater a new animation range
  16295. * @param name defines the name of the range
  16296. * @param from defines the start key
  16297. * @param to defines the end key
  16298. */
  16299. createAnimationRange(name: string, from: number, to: number): void;
  16300. /**
  16301. * Delete a specific animation range
  16302. * @param name defines the name of the range
  16303. * @param deleteFrames defines if frames must be removed as well
  16304. */
  16305. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16306. /**
  16307. * Gets a specific animation range
  16308. * @param name defines the name of the range to look for
  16309. * @returns the requested animation range or null if not found
  16310. */
  16311. getAnimationRange(name: string): Nullable<AnimationRange>;
  16312. /**
  16313. * Gets the list of all animation ranges defined on this skeleton
  16314. * @returns an array
  16315. */
  16316. getAnimationRanges(): Nullable<AnimationRange>[];
  16317. /**
  16318. * Copy animation range from a source skeleton.
  16319. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16320. * @param source defines the source skeleton
  16321. * @param name defines the name of the range to copy
  16322. * @param rescaleAsRequired defines if rescaling must be applied if required
  16323. * @returns true if operation was successful
  16324. */
  16325. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16326. /**
  16327. * Forces the skeleton to go to rest pose
  16328. */
  16329. returnToRest(): void;
  16330. private _getHighestAnimationFrame;
  16331. /**
  16332. * Begin a specific animation range
  16333. * @param name defines the name of the range to start
  16334. * @param loop defines if looping must be turned on (false by default)
  16335. * @param speedRatio defines the speed ratio to apply (1 by default)
  16336. * @param onAnimationEnd defines a callback which will be called when animation will end
  16337. * @returns a new animatable
  16338. */
  16339. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16340. /**
  16341. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16342. * @param skeleton defines the Skeleton containing the animation range to convert
  16343. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16344. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16345. * @returns the original skeleton
  16346. */
  16347. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16348. /** @hidden */
  16349. _markAsDirty(): void;
  16350. /** @hidden */
  16351. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16352. /** @hidden */
  16353. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16354. private _computeTransformMatrices;
  16355. /**
  16356. * Build all resources required to render a skeleton
  16357. */
  16358. prepare(): void;
  16359. /**
  16360. * Gets the list of animatables currently running for this skeleton
  16361. * @returns an array of animatables
  16362. */
  16363. getAnimatables(): IAnimatable[];
  16364. /**
  16365. * Clone the current skeleton
  16366. * @param name defines the name of the new skeleton
  16367. * @param id defines the id of the new skeleton
  16368. * @returns the new skeleton
  16369. */
  16370. clone(name: string, id?: string): Skeleton;
  16371. /**
  16372. * Enable animation blending for this skeleton
  16373. * @param blendingSpeed defines the blending speed to apply
  16374. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16375. */
  16376. enableBlending(blendingSpeed?: number): void;
  16377. /**
  16378. * Releases all resources associated with the current skeleton
  16379. */
  16380. dispose(): void;
  16381. /**
  16382. * Serialize the skeleton in a JSON object
  16383. * @returns a JSON object
  16384. */
  16385. serialize(): any;
  16386. /**
  16387. * Creates a new skeleton from serialized data
  16388. * @param parsedSkeleton defines the serialized data
  16389. * @param scene defines the hosting scene
  16390. * @returns a new skeleton
  16391. */
  16392. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16393. /**
  16394. * Compute all node absolute transforms
  16395. * @param forceUpdate defines if computation must be done even if cache is up to date
  16396. */
  16397. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16398. /**
  16399. * Gets the root pose matrix
  16400. * @returns a matrix
  16401. */
  16402. getPoseMatrix(): Nullable<Matrix>;
  16403. /**
  16404. * Sorts bones per internal index
  16405. */
  16406. sortBones(): void;
  16407. private _sortBones;
  16408. }
  16409. }
  16410. declare module "babylonjs/Meshes/instancedMesh" {
  16411. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16412. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16413. import { Camera } from "babylonjs/Cameras/camera";
  16414. import { Node } from "babylonjs/node";
  16415. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16416. import { Mesh } from "babylonjs/Meshes/mesh";
  16417. import { Material } from "babylonjs/Materials/material";
  16418. import { Skeleton } from "babylonjs/Bones/skeleton";
  16419. import { Light } from "babylonjs/Lights/light";
  16420. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16421. /**
  16422. * Creates an instance based on a source mesh.
  16423. */
  16424. export class InstancedMesh extends AbstractMesh {
  16425. private _sourceMesh;
  16426. private _currentLOD;
  16427. /** @hidden */
  16428. _indexInSourceMeshInstanceArray: number;
  16429. constructor(name: string, source: Mesh);
  16430. /**
  16431. * Returns the string "InstancedMesh".
  16432. */
  16433. getClassName(): string;
  16434. /** Gets the list of lights affecting that mesh */
  16435. get lightSources(): Light[];
  16436. _resyncLightSources(): void;
  16437. _resyncLightSource(light: Light): void;
  16438. _removeLightSource(light: Light, dispose: boolean): void;
  16439. /**
  16440. * If the source mesh receives shadows
  16441. */
  16442. get receiveShadows(): boolean;
  16443. /**
  16444. * The material of the source mesh
  16445. */
  16446. get material(): Nullable<Material>;
  16447. /**
  16448. * Visibility of the source mesh
  16449. */
  16450. get visibility(): number;
  16451. /**
  16452. * Skeleton of the source mesh
  16453. */
  16454. get skeleton(): Nullable<Skeleton>;
  16455. /**
  16456. * Rendering ground id of the source mesh
  16457. */
  16458. get renderingGroupId(): number;
  16459. set renderingGroupId(value: number);
  16460. /**
  16461. * Returns the total number of vertices (integer).
  16462. */
  16463. getTotalVertices(): number;
  16464. /**
  16465. * Returns a positive integer : the total number of indices in this mesh geometry.
  16466. * @returns the numner of indices or zero if the mesh has no geometry.
  16467. */
  16468. getTotalIndices(): number;
  16469. /**
  16470. * The source mesh of the instance
  16471. */
  16472. get sourceMesh(): Mesh;
  16473. /**
  16474. * Creates a new InstancedMesh object from the mesh model.
  16475. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16476. * @param name defines the name of the new instance
  16477. * @returns a new InstancedMesh
  16478. */
  16479. createInstance(name: string): InstancedMesh;
  16480. /**
  16481. * Is this node ready to be used/rendered
  16482. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16483. * @return {boolean} is it ready
  16484. */
  16485. isReady(completeCheck?: boolean): boolean;
  16486. /**
  16487. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16488. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16489. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  16490. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16491. */
  16492. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16493. /**
  16494. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16495. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16496. * The `data` are either a numeric array either a Float32Array.
  16497. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16498. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  16499. * Note that a new underlying VertexBuffer object is created each call.
  16500. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16501. *
  16502. * Possible `kind` values :
  16503. * - VertexBuffer.PositionKind
  16504. * - VertexBuffer.UVKind
  16505. * - VertexBuffer.UV2Kind
  16506. * - VertexBuffer.UV3Kind
  16507. * - VertexBuffer.UV4Kind
  16508. * - VertexBuffer.UV5Kind
  16509. * - VertexBuffer.UV6Kind
  16510. * - VertexBuffer.ColorKind
  16511. * - VertexBuffer.MatricesIndicesKind
  16512. * - VertexBuffer.MatricesIndicesExtraKind
  16513. * - VertexBuffer.MatricesWeightsKind
  16514. * - VertexBuffer.MatricesWeightsExtraKind
  16515. *
  16516. * Returns the Mesh.
  16517. */
  16518. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16519. /**
  16520. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16521. * If the mesh has no geometry, it is simply returned as it is.
  16522. * The `data` are either a numeric array either a Float32Array.
  16523. * No new underlying VertexBuffer object is created.
  16524. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16525. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16526. *
  16527. * Possible `kind` values :
  16528. * - VertexBuffer.PositionKind
  16529. * - VertexBuffer.UVKind
  16530. * - VertexBuffer.UV2Kind
  16531. * - VertexBuffer.UV3Kind
  16532. * - VertexBuffer.UV4Kind
  16533. * - VertexBuffer.UV5Kind
  16534. * - VertexBuffer.UV6Kind
  16535. * - VertexBuffer.ColorKind
  16536. * - VertexBuffer.MatricesIndicesKind
  16537. * - VertexBuffer.MatricesIndicesExtraKind
  16538. * - VertexBuffer.MatricesWeightsKind
  16539. * - VertexBuffer.MatricesWeightsExtraKind
  16540. *
  16541. * Returns the Mesh.
  16542. */
  16543. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16544. /**
  16545. * Sets the mesh indices.
  16546. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16547. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16548. * This method creates a new index buffer each call.
  16549. * Returns the Mesh.
  16550. */
  16551. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16552. /**
  16553. * Boolean : True if the mesh owns the requested kind of data.
  16554. */
  16555. isVerticesDataPresent(kind: string): boolean;
  16556. /**
  16557. * Returns an array of indices (IndicesArray).
  16558. */
  16559. getIndices(): Nullable<IndicesArray>;
  16560. get _positions(): Nullable<Vector3[]>;
  16561. /**
  16562. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16563. * This means the mesh underlying bounding box and sphere are recomputed.
  16564. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16565. * @returns the current mesh
  16566. */
  16567. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16568. /** @hidden */
  16569. _preActivate(): InstancedMesh;
  16570. /** @hidden */
  16571. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16572. /** @hidden */
  16573. _postActivate(): void;
  16574. getWorldMatrix(): Matrix;
  16575. get isAnInstance(): boolean;
  16576. /**
  16577. * Returns the current associated LOD AbstractMesh.
  16578. */
  16579. getLOD(camera: Camera): AbstractMesh;
  16580. /** @hidden */
  16581. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16582. /** @hidden */
  16583. _syncSubMeshes(): InstancedMesh;
  16584. /** @hidden */
  16585. _generatePointsArray(): boolean;
  16586. /**
  16587. * Creates a new InstancedMesh from the current mesh.
  16588. * - name (string) : the cloned mesh name
  16589. * - newParent (optional Node) : the optional Node to parent the clone to.
  16590. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16591. *
  16592. * Returns the clone.
  16593. */
  16594. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16595. /**
  16596. * Disposes the InstancedMesh.
  16597. * Returns nothing.
  16598. */
  16599. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16600. }
  16601. module "babylonjs/Meshes/mesh" {
  16602. interface Mesh {
  16603. /**
  16604. * Register a custom buffer that will be instanced
  16605. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16606. * @param kind defines the buffer kind
  16607. * @param stride defines the stride in floats
  16608. */
  16609. registerInstancedBuffer(kind: string, stride: number): void;
  16610. /**
  16611. * true to use the edge renderer for all instances of this mesh
  16612. */
  16613. edgesShareWithInstances: boolean;
  16614. /** @hidden */
  16615. _userInstancedBuffersStorage: {
  16616. data: {
  16617. [key: string]: Float32Array;
  16618. };
  16619. sizes: {
  16620. [key: string]: number;
  16621. };
  16622. vertexBuffers: {
  16623. [key: string]: Nullable<VertexBuffer>;
  16624. };
  16625. strides: {
  16626. [key: string]: number;
  16627. };
  16628. };
  16629. }
  16630. }
  16631. module "babylonjs/Meshes/abstractMesh" {
  16632. interface AbstractMesh {
  16633. /**
  16634. * Object used to store instanced buffers defined by user
  16635. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16636. */
  16637. instancedBuffers: {
  16638. [key: string]: any;
  16639. };
  16640. }
  16641. }
  16642. }
  16643. declare module "babylonjs/Materials/shaderMaterial" {
  16644. import { Nullable } from "babylonjs/types";
  16645. import { Scene } from "babylonjs/scene";
  16646. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16647. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16648. import { Mesh } from "babylonjs/Meshes/mesh";
  16649. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16650. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16651. import { Effect } from "babylonjs/Materials/effect";
  16652. import { Material } from "babylonjs/Materials/material";
  16653. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16654. /**
  16655. * Defines the options associated with the creation of a shader material.
  16656. */
  16657. export interface IShaderMaterialOptions {
  16658. /**
  16659. * Does the material work in alpha blend mode
  16660. */
  16661. needAlphaBlending: boolean;
  16662. /**
  16663. * Does the material work in alpha test mode
  16664. */
  16665. needAlphaTesting: boolean;
  16666. /**
  16667. * The list of attribute names used in the shader
  16668. */
  16669. attributes: string[];
  16670. /**
  16671. * The list of unifrom names used in the shader
  16672. */
  16673. uniforms: string[];
  16674. /**
  16675. * The list of UBO names used in the shader
  16676. */
  16677. uniformBuffers: string[];
  16678. /**
  16679. * The list of sampler names used in the shader
  16680. */
  16681. samplers: string[];
  16682. /**
  16683. * The list of defines used in the shader
  16684. */
  16685. defines: string[];
  16686. }
  16687. /**
  16688. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  16689. *
  16690. * This returned material effects how the mesh will look based on the code in the shaders.
  16691. *
  16692. * @see https://doc.babylonjs.com/how_to/shader_material
  16693. */
  16694. export class ShaderMaterial extends Material {
  16695. private _shaderPath;
  16696. private _options;
  16697. private _textures;
  16698. private _textureArrays;
  16699. private _floats;
  16700. private _ints;
  16701. private _floatsArrays;
  16702. private _colors3;
  16703. private _colors3Arrays;
  16704. private _colors4;
  16705. private _colors4Arrays;
  16706. private _vectors2;
  16707. private _vectors3;
  16708. private _vectors4;
  16709. private _matrices;
  16710. private _matrixArrays;
  16711. private _matrices3x3;
  16712. private _matrices2x2;
  16713. private _vectors2Arrays;
  16714. private _vectors3Arrays;
  16715. private _vectors4Arrays;
  16716. private _cachedWorldViewMatrix;
  16717. private _cachedWorldViewProjectionMatrix;
  16718. private _renderId;
  16719. private _multiview;
  16720. private _cachedDefines;
  16721. /** Define the Url to load snippets */
  16722. static SnippetUrl: string;
  16723. /** Snippet ID if the material was created from the snippet server */
  16724. snippetId: string;
  16725. /**
  16726. * Instantiate a new shader material.
  16727. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  16728. * This returned material effects how the mesh will look based on the code in the shaders.
  16729. * @see https://doc.babylonjs.com/how_to/shader_material
  16730. * @param name Define the name of the material in the scene
  16731. * @param scene Define the scene the material belongs to
  16732. * @param shaderPath Defines the route to the shader code in one of three ways:
  16733. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16734. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16735. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16736. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16737. * @param options Define the options used to create the shader
  16738. */
  16739. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16740. /**
  16741. * Gets the shader path used to define the shader code
  16742. * It can be modified to trigger a new compilation
  16743. */
  16744. get shaderPath(): any;
  16745. /**
  16746. * Sets the shader path used to define the shader code
  16747. * It can be modified to trigger a new compilation
  16748. */
  16749. set shaderPath(shaderPath: any);
  16750. /**
  16751. * Gets the options used to compile the shader.
  16752. * They can be modified to trigger a new compilation
  16753. */
  16754. get options(): IShaderMaterialOptions;
  16755. /**
  16756. * Gets the current class name of the material e.g. "ShaderMaterial"
  16757. * Mainly use in serialization.
  16758. * @returns the class name
  16759. */
  16760. getClassName(): string;
  16761. /**
  16762. * Specifies if the material will require alpha blending
  16763. * @returns a boolean specifying if alpha blending is needed
  16764. */
  16765. needAlphaBlending(): boolean;
  16766. /**
  16767. * Specifies if this material should be rendered in alpha test mode
  16768. * @returns a boolean specifying if an alpha test is needed.
  16769. */
  16770. needAlphaTesting(): boolean;
  16771. private _checkUniform;
  16772. /**
  16773. * Set a texture in the shader.
  16774. * @param name Define the name of the uniform samplers as defined in the shader
  16775. * @param texture Define the texture to bind to this sampler
  16776. * @return the material itself allowing "fluent" like uniform updates
  16777. */
  16778. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16779. /**
  16780. * Set a texture array in the shader.
  16781. * @param name Define the name of the uniform sampler array as defined in the shader
  16782. * @param textures Define the list of textures to bind to this sampler
  16783. * @return the material itself allowing "fluent" like uniform updates
  16784. */
  16785. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16786. /**
  16787. * Set a float in the shader.
  16788. * @param name Define the name of the uniform as defined in the shader
  16789. * @param value Define the value to give to the uniform
  16790. * @return the material itself allowing "fluent" like uniform updates
  16791. */
  16792. setFloat(name: string, value: number): ShaderMaterial;
  16793. /**
  16794. * Set a int in the shader.
  16795. * @param name Define the name of the uniform as defined in the shader
  16796. * @param value Define the value to give to the uniform
  16797. * @return the material itself allowing "fluent" like uniform updates
  16798. */
  16799. setInt(name: string, value: number): ShaderMaterial;
  16800. /**
  16801. * Set an array of floats in the shader.
  16802. * @param name Define the name of the uniform as defined in the shader
  16803. * @param value Define the value to give to the uniform
  16804. * @return the material itself allowing "fluent" like uniform updates
  16805. */
  16806. setFloats(name: string, value: number[]): ShaderMaterial;
  16807. /**
  16808. * Set a vec3 in the shader from a Color3.
  16809. * @param name Define the name of the uniform as defined in the shader
  16810. * @param value Define the value to give to the uniform
  16811. * @return the material itself allowing "fluent" like uniform updates
  16812. */
  16813. setColor3(name: string, value: Color3): ShaderMaterial;
  16814. /**
  16815. * Set a vec3 array in the shader from a Color3 array.
  16816. * @param name Define the name of the uniform as defined in the shader
  16817. * @param value Define the value to give to the uniform
  16818. * @return the material itself allowing "fluent" like uniform updates
  16819. */
  16820. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16821. /**
  16822. * Set a vec4 in the shader from a Color4.
  16823. * @param name Define the name of the uniform as defined in the shader
  16824. * @param value Define the value to give to the uniform
  16825. * @return the material itself allowing "fluent" like uniform updates
  16826. */
  16827. setColor4(name: string, value: Color4): ShaderMaterial;
  16828. /**
  16829. * Set a vec4 array in the shader from a Color4 array.
  16830. * @param name Define the name of the uniform as defined in the shader
  16831. * @param value Define the value to give to the uniform
  16832. * @return the material itself allowing "fluent" like uniform updates
  16833. */
  16834. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16835. /**
  16836. * Set a vec2 in the shader from a Vector2.
  16837. * @param name Define the name of the uniform as defined in the shader
  16838. * @param value Define the value to give to the uniform
  16839. * @return the material itself allowing "fluent" like uniform updates
  16840. */
  16841. setVector2(name: string, value: Vector2): ShaderMaterial;
  16842. /**
  16843. * Set a vec3 in the shader from a Vector3.
  16844. * @param name Define the name of the uniform as defined in the shader
  16845. * @param value Define the value to give to the uniform
  16846. * @return the material itself allowing "fluent" like uniform updates
  16847. */
  16848. setVector3(name: string, value: Vector3): ShaderMaterial;
  16849. /**
  16850. * Set a vec4 in the shader from a Vector4.
  16851. * @param name Define the name of the uniform as defined in the shader
  16852. * @param value Define the value to give to the uniform
  16853. * @return the material itself allowing "fluent" like uniform updates
  16854. */
  16855. setVector4(name: string, value: Vector4): ShaderMaterial;
  16856. /**
  16857. * Set a mat4 in the shader from a Matrix.
  16858. * @param name Define the name of the uniform as defined in the shader
  16859. * @param value Define the value to give to the uniform
  16860. * @return the material itself allowing "fluent" like uniform updates
  16861. */
  16862. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16863. /**
  16864. * Set a float32Array in the shader from a matrix array.
  16865. * @param name Define the name of the uniform as defined in the shader
  16866. * @param value Define the value to give to the uniform
  16867. * @return the material itself allowing "fluent" like uniform updates
  16868. */
  16869. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16870. /**
  16871. * Set a mat3 in the shader from a Float32Array.
  16872. * @param name Define the name of the uniform as defined in the shader
  16873. * @param value Define the value to give to the uniform
  16874. * @return the material itself allowing "fluent" like uniform updates
  16875. */
  16876. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16877. /**
  16878. * Set a mat2 in the shader from a Float32Array.
  16879. * @param name Define the name of the uniform as defined in the shader
  16880. * @param value Define the value to give to the uniform
  16881. * @return the material itself allowing "fluent" like uniform updates
  16882. */
  16883. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16884. /**
  16885. * Set a vec2 array in the shader from a number array.
  16886. * @param name Define the name of the uniform as defined in the shader
  16887. * @param value Define the value to give to the uniform
  16888. * @return the material itself allowing "fluent" like uniform updates
  16889. */
  16890. setArray2(name: string, value: number[]): ShaderMaterial;
  16891. /**
  16892. * Set a vec3 array in the shader from a number array.
  16893. * @param name Define the name of the uniform as defined in the shader
  16894. * @param value Define the value to give to the uniform
  16895. * @return the material itself allowing "fluent" like uniform updates
  16896. */
  16897. setArray3(name: string, value: number[]): ShaderMaterial;
  16898. /**
  16899. * Set a vec4 array in the shader from a number array.
  16900. * @param name Define the name of the uniform as defined in the shader
  16901. * @param value Define the value to give to the uniform
  16902. * @return the material itself allowing "fluent" like uniform updates
  16903. */
  16904. setArray4(name: string, value: number[]): ShaderMaterial;
  16905. private _checkCache;
  16906. /**
  16907. * Specifies that the submesh is ready to be used
  16908. * @param mesh defines the mesh to check
  16909. * @param subMesh defines which submesh to check
  16910. * @param useInstances specifies that instances should be used
  16911. * @returns a boolean indicating that the submesh is ready or not
  16912. */
  16913. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16914. /**
  16915. * Checks if the material is ready to render the requested mesh
  16916. * @param mesh Define the mesh to render
  16917. * @param useInstances Define whether or not the material is used with instances
  16918. * @returns true if ready, otherwise false
  16919. */
  16920. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16921. /**
  16922. * Binds the world matrix to the material
  16923. * @param world defines the world transformation matrix
  16924. * @param effectOverride - If provided, use this effect instead of internal effect
  16925. */
  16926. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16927. /**
  16928. * Binds the submesh to this material by preparing the effect and shader to draw
  16929. * @param world defines the world transformation matrix
  16930. * @param mesh defines the mesh containing the submesh
  16931. * @param subMesh defines the submesh to bind the material to
  16932. */
  16933. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16934. /**
  16935. * Binds the material to the mesh
  16936. * @param world defines the world transformation matrix
  16937. * @param mesh defines the mesh to bind the material to
  16938. * @param effectOverride - If provided, use this effect instead of internal effect
  16939. */
  16940. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16941. protected _afterBind(mesh?: Mesh): void;
  16942. /**
  16943. * Gets the active textures from the material
  16944. * @returns an array of textures
  16945. */
  16946. getActiveTextures(): BaseTexture[];
  16947. /**
  16948. * Specifies if the material uses a texture
  16949. * @param texture defines the texture to check against the material
  16950. * @returns a boolean specifying if the material uses the texture
  16951. */
  16952. hasTexture(texture: BaseTexture): boolean;
  16953. /**
  16954. * Makes a duplicate of the material, and gives it a new name
  16955. * @param name defines the new name for the duplicated material
  16956. * @returns the cloned material
  16957. */
  16958. clone(name: string): ShaderMaterial;
  16959. /**
  16960. * Disposes the material
  16961. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16962. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16963. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16964. */
  16965. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16966. /**
  16967. * Serializes this material in a JSON representation
  16968. * @returns the serialized material object
  16969. */
  16970. serialize(): any;
  16971. /**
  16972. * Creates a shader material from parsed shader material data
  16973. * @param source defines the JSON represnetation of the material
  16974. * @param scene defines the hosting scene
  16975. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16976. * @returns a new material
  16977. */
  16978. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16979. /**
  16980. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16981. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16982. * @param url defines the url to load from
  16983. * @param scene defines the hosting scene
  16984. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16985. * @returns a promise that will resolve to the new ShaderMaterial
  16986. */
  16987. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16988. /**
  16989. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16990. * @param snippetId defines the snippet to load
  16991. * @param scene defines the hosting scene
  16992. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16993. * @returns a promise that will resolve to the new ShaderMaterial
  16994. */
  16995. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16996. }
  16997. }
  16998. declare module "babylonjs/Shaders/color.fragment" {
  16999. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17000. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17001. /** @hidden */
  17002. export var colorPixelShader: {
  17003. name: string;
  17004. shader: string;
  17005. };
  17006. }
  17007. declare module "babylonjs/Shaders/color.vertex" {
  17008. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17009. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17010. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17011. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17012. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17013. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17014. /** @hidden */
  17015. export var colorVertexShader: {
  17016. name: string;
  17017. shader: string;
  17018. };
  17019. }
  17020. declare module "babylonjs/Meshes/linesMesh" {
  17021. import { Nullable } from "babylonjs/types";
  17022. import { Scene } from "babylonjs/scene";
  17023. import { Color3 } from "babylonjs/Maths/math.color";
  17024. import { Node } from "babylonjs/node";
  17025. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17026. import { Mesh } from "babylonjs/Meshes/mesh";
  17027. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17028. import { Effect } from "babylonjs/Materials/effect";
  17029. import { Material } from "babylonjs/Materials/material";
  17030. import "babylonjs/Shaders/color.fragment";
  17031. import "babylonjs/Shaders/color.vertex";
  17032. /**
  17033. * Line mesh
  17034. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17035. */
  17036. export class LinesMesh extends Mesh {
  17037. /**
  17038. * If vertex color should be applied to the mesh
  17039. */
  17040. readonly useVertexColor?: boolean | undefined;
  17041. /**
  17042. * If vertex alpha should be applied to the mesh
  17043. */
  17044. readonly useVertexAlpha?: boolean | undefined;
  17045. /**
  17046. * Color of the line (Default: White)
  17047. */
  17048. color: Color3;
  17049. /**
  17050. * Alpha of the line (Default: 1)
  17051. */
  17052. alpha: number;
  17053. /**
  17054. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17055. * This margin is expressed in world space coordinates, so its value may vary.
  17056. * Default value is 0.1
  17057. */
  17058. intersectionThreshold: number;
  17059. private _colorShader;
  17060. private color4;
  17061. /**
  17062. * Creates a new LinesMesh
  17063. * @param name defines the name
  17064. * @param scene defines the hosting scene
  17065. * @param parent defines the parent mesh if any
  17066. * @param source defines the optional source LinesMesh used to clone data from
  17067. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17068. * When false, achieved by calling a clone(), also passing False.
  17069. * This will make creation of children, recursive.
  17070. * @param useVertexColor defines if this LinesMesh supports vertex color
  17071. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17072. */
  17073. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17074. /**
  17075. * If vertex color should be applied to the mesh
  17076. */
  17077. useVertexColor?: boolean | undefined,
  17078. /**
  17079. * If vertex alpha should be applied to the mesh
  17080. */
  17081. useVertexAlpha?: boolean | undefined);
  17082. private _addClipPlaneDefine;
  17083. private _removeClipPlaneDefine;
  17084. isReady(): boolean;
  17085. /**
  17086. * Returns the string "LineMesh"
  17087. */
  17088. getClassName(): string;
  17089. /**
  17090. * @hidden
  17091. */
  17092. get material(): Material;
  17093. /**
  17094. * @hidden
  17095. */
  17096. set material(value: Material);
  17097. /**
  17098. * @hidden
  17099. */
  17100. get checkCollisions(): boolean;
  17101. /** @hidden */
  17102. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17103. /** @hidden */
  17104. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17105. /**
  17106. * Disposes of the line mesh
  17107. * @param doNotRecurse If children should be disposed
  17108. */
  17109. dispose(doNotRecurse?: boolean): void;
  17110. /**
  17111. * Returns a new LineMesh object cloned from the current one.
  17112. */
  17113. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17114. /**
  17115. * Creates a new InstancedLinesMesh object from the mesh model.
  17116. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17117. * @param name defines the name of the new instance
  17118. * @returns a new InstancedLinesMesh
  17119. */
  17120. createInstance(name: string): InstancedLinesMesh;
  17121. }
  17122. /**
  17123. * Creates an instance based on a source LinesMesh
  17124. */
  17125. export class InstancedLinesMesh extends InstancedMesh {
  17126. /**
  17127. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17128. * This margin is expressed in world space coordinates, so its value may vary.
  17129. * Initilized with the intersectionThreshold value of the source LinesMesh
  17130. */
  17131. intersectionThreshold: number;
  17132. constructor(name: string, source: LinesMesh);
  17133. /**
  17134. * Returns the string "InstancedLinesMesh".
  17135. */
  17136. getClassName(): string;
  17137. }
  17138. }
  17139. declare module "babylonjs/Shaders/line.fragment" {
  17140. /** @hidden */
  17141. export var linePixelShader: {
  17142. name: string;
  17143. shader: string;
  17144. };
  17145. }
  17146. declare module "babylonjs/Shaders/line.vertex" {
  17147. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17148. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17149. /** @hidden */
  17150. export var lineVertexShader: {
  17151. name: string;
  17152. shader: string;
  17153. };
  17154. }
  17155. declare module "babylonjs/Rendering/edgesRenderer" {
  17156. import { Nullable } from "babylonjs/types";
  17157. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17159. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17160. import { IDisposable } from "babylonjs/scene";
  17161. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17162. import "babylonjs/Shaders/line.fragment";
  17163. import "babylonjs/Shaders/line.vertex";
  17164. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17165. import { SmartArray } from "babylonjs/Misc/smartArray";
  17166. module "babylonjs/scene" {
  17167. interface Scene {
  17168. /** @hidden */
  17169. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17170. }
  17171. }
  17172. module "babylonjs/Meshes/abstractMesh" {
  17173. interface AbstractMesh {
  17174. /**
  17175. * Gets the edgesRenderer associated with the mesh
  17176. */
  17177. edgesRenderer: Nullable<EdgesRenderer>;
  17178. }
  17179. }
  17180. module "babylonjs/Meshes/linesMesh" {
  17181. interface LinesMesh {
  17182. /**
  17183. * Enables the edge rendering mode on the mesh.
  17184. * This mode makes the mesh edges visible
  17185. * @param epsilon defines the maximal distance between two angles to detect a face
  17186. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17187. * @returns the currentAbstractMesh
  17188. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17189. */
  17190. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17191. }
  17192. }
  17193. module "babylonjs/Meshes/linesMesh" {
  17194. interface InstancedLinesMesh {
  17195. /**
  17196. * Enables the edge rendering mode on the mesh.
  17197. * This mode makes the mesh edges visible
  17198. * @param epsilon defines the maximal distance between two angles to detect a face
  17199. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17200. * @returns the current InstancedLinesMesh
  17201. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17202. */
  17203. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17204. }
  17205. }
  17206. /**
  17207. * Defines the minimum contract an Edges renderer should follow.
  17208. */
  17209. export interface IEdgesRenderer extends IDisposable {
  17210. /**
  17211. * Gets or sets a boolean indicating if the edgesRenderer is active
  17212. */
  17213. isEnabled: boolean;
  17214. /**
  17215. * Renders the edges of the attached mesh,
  17216. */
  17217. render(): void;
  17218. /**
  17219. * Checks wether or not the edges renderer is ready to render.
  17220. * @return true if ready, otherwise false.
  17221. */
  17222. isReady(): boolean;
  17223. /**
  17224. * List of instances to render in case the source mesh has instances
  17225. */
  17226. customInstances: SmartArray<Matrix>;
  17227. }
  17228. /**
  17229. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17230. */
  17231. export class EdgesRenderer implements IEdgesRenderer {
  17232. /**
  17233. * Define the size of the edges with an orthographic camera
  17234. */
  17235. edgesWidthScalerForOrthographic: number;
  17236. /**
  17237. * Define the size of the edges with a perspective camera
  17238. */
  17239. edgesWidthScalerForPerspective: number;
  17240. protected _source: AbstractMesh;
  17241. protected _linesPositions: number[];
  17242. protected _linesNormals: number[];
  17243. protected _linesIndices: number[];
  17244. protected _epsilon: number;
  17245. protected _indicesCount: number;
  17246. protected _lineShader: ShaderMaterial;
  17247. protected _ib: DataBuffer;
  17248. protected _buffers: {
  17249. [key: string]: Nullable<VertexBuffer>;
  17250. };
  17251. protected _buffersForInstances: {
  17252. [key: string]: Nullable<VertexBuffer>;
  17253. };
  17254. protected _checkVerticesInsteadOfIndices: boolean;
  17255. private _meshRebuildObserver;
  17256. private _meshDisposeObserver;
  17257. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17258. isEnabled: boolean;
  17259. /**
  17260. * List of instances to render in case the source mesh has instances
  17261. */
  17262. customInstances: SmartArray<Matrix>;
  17263. private static GetShader;
  17264. /**
  17265. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17266. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17267. * @param source Mesh used to create edges
  17268. * @param epsilon sum of angles in adjacency to check for edge
  17269. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17270. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17271. */
  17272. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17273. protected _prepareRessources(): void;
  17274. /** @hidden */
  17275. _rebuild(): void;
  17276. /**
  17277. * Releases the required resources for the edges renderer
  17278. */
  17279. dispose(): void;
  17280. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17281. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17282. /**
  17283. * Checks if the pair of p0 and p1 is en edge
  17284. * @param faceIndex
  17285. * @param edge
  17286. * @param faceNormals
  17287. * @param p0
  17288. * @param p1
  17289. * @private
  17290. */
  17291. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17292. /**
  17293. * push line into the position, normal and index buffer
  17294. * @protected
  17295. */
  17296. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17297. /**
  17298. * Generates lines edges from adjacencjes
  17299. * @private
  17300. */
  17301. _generateEdgesLines(): void;
  17302. /**
  17303. * Checks wether or not the edges renderer is ready to render.
  17304. * @return true if ready, otherwise false.
  17305. */
  17306. isReady(): boolean;
  17307. /**
  17308. * Renders the edges of the attached mesh,
  17309. */
  17310. render(): void;
  17311. }
  17312. /**
  17313. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17314. */
  17315. export class LineEdgesRenderer extends EdgesRenderer {
  17316. /**
  17317. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17318. * @param source LineMesh used to generate edges
  17319. * @param epsilon not important (specified angle for edge detection)
  17320. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17321. */
  17322. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17323. /**
  17324. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17325. */
  17326. _generateEdgesLines(): void;
  17327. }
  17328. }
  17329. declare module "babylonjs/Rendering/renderingGroup" {
  17330. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17331. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17333. import { Nullable } from "babylonjs/types";
  17334. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17335. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17336. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17337. import { Material } from "babylonjs/Materials/material";
  17338. import { Scene } from "babylonjs/scene";
  17339. /**
  17340. * This represents the object necessary to create a rendering group.
  17341. * This is exclusively used and created by the rendering manager.
  17342. * To modify the behavior, you use the available helpers in your scene or meshes.
  17343. * @hidden
  17344. */
  17345. export class RenderingGroup {
  17346. index: number;
  17347. private static _zeroVector;
  17348. private _scene;
  17349. private _opaqueSubMeshes;
  17350. private _transparentSubMeshes;
  17351. private _alphaTestSubMeshes;
  17352. private _depthOnlySubMeshes;
  17353. private _particleSystems;
  17354. private _spriteManagers;
  17355. private _opaqueSortCompareFn;
  17356. private _alphaTestSortCompareFn;
  17357. private _transparentSortCompareFn;
  17358. private _renderOpaque;
  17359. private _renderAlphaTest;
  17360. private _renderTransparent;
  17361. /** @hidden */
  17362. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17363. onBeforeTransparentRendering: () => void;
  17364. /**
  17365. * Set the opaque sort comparison function.
  17366. * If null the sub meshes will be render in the order they were created
  17367. */
  17368. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17369. /**
  17370. * Set the alpha test sort comparison function.
  17371. * If null the sub meshes will be render in the order they were created
  17372. */
  17373. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17374. /**
  17375. * Set the transparent sort comparison function.
  17376. * If null the sub meshes will be render in the order they were created
  17377. */
  17378. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17379. /**
  17380. * Creates a new rendering group.
  17381. * @param index The rendering group index
  17382. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17383. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17384. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17385. */
  17386. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17387. /**
  17388. * Render all the sub meshes contained in the group.
  17389. * @param customRenderFunction Used to override the default render behaviour of the group.
  17390. * @returns true if rendered some submeshes.
  17391. */
  17392. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17393. /**
  17394. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17395. * @param subMeshes The submeshes to render
  17396. */
  17397. private renderOpaqueSorted;
  17398. /**
  17399. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17400. * @param subMeshes The submeshes to render
  17401. */
  17402. private renderAlphaTestSorted;
  17403. /**
  17404. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17405. * @param subMeshes The submeshes to render
  17406. */
  17407. private renderTransparentSorted;
  17408. /**
  17409. * Renders the submeshes in a specified order.
  17410. * @param subMeshes The submeshes to sort before render
  17411. * @param sortCompareFn The comparison function use to sort
  17412. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17413. * @param transparent Specifies to activate blending if true
  17414. */
  17415. private static renderSorted;
  17416. /**
  17417. * Renders the submeshes in the order they were dispatched (no sort applied).
  17418. * @param subMeshes The submeshes to render
  17419. */
  17420. private static renderUnsorted;
  17421. /**
  17422. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17423. * are rendered back to front if in the same alpha index.
  17424. *
  17425. * @param a The first submesh
  17426. * @param b The second submesh
  17427. * @returns The result of the comparison
  17428. */
  17429. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17430. /**
  17431. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17432. * are rendered back to front.
  17433. *
  17434. * @param a The first submesh
  17435. * @param b The second submesh
  17436. * @returns The result of the comparison
  17437. */
  17438. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17439. /**
  17440. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17441. * are rendered front to back (prevent overdraw).
  17442. *
  17443. * @param a The first submesh
  17444. * @param b The second submesh
  17445. * @returns The result of the comparison
  17446. */
  17447. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17448. /**
  17449. * Resets the different lists of submeshes to prepare a new frame.
  17450. */
  17451. prepare(): void;
  17452. dispose(): void;
  17453. /**
  17454. * Inserts the submesh in its correct queue depending on its material.
  17455. * @param subMesh The submesh to dispatch
  17456. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17457. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17458. */
  17459. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17460. dispatchSprites(spriteManager: ISpriteManager): void;
  17461. dispatchParticles(particleSystem: IParticleSystem): void;
  17462. private _renderParticles;
  17463. private _renderSprites;
  17464. }
  17465. }
  17466. declare module "babylonjs/Rendering/renderingManager" {
  17467. import { Nullable } from "babylonjs/types";
  17468. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17469. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17470. import { SmartArray } from "babylonjs/Misc/smartArray";
  17471. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17472. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17473. import { Material } from "babylonjs/Materials/material";
  17474. import { Scene } from "babylonjs/scene";
  17475. import { Camera } from "babylonjs/Cameras/camera";
  17476. /**
  17477. * Interface describing the different options available in the rendering manager
  17478. * regarding Auto Clear between groups.
  17479. */
  17480. export interface IRenderingManagerAutoClearSetup {
  17481. /**
  17482. * Defines whether or not autoclear is enable.
  17483. */
  17484. autoClear: boolean;
  17485. /**
  17486. * Defines whether or not to autoclear the depth buffer.
  17487. */
  17488. depth: boolean;
  17489. /**
  17490. * Defines whether or not to autoclear the stencil buffer.
  17491. */
  17492. stencil: boolean;
  17493. }
  17494. /**
  17495. * This class is used by the onRenderingGroupObservable
  17496. */
  17497. export class RenderingGroupInfo {
  17498. /**
  17499. * The Scene that being rendered
  17500. */
  17501. scene: Scene;
  17502. /**
  17503. * The camera currently used for the rendering pass
  17504. */
  17505. camera: Nullable<Camera>;
  17506. /**
  17507. * The ID of the renderingGroup being processed
  17508. */
  17509. renderingGroupId: number;
  17510. }
  17511. /**
  17512. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17513. * It is enable to manage the different groups as well as the different necessary sort functions.
  17514. * This should not be used directly aside of the few static configurations
  17515. */
  17516. export class RenderingManager {
  17517. /**
  17518. * The max id used for rendering groups (not included)
  17519. */
  17520. static MAX_RENDERINGGROUPS: number;
  17521. /**
  17522. * The min id used for rendering groups (included)
  17523. */
  17524. static MIN_RENDERINGGROUPS: number;
  17525. /**
  17526. * Used to globally prevent autoclearing scenes.
  17527. */
  17528. static AUTOCLEAR: boolean;
  17529. /**
  17530. * @hidden
  17531. */
  17532. _useSceneAutoClearSetup: boolean;
  17533. private _scene;
  17534. private _renderingGroups;
  17535. private _depthStencilBufferAlreadyCleaned;
  17536. private _autoClearDepthStencil;
  17537. private _customOpaqueSortCompareFn;
  17538. private _customAlphaTestSortCompareFn;
  17539. private _customTransparentSortCompareFn;
  17540. private _renderingGroupInfo;
  17541. /**
  17542. * Instantiates a new rendering group for a particular scene
  17543. * @param scene Defines the scene the groups belongs to
  17544. */
  17545. constructor(scene: Scene);
  17546. private _clearDepthStencilBuffer;
  17547. /**
  17548. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17549. * @hidden
  17550. */
  17551. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17552. /**
  17553. * Resets the different information of the group to prepare a new frame
  17554. * @hidden
  17555. */
  17556. reset(): void;
  17557. /**
  17558. * Dispose and release the group and its associated resources.
  17559. * @hidden
  17560. */
  17561. dispose(): void;
  17562. /**
  17563. * Clear the info related to rendering groups preventing retention points during dispose.
  17564. */
  17565. freeRenderingGroups(): void;
  17566. private _prepareRenderingGroup;
  17567. /**
  17568. * Add a sprite manager to the rendering manager in order to render it this frame.
  17569. * @param spriteManager Define the sprite manager to render
  17570. */
  17571. dispatchSprites(spriteManager: ISpriteManager): void;
  17572. /**
  17573. * Add a particle system to the rendering manager in order to render it this frame.
  17574. * @param particleSystem Define the particle system to render
  17575. */
  17576. dispatchParticles(particleSystem: IParticleSystem): void;
  17577. /**
  17578. * Add a submesh to the manager in order to render it this frame
  17579. * @param subMesh The submesh to dispatch
  17580. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17581. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17582. */
  17583. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17584. /**
  17585. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17586. * This allowed control for front to back rendering or reversly depending of the special needs.
  17587. *
  17588. * @param renderingGroupId The rendering group id corresponding to its index
  17589. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17590. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17591. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17592. */
  17593. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  17594. /**
  17595. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17596. *
  17597. * @param renderingGroupId The rendering group id corresponding to its index
  17598. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17599. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17600. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17601. */
  17602. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17603. /**
  17604. * Gets the current auto clear configuration for one rendering group of the rendering
  17605. * manager.
  17606. * @param index the rendering group index to get the information for
  17607. * @returns The auto clear setup for the requested rendering group
  17608. */
  17609. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17610. }
  17611. }
  17612. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17613. import { SmartArray } from "babylonjs/Misc/smartArray";
  17614. import { Nullable } from "babylonjs/types";
  17615. import { Scene } from "babylonjs/scene";
  17616. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17617. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17618. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17619. import { Mesh } from "babylonjs/Meshes/mesh";
  17620. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17621. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17622. import { Effect } from "babylonjs/Materials/effect";
  17623. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17624. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17625. import "babylonjs/Shaders/shadowMap.fragment";
  17626. import "babylonjs/Shaders/shadowMap.vertex";
  17627. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17628. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17629. import { Observable } from "babylonjs/Misc/observable";
  17630. /**
  17631. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17632. */
  17633. export interface ICustomShaderOptions {
  17634. /**
  17635. * Gets or sets the custom shader name to use
  17636. */
  17637. shaderName: string;
  17638. /**
  17639. * The list of attribute names used in the shader
  17640. */
  17641. attributes?: string[];
  17642. /**
  17643. * The list of unifrom names used in the shader
  17644. */
  17645. uniforms?: string[];
  17646. /**
  17647. * The list of sampler names used in the shader
  17648. */
  17649. samplers?: string[];
  17650. /**
  17651. * The list of defines used in the shader
  17652. */
  17653. defines?: string[];
  17654. }
  17655. /**
  17656. * Interface to implement to create a shadow generator compatible with BJS.
  17657. */
  17658. export interface IShadowGenerator {
  17659. /**
  17660. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17661. * @returns The render target texture if present otherwise, null
  17662. */
  17663. getShadowMap(): Nullable<RenderTargetTexture>;
  17664. /**
  17665. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17666. * @param subMesh The submesh we want to render in the shadow map
  17667. * @param useInstances Defines wether will draw in the map using instances
  17668. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17669. * @returns true if ready otherwise, false
  17670. */
  17671. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17672. /**
  17673. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17674. * @param defines Defines of the material we want to update
  17675. * @param lightIndex Index of the light in the enabled light list of the material
  17676. */
  17677. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17678. /**
  17679. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17680. * defined in the generator but impacting the effect).
  17681. * It implies the unifroms available on the materials are the standard BJS ones.
  17682. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17683. * @param effect The effect we are binfing the information for
  17684. */
  17685. bindShadowLight(lightIndex: string, effect: Effect): void;
  17686. /**
  17687. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17688. * (eq to shadow prjection matrix * light transform matrix)
  17689. * @returns The transform matrix used to create the shadow map
  17690. */
  17691. getTransformMatrix(): Matrix;
  17692. /**
  17693. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17694. * Cube and 2D textures for instance.
  17695. */
  17696. recreateShadowMap(): void;
  17697. /**
  17698. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17699. * @param onCompiled Callback triggered at the and of the effects compilation
  17700. * @param options Sets of optional options forcing the compilation with different modes
  17701. */
  17702. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17703. useInstances: boolean;
  17704. }>): void;
  17705. /**
  17706. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17707. * @param options Sets of optional options forcing the compilation with different modes
  17708. * @returns A promise that resolves when the compilation completes
  17709. */
  17710. forceCompilationAsync(options?: Partial<{
  17711. useInstances: boolean;
  17712. }>): Promise<void>;
  17713. /**
  17714. * Serializes the shadow generator setup to a json object.
  17715. * @returns The serialized JSON object
  17716. */
  17717. serialize(): any;
  17718. /**
  17719. * Disposes the Shadow map and related Textures and effects.
  17720. */
  17721. dispose(): void;
  17722. }
  17723. /**
  17724. * Default implementation IShadowGenerator.
  17725. * This is the main object responsible of generating shadows in the framework.
  17726. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17727. */
  17728. export class ShadowGenerator implements IShadowGenerator {
  17729. /**
  17730. * Name of the shadow generator class
  17731. */
  17732. static CLASSNAME: string;
  17733. /**
  17734. * Shadow generator mode None: no filtering applied.
  17735. */
  17736. static readonly FILTER_NONE: number;
  17737. /**
  17738. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17739. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17740. */
  17741. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17742. /**
  17743. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17744. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17745. */
  17746. static readonly FILTER_POISSONSAMPLING: number;
  17747. /**
  17748. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17749. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17750. */
  17751. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17752. /**
  17753. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17754. * edge artifacts on steep falloff.
  17755. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17756. */
  17757. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17758. /**
  17759. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17760. * edge artifacts on steep falloff.
  17761. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17762. */
  17763. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17764. /**
  17765. * Shadow generator mode PCF: Percentage Closer Filtering
  17766. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17767. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17768. */
  17769. static readonly FILTER_PCF: number;
  17770. /**
  17771. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17772. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17773. * Contact Hardening
  17774. */
  17775. static readonly FILTER_PCSS: number;
  17776. /**
  17777. * Reserved for PCF and PCSS
  17778. * Highest Quality.
  17779. *
  17780. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17781. *
  17782. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17783. */
  17784. static readonly QUALITY_HIGH: number;
  17785. /**
  17786. * Reserved for PCF and PCSS
  17787. * Good tradeoff for quality/perf cross devices
  17788. *
  17789. * Execute PCF on a 3*3 kernel.
  17790. *
  17791. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17792. */
  17793. static readonly QUALITY_MEDIUM: number;
  17794. /**
  17795. * Reserved for PCF and PCSS
  17796. * The lowest quality but the fastest.
  17797. *
  17798. * Execute PCF on a 1*1 kernel.
  17799. *
  17800. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17801. */
  17802. static readonly QUALITY_LOW: number;
  17803. /** Gets or sets the custom shader name to use */
  17804. customShaderOptions: ICustomShaderOptions;
  17805. /**
  17806. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17807. */
  17808. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17809. /**
  17810. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17811. */
  17812. onAfterShadowMapRenderObservable: Observable<Effect>;
  17813. /**
  17814. * Observable triggered before a mesh is rendered in the shadow map.
  17815. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17816. */
  17817. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17818. /**
  17819. * Observable triggered after a mesh is rendered in the shadow map.
  17820. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17821. */
  17822. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17823. protected _bias: number;
  17824. /**
  17825. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17826. */
  17827. get bias(): number;
  17828. /**
  17829. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17830. */
  17831. set bias(bias: number);
  17832. protected _normalBias: number;
  17833. /**
  17834. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17835. */
  17836. get normalBias(): number;
  17837. /**
  17838. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17839. */
  17840. set normalBias(normalBias: number);
  17841. protected _blurBoxOffset: number;
  17842. /**
  17843. * Gets the blur box offset: offset applied during the blur pass.
  17844. * Only useful if useKernelBlur = false
  17845. */
  17846. get blurBoxOffset(): number;
  17847. /**
  17848. * Sets the blur box offset: offset applied during the blur pass.
  17849. * Only useful if useKernelBlur = false
  17850. */
  17851. set blurBoxOffset(value: number);
  17852. protected _blurScale: number;
  17853. /**
  17854. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17855. * 2 means half of the size.
  17856. */
  17857. get blurScale(): number;
  17858. /**
  17859. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17860. * 2 means half of the size.
  17861. */
  17862. set blurScale(value: number);
  17863. protected _blurKernel: number;
  17864. /**
  17865. * Gets the blur kernel: kernel size of the blur pass.
  17866. * Only useful if useKernelBlur = true
  17867. */
  17868. get blurKernel(): number;
  17869. /**
  17870. * Sets the blur kernel: kernel size of the blur pass.
  17871. * Only useful if useKernelBlur = true
  17872. */
  17873. set blurKernel(value: number);
  17874. protected _useKernelBlur: boolean;
  17875. /**
  17876. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17877. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17878. */
  17879. get useKernelBlur(): boolean;
  17880. /**
  17881. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17882. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17883. */
  17884. set useKernelBlur(value: boolean);
  17885. protected _depthScale: number;
  17886. /**
  17887. * Gets the depth scale used in ESM mode.
  17888. */
  17889. get depthScale(): number;
  17890. /**
  17891. * Sets the depth scale used in ESM mode.
  17892. * This can override the scale stored on the light.
  17893. */
  17894. set depthScale(value: number);
  17895. protected _validateFilter(filter: number): number;
  17896. protected _filter: number;
  17897. /**
  17898. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17899. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17900. */
  17901. get filter(): number;
  17902. /**
  17903. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17904. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17905. */
  17906. set filter(value: number);
  17907. /**
  17908. * Gets if the current filter is set to Poisson Sampling.
  17909. */
  17910. get usePoissonSampling(): boolean;
  17911. /**
  17912. * Sets the current filter to Poisson Sampling.
  17913. */
  17914. set usePoissonSampling(value: boolean);
  17915. /**
  17916. * Gets if the current filter is set to ESM.
  17917. */
  17918. get useExponentialShadowMap(): boolean;
  17919. /**
  17920. * Sets the current filter is to ESM.
  17921. */
  17922. set useExponentialShadowMap(value: boolean);
  17923. /**
  17924. * Gets if the current filter is set to filtered ESM.
  17925. */
  17926. get useBlurExponentialShadowMap(): boolean;
  17927. /**
  17928. * Gets if the current filter is set to filtered ESM.
  17929. */
  17930. set useBlurExponentialShadowMap(value: boolean);
  17931. /**
  17932. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17933. * exponential to prevent steep falloff artifacts).
  17934. */
  17935. get useCloseExponentialShadowMap(): boolean;
  17936. /**
  17937. * Sets the current filter to "close ESM" (using the inverse of the
  17938. * exponential to prevent steep falloff artifacts).
  17939. */
  17940. set useCloseExponentialShadowMap(value: boolean);
  17941. /**
  17942. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17943. * exponential to prevent steep falloff artifacts).
  17944. */
  17945. get useBlurCloseExponentialShadowMap(): boolean;
  17946. /**
  17947. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17948. * exponential to prevent steep falloff artifacts).
  17949. */
  17950. set useBlurCloseExponentialShadowMap(value: boolean);
  17951. /**
  17952. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17953. */
  17954. get usePercentageCloserFiltering(): boolean;
  17955. /**
  17956. * Sets the current filter to "PCF" (percentage closer filtering).
  17957. */
  17958. set usePercentageCloserFiltering(value: boolean);
  17959. protected _filteringQuality: number;
  17960. /**
  17961. * Gets the PCF or PCSS Quality.
  17962. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17963. */
  17964. get filteringQuality(): number;
  17965. /**
  17966. * Sets the PCF or PCSS Quality.
  17967. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17968. */
  17969. set filteringQuality(filteringQuality: number);
  17970. /**
  17971. * Gets if the current filter is set to "PCSS" (contact hardening).
  17972. */
  17973. get useContactHardeningShadow(): boolean;
  17974. /**
  17975. * Sets the current filter to "PCSS" (contact hardening).
  17976. */
  17977. set useContactHardeningShadow(value: boolean);
  17978. protected _contactHardeningLightSizeUVRatio: number;
  17979. /**
  17980. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17981. * Using a ratio helps keeping shape stability independently of the map size.
  17982. *
  17983. * It does not account for the light projection as it was having too much
  17984. * instability during the light setup or during light position changes.
  17985. *
  17986. * Only valid if useContactHardeningShadow is true.
  17987. */
  17988. get contactHardeningLightSizeUVRatio(): number;
  17989. /**
  17990. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17991. * Using a ratio helps keeping shape stability independently of the map size.
  17992. *
  17993. * It does not account for the light projection as it was having too much
  17994. * instability during the light setup or during light position changes.
  17995. *
  17996. * Only valid if useContactHardeningShadow is true.
  17997. */
  17998. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17999. protected _darkness: number;
  18000. /** Gets or sets the actual darkness of a shadow */
  18001. get darkness(): number;
  18002. set darkness(value: number);
  18003. /**
  18004. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18005. * 0 means strongest and 1 would means no shadow.
  18006. * @returns the darkness.
  18007. */
  18008. getDarkness(): number;
  18009. /**
  18010. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18011. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18012. * @returns the shadow generator allowing fluent coding.
  18013. */
  18014. setDarkness(darkness: number): ShadowGenerator;
  18015. protected _transparencyShadow: boolean;
  18016. /** Gets or sets the ability to have transparent shadow */
  18017. get transparencyShadow(): boolean;
  18018. set transparencyShadow(value: boolean);
  18019. /**
  18020. * Sets the ability to have transparent shadow (boolean).
  18021. * @param transparent True if transparent else False
  18022. * @returns the shadow generator allowing fluent coding
  18023. */
  18024. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18025. /**
  18026. * Enables or disables shadows with varying strength based on the transparency
  18027. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18028. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18029. * mesh.visibility * alphaTexture.a
  18030. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18031. */
  18032. enableSoftTransparentShadow: boolean;
  18033. protected _shadowMap: Nullable<RenderTargetTexture>;
  18034. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18035. /**
  18036. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18037. * @returns The render target texture if present otherwise, null
  18038. */
  18039. getShadowMap(): Nullable<RenderTargetTexture>;
  18040. /**
  18041. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18042. * @returns The render target texture if the shadow map is present otherwise, null
  18043. */
  18044. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18045. /**
  18046. * Gets the class name of that object
  18047. * @returns "ShadowGenerator"
  18048. */
  18049. getClassName(): string;
  18050. /**
  18051. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18052. * @param mesh Mesh to add
  18053. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18054. * @returns the Shadow Generator itself
  18055. */
  18056. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18057. /**
  18058. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18059. * @param mesh Mesh to remove
  18060. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18061. * @returns the Shadow Generator itself
  18062. */
  18063. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18064. /**
  18065. * Controls the extent to which the shadows fade out at the edge of the frustum
  18066. */
  18067. frustumEdgeFalloff: number;
  18068. protected _light: IShadowLight;
  18069. /**
  18070. * Returns the associated light object.
  18071. * @returns the light generating the shadow
  18072. */
  18073. getLight(): IShadowLight;
  18074. /**
  18075. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18076. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18077. * It might on the other hand introduce peter panning.
  18078. */
  18079. forceBackFacesOnly: boolean;
  18080. protected _scene: Scene;
  18081. protected _lightDirection: Vector3;
  18082. protected _effect: Effect;
  18083. protected _viewMatrix: Matrix;
  18084. protected _projectionMatrix: Matrix;
  18085. protected _transformMatrix: Matrix;
  18086. protected _cachedPosition: Vector3;
  18087. protected _cachedDirection: Vector3;
  18088. protected _cachedDefines: string;
  18089. protected _currentRenderID: number;
  18090. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18091. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18092. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18093. protected _blurPostProcesses: PostProcess[];
  18094. protected _mapSize: number;
  18095. protected _currentFaceIndex: number;
  18096. protected _currentFaceIndexCache: number;
  18097. protected _textureType: number;
  18098. protected _defaultTextureMatrix: Matrix;
  18099. protected _storedUniqueId: Nullable<number>;
  18100. /** @hidden */
  18101. static _SceneComponentInitialization: (scene: Scene) => void;
  18102. /**
  18103. * Creates a ShadowGenerator object.
  18104. * A ShadowGenerator is the required tool to use the shadows.
  18105. * Each light casting shadows needs to use its own ShadowGenerator.
  18106. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18107. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18108. * @param light The light object generating the shadows.
  18109. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  18110. */
  18111. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18112. protected _initializeGenerator(): void;
  18113. protected _createTargetRenderTexture(): void;
  18114. protected _initializeShadowMap(): void;
  18115. protected _initializeBlurRTTAndPostProcesses(): void;
  18116. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18117. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18118. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18119. protected _applyFilterValues(): void;
  18120. /**
  18121. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18122. * @param onCompiled Callback triggered at the and of the effects compilation
  18123. * @param options Sets of optional options forcing the compilation with different modes
  18124. */
  18125. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18126. useInstances: boolean;
  18127. }>): void;
  18128. /**
  18129. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18130. * @param options Sets of optional options forcing the compilation with different modes
  18131. * @returns A promise that resolves when the compilation completes
  18132. */
  18133. forceCompilationAsync(options?: Partial<{
  18134. useInstances: boolean;
  18135. }>): Promise<void>;
  18136. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18137. private _prepareShadowDefines;
  18138. /**
  18139. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18140. * @param subMesh The submesh we want to render in the shadow map
  18141. * @param useInstances Defines wether will draw in the map using instances
  18142. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18143. * @returns true if ready otherwise, false
  18144. */
  18145. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18146. /**
  18147. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18148. * @param defines Defines of the material we want to update
  18149. * @param lightIndex Index of the light in the enabled light list of the material
  18150. */
  18151. prepareDefines(defines: any, lightIndex: number): void;
  18152. /**
  18153. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18154. * defined in the generator but impacting the effect).
  18155. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18156. * @param effect The effect we are binfing the information for
  18157. */
  18158. bindShadowLight(lightIndex: string, effect: Effect): void;
  18159. /**
  18160. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18161. * (eq to shadow prjection matrix * light transform matrix)
  18162. * @returns The transform matrix used to create the shadow map
  18163. */
  18164. getTransformMatrix(): Matrix;
  18165. /**
  18166. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18167. * Cube and 2D textures for instance.
  18168. */
  18169. recreateShadowMap(): void;
  18170. protected _disposeBlurPostProcesses(): void;
  18171. protected _disposeRTTandPostProcesses(): void;
  18172. /**
  18173. * Disposes the ShadowGenerator.
  18174. * Returns nothing.
  18175. */
  18176. dispose(): void;
  18177. /**
  18178. * Serializes the shadow generator setup to a json object.
  18179. * @returns The serialized JSON object
  18180. */
  18181. serialize(): any;
  18182. /**
  18183. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18184. * @param parsedShadowGenerator The JSON object to parse
  18185. * @param scene The scene to create the shadow map for
  18186. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18187. * @returns The parsed shadow generator
  18188. */
  18189. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18190. }
  18191. }
  18192. declare module "babylonjs/Lights/light" {
  18193. import { Nullable } from "babylonjs/types";
  18194. import { Scene } from "babylonjs/scene";
  18195. import { Vector3 } from "babylonjs/Maths/math.vector";
  18196. import { Color3 } from "babylonjs/Maths/math.color";
  18197. import { Node } from "babylonjs/node";
  18198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18199. import { Effect } from "babylonjs/Materials/effect";
  18200. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18201. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18202. /**
  18203. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18204. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18205. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  18206. */
  18207. export abstract class Light extends Node {
  18208. /**
  18209. * Falloff Default: light is falling off following the material specification:
  18210. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18211. */
  18212. static readonly FALLOFF_DEFAULT: number;
  18213. /**
  18214. * Falloff Physical: light is falling off following the inverse squared distance law.
  18215. */
  18216. static readonly FALLOFF_PHYSICAL: number;
  18217. /**
  18218. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18219. * to enhance interoperability with other engines.
  18220. */
  18221. static readonly FALLOFF_GLTF: number;
  18222. /**
  18223. * Falloff Standard: light is falling off like in the standard material
  18224. * to enhance interoperability with other materials.
  18225. */
  18226. static readonly FALLOFF_STANDARD: number;
  18227. /**
  18228. * If every light affecting the material is in this lightmapMode,
  18229. * material.lightmapTexture adds or multiplies
  18230. * (depends on material.useLightmapAsShadowmap)
  18231. * after every other light calculations.
  18232. */
  18233. static readonly LIGHTMAP_DEFAULT: number;
  18234. /**
  18235. * material.lightmapTexture as only diffuse lighting from this light
  18236. * adds only specular lighting from this light
  18237. * adds dynamic shadows
  18238. */
  18239. static readonly LIGHTMAP_SPECULAR: number;
  18240. /**
  18241. * material.lightmapTexture as only lighting
  18242. * no light calculation from this light
  18243. * only adds dynamic shadows from this light
  18244. */
  18245. static readonly LIGHTMAP_SHADOWSONLY: number;
  18246. /**
  18247. * Each light type uses the default quantity according to its type:
  18248. * point/spot lights use luminous intensity
  18249. * directional lights use illuminance
  18250. */
  18251. static readonly INTENSITYMODE_AUTOMATIC: number;
  18252. /**
  18253. * lumen (lm)
  18254. */
  18255. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18256. /**
  18257. * candela (lm/sr)
  18258. */
  18259. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18260. /**
  18261. * lux (lm/m^2)
  18262. */
  18263. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18264. /**
  18265. * nit (cd/m^2)
  18266. */
  18267. static readonly INTENSITYMODE_LUMINANCE: number;
  18268. /**
  18269. * Light type const id of the point light.
  18270. */
  18271. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18272. /**
  18273. * Light type const id of the directional light.
  18274. */
  18275. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18276. /**
  18277. * Light type const id of the spot light.
  18278. */
  18279. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18280. /**
  18281. * Light type const id of the hemispheric light.
  18282. */
  18283. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18284. /**
  18285. * Diffuse gives the basic color to an object.
  18286. */
  18287. diffuse: Color3;
  18288. /**
  18289. * Specular produces a highlight color on an object.
  18290. * Note: This is note affecting PBR materials.
  18291. */
  18292. specular: Color3;
  18293. /**
  18294. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18295. * falling off base on range or angle.
  18296. * This can be set to any values in Light.FALLOFF_x.
  18297. *
  18298. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18299. * other types of materials.
  18300. */
  18301. falloffType: number;
  18302. /**
  18303. * Strength of the light.
  18304. * Note: By default it is define in the framework own unit.
  18305. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18306. */
  18307. intensity: number;
  18308. private _range;
  18309. protected _inverseSquaredRange: number;
  18310. /**
  18311. * Defines how far from the source the light is impacting in scene units.
  18312. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18313. */
  18314. get range(): number;
  18315. /**
  18316. * Defines how far from the source the light is impacting in scene units.
  18317. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18318. */
  18319. set range(value: number);
  18320. /**
  18321. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18322. * of light.
  18323. */
  18324. private _photometricScale;
  18325. private _intensityMode;
  18326. /**
  18327. * Gets the photometric scale used to interpret the intensity.
  18328. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18329. */
  18330. get intensityMode(): number;
  18331. /**
  18332. * Sets the photometric scale used to interpret the intensity.
  18333. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18334. */
  18335. set intensityMode(value: number);
  18336. private _radius;
  18337. /**
  18338. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18339. */
  18340. get radius(): number;
  18341. /**
  18342. * sets the light radius used by PBR Materials to simulate soft area lights.
  18343. */
  18344. set radius(value: number);
  18345. private _renderPriority;
  18346. /**
  18347. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18348. * exceeding the number allowed of the materials.
  18349. */
  18350. renderPriority: number;
  18351. private _shadowEnabled;
  18352. /**
  18353. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18354. * the current shadow generator.
  18355. */
  18356. get shadowEnabled(): boolean;
  18357. /**
  18358. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18359. * the current shadow generator.
  18360. */
  18361. set shadowEnabled(value: boolean);
  18362. private _includedOnlyMeshes;
  18363. /**
  18364. * Gets the only meshes impacted by this light.
  18365. */
  18366. get includedOnlyMeshes(): AbstractMesh[];
  18367. /**
  18368. * Sets the only meshes impacted by this light.
  18369. */
  18370. set includedOnlyMeshes(value: AbstractMesh[]);
  18371. private _excludedMeshes;
  18372. /**
  18373. * Gets the meshes not impacted by this light.
  18374. */
  18375. get excludedMeshes(): AbstractMesh[];
  18376. /**
  18377. * Sets the meshes not impacted by this light.
  18378. */
  18379. set excludedMeshes(value: AbstractMesh[]);
  18380. private _excludeWithLayerMask;
  18381. /**
  18382. * Gets the layer id use to find what meshes are not impacted by the light.
  18383. * Inactive if 0
  18384. */
  18385. get excludeWithLayerMask(): number;
  18386. /**
  18387. * Sets the layer id use to find what meshes are not impacted by the light.
  18388. * Inactive if 0
  18389. */
  18390. set excludeWithLayerMask(value: number);
  18391. private _includeOnlyWithLayerMask;
  18392. /**
  18393. * Gets the layer id use to find what meshes are impacted by the light.
  18394. * Inactive if 0
  18395. */
  18396. get includeOnlyWithLayerMask(): number;
  18397. /**
  18398. * Sets the layer id use to find what meshes are impacted by the light.
  18399. * Inactive if 0
  18400. */
  18401. set includeOnlyWithLayerMask(value: number);
  18402. private _lightmapMode;
  18403. /**
  18404. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18405. */
  18406. get lightmapMode(): number;
  18407. /**
  18408. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18409. */
  18410. set lightmapMode(value: number);
  18411. /**
  18412. * Shadow generator associted to the light.
  18413. * @hidden Internal use only.
  18414. */
  18415. _shadowGenerator: Nullable<IShadowGenerator>;
  18416. /**
  18417. * @hidden Internal use only.
  18418. */
  18419. _excludedMeshesIds: string[];
  18420. /**
  18421. * @hidden Internal use only.
  18422. */
  18423. _includedOnlyMeshesIds: string[];
  18424. /**
  18425. * The current light unifom buffer.
  18426. * @hidden Internal use only.
  18427. */
  18428. _uniformBuffer: UniformBuffer;
  18429. /** @hidden */
  18430. _renderId: number;
  18431. /**
  18432. * Creates a Light object in the scene.
  18433. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18434. * @param name The firendly name of the light
  18435. * @param scene The scene the light belongs too
  18436. */
  18437. constructor(name: string, scene: Scene);
  18438. protected abstract _buildUniformLayout(): void;
  18439. /**
  18440. * Sets the passed Effect "effect" with the Light information.
  18441. * @param effect The effect to update
  18442. * @param lightIndex The index of the light in the effect to update
  18443. * @returns The light
  18444. */
  18445. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18446. /**
  18447. * Sets the passed Effect "effect" with the Light textures.
  18448. * @param effect The effect to update
  18449. * @param lightIndex The index of the light in the effect to update
  18450. * @returns The light
  18451. */
  18452. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18453. /**
  18454. * Binds the lights information from the scene to the effect for the given mesh.
  18455. * @param lightIndex Light index
  18456. * @param scene The scene where the light belongs to
  18457. * @param effect The effect we are binding the data to
  18458. * @param useSpecular Defines if specular is supported
  18459. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18460. */
  18461. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18462. /**
  18463. * Sets the passed Effect "effect" with the Light information.
  18464. * @param effect The effect to update
  18465. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18466. * @returns The light
  18467. */
  18468. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18469. /**
  18470. * Returns the string "Light".
  18471. * @returns the class name
  18472. */
  18473. getClassName(): string;
  18474. /** @hidden */
  18475. readonly _isLight: boolean;
  18476. /**
  18477. * Converts the light information to a readable string for debug purpose.
  18478. * @param fullDetails Supports for multiple levels of logging within scene loading
  18479. * @returns the human readable light info
  18480. */
  18481. toString(fullDetails?: boolean): string;
  18482. /** @hidden */
  18483. protected _syncParentEnabledState(): void;
  18484. /**
  18485. * Set the enabled state of this node.
  18486. * @param value - the new enabled state
  18487. */
  18488. setEnabled(value: boolean): void;
  18489. /**
  18490. * Returns the Light associated shadow generator if any.
  18491. * @return the associated shadow generator.
  18492. */
  18493. getShadowGenerator(): Nullable<IShadowGenerator>;
  18494. /**
  18495. * Returns a Vector3, the absolute light position in the World.
  18496. * @returns the world space position of the light
  18497. */
  18498. getAbsolutePosition(): Vector3;
  18499. /**
  18500. * Specifies if the light will affect the passed mesh.
  18501. * @param mesh The mesh to test against the light
  18502. * @return true the mesh is affected otherwise, false.
  18503. */
  18504. canAffectMesh(mesh: AbstractMesh): boolean;
  18505. /**
  18506. * Sort function to order lights for rendering.
  18507. * @param a First Light object to compare to second.
  18508. * @param b Second Light object to compare first.
  18509. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18510. */
  18511. static CompareLightsPriority(a: Light, b: Light): number;
  18512. /**
  18513. * Releases resources associated with this node.
  18514. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18515. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18516. */
  18517. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18518. /**
  18519. * Returns the light type ID (integer).
  18520. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18521. */
  18522. getTypeID(): number;
  18523. /**
  18524. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18525. * @returns the scaled intensity in intensity mode unit
  18526. */
  18527. getScaledIntensity(): number;
  18528. /**
  18529. * Returns a new Light object, named "name", from the current one.
  18530. * @param name The name of the cloned light
  18531. * @param newParent The parent of this light, if it has one
  18532. * @returns the new created light
  18533. */
  18534. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18535. /**
  18536. * Serializes the current light into a Serialization object.
  18537. * @returns the serialized object.
  18538. */
  18539. serialize(): any;
  18540. /**
  18541. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18542. * This new light is named "name" and added to the passed scene.
  18543. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18544. * @param name The friendly name of the light
  18545. * @param scene The scene the new light will belong to
  18546. * @returns the constructor function
  18547. */
  18548. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18549. /**
  18550. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18551. * @param parsedLight The JSON representation of the light
  18552. * @param scene The scene to create the parsed light in
  18553. * @returns the created light after parsing
  18554. */
  18555. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18556. private _hookArrayForExcluded;
  18557. private _hookArrayForIncludedOnly;
  18558. private _resyncMeshes;
  18559. /**
  18560. * Forces the meshes to update their light related information in their rendering used effects
  18561. * @hidden Internal Use Only
  18562. */
  18563. _markMeshesAsLightDirty(): void;
  18564. /**
  18565. * Recomputes the cached photometric scale if needed.
  18566. */
  18567. private _computePhotometricScale;
  18568. /**
  18569. * Returns the Photometric Scale according to the light type and intensity mode.
  18570. */
  18571. private _getPhotometricScale;
  18572. /**
  18573. * Reorder the light in the scene according to their defined priority.
  18574. * @hidden Internal Use Only
  18575. */
  18576. _reorderLightsInScene(): void;
  18577. /**
  18578. * Prepares the list of defines specific to the light type.
  18579. * @param defines the list of defines
  18580. * @param lightIndex defines the index of the light for the effect
  18581. */
  18582. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18583. }
  18584. }
  18585. declare module "babylonjs/Cameras/targetCamera" {
  18586. import { Nullable } from "babylonjs/types";
  18587. import { Camera } from "babylonjs/Cameras/camera";
  18588. import { Scene } from "babylonjs/scene";
  18589. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18590. /**
  18591. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18592. * This is the base of the follow, arc rotate cameras and Free camera
  18593. * @see https://doc.babylonjs.com/features/cameras
  18594. */
  18595. export class TargetCamera extends Camera {
  18596. private static _RigCamTransformMatrix;
  18597. private static _TargetTransformMatrix;
  18598. private static _TargetFocalPoint;
  18599. private _tmpUpVector;
  18600. private _tmpTargetVector;
  18601. /**
  18602. * Define the current direction the camera is moving to
  18603. */
  18604. cameraDirection: Vector3;
  18605. /**
  18606. * Define the current rotation the camera is rotating to
  18607. */
  18608. cameraRotation: Vector2;
  18609. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18610. ignoreParentScaling: boolean;
  18611. /**
  18612. * When set, the up vector of the camera will be updated by the rotation of the camera
  18613. */
  18614. updateUpVectorFromRotation: boolean;
  18615. private _tmpQuaternion;
  18616. /**
  18617. * Define the current rotation of the camera
  18618. */
  18619. rotation: Vector3;
  18620. /**
  18621. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18622. */
  18623. rotationQuaternion: Quaternion;
  18624. /**
  18625. * Define the current speed of the camera
  18626. */
  18627. speed: number;
  18628. /**
  18629. * Add constraint to the camera to prevent it to move freely in all directions and
  18630. * around all axis.
  18631. */
  18632. noRotationConstraint: boolean;
  18633. /**
  18634. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18635. * panning
  18636. */
  18637. invertRotation: boolean;
  18638. /**
  18639. * Speed multiplier for inverse camera panning
  18640. */
  18641. inverseRotationSpeed: number;
  18642. /**
  18643. * Define the current target of the camera as an object or a position.
  18644. */
  18645. lockedTarget: any;
  18646. /** @hidden */
  18647. _currentTarget: Vector3;
  18648. /** @hidden */
  18649. _initialFocalDistance: number;
  18650. /** @hidden */
  18651. _viewMatrix: Matrix;
  18652. /** @hidden */
  18653. _camMatrix: Matrix;
  18654. /** @hidden */
  18655. _cameraTransformMatrix: Matrix;
  18656. /** @hidden */
  18657. _cameraRotationMatrix: Matrix;
  18658. /** @hidden */
  18659. _referencePoint: Vector3;
  18660. /** @hidden */
  18661. _transformedReferencePoint: Vector3;
  18662. /** @hidden */
  18663. _reset: () => void;
  18664. private _defaultUp;
  18665. /**
  18666. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18667. * This is the base of the follow, arc rotate cameras and Free camera
  18668. * @see https://doc.babylonjs.com/features/cameras
  18669. * @param name Defines the name of the camera in the scene
  18670. * @param position Defines the start position of the camera in the scene
  18671. * @param scene Defines the scene the camera belongs to
  18672. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18673. */
  18674. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18675. /**
  18676. * Gets the position in front of the camera at a given distance.
  18677. * @param distance The distance from the camera we want the position to be
  18678. * @returns the position
  18679. */
  18680. getFrontPosition(distance: number): Vector3;
  18681. /** @hidden */
  18682. _getLockedTargetPosition(): Nullable<Vector3>;
  18683. private _storedPosition;
  18684. private _storedRotation;
  18685. private _storedRotationQuaternion;
  18686. /**
  18687. * Store current camera state of the camera (fov, position, rotation, etc..)
  18688. * @returns the camera
  18689. */
  18690. storeState(): Camera;
  18691. /**
  18692. * Restored camera state. You must call storeState() first
  18693. * @returns whether it was successful or not
  18694. * @hidden
  18695. */
  18696. _restoreStateValues(): boolean;
  18697. /** @hidden */
  18698. _initCache(): void;
  18699. /** @hidden */
  18700. _updateCache(ignoreParentClass?: boolean): void;
  18701. /** @hidden */
  18702. _isSynchronizedViewMatrix(): boolean;
  18703. /** @hidden */
  18704. _computeLocalCameraSpeed(): number;
  18705. /**
  18706. * Defines the target the camera should look at.
  18707. * @param target Defines the new target as a Vector or a mesh
  18708. */
  18709. setTarget(target: Vector3): void;
  18710. /**
  18711. * Return the current target position of the camera. This value is expressed in local space.
  18712. * @returns the target position
  18713. */
  18714. getTarget(): Vector3;
  18715. /** @hidden */
  18716. _decideIfNeedsToMove(): boolean;
  18717. /** @hidden */
  18718. _updatePosition(): void;
  18719. /** @hidden */
  18720. _checkInputs(): void;
  18721. protected _updateCameraRotationMatrix(): void;
  18722. /**
  18723. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  18724. * @returns the current camera
  18725. */
  18726. private _rotateUpVectorWithCameraRotationMatrix;
  18727. private _cachedRotationZ;
  18728. private _cachedQuaternionRotationZ;
  18729. /** @hidden */
  18730. _getViewMatrix(): Matrix;
  18731. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18732. /**
  18733. * @hidden
  18734. */
  18735. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18736. /**
  18737. * @hidden
  18738. */
  18739. _updateRigCameras(): void;
  18740. private _getRigCamPositionAndTarget;
  18741. /**
  18742. * Gets the current object class name.
  18743. * @return the class name
  18744. */
  18745. getClassName(): string;
  18746. }
  18747. }
  18748. declare module "babylonjs/Events/keyboardEvents" {
  18749. /**
  18750. * Gather the list of keyboard event types as constants.
  18751. */
  18752. export class KeyboardEventTypes {
  18753. /**
  18754. * The keydown event is fired when a key becomes active (pressed).
  18755. */
  18756. static readonly KEYDOWN: number;
  18757. /**
  18758. * The keyup event is fired when a key has been released.
  18759. */
  18760. static readonly KEYUP: number;
  18761. }
  18762. /**
  18763. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18764. */
  18765. export class KeyboardInfo {
  18766. /**
  18767. * Defines the type of event (KeyboardEventTypes)
  18768. */
  18769. type: number;
  18770. /**
  18771. * Defines the related dom event
  18772. */
  18773. event: KeyboardEvent;
  18774. /**
  18775. * Instantiates a new keyboard info.
  18776. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18777. * @param type Defines the type of event (KeyboardEventTypes)
  18778. * @param event Defines the related dom event
  18779. */
  18780. constructor(
  18781. /**
  18782. * Defines the type of event (KeyboardEventTypes)
  18783. */
  18784. type: number,
  18785. /**
  18786. * Defines the related dom event
  18787. */
  18788. event: KeyboardEvent);
  18789. }
  18790. /**
  18791. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18792. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18793. */
  18794. export class KeyboardInfoPre extends KeyboardInfo {
  18795. /**
  18796. * Defines the type of event (KeyboardEventTypes)
  18797. */
  18798. type: number;
  18799. /**
  18800. * Defines the related dom event
  18801. */
  18802. event: KeyboardEvent;
  18803. /**
  18804. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18805. */
  18806. skipOnPointerObservable: boolean;
  18807. /**
  18808. * Instantiates a new keyboard pre info.
  18809. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18810. * @param type Defines the type of event (KeyboardEventTypes)
  18811. * @param event Defines the related dom event
  18812. */
  18813. constructor(
  18814. /**
  18815. * Defines the type of event (KeyboardEventTypes)
  18816. */
  18817. type: number,
  18818. /**
  18819. * Defines the related dom event
  18820. */
  18821. event: KeyboardEvent);
  18822. }
  18823. }
  18824. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  18825. import { Nullable } from "babylonjs/types";
  18826. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18827. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18828. /**
  18829. * Manage the keyboard inputs to control the movement of a free camera.
  18830. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18831. */
  18832. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18833. /**
  18834. * Defines the camera the input is attached to.
  18835. */
  18836. camera: FreeCamera;
  18837. /**
  18838. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18839. */
  18840. keysUp: number[];
  18841. /**
  18842. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18843. */
  18844. keysUpward: number[];
  18845. /**
  18846. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18847. */
  18848. keysDown: number[];
  18849. /**
  18850. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18851. */
  18852. keysDownward: number[];
  18853. /**
  18854. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18855. */
  18856. keysLeft: number[];
  18857. /**
  18858. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18859. */
  18860. keysRight: number[];
  18861. private _keys;
  18862. private _onCanvasBlurObserver;
  18863. private _onKeyboardObserver;
  18864. private _engine;
  18865. private _scene;
  18866. /**
  18867. * Attach the input controls to a specific dom element to get the input from.
  18868. * @param element Defines the element the controls should be listened from
  18869. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18870. */
  18871. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18872. /**
  18873. * Detach the current controls from the specified dom element.
  18874. * @param element Defines the element to stop listening the inputs from
  18875. */
  18876. detachControl(element: Nullable<HTMLElement>): void;
  18877. /**
  18878. * Update the current camera state depending on the inputs that have been used this frame.
  18879. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18880. */
  18881. checkInputs(): void;
  18882. /**
  18883. * Gets the class name of the current intput.
  18884. * @returns the class name
  18885. */
  18886. getClassName(): string;
  18887. /** @hidden */
  18888. _onLostFocus(): void;
  18889. /**
  18890. * Get the friendly name associated with the input class.
  18891. * @returns the input friendly name
  18892. */
  18893. getSimpleName(): string;
  18894. }
  18895. }
  18896. declare module "babylonjs/Events/pointerEvents" {
  18897. import { Nullable } from "babylonjs/types";
  18898. import { Vector2 } from "babylonjs/Maths/math.vector";
  18899. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18900. import { Ray } from "babylonjs/Culling/ray";
  18901. /**
  18902. * Gather the list of pointer event types as constants.
  18903. */
  18904. export class PointerEventTypes {
  18905. /**
  18906. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  18907. */
  18908. static readonly POINTERDOWN: number;
  18909. /**
  18910. * The pointerup event is fired when a pointer is no longer active.
  18911. */
  18912. static readonly POINTERUP: number;
  18913. /**
  18914. * The pointermove event is fired when a pointer changes coordinates.
  18915. */
  18916. static readonly POINTERMOVE: number;
  18917. /**
  18918. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18919. */
  18920. static readonly POINTERWHEEL: number;
  18921. /**
  18922. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18923. */
  18924. static readonly POINTERPICK: number;
  18925. /**
  18926. * The pointertap event is fired when a the object has been touched and released without drag.
  18927. */
  18928. static readonly POINTERTAP: number;
  18929. /**
  18930. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18931. */
  18932. static readonly POINTERDOUBLETAP: number;
  18933. }
  18934. /**
  18935. * Base class of pointer info types.
  18936. */
  18937. export class PointerInfoBase {
  18938. /**
  18939. * Defines the type of event (PointerEventTypes)
  18940. */
  18941. type: number;
  18942. /**
  18943. * Defines the related dom event
  18944. */
  18945. event: PointerEvent | MouseWheelEvent;
  18946. /**
  18947. * Instantiates the base class of pointers info.
  18948. * @param type Defines the type of event (PointerEventTypes)
  18949. * @param event Defines the related dom event
  18950. */
  18951. constructor(
  18952. /**
  18953. * Defines the type of event (PointerEventTypes)
  18954. */
  18955. type: number,
  18956. /**
  18957. * Defines the related dom event
  18958. */
  18959. event: PointerEvent | MouseWheelEvent);
  18960. }
  18961. /**
  18962. * This class is used to store pointer related info for the onPrePointerObservable event.
  18963. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18964. */
  18965. export class PointerInfoPre extends PointerInfoBase {
  18966. /**
  18967. * Ray from a pointer if availible (eg. 6dof controller)
  18968. */
  18969. ray: Nullable<Ray>;
  18970. /**
  18971. * Defines the local position of the pointer on the canvas.
  18972. */
  18973. localPosition: Vector2;
  18974. /**
  18975. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18976. */
  18977. skipOnPointerObservable: boolean;
  18978. /**
  18979. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18980. * @param type Defines the type of event (PointerEventTypes)
  18981. * @param event Defines the related dom event
  18982. * @param localX Defines the local x coordinates of the pointer when the event occured
  18983. * @param localY Defines the local y coordinates of the pointer when the event occured
  18984. */
  18985. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18986. }
  18987. /**
  18988. * This type contains all the data related to a pointer event in Babylon.js.
  18989. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  18990. */
  18991. export class PointerInfo extends PointerInfoBase {
  18992. /**
  18993. * Defines the picking info associated to the info (if any)\
  18994. */
  18995. pickInfo: Nullable<PickingInfo>;
  18996. /**
  18997. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18998. * @param type Defines the type of event (PointerEventTypes)
  18999. * @param event Defines the related dom event
  19000. * @param pickInfo Defines the picking info associated to the info (if any)\
  19001. */
  19002. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19003. /**
  19004. * Defines the picking info associated to the info (if any)\
  19005. */
  19006. pickInfo: Nullable<PickingInfo>);
  19007. }
  19008. /**
  19009. * Data relating to a touch event on the screen.
  19010. */
  19011. export interface PointerTouch {
  19012. /**
  19013. * X coordinate of touch.
  19014. */
  19015. x: number;
  19016. /**
  19017. * Y coordinate of touch.
  19018. */
  19019. y: number;
  19020. /**
  19021. * Id of touch. Unique for each finger.
  19022. */
  19023. pointerId: number;
  19024. /**
  19025. * Event type passed from DOM.
  19026. */
  19027. type: any;
  19028. }
  19029. }
  19030. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19031. import { Observable } from "babylonjs/Misc/observable";
  19032. import { Nullable } from "babylonjs/types";
  19033. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19034. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19035. /**
  19036. * Manage the mouse inputs to control the movement of a free camera.
  19037. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19038. */
  19039. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19040. /**
  19041. * Define if touch is enabled in the mouse input
  19042. */
  19043. touchEnabled: boolean;
  19044. /**
  19045. * Defines the camera the input is attached to.
  19046. */
  19047. camera: FreeCamera;
  19048. /**
  19049. * Defines the buttons associated with the input to handle camera move.
  19050. */
  19051. buttons: number[];
  19052. /**
  19053. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19054. */
  19055. angularSensibility: number;
  19056. private _pointerInput;
  19057. private _onMouseMove;
  19058. private _observer;
  19059. private previousPosition;
  19060. /**
  19061. * Observable for when a pointer move event occurs containing the move offset
  19062. */
  19063. onPointerMovedObservable: Observable<{
  19064. offsetX: number;
  19065. offsetY: number;
  19066. }>;
  19067. /**
  19068. * @hidden
  19069. * If the camera should be rotated automatically based on pointer movement
  19070. */
  19071. _allowCameraRotation: boolean;
  19072. /**
  19073. * Manage the mouse inputs to control the movement of a free camera.
  19074. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19075. * @param touchEnabled Defines if touch is enabled or not
  19076. */
  19077. constructor(
  19078. /**
  19079. * Define if touch is enabled in the mouse input
  19080. */
  19081. touchEnabled?: boolean);
  19082. /**
  19083. * Attach the input controls to a specific dom element to get the input from.
  19084. * @param element Defines the element the controls should be listened from
  19085. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19086. */
  19087. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19088. /**
  19089. * Called on JS contextmenu event.
  19090. * Override this method to provide functionality.
  19091. */
  19092. protected onContextMenu(evt: PointerEvent): void;
  19093. /**
  19094. * Detach the current controls from the specified dom element.
  19095. * @param element Defines the element to stop listening the inputs from
  19096. */
  19097. detachControl(element: Nullable<HTMLElement>): void;
  19098. /**
  19099. * Gets the class name of the current intput.
  19100. * @returns the class name
  19101. */
  19102. getClassName(): string;
  19103. /**
  19104. * Get the friendly name associated with the input class.
  19105. * @returns the input friendly name
  19106. */
  19107. getSimpleName(): string;
  19108. }
  19109. }
  19110. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19111. import { Nullable } from "babylonjs/types";
  19112. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19113. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19114. /**
  19115. * Manage the touch inputs to control the movement of a free camera.
  19116. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19117. */
  19118. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19119. /**
  19120. * Defines the camera the input is attached to.
  19121. */
  19122. camera: FreeCamera;
  19123. /**
  19124. * Defines the touch sensibility for rotation.
  19125. * The higher the faster.
  19126. */
  19127. touchAngularSensibility: number;
  19128. /**
  19129. * Defines the touch sensibility for move.
  19130. * The higher the faster.
  19131. */
  19132. touchMoveSensibility: number;
  19133. private _offsetX;
  19134. private _offsetY;
  19135. private _pointerPressed;
  19136. private _pointerInput;
  19137. private _observer;
  19138. private _onLostFocus;
  19139. /**
  19140. * Attach the input controls to a specific dom element to get the input from.
  19141. * @param element Defines the element the controls should be listened from
  19142. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19143. */
  19144. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19145. /**
  19146. * Detach the current controls from the specified dom element.
  19147. * @param element Defines the element to stop listening the inputs from
  19148. */
  19149. detachControl(element: Nullable<HTMLElement>): void;
  19150. /**
  19151. * Update the current camera state depending on the inputs that have been used this frame.
  19152. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19153. */
  19154. checkInputs(): void;
  19155. /**
  19156. * Gets the class name of the current intput.
  19157. * @returns the class name
  19158. */
  19159. getClassName(): string;
  19160. /**
  19161. * Get the friendly name associated with the input class.
  19162. * @returns the input friendly name
  19163. */
  19164. getSimpleName(): string;
  19165. }
  19166. }
  19167. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19168. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19169. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19170. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19171. import { Nullable } from "babylonjs/types";
  19172. /**
  19173. * Default Inputs manager for the FreeCamera.
  19174. * It groups all the default supported inputs for ease of use.
  19175. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19176. */
  19177. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19178. /**
  19179. * @hidden
  19180. */
  19181. _mouseInput: Nullable<FreeCameraMouseInput>;
  19182. /**
  19183. * Instantiates a new FreeCameraInputsManager.
  19184. * @param camera Defines the camera the inputs belong to
  19185. */
  19186. constructor(camera: FreeCamera);
  19187. /**
  19188. * Add keyboard input support to the input manager.
  19189. * @returns the current input manager
  19190. */
  19191. addKeyboard(): FreeCameraInputsManager;
  19192. /**
  19193. * Add mouse input support to the input manager.
  19194. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19195. * @returns the current input manager
  19196. */
  19197. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19198. /**
  19199. * Removes the mouse input support from the manager
  19200. * @returns the current input manager
  19201. */
  19202. removeMouse(): FreeCameraInputsManager;
  19203. /**
  19204. * Add touch input support to the input manager.
  19205. * @returns the current input manager
  19206. */
  19207. addTouch(): FreeCameraInputsManager;
  19208. /**
  19209. * Remove all attached input methods from a camera
  19210. */
  19211. clear(): void;
  19212. }
  19213. }
  19214. declare module "babylonjs/Cameras/freeCamera" {
  19215. import { Vector3 } from "babylonjs/Maths/math.vector";
  19216. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19217. import { Scene } from "babylonjs/scene";
  19218. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19219. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19220. /**
  19221. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19222. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19223. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19224. */
  19225. export class FreeCamera extends TargetCamera {
  19226. /**
  19227. * Define the collision ellipsoid of the camera.
  19228. * This is helpful to simulate a camera body like the player body around the camera
  19229. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19230. */
  19231. ellipsoid: Vector3;
  19232. /**
  19233. * Define an offset for the position of the ellipsoid around the camera.
  19234. * This can be helpful to determine the center of the body near the gravity center of the body
  19235. * instead of its head.
  19236. */
  19237. ellipsoidOffset: Vector3;
  19238. /**
  19239. * Enable or disable collisions of the camera with the rest of the scene objects.
  19240. */
  19241. checkCollisions: boolean;
  19242. /**
  19243. * Enable or disable gravity on the camera.
  19244. */
  19245. applyGravity: boolean;
  19246. /**
  19247. * Define the input manager associated to the camera.
  19248. */
  19249. inputs: FreeCameraInputsManager;
  19250. /**
  19251. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19252. * Higher values reduce sensitivity.
  19253. */
  19254. get angularSensibility(): number;
  19255. /**
  19256. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19257. * Higher values reduce sensitivity.
  19258. */
  19259. set angularSensibility(value: number);
  19260. /**
  19261. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19262. */
  19263. get keysUp(): number[];
  19264. set keysUp(value: number[]);
  19265. /**
  19266. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19267. */
  19268. get keysUpward(): number[];
  19269. set keysUpward(value: number[]);
  19270. /**
  19271. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19272. */
  19273. get keysDown(): number[];
  19274. set keysDown(value: number[]);
  19275. /**
  19276. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19277. */
  19278. get keysDownward(): number[];
  19279. set keysDownward(value: number[]);
  19280. /**
  19281. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19282. */
  19283. get keysLeft(): number[];
  19284. set keysLeft(value: number[]);
  19285. /**
  19286. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19287. */
  19288. get keysRight(): number[];
  19289. set keysRight(value: number[]);
  19290. /**
  19291. * Event raised when the camera collide with a mesh in the scene.
  19292. */
  19293. onCollide: (collidedMesh: AbstractMesh) => void;
  19294. private _collider;
  19295. private _needMoveForGravity;
  19296. private _oldPosition;
  19297. private _diffPosition;
  19298. private _newPosition;
  19299. /** @hidden */
  19300. _localDirection: Vector3;
  19301. /** @hidden */
  19302. _transformedDirection: Vector3;
  19303. /**
  19304. * Instantiates a Free Camera.
  19305. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19306. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19307. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19308. * @param name Define the name of the camera in the scene
  19309. * @param position Define the start position of the camera in the scene
  19310. * @param scene Define the scene the camera belongs to
  19311. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19312. */
  19313. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19314. /**
  19315. * Attached controls to the current camera.
  19316. * @param element Defines the element the controls should be listened from
  19317. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19318. */
  19319. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19320. /**
  19321. * Detach the current controls from the camera.
  19322. * The camera will stop reacting to inputs.
  19323. * @param element Defines the element to stop listening the inputs from
  19324. */
  19325. detachControl(element: HTMLElement): void;
  19326. private _collisionMask;
  19327. /**
  19328. * Define a collision mask to limit the list of object the camera can collide with
  19329. */
  19330. get collisionMask(): number;
  19331. set collisionMask(mask: number);
  19332. /** @hidden */
  19333. _collideWithWorld(displacement: Vector3): void;
  19334. private _onCollisionPositionChange;
  19335. /** @hidden */
  19336. _checkInputs(): void;
  19337. /** @hidden */
  19338. _decideIfNeedsToMove(): boolean;
  19339. /** @hidden */
  19340. _updatePosition(): void;
  19341. /**
  19342. * Destroy the camera and release the current resources hold by it.
  19343. */
  19344. dispose(): void;
  19345. /**
  19346. * Gets the current object class name.
  19347. * @return the class name
  19348. */
  19349. getClassName(): string;
  19350. }
  19351. }
  19352. declare module "babylonjs/Gamepads/gamepad" {
  19353. import { Observable } from "babylonjs/Misc/observable";
  19354. /**
  19355. * Represents a gamepad control stick position
  19356. */
  19357. export class StickValues {
  19358. /**
  19359. * The x component of the control stick
  19360. */
  19361. x: number;
  19362. /**
  19363. * The y component of the control stick
  19364. */
  19365. y: number;
  19366. /**
  19367. * Initializes the gamepad x and y control stick values
  19368. * @param x The x component of the gamepad control stick value
  19369. * @param y The y component of the gamepad control stick value
  19370. */
  19371. constructor(
  19372. /**
  19373. * The x component of the control stick
  19374. */
  19375. x: number,
  19376. /**
  19377. * The y component of the control stick
  19378. */
  19379. y: number);
  19380. }
  19381. /**
  19382. * An interface which manages callbacks for gamepad button changes
  19383. */
  19384. export interface GamepadButtonChanges {
  19385. /**
  19386. * Called when a gamepad has been changed
  19387. */
  19388. changed: boolean;
  19389. /**
  19390. * Called when a gamepad press event has been triggered
  19391. */
  19392. pressChanged: boolean;
  19393. /**
  19394. * Called when a touch event has been triggered
  19395. */
  19396. touchChanged: boolean;
  19397. /**
  19398. * Called when a value has changed
  19399. */
  19400. valueChanged: boolean;
  19401. }
  19402. /**
  19403. * Represents a gamepad
  19404. */
  19405. export class Gamepad {
  19406. /**
  19407. * The id of the gamepad
  19408. */
  19409. id: string;
  19410. /**
  19411. * The index of the gamepad
  19412. */
  19413. index: number;
  19414. /**
  19415. * The browser gamepad
  19416. */
  19417. browserGamepad: any;
  19418. /**
  19419. * Specifies what type of gamepad this represents
  19420. */
  19421. type: number;
  19422. private _leftStick;
  19423. private _rightStick;
  19424. /** @hidden */
  19425. _isConnected: boolean;
  19426. private _leftStickAxisX;
  19427. private _leftStickAxisY;
  19428. private _rightStickAxisX;
  19429. private _rightStickAxisY;
  19430. /**
  19431. * Triggered when the left control stick has been changed
  19432. */
  19433. private _onleftstickchanged;
  19434. /**
  19435. * Triggered when the right control stick has been changed
  19436. */
  19437. private _onrightstickchanged;
  19438. /**
  19439. * Represents a gamepad controller
  19440. */
  19441. static GAMEPAD: number;
  19442. /**
  19443. * Represents a generic controller
  19444. */
  19445. static GENERIC: number;
  19446. /**
  19447. * Represents an XBox controller
  19448. */
  19449. static XBOX: number;
  19450. /**
  19451. * Represents a pose-enabled controller
  19452. */
  19453. static POSE_ENABLED: number;
  19454. /**
  19455. * Represents an Dual Shock controller
  19456. */
  19457. static DUALSHOCK: number;
  19458. /**
  19459. * Specifies whether the left control stick should be Y-inverted
  19460. */
  19461. protected _invertLeftStickY: boolean;
  19462. /**
  19463. * Specifies if the gamepad has been connected
  19464. */
  19465. get isConnected(): boolean;
  19466. /**
  19467. * Initializes the gamepad
  19468. * @param id The id of the gamepad
  19469. * @param index The index of the gamepad
  19470. * @param browserGamepad The browser gamepad
  19471. * @param leftStickX The x component of the left joystick
  19472. * @param leftStickY The y component of the left joystick
  19473. * @param rightStickX The x component of the right joystick
  19474. * @param rightStickY The y component of the right joystick
  19475. */
  19476. constructor(
  19477. /**
  19478. * The id of the gamepad
  19479. */
  19480. id: string,
  19481. /**
  19482. * The index of the gamepad
  19483. */
  19484. index: number,
  19485. /**
  19486. * The browser gamepad
  19487. */
  19488. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19489. /**
  19490. * Callback triggered when the left joystick has changed
  19491. * @param callback
  19492. */
  19493. onleftstickchanged(callback: (values: StickValues) => void): void;
  19494. /**
  19495. * Callback triggered when the right joystick has changed
  19496. * @param callback
  19497. */
  19498. onrightstickchanged(callback: (values: StickValues) => void): void;
  19499. /**
  19500. * Gets the left joystick
  19501. */
  19502. get leftStick(): StickValues;
  19503. /**
  19504. * Sets the left joystick values
  19505. */
  19506. set leftStick(newValues: StickValues);
  19507. /**
  19508. * Gets the right joystick
  19509. */
  19510. get rightStick(): StickValues;
  19511. /**
  19512. * Sets the right joystick value
  19513. */
  19514. set rightStick(newValues: StickValues);
  19515. /**
  19516. * Updates the gamepad joystick positions
  19517. */
  19518. update(): void;
  19519. /**
  19520. * Disposes the gamepad
  19521. */
  19522. dispose(): void;
  19523. }
  19524. /**
  19525. * Represents a generic gamepad
  19526. */
  19527. export class GenericPad extends Gamepad {
  19528. private _buttons;
  19529. private _onbuttondown;
  19530. private _onbuttonup;
  19531. /**
  19532. * Observable triggered when a button has been pressed
  19533. */
  19534. onButtonDownObservable: Observable<number>;
  19535. /**
  19536. * Observable triggered when a button has been released
  19537. */
  19538. onButtonUpObservable: Observable<number>;
  19539. /**
  19540. * Callback triggered when a button has been pressed
  19541. * @param callback Called when a button has been pressed
  19542. */
  19543. onbuttondown(callback: (buttonPressed: number) => void): void;
  19544. /**
  19545. * Callback triggered when a button has been released
  19546. * @param callback Called when a button has been released
  19547. */
  19548. onbuttonup(callback: (buttonReleased: number) => void): void;
  19549. /**
  19550. * Initializes the generic gamepad
  19551. * @param id The id of the generic gamepad
  19552. * @param index The index of the generic gamepad
  19553. * @param browserGamepad The browser gamepad
  19554. */
  19555. constructor(id: string, index: number, browserGamepad: any);
  19556. private _setButtonValue;
  19557. /**
  19558. * Updates the generic gamepad
  19559. */
  19560. update(): void;
  19561. /**
  19562. * Disposes the generic gamepad
  19563. */
  19564. dispose(): void;
  19565. }
  19566. }
  19567. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19568. import { Observable } from "babylonjs/Misc/observable";
  19569. import { Nullable } from "babylonjs/types";
  19570. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19571. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19573. import { Ray } from "babylonjs/Culling/ray";
  19574. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19575. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19576. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19577. /**
  19578. * Defines the types of pose enabled controllers that are supported
  19579. */
  19580. export enum PoseEnabledControllerType {
  19581. /**
  19582. * HTC Vive
  19583. */
  19584. VIVE = 0,
  19585. /**
  19586. * Oculus Rift
  19587. */
  19588. OCULUS = 1,
  19589. /**
  19590. * Windows mixed reality
  19591. */
  19592. WINDOWS = 2,
  19593. /**
  19594. * Samsung gear VR
  19595. */
  19596. GEAR_VR = 3,
  19597. /**
  19598. * Google Daydream
  19599. */
  19600. DAYDREAM = 4,
  19601. /**
  19602. * Generic
  19603. */
  19604. GENERIC = 5
  19605. }
  19606. /**
  19607. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19608. */
  19609. export interface MutableGamepadButton {
  19610. /**
  19611. * Value of the button/trigger
  19612. */
  19613. value: number;
  19614. /**
  19615. * If the button/trigger is currently touched
  19616. */
  19617. touched: boolean;
  19618. /**
  19619. * If the button/trigger is currently pressed
  19620. */
  19621. pressed: boolean;
  19622. }
  19623. /**
  19624. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19625. * @hidden
  19626. */
  19627. export interface ExtendedGamepadButton extends GamepadButton {
  19628. /**
  19629. * If the button/trigger is currently pressed
  19630. */
  19631. readonly pressed: boolean;
  19632. /**
  19633. * If the button/trigger is currently touched
  19634. */
  19635. readonly touched: boolean;
  19636. /**
  19637. * Value of the button/trigger
  19638. */
  19639. readonly value: number;
  19640. }
  19641. /** @hidden */
  19642. export interface _GamePadFactory {
  19643. /**
  19644. * Returns whether or not the current gamepad can be created for this type of controller.
  19645. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19646. * @returns true if it can be created, otherwise false
  19647. */
  19648. canCreate(gamepadInfo: any): boolean;
  19649. /**
  19650. * Creates a new instance of the Gamepad.
  19651. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19652. * @returns the new gamepad instance
  19653. */
  19654. create(gamepadInfo: any): Gamepad;
  19655. }
  19656. /**
  19657. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19658. */
  19659. export class PoseEnabledControllerHelper {
  19660. /** @hidden */
  19661. static _ControllerFactories: _GamePadFactory[];
  19662. /** @hidden */
  19663. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19664. /**
  19665. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19666. * @param vrGamepad the gamepad to initialized
  19667. * @returns a vr controller of the type the gamepad identified as
  19668. */
  19669. static InitiateController(vrGamepad: any): Gamepad;
  19670. }
  19671. /**
  19672. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19673. */
  19674. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19675. /**
  19676. * If the controller is used in a webXR session
  19677. */
  19678. isXR: boolean;
  19679. private _deviceRoomPosition;
  19680. private _deviceRoomRotationQuaternion;
  19681. /**
  19682. * The device position in babylon space
  19683. */
  19684. devicePosition: Vector3;
  19685. /**
  19686. * The device rotation in babylon space
  19687. */
  19688. deviceRotationQuaternion: Quaternion;
  19689. /**
  19690. * The scale factor of the device in babylon space
  19691. */
  19692. deviceScaleFactor: number;
  19693. /**
  19694. * (Likely devicePosition should be used instead) The device position in its room space
  19695. */
  19696. position: Vector3;
  19697. /**
  19698. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19699. */
  19700. rotationQuaternion: Quaternion;
  19701. /**
  19702. * The type of controller (Eg. Windows mixed reality)
  19703. */
  19704. controllerType: PoseEnabledControllerType;
  19705. protected _calculatedPosition: Vector3;
  19706. private _calculatedRotation;
  19707. /**
  19708. * The raw pose from the device
  19709. */
  19710. rawPose: DevicePose;
  19711. private _trackPosition;
  19712. private _maxRotationDistFromHeadset;
  19713. private _draggedRoomRotation;
  19714. /**
  19715. * @hidden
  19716. */
  19717. _disableTrackPosition(fixedPosition: Vector3): void;
  19718. /**
  19719. * Internal, the mesh attached to the controller
  19720. * @hidden
  19721. */
  19722. _mesh: Nullable<AbstractMesh>;
  19723. private _poseControlledCamera;
  19724. private _leftHandSystemQuaternion;
  19725. /**
  19726. * Internal, matrix used to convert room space to babylon space
  19727. * @hidden
  19728. */
  19729. _deviceToWorld: Matrix;
  19730. /**
  19731. * Node to be used when casting a ray from the controller
  19732. * @hidden
  19733. */
  19734. _pointingPoseNode: Nullable<TransformNode>;
  19735. /**
  19736. * Name of the child mesh that can be used to cast a ray from the controller
  19737. */
  19738. static readonly POINTING_POSE: string;
  19739. /**
  19740. * Creates a new PoseEnabledController from a gamepad
  19741. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19742. */
  19743. constructor(browserGamepad: any);
  19744. private _workingMatrix;
  19745. /**
  19746. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19747. */
  19748. update(): void;
  19749. /**
  19750. * Updates only the pose device and mesh without doing any button event checking
  19751. */
  19752. protected _updatePoseAndMesh(): void;
  19753. /**
  19754. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19755. * @param poseData raw pose fromthe device
  19756. */
  19757. updateFromDevice(poseData: DevicePose): void;
  19758. /**
  19759. * @hidden
  19760. */
  19761. _meshAttachedObservable: Observable<AbstractMesh>;
  19762. /**
  19763. * Attaches a mesh to the controller
  19764. * @param mesh the mesh to be attached
  19765. */
  19766. attachToMesh(mesh: AbstractMesh): void;
  19767. /**
  19768. * Attaches the controllers mesh to a camera
  19769. * @param camera the camera the mesh should be attached to
  19770. */
  19771. attachToPoseControlledCamera(camera: TargetCamera): void;
  19772. /**
  19773. * Disposes of the controller
  19774. */
  19775. dispose(): void;
  19776. /**
  19777. * The mesh that is attached to the controller
  19778. */
  19779. get mesh(): Nullable<AbstractMesh>;
  19780. /**
  19781. * Gets the ray of the controller in the direction the controller is pointing
  19782. * @param length the length the resulting ray should be
  19783. * @returns a ray in the direction the controller is pointing
  19784. */
  19785. getForwardRay(length?: number): Ray;
  19786. }
  19787. }
  19788. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19789. import { Observable } from "babylonjs/Misc/observable";
  19790. import { Scene } from "babylonjs/scene";
  19791. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19792. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19793. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19794. import { Nullable } from "babylonjs/types";
  19795. /**
  19796. * Defines the WebVRController object that represents controllers tracked in 3D space
  19797. */
  19798. export abstract class WebVRController extends PoseEnabledController {
  19799. /**
  19800. * Internal, the default controller model for the controller
  19801. */
  19802. protected _defaultModel: Nullable<AbstractMesh>;
  19803. /**
  19804. * Fired when the trigger state has changed
  19805. */
  19806. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19807. /**
  19808. * Fired when the main button state has changed
  19809. */
  19810. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19811. /**
  19812. * Fired when the secondary button state has changed
  19813. */
  19814. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19815. /**
  19816. * Fired when the pad state has changed
  19817. */
  19818. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19819. /**
  19820. * Fired when controllers stick values have changed
  19821. */
  19822. onPadValuesChangedObservable: Observable<StickValues>;
  19823. /**
  19824. * Array of button availible on the controller
  19825. */
  19826. protected _buttons: Array<MutableGamepadButton>;
  19827. private _onButtonStateChange;
  19828. /**
  19829. * Fired when a controller button's state has changed
  19830. * @param callback the callback containing the button that was modified
  19831. */
  19832. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19833. /**
  19834. * X and Y axis corresponding to the controllers joystick
  19835. */
  19836. pad: StickValues;
  19837. /**
  19838. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19839. */
  19840. hand: string;
  19841. /**
  19842. * The default controller model for the controller
  19843. */
  19844. get defaultModel(): Nullable<AbstractMesh>;
  19845. /**
  19846. * Creates a new WebVRController from a gamepad
  19847. * @param vrGamepad the gamepad that the WebVRController should be created from
  19848. */
  19849. constructor(vrGamepad: any);
  19850. /**
  19851. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19852. */
  19853. update(): void;
  19854. /**
  19855. * Function to be called when a button is modified
  19856. */
  19857. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19858. /**
  19859. * Loads a mesh and attaches it to the controller
  19860. * @param scene the scene the mesh should be added to
  19861. * @param meshLoaded callback for when the mesh has been loaded
  19862. */
  19863. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19864. private _setButtonValue;
  19865. private _changes;
  19866. private _checkChanges;
  19867. /**
  19868. * Disposes of th webVRCOntroller
  19869. */
  19870. dispose(): void;
  19871. }
  19872. }
  19873. declare module "babylonjs/Lights/hemisphericLight" {
  19874. import { Nullable } from "babylonjs/types";
  19875. import { Scene } from "babylonjs/scene";
  19876. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19877. import { Color3 } from "babylonjs/Maths/math.color";
  19878. import { Effect } from "babylonjs/Materials/effect";
  19879. import { Light } from "babylonjs/Lights/light";
  19880. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19881. /**
  19882. * The HemisphericLight simulates the ambient environment light,
  19883. * so the passed direction is the light reflection direction, not the incoming direction.
  19884. */
  19885. export class HemisphericLight extends Light {
  19886. /**
  19887. * The groundColor is the light in the opposite direction to the one specified during creation.
  19888. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  19889. */
  19890. groundColor: Color3;
  19891. /**
  19892. * The light reflection direction, not the incoming direction.
  19893. */
  19894. direction: Vector3;
  19895. /**
  19896. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19897. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19898. * The HemisphericLight can't cast shadows.
  19899. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19900. * @param name The friendly name of the light
  19901. * @param direction The direction of the light reflection
  19902. * @param scene The scene the light belongs to
  19903. */
  19904. constructor(name: string, direction: Vector3, scene: Scene);
  19905. protected _buildUniformLayout(): void;
  19906. /**
  19907. * Returns the string "HemisphericLight".
  19908. * @return The class name
  19909. */
  19910. getClassName(): string;
  19911. /**
  19912. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19913. * Returns the updated direction.
  19914. * @param target The target the direction should point to
  19915. * @return The computed direction
  19916. */
  19917. setDirectionToTarget(target: Vector3): Vector3;
  19918. /**
  19919. * Returns the shadow generator associated to the light.
  19920. * @returns Always null for hemispheric lights because it does not support shadows.
  19921. */
  19922. getShadowGenerator(): Nullable<IShadowGenerator>;
  19923. /**
  19924. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19925. * @param effect The effect to update
  19926. * @param lightIndex The index of the light in the effect to update
  19927. * @returns The hemispheric light
  19928. */
  19929. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19930. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19931. /**
  19932. * Computes the world matrix of the node
  19933. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19934. * @param useWasUpdatedFlag defines a reserved property
  19935. * @returns the world matrix
  19936. */
  19937. computeWorldMatrix(): Matrix;
  19938. /**
  19939. * Returns the integer 3.
  19940. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19941. */
  19942. getTypeID(): number;
  19943. /**
  19944. * Prepares the list of defines specific to the light type.
  19945. * @param defines the list of defines
  19946. * @param lightIndex defines the index of the light for the effect
  19947. */
  19948. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19949. }
  19950. }
  19951. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19952. /** @hidden */
  19953. export var vrMultiviewToSingleviewPixelShader: {
  19954. name: string;
  19955. shader: string;
  19956. };
  19957. }
  19958. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19959. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19960. import { Scene } from "babylonjs/scene";
  19961. /**
  19962. * Renders to multiple views with a single draw call
  19963. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19964. */
  19965. export class MultiviewRenderTarget extends RenderTargetTexture {
  19966. /**
  19967. * Creates a multiview render target
  19968. * @param scene scene used with the render target
  19969. * @param size the size of the render target (used for each view)
  19970. */
  19971. constructor(scene: Scene, size?: number | {
  19972. width: number;
  19973. height: number;
  19974. } | {
  19975. ratio: number;
  19976. });
  19977. /**
  19978. * @hidden
  19979. * @param faceIndex the face index, if its a cube texture
  19980. */
  19981. _bindFrameBuffer(faceIndex?: number): void;
  19982. /**
  19983. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19984. * @returns the view count
  19985. */
  19986. getViewCount(): number;
  19987. }
  19988. }
  19989. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19990. import { Camera } from "babylonjs/Cameras/camera";
  19991. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19992. import { Nullable } from "babylonjs/types";
  19993. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19994. import { Matrix } from "babylonjs/Maths/math.vector";
  19995. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19996. module "babylonjs/Engines/engine" {
  19997. interface Engine {
  19998. /**
  19999. * Creates a new multiview render target
  20000. * @param width defines the width of the texture
  20001. * @param height defines the height of the texture
  20002. * @returns the created multiview texture
  20003. */
  20004. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20005. /**
  20006. * Binds a multiview framebuffer to be drawn to
  20007. * @param multiviewTexture texture to bind
  20008. */
  20009. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20010. }
  20011. }
  20012. module "babylonjs/Cameras/camera" {
  20013. interface Camera {
  20014. /**
  20015. * @hidden
  20016. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  20017. */
  20018. _useMultiviewToSingleView: boolean;
  20019. /**
  20020. * @hidden
  20021. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  20022. */
  20023. _multiviewTexture: Nullable<RenderTargetTexture>;
  20024. /**
  20025. * @hidden
  20026. * ensures the multiview texture of the camera exists and has the specified width/height
  20027. * @param width height to set on the multiview texture
  20028. * @param height width to set on the multiview texture
  20029. */
  20030. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20031. }
  20032. }
  20033. module "babylonjs/scene" {
  20034. interface Scene {
  20035. /** @hidden */
  20036. _transformMatrixR: Matrix;
  20037. /** @hidden */
  20038. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20039. /** @hidden */
  20040. _createMultiviewUbo(): void;
  20041. /** @hidden */
  20042. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20043. /** @hidden */
  20044. _renderMultiviewToSingleView(camera: Camera): void;
  20045. }
  20046. }
  20047. }
  20048. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20049. import { Camera } from "babylonjs/Cameras/camera";
  20050. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20051. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20052. import "babylonjs/Engines/Extensions/engine.multiview";
  20053. /**
  20054. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20055. * This will not be used for webXR as it supports displaying texture arrays directly
  20056. */
  20057. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20058. /**
  20059. * Initializes a VRMultiviewToSingleview
  20060. * @param name name of the post process
  20061. * @param camera camera to be applied to
  20062. * @param scaleFactor scaling factor to the size of the output texture
  20063. */
  20064. constructor(name: string, camera: Camera, scaleFactor: number);
  20065. }
  20066. }
  20067. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20068. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20069. import { Nullable } from "babylonjs/types";
  20070. import { Size } from "babylonjs/Maths/math.size";
  20071. import { Observable } from "babylonjs/Misc/observable";
  20072. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20073. /**
  20074. * Interface used to define additional presentation attributes
  20075. */
  20076. export interface IVRPresentationAttributes {
  20077. /**
  20078. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20079. */
  20080. highRefreshRate: boolean;
  20081. /**
  20082. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20083. */
  20084. foveationLevel: number;
  20085. }
  20086. module "babylonjs/Engines/engine" {
  20087. interface Engine {
  20088. /** @hidden */
  20089. _vrDisplay: any;
  20090. /** @hidden */
  20091. _vrSupported: boolean;
  20092. /** @hidden */
  20093. _oldSize: Size;
  20094. /** @hidden */
  20095. _oldHardwareScaleFactor: number;
  20096. /** @hidden */
  20097. _vrExclusivePointerMode: boolean;
  20098. /** @hidden */
  20099. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20100. /** @hidden */
  20101. _onVRDisplayPointerRestricted: () => void;
  20102. /** @hidden */
  20103. _onVRDisplayPointerUnrestricted: () => void;
  20104. /** @hidden */
  20105. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20106. /** @hidden */
  20107. _onVrDisplayDisconnect: Nullable<() => void>;
  20108. /** @hidden */
  20109. _onVrDisplayPresentChange: Nullable<() => void>;
  20110. /**
  20111. * Observable signaled when VR display mode changes
  20112. */
  20113. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20114. /**
  20115. * Observable signaled when VR request present is complete
  20116. */
  20117. onVRRequestPresentComplete: Observable<boolean>;
  20118. /**
  20119. * Observable signaled when VR request present starts
  20120. */
  20121. onVRRequestPresentStart: Observable<Engine>;
  20122. /**
  20123. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20124. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20125. */
  20126. isInVRExclusivePointerMode: boolean;
  20127. /**
  20128. * Gets a boolean indicating if a webVR device was detected
  20129. * @returns true if a webVR device was detected
  20130. */
  20131. isVRDevicePresent(): boolean;
  20132. /**
  20133. * Gets the current webVR device
  20134. * @returns the current webVR device (or null)
  20135. */
  20136. getVRDevice(): any;
  20137. /**
  20138. * Initializes a webVR display and starts listening to display change events
  20139. * The onVRDisplayChangedObservable will be notified upon these changes
  20140. * @returns A promise containing a VRDisplay and if vr is supported
  20141. */
  20142. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20143. /** @hidden */
  20144. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20145. /**
  20146. * Gets or sets the presentation attributes used to configure VR rendering
  20147. */
  20148. vrPresentationAttributes?: IVRPresentationAttributes;
  20149. /**
  20150. * Call this function to switch to webVR mode
  20151. * Will do nothing if webVR is not supported or if there is no webVR device
  20152. * @param options the webvr options provided to the camera. mainly used for multiview
  20153. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20154. */
  20155. enableVR(options: WebVROptions): void;
  20156. /** @hidden */
  20157. _onVRFullScreenTriggered(): void;
  20158. }
  20159. }
  20160. }
  20161. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20162. import { Nullable } from "babylonjs/types";
  20163. import { Observable } from "babylonjs/Misc/observable";
  20164. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20165. import { Scene } from "babylonjs/scene";
  20166. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20167. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20168. import { Node } from "babylonjs/node";
  20169. import { Ray } from "babylonjs/Culling/ray";
  20170. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20171. import "babylonjs/Engines/Extensions/engine.webVR";
  20172. /**
  20173. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20174. * IMPORTANT!! The data is right-hand data.
  20175. * @export
  20176. * @interface DevicePose
  20177. */
  20178. export interface DevicePose {
  20179. /**
  20180. * The position of the device, values in array are [x,y,z].
  20181. */
  20182. readonly position: Nullable<Float32Array>;
  20183. /**
  20184. * The linearVelocity of the device, values in array are [x,y,z].
  20185. */
  20186. readonly linearVelocity: Nullable<Float32Array>;
  20187. /**
  20188. * The linearAcceleration of the device, values in array are [x,y,z].
  20189. */
  20190. readonly linearAcceleration: Nullable<Float32Array>;
  20191. /**
  20192. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20193. */
  20194. readonly orientation: Nullable<Float32Array>;
  20195. /**
  20196. * The angularVelocity of the device, values in array are [x,y,z].
  20197. */
  20198. readonly angularVelocity: Nullable<Float32Array>;
  20199. /**
  20200. * The angularAcceleration of the device, values in array are [x,y,z].
  20201. */
  20202. readonly angularAcceleration: Nullable<Float32Array>;
  20203. }
  20204. /**
  20205. * Interface representing a pose controlled object in Babylon.
  20206. * A pose controlled object has both regular pose values as well as pose values
  20207. * from an external device such as a VR head mounted display
  20208. */
  20209. export interface PoseControlled {
  20210. /**
  20211. * The position of the object in babylon space.
  20212. */
  20213. position: Vector3;
  20214. /**
  20215. * The rotation quaternion of the object in babylon space.
  20216. */
  20217. rotationQuaternion: Quaternion;
  20218. /**
  20219. * The position of the device in babylon space.
  20220. */
  20221. devicePosition?: Vector3;
  20222. /**
  20223. * The rotation quaternion of the device in babylon space.
  20224. */
  20225. deviceRotationQuaternion: Quaternion;
  20226. /**
  20227. * The raw pose coming from the device.
  20228. */
  20229. rawPose: Nullable<DevicePose>;
  20230. /**
  20231. * The scale of the device to be used when translating from device space to babylon space.
  20232. */
  20233. deviceScaleFactor: number;
  20234. /**
  20235. * Updates the poseControlled values based on the input device pose.
  20236. * @param poseData the pose data to update the object with
  20237. */
  20238. updateFromDevice(poseData: DevicePose): void;
  20239. }
  20240. /**
  20241. * Set of options to customize the webVRCamera
  20242. */
  20243. export interface WebVROptions {
  20244. /**
  20245. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20246. */
  20247. trackPosition?: boolean;
  20248. /**
  20249. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20250. */
  20251. positionScale?: number;
  20252. /**
  20253. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20254. */
  20255. displayName?: string;
  20256. /**
  20257. * Should the native controller meshes be initialized. (default: true)
  20258. */
  20259. controllerMeshes?: boolean;
  20260. /**
  20261. * Creating a default HemiLight only on controllers. (default: true)
  20262. */
  20263. defaultLightingOnControllers?: boolean;
  20264. /**
  20265. * If you don't want to use the default VR button of the helper. (default: false)
  20266. */
  20267. useCustomVRButton?: boolean;
  20268. /**
  20269. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20270. */
  20271. customVRButton?: HTMLButtonElement;
  20272. /**
  20273. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20274. */
  20275. rayLength?: number;
  20276. /**
  20277. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20278. */
  20279. defaultHeight?: number;
  20280. /**
  20281. * If multiview should be used if availible (default: false)
  20282. */
  20283. useMultiview?: boolean;
  20284. }
  20285. /**
  20286. * This represents a WebVR camera.
  20287. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20288. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20289. */
  20290. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20291. private webVROptions;
  20292. /**
  20293. * @hidden
  20294. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20295. */
  20296. _vrDevice: any;
  20297. /**
  20298. * The rawPose of the vrDevice.
  20299. */
  20300. rawPose: Nullable<DevicePose>;
  20301. private _onVREnabled;
  20302. private _specsVersion;
  20303. private _attached;
  20304. private _frameData;
  20305. protected _descendants: Array<Node>;
  20306. private _deviceRoomPosition;
  20307. /** @hidden */
  20308. _deviceRoomRotationQuaternion: Quaternion;
  20309. private _standingMatrix;
  20310. /**
  20311. * Represents device position in babylon space.
  20312. */
  20313. devicePosition: Vector3;
  20314. /**
  20315. * Represents device rotation in babylon space.
  20316. */
  20317. deviceRotationQuaternion: Quaternion;
  20318. /**
  20319. * The scale of the device to be used when translating from device space to babylon space.
  20320. */
  20321. deviceScaleFactor: number;
  20322. private _deviceToWorld;
  20323. private _worldToDevice;
  20324. /**
  20325. * References to the webVR controllers for the vrDevice.
  20326. */
  20327. controllers: Array<WebVRController>;
  20328. /**
  20329. * Emits an event when a controller is attached.
  20330. */
  20331. onControllersAttachedObservable: Observable<WebVRController[]>;
  20332. /**
  20333. * Emits an event when a controller's mesh has been loaded;
  20334. */
  20335. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20336. /**
  20337. * Emits an event when the HMD's pose has been updated.
  20338. */
  20339. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20340. private _poseSet;
  20341. /**
  20342. * If the rig cameras be used as parent instead of this camera.
  20343. */
  20344. rigParenting: boolean;
  20345. private _lightOnControllers;
  20346. private _defaultHeight?;
  20347. /**
  20348. * Instantiates a WebVRFreeCamera.
  20349. * @param name The name of the WebVRFreeCamera
  20350. * @param position The starting anchor position for the camera
  20351. * @param scene The scene the camera belongs to
  20352. * @param webVROptions a set of customizable options for the webVRCamera
  20353. */
  20354. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20355. /**
  20356. * Gets the device distance from the ground in meters.
  20357. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  20358. */
  20359. deviceDistanceToRoomGround(): number;
  20360. /**
  20361. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20362. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20363. */
  20364. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20365. /**
  20366. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20367. * @returns A promise with a boolean set to if the standing matrix is supported.
  20368. */
  20369. useStandingMatrixAsync(): Promise<boolean>;
  20370. /**
  20371. * Disposes the camera
  20372. */
  20373. dispose(): void;
  20374. /**
  20375. * Gets a vrController by name.
  20376. * @param name The name of the controller to retreive
  20377. * @returns the controller matching the name specified or null if not found
  20378. */
  20379. getControllerByName(name: string): Nullable<WebVRController>;
  20380. private _leftController;
  20381. /**
  20382. * The controller corresponding to the users left hand.
  20383. */
  20384. get leftController(): Nullable<WebVRController>;
  20385. private _rightController;
  20386. /**
  20387. * The controller corresponding to the users right hand.
  20388. */
  20389. get rightController(): Nullable<WebVRController>;
  20390. /**
  20391. * Casts a ray forward from the vrCamera's gaze.
  20392. * @param length Length of the ray (default: 100)
  20393. * @returns the ray corresponding to the gaze
  20394. */
  20395. getForwardRay(length?: number): Ray;
  20396. /**
  20397. * @hidden
  20398. * Updates the camera based on device's frame data
  20399. */
  20400. _checkInputs(): void;
  20401. /**
  20402. * Updates the poseControlled values based on the input device pose.
  20403. * @param poseData Pose coming from the device
  20404. */
  20405. updateFromDevice(poseData: DevicePose): void;
  20406. private _htmlElementAttached;
  20407. private _detachIfAttached;
  20408. /**
  20409. * WebVR's attach control will start broadcasting frames to the device.
  20410. * Note that in certain browsers (chrome for example) this function must be called
  20411. * within a user-interaction callback. Example:
  20412. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20413. *
  20414. * @param element html element to attach the vrDevice to
  20415. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20416. */
  20417. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20418. /**
  20419. * Detaches the camera from the html element and disables VR
  20420. *
  20421. * @param element html element to detach from
  20422. */
  20423. detachControl(element: HTMLElement): void;
  20424. /**
  20425. * @returns the name of this class
  20426. */
  20427. getClassName(): string;
  20428. /**
  20429. * Calls resetPose on the vrDisplay
  20430. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20431. */
  20432. resetToCurrentRotation(): void;
  20433. /**
  20434. * @hidden
  20435. * Updates the rig cameras (left and right eye)
  20436. */
  20437. _updateRigCameras(): void;
  20438. private _workingVector;
  20439. private _oneVector;
  20440. private _workingMatrix;
  20441. private updateCacheCalled;
  20442. private _correctPositionIfNotTrackPosition;
  20443. /**
  20444. * @hidden
  20445. * Updates the cached values of the camera
  20446. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20447. */
  20448. _updateCache(ignoreParentClass?: boolean): void;
  20449. /**
  20450. * @hidden
  20451. * Get current device position in babylon world
  20452. */
  20453. _computeDevicePosition(): void;
  20454. /**
  20455. * Updates the current device position and rotation in the babylon world
  20456. */
  20457. update(): void;
  20458. /**
  20459. * @hidden
  20460. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20461. * @returns an identity matrix
  20462. */
  20463. _getViewMatrix(): Matrix;
  20464. private _tmpMatrix;
  20465. /**
  20466. * This function is called by the two RIG cameras.
  20467. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20468. * @hidden
  20469. */
  20470. _getWebVRViewMatrix(): Matrix;
  20471. /** @hidden */
  20472. _getWebVRProjectionMatrix(): Matrix;
  20473. private _onGamepadConnectedObserver;
  20474. private _onGamepadDisconnectedObserver;
  20475. private _updateCacheWhenTrackingDisabledObserver;
  20476. /**
  20477. * Initializes the controllers and their meshes
  20478. */
  20479. initControllers(): void;
  20480. }
  20481. }
  20482. declare module "babylonjs/Materials/materialHelper" {
  20483. import { Nullable } from "babylonjs/types";
  20484. import { Scene } from "babylonjs/scene";
  20485. import { Engine } from "babylonjs/Engines/engine";
  20486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20487. import { Light } from "babylonjs/Lights/light";
  20488. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20489. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20490. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20491. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20492. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20493. /**
  20494. * "Static Class" containing the most commonly used helper while dealing with material for
  20495. * rendering purpose.
  20496. *
  20497. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20498. *
  20499. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20500. */
  20501. export class MaterialHelper {
  20502. /**
  20503. * Bind the current view position to an effect.
  20504. * @param effect The effect to be bound
  20505. * @param scene The scene the eyes position is used from
  20506. * @param variableName name of the shader variable that will hold the eye position
  20507. */
  20508. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20509. /**
  20510. * Helps preparing the defines values about the UVs in used in the effect.
  20511. * UVs are shared as much as we can accross channels in the shaders.
  20512. * @param texture The texture we are preparing the UVs for
  20513. * @param defines The defines to update
  20514. * @param key The channel key "diffuse", "specular"... used in the shader
  20515. */
  20516. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20517. /**
  20518. * Binds a texture matrix value to its corrsponding uniform
  20519. * @param texture The texture to bind the matrix for
  20520. * @param uniformBuffer The uniform buffer receivin the data
  20521. * @param key The channel key "diffuse", "specular"... used in the shader
  20522. */
  20523. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20524. /**
  20525. * Gets the current status of the fog (should it be enabled?)
  20526. * @param mesh defines the mesh to evaluate for fog support
  20527. * @param scene defines the hosting scene
  20528. * @returns true if fog must be enabled
  20529. */
  20530. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20531. /**
  20532. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20533. * @param mesh defines the current mesh
  20534. * @param scene defines the current scene
  20535. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20536. * @param pointsCloud defines if point cloud rendering has to be turned on
  20537. * @param fogEnabled defines if fog has to be turned on
  20538. * @param alphaTest defines if alpha testing has to be turned on
  20539. * @param defines defines the current list of defines
  20540. */
  20541. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20542. /**
  20543. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20544. * @param scene defines the current scene
  20545. * @param engine defines the current engine
  20546. * @param defines specifies the list of active defines
  20547. * @param useInstances defines if instances have to be turned on
  20548. * @param useClipPlane defines if clip plane have to be turned on
  20549. * @param useInstances defines if instances have to be turned on
  20550. * @param useThinInstances defines if thin instances have to be turned on
  20551. */
  20552. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20553. /**
  20554. * Prepares the defines for bones
  20555. * @param mesh The mesh containing the geometry data we will draw
  20556. * @param defines The defines to update
  20557. */
  20558. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20559. /**
  20560. * Prepares the defines for morph targets
  20561. * @param mesh The mesh containing the geometry data we will draw
  20562. * @param defines The defines to update
  20563. */
  20564. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20565. /**
  20566. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20567. * @param mesh The mesh containing the geometry data we will draw
  20568. * @param defines The defines to update
  20569. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20570. * @param useBones Precise whether bones should be used or not (override mesh info)
  20571. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20572. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20573. * @returns false if defines are considered not dirty and have not been checked
  20574. */
  20575. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20576. /**
  20577. * Prepares the defines related to multiview
  20578. * @param scene The scene we are intending to draw
  20579. * @param defines The defines to update
  20580. */
  20581. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20582. /**
  20583. * Prepares the defines related to the prepass
  20584. * @param scene The scene we are intending to draw
  20585. * @param defines The defines to update
  20586. * @param shouldRenderToMRT Indicates if this material renders to several textures in the prepass
  20587. */
  20588. static PrepareDefinesForPrePass(scene: Scene, defines: any, shouldRenderToMRT: boolean): void;
  20589. /**
  20590. * Prepares the defines related to the light information passed in parameter
  20591. * @param scene The scene we are intending to draw
  20592. * @param mesh The mesh the effect is compiling for
  20593. * @param light The light the effect is compiling for
  20594. * @param lightIndex The index of the light
  20595. * @param defines The defines to update
  20596. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20597. * @param state Defines the current state regarding what is needed (normals, etc...)
  20598. */
  20599. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20600. needNormals: boolean;
  20601. needRebuild: boolean;
  20602. shadowEnabled: boolean;
  20603. specularEnabled: boolean;
  20604. lightmapMode: boolean;
  20605. }): void;
  20606. /**
  20607. * Prepares the defines related to the light information passed in parameter
  20608. * @param scene The scene we are intending to draw
  20609. * @param mesh The mesh the effect is compiling for
  20610. * @param defines The defines to update
  20611. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20612. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20613. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20614. * @returns true if normals will be required for the rest of the effect
  20615. */
  20616. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20617. /**
  20618. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20619. * @param lightIndex defines the light index
  20620. * @param uniformsList The uniform list
  20621. * @param samplersList The sampler list
  20622. * @param projectedLightTexture defines if projected texture must be used
  20623. * @param uniformBuffersList defines an optional list of uniform buffers
  20624. */
  20625. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20626. /**
  20627. * Prepares the uniforms and samplers list to be used in the effect
  20628. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20629. * @param samplersList The sampler list
  20630. * @param defines The defines helping in the list generation
  20631. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20632. */
  20633. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20634. /**
  20635. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20636. * @param defines The defines to update while falling back
  20637. * @param fallbacks The authorized effect fallbacks
  20638. * @param maxSimultaneousLights The maximum number of lights allowed
  20639. * @param rank the current rank of the Effect
  20640. * @returns The newly affected rank
  20641. */
  20642. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20643. private static _TmpMorphInfluencers;
  20644. /**
  20645. * Prepares the list of attributes required for morph targets according to the effect defines.
  20646. * @param attribs The current list of supported attribs
  20647. * @param mesh The mesh to prepare the morph targets attributes for
  20648. * @param influencers The number of influencers
  20649. */
  20650. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20651. /**
  20652. * Prepares the list of attributes required for morph targets according to the effect defines.
  20653. * @param attribs The current list of supported attribs
  20654. * @param mesh The mesh to prepare the morph targets attributes for
  20655. * @param defines The current Defines of the effect
  20656. */
  20657. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20658. /**
  20659. * Prepares the list of attributes required for bones according to the effect defines.
  20660. * @param attribs The current list of supported attribs
  20661. * @param mesh The mesh to prepare the bones attributes for
  20662. * @param defines The current Defines of the effect
  20663. * @param fallbacks The current efffect fallback strategy
  20664. */
  20665. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20666. /**
  20667. * Check and prepare the list of attributes required for instances according to the effect defines.
  20668. * @param attribs The current list of supported attribs
  20669. * @param defines The current MaterialDefines of the effect
  20670. */
  20671. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20672. /**
  20673. * Add the list of attributes required for instances to the attribs array.
  20674. * @param attribs The current list of supported attribs
  20675. */
  20676. static PushAttributesForInstances(attribs: string[]): void;
  20677. /**
  20678. * Binds the light information to the effect.
  20679. * @param light The light containing the generator
  20680. * @param effect The effect we are binding the data to
  20681. * @param lightIndex The light index in the effect used to render
  20682. */
  20683. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20684. /**
  20685. * Binds the lights information from the scene to the effect for the given mesh.
  20686. * @param light Light to bind
  20687. * @param lightIndex Light index
  20688. * @param scene The scene where the light belongs to
  20689. * @param effect The effect we are binding the data to
  20690. * @param useSpecular Defines if specular is supported
  20691. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20692. */
  20693. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20694. /**
  20695. * Binds the lights information from the scene to the effect for the given mesh.
  20696. * @param scene The scene the lights belongs to
  20697. * @param mesh The mesh we are binding the information to render
  20698. * @param effect The effect we are binding the data to
  20699. * @param defines The generated defines for the effect
  20700. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20701. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20702. */
  20703. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20704. private static _tempFogColor;
  20705. /**
  20706. * Binds the fog information from the scene to the effect for the given mesh.
  20707. * @param scene The scene the lights belongs to
  20708. * @param mesh The mesh we are binding the information to render
  20709. * @param effect The effect we are binding the data to
  20710. * @param linearSpace Defines if the fog effect is applied in linear space
  20711. */
  20712. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20713. /**
  20714. * Binds the bones information from the mesh to the effect.
  20715. * @param mesh The mesh we are binding the information to render
  20716. * @param effect The effect we are binding the data to
  20717. */
  20718. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20719. /**
  20720. * Binds the morph targets information from the mesh to the effect.
  20721. * @param abstractMesh The mesh we are binding the information to render
  20722. * @param effect The effect we are binding the data to
  20723. */
  20724. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20725. /**
  20726. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20727. * @param defines The generated defines used in the effect
  20728. * @param effect The effect we are binding the data to
  20729. * @param scene The scene we are willing to render with logarithmic scale for
  20730. */
  20731. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20732. /**
  20733. * Binds the clip plane information from the scene to the effect.
  20734. * @param scene The scene the clip plane information are extracted from
  20735. * @param effect The effect we are binding the data to
  20736. */
  20737. static BindClipPlane(effect: Effect, scene: Scene): void;
  20738. }
  20739. }
  20740. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  20741. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20742. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20743. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  20744. import { Nullable } from "babylonjs/types";
  20745. import { Effect } from "babylonjs/Materials/effect";
  20746. import { Matrix } from "babylonjs/Maths/math.vector";
  20747. import { Scene } from "babylonjs/scene";
  20748. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  20749. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  20750. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20751. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  20752. import { Observable } from "babylonjs/Misc/observable";
  20753. /**
  20754. * Block used to expose an input value
  20755. */
  20756. export class InputBlock extends NodeMaterialBlock {
  20757. private _mode;
  20758. private _associatedVariableName;
  20759. private _storedValue;
  20760. private _valueCallback;
  20761. private _type;
  20762. private _animationType;
  20763. /** Gets or set a value used to limit the range of float values */
  20764. min: number;
  20765. /** Gets or set a value used to limit the range of float values */
  20766. max: number;
  20767. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20768. isBoolean: boolean;
  20769. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20770. matrixMode: number;
  20771. /** @hidden */
  20772. _systemValue: Nullable<NodeMaterialSystemValues>;
  20773. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20774. visibleInInspector: boolean;
  20775. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20776. isConstant: boolean;
  20777. /** Gets or sets the group to use to display this block in the Inspector */
  20778. groupInInspector: string;
  20779. /** Gets an observable raised when the value is changed */
  20780. onValueChangedObservable: Observable<InputBlock>;
  20781. /**
  20782. * Gets or sets the connection point type (default is float)
  20783. */
  20784. get type(): NodeMaterialBlockConnectionPointTypes;
  20785. /**
  20786. * Creates a new InputBlock
  20787. * @param name defines the block name
  20788. * @param target defines the target of that block (Vertex by default)
  20789. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20790. */
  20791. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20792. /**
  20793. * Gets the output component
  20794. */
  20795. get output(): NodeMaterialConnectionPoint;
  20796. /**
  20797. * Set the source of this connection point to a vertex attribute
  20798. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20799. * @returns the current connection point
  20800. */
  20801. setAsAttribute(attributeName?: string): InputBlock;
  20802. /**
  20803. * Set the source of this connection point to a system value
  20804. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20805. * @returns the current connection point
  20806. */
  20807. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20808. /**
  20809. * Gets or sets the value of that point.
  20810. * Please note that this value will be ignored if valueCallback is defined
  20811. */
  20812. get value(): any;
  20813. set value(value: any);
  20814. /**
  20815. * Gets or sets a callback used to get the value of that point.
  20816. * Please note that setting this value will force the connection point to ignore the value property
  20817. */
  20818. get valueCallback(): () => any;
  20819. set valueCallback(value: () => any);
  20820. /**
  20821. * Gets or sets the associated variable name in the shader
  20822. */
  20823. get associatedVariableName(): string;
  20824. set associatedVariableName(value: string);
  20825. /** Gets or sets the type of animation applied to the input */
  20826. get animationType(): AnimatedInputBlockTypes;
  20827. set animationType(value: AnimatedInputBlockTypes);
  20828. /**
  20829. * Gets a boolean indicating that this connection point not defined yet
  20830. */
  20831. get isUndefined(): boolean;
  20832. /**
  20833. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20834. * In this case the connection point name must be the name of the uniform to use.
  20835. * Can only be set on inputs
  20836. */
  20837. get isUniform(): boolean;
  20838. set isUniform(value: boolean);
  20839. /**
  20840. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20841. * In this case the connection point name must be the name of the attribute to use
  20842. * Can only be set on inputs
  20843. */
  20844. get isAttribute(): boolean;
  20845. set isAttribute(value: boolean);
  20846. /**
  20847. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20848. * Can only be set on exit points
  20849. */
  20850. get isVarying(): boolean;
  20851. set isVarying(value: boolean);
  20852. /**
  20853. * Gets a boolean indicating that the current connection point is a system value
  20854. */
  20855. get isSystemValue(): boolean;
  20856. /**
  20857. * Gets or sets the current well known value or null if not defined as a system value
  20858. */
  20859. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20860. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20861. /**
  20862. * Gets the current class name
  20863. * @returns the class name
  20864. */
  20865. getClassName(): string;
  20866. /**
  20867. * Animate the input if animationType !== None
  20868. * @param scene defines the rendering scene
  20869. */
  20870. animate(scene: Scene): void;
  20871. private _emitDefine;
  20872. initialize(state: NodeMaterialBuildState): void;
  20873. /**
  20874. * Set the input block to its default value (based on its type)
  20875. */
  20876. setDefaultValue(): void;
  20877. private _emitConstant;
  20878. /** @hidden */
  20879. get _noContextSwitch(): boolean;
  20880. private _emit;
  20881. /** @hidden */
  20882. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20883. /** @hidden */
  20884. _transmit(effect: Effect, scene: Scene): void;
  20885. protected _buildBlock(state: NodeMaterialBuildState): void;
  20886. protected _dumpPropertiesCode(): string;
  20887. dispose(): void;
  20888. serialize(): any;
  20889. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20890. }
  20891. }
  20892. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  20893. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20894. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20895. import { Nullable } from "babylonjs/types";
  20896. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  20897. import { Observable } from "babylonjs/Misc/observable";
  20898. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20899. /**
  20900. * Enum used to define the compatibility state between two connection points
  20901. */
  20902. export enum NodeMaterialConnectionPointCompatibilityStates {
  20903. /** Points are compatibles */
  20904. Compatible = 0,
  20905. /** Points are incompatible because of their types */
  20906. TypeIncompatible = 1,
  20907. /** Points are incompatible because of their targets (vertex vs fragment) */
  20908. TargetIncompatible = 2
  20909. }
  20910. /**
  20911. * Defines the direction of a connection point
  20912. */
  20913. export enum NodeMaterialConnectionPointDirection {
  20914. /** Input */
  20915. Input = 0,
  20916. /** Output */
  20917. Output = 1
  20918. }
  20919. /**
  20920. * Defines a connection point for a block
  20921. */
  20922. export class NodeMaterialConnectionPoint {
  20923. /** @hidden */
  20924. _ownerBlock: NodeMaterialBlock;
  20925. /** @hidden */
  20926. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20927. private _endpoints;
  20928. private _associatedVariableName;
  20929. private _direction;
  20930. /** @hidden */
  20931. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20932. /** @hidden */
  20933. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20934. private _type;
  20935. /** @hidden */
  20936. _enforceAssociatedVariableName: boolean;
  20937. /** Gets the direction of the point */
  20938. get direction(): NodeMaterialConnectionPointDirection;
  20939. /** Indicates that this connection point needs dual validation before being connected to another point */
  20940. needDualDirectionValidation: boolean;
  20941. /**
  20942. * Gets or sets the additional types supported by this connection point
  20943. */
  20944. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20945. /**
  20946. * Gets or sets the additional types excluded by this connection point
  20947. */
  20948. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20949. /**
  20950. * Observable triggered when this point is connected
  20951. */
  20952. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20953. /**
  20954. * Gets or sets the associated variable name in the shader
  20955. */
  20956. get associatedVariableName(): string;
  20957. set associatedVariableName(value: string);
  20958. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20959. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20960. /**
  20961. * Gets or sets the connection point type (default is float)
  20962. */
  20963. get type(): NodeMaterialBlockConnectionPointTypes;
  20964. set type(value: NodeMaterialBlockConnectionPointTypes);
  20965. /**
  20966. * Gets or sets the connection point name
  20967. */
  20968. name: string;
  20969. /**
  20970. * Gets or sets the connection point name
  20971. */
  20972. displayName: string;
  20973. /**
  20974. * Gets or sets a boolean indicating that this connection point can be omitted
  20975. */
  20976. isOptional: boolean;
  20977. /**
  20978. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20979. */
  20980. isExposedOnFrame: boolean;
  20981. /**
  20982. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20983. */
  20984. define: string;
  20985. /** @hidden */
  20986. _prioritizeVertex: boolean;
  20987. private _target;
  20988. /** Gets or sets the target of that connection point */
  20989. get target(): NodeMaterialBlockTargets;
  20990. set target(value: NodeMaterialBlockTargets);
  20991. /**
  20992. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20993. */
  20994. get isConnected(): boolean;
  20995. /**
  20996. * Gets a boolean indicating that the current point is connected to an input block
  20997. */
  20998. get isConnectedToInputBlock(): boolean;
  20999. /**
  21000. * Gets a the connected input block (if any)
  21001. */
  21002. get connectInputBlock(): Nullable<InputBlock>;
  21003. /** Get the other side of the connection (if any) */
  21004. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21005. /** Get the block that owns this connection point */
  21006. get ownerBlock(): NodeMaterialBlock;
  21007. /** Get the block connected on the other side of this connection (if any) */
  21008. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21009. /** Get the block connected on the endpoints of this connection (if any) */
  21010. get connectedBlocks(): Array<NodeMaterialBlock>;
  21011. /** Gets the list of connected endpoints */
  21012. get endpoints(): NodeMaterialConnectionPoint[];
  21013. /** Gets a boolean indicating if that output point is connected to at least one input */
  21014. get hasEndpoints(): boolean;
  21015. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21016. get isConnectedInVertexShader(): boolean;
  21017. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21018. get isConnectedInFragmentShader(): boolean;
  21019. /**
  21020. * Creates a block suitable to be used as an input for this input point.
  21021. * If null is returned, a block based on the point type will be created.
  21022. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  21023. */
  21024. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21025. /**
  21026. * Creates a new connection point
  21027. * @param name defines the connection point name
  21028. * @param ownerBlock defines the block hosting this connection point
  21029. * @param direction defines the direction of the connection point
  21030. */
  21031. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21032. /**
  21033. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21034. * @returns the class name
  21035. */
  21036. getClassName(): string;
  21037. /**
  21038. * Gets a boolean indicating if the current point can be connected to another point
  21039. * @param connectionPoint defines the other connection point
  21040. * @returns a boolean
  21041. */
  21042. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21043. /**
  21044. * Gets a number indicating if the current point can be connected to another point
  21045. * @param connectionPoint defines the other connection point
  21046. * @returns a number defining the compatibility state
  21047. */
  21048. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21049. /**
  21050. * Connect this point to another connection point
  21051. * @param connectionPoint defines the other connection point
  21052. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21053. * @returns the current connection point
  21054. */
  21055. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21056. /**
  21057. * Disconnect this point from one of his endpoint
  21058. * @param endpoint defines the other connection point
  21059. * @returns the current connection point
  21060. */
  21061. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21062. /**
  21063. * Serializes this point in a JSON representation
  21064. * @param isInput defines if the connection point is an input (default is true)
  21065. * @returns the serialized point object
  21066. */
  21067. serialize(isInput?: boolean): any;
  21068. /**
  21069. * Release resources
  21070. */
  21071. dispose(): void;
  21072. }
  21073. }
  21074. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21075. /**
  21076. * Enum used to define the material modes
  21077. */
  21078. export enum NodeMaterialModes {
  21079. /** Regular material */
  21080. Material = 0,
  21081. /** For post process */
  21082. PostProcess = 1,
  21083. /** For particle system */
  21084. Particle = 2
  21085. }
  21086. }
  21087. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21088. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21089. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21090. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21091. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21093. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21094. import { Effect } from "babylonjs/Materials/effect";
  21095. import { Mesh } from "babylonjs/Meshes/mesh";
  21096. import { Nullable } from "babylonjs/types";
  21097. import { Texture } from "babylonjs/Materials/Textures/texture";
  21098. import { Scene } from "babylonjs/scene";
  21099. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21100. /**
  21101. * Block used to read a texture from a sampler
  21102. */
  21103. export class TextureBlock extends NodeMaterialBlock {
  21104. private _defineName;
  21105. private _linearDefineName;
  21106. private _gammaDefineName;
  21107. private _tempTextureRead;
  21108. private _samplerName;
  21109. private _transformedUVName;
  21110. private _textureTransformName;
  21111. private _textureInfoName;
  21112. private _mainUVName;
  21113. private _mainUVDefineName;
  21114. private _fragmentOnly;
  21115. /**
  21116. * Gets or sets the texture associated with the node
  21117. */
  21118. texture: Nullable<Texture>;
  21119. /**
  21120. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21121. */
  21122. convertToGammaSpace: boolean;
  21123. /**
  21124. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21125. */
  21126. convertToLinearSpace: boolean;
  21127. /**
  21128. * Create a new TextureBlock
  21129. * @param name defines the block name
  21130. */
  21131. constructor(name: string, fragmentOnly?: boolean);
  21132. /**
  21133. * Gets the current class name
  21134. * @returns the class name
  21135. */
  21136. getClassName(): string;
  21137. /**
  21138. * Gets the uv input component
  21139. */
  21140. get uv(): NodeMaterialConnectionPoint;
  21141. /**
  21142. * Gets the rgba output component
  21143. */
  21144. get rgba(): NodeMaterialConnectionPoint;
  21145. /**
  21146. * Gets the rgb output component
  21147. */
  21148. get rgb(): NodeMaterialConnectionPoint;
  21149. /**
  21150. * Gets the r output component
  21151. */
  21152. get r(): NodeMaterialConnectionPoint;
  21153. /**
  21154. * Gets the g output component
  21155. */
  21156. get g(): NodeMaterialConnectionPoint;
  21157. /**
  21158. * Gets the b output component
  21159. */
  21160. get b(): NodeMaterialConnectionPoint;
  21161. /**
  21162. * Gets the a output component
  21163. */
  21164. get a(): NodeMaterialConnectionPoint;
  21165. get target(): NodeMaterialBlockTargets;
  21166. autoConfigure(material: NodeMaterial): void;
  21167. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21168. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21169. isReady(): boolean;
  21170. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21171. private get _isMixed();
  21172. private _injectVertexCode;
  21173. private _writeTextureRead;
  21174. private _writeOutput;
  21175. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21176. protected _dumpPropertiesCode(): string;
  21177. serialize(): any;
  21178. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21179. }
  21180. }
  21181. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21182. /** @hidden */
  21183. export var reflectionFunction: {
  21184. name: string;
  21185. shader: string;
  21186. };
  21187. }
  21188. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21189. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21190. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21191. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21192. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21194. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21195. import { Effect } from "babylonjs/Materials/effect";
  21196. import { Mesh } from "babylonjs/Meshes/mesh";
  21197. import { Nullable } from "babylonjs/types";
  21198. import { Scene } from "babylonjs/scene";
  21199. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21200. /**
  21201. * Base block used to read a reflection texture from a sampler
  21202. */
  21203. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21204. /** @hidden */
  21205. _define3DName: string;
  21206. /** @hidden */
  21207. _defineCubicName: string;
  21208. /** @hidden */
  21209. _defineExplicitName: string;
  21210. /** @hidden */
  21211. _defineProjectionName: string;
  21212. /** @hidden */
  21213. _defineLocalCubicName: string;
  21214. /** @hidden */
  21215. _defineSphericalName: string;
  21216. /** @hidden */
  21217. _definePlanarName: string;
  21218. /** @hidden */
  21219. _defineEquirectangularName: string;
  21220. /** @hidden */
  21221. _defineMirroredEquirectangularFixedName: string;
  21222. /** @hidden */
  21223. _defineEquirectangularFixedName: string;
  21224. /** @hidden */
  21225. _defineSkyboxName: string;
  21226. /** @hidden */
  21227. _defineOppositeZ: string;
  21228. /** @hidden */
  21229. _cubeSamplerName: string;
  21230. /** @hidden */
  21231. _2DSamplerName: string;
  21232. protected _positionUVWName: string;
  21233. protected _directionWName: string;
  21234. protected _reflectionVectorName: string;
  21235. /** @hidden */
  21236. _reflectionCoordsName: string;
  21237. /** @hidden */
  21238. _reflectionMatrixName: string;
  21239. protected _reflectionColorName: string;
  21240. /**
  21241. * Gets or sets the texture associated with the node
  21242. */
  21243. texture: Nullable<BaseTexture>;
  21244. /**
  21245. * Create a new ReflectionTextureBaseBlock
  21246. * @param name defines the block name
  21247. */
  21248. constructor(name: string);
  21249. /**
  21250. * Gets the current class name
  21251. * @returns the class name
  21252. */
  21253. getClassName(): string;
  21254. /**
  21255. * Gets the world position input component
  21256. */
  21257. abstract get position(): NodeMaterialConnectionPoint;
  21258. /**
  21259. * Gets the world position input component
  21260. */
  21261. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21262. /**
  21263. * Gets the world normal input component
  21264. */
  21265. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21266. /**
  21267. * Gets the world input component
  21268. */
  21269. abstract get world(): NodeMaterialConnectionPoint;
  21270. /**
  21271. * Gets the camera (or eye) position component
  21272. */
  21273. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21274. /**
  21275. * Gets the view input component
  21276. */
  21277. abstract get view(): NodeMaterialConnectionPoint;
  21278. protected _getTexture(): Nullable<BaseTexture>;
  21279. autoConfigure(material: NodeMaterial): void;
  21280. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21281. isReady(): boolean;
  21282. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21283. /**
  21284. * Gets the code to inject in the vertex shader
  21285. * @param state current state of the node material building
  21286. * @returns the shader code
  21287. */
  21288. handleVertexSide(state: NodeMaterialBuildState): string;
  21289. /**
  21290. * Handles the inits for the fragment code path
  21291. * @param state node material build state
  21292. */
  21293. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21294. /**
  21295. * Generates the reflection coords code for the fragment code path
  21296. * @param worldNormalVarName name of the world normal variable
  21297. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21298. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21299. * @returns the shader code
  21300. */
  21301. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21302. /**
  21303. * Generates the reflection color code for the fragment code path
  21304. * @param lodVarName name of the lod variable
  21305. * @param swizzleLookupTexture swizzle to use for the final color variable
  21306. * @returns the shader code
  21307. */
  21308. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21309. /**
  21310. * Generates the code corresponding to the connected output points
  21311. * @param state node material build state
  21312. * @param varName name of the variable to output
  21313. * @returns the shader code
  21314. */
  21315. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21316. protected _buildBlock(state: NodeMaterialBuildState): this;
  21317. protected _dumpPropertiesCode(): string;
  21318. serialize(): any;
  21319. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21320. }
  21321. }
  21322. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21323. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21324. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21325. import { Nullable } from "babylonjs/types";
  21326. /**
  21327. * Defines a connection point to be used for points with a custom object type
  21328. */
  21329. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21330. private _blockType;
  21331. private _blockName;
  21332. private _nameForCheking?;
  21333. /**
  21334. * Creates a new connection point
  21335. * @param name defines the connection point name
  21336. * @param ownerBlock defines the block hosting this connection point
  21337. * @param direction defines the direction of the connection point
  21338. */
  21339. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21340. /**
  21341. * Gets a number indicating if the current point can be connected to another point
  21342. * @param connectionPoint defines the other connection point
  21343. * @returns a number defining the compatibility state
  21344. */
  21345. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21346. /**
  21347. * Creates a block suitable to be used as an input for this input point.
  21348. * If null is returned, a block based on the point type will be created.
  21349. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  21350. */
  21351. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21352. }
  21353. }
  21354. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21355. /**
  21356. * Enum defining the type of properties that can be edited in the property pages in the NME
  21357. */
  21358. export enum PropertyTypeForEdition {
  21359. /** property is a boolean */
  21360. Boolean = 0,
  21361. /** property is a float */
  21362. Float = 1,
  21363. /** property is a Vector2 */
  21364. Vector2 = 2,
  21365. /** property is a list of values */
  21366. List = 3
  21367. }
  21368. /**
  21369. * Interface that defines an option in a variable of type list
  21370. */
  21371. export interface IEditablePropertyListOption {
  21372. /** label of the option */
  21373. "label": string;
  21374. /** value of the option */
  21375. "value": number;
  21376. }
  21377. /**
  21378. * Interface that defines the options available for an editable property
  21379. */
  21380. export interface IEditablePropertyOption {
  21381. /** min value */
  21382. "min"?: number;
  21383. /** max value */
  21384. "max"?: number;
  21385. /** notifiers: indicates which actions to take when the property is changed */
  21386. "notifiers"?: {
  21387. /** the material should be rebuilt */
  21388. "rebuild"?: boolean;
  21389. /** the preview should be updated */
  21390. "update"?: boolean;
  21391. };
  21392. /** list of the options for a variable of type list */
  21393. "options"?: IEditablePropertyListOption[];
  21394. }
  21395. /**
  21396. * Interface that describes an editable property
  21397. */
  21398. export interface IPropertyDescriptionForEdition {
  21399. /** name of the property */
  21400. "propertyName": string;
  21401. /** display name of the property */
  21402. "displayName": string;
  21403. /** type of the property */
  21404. "type": PropertyTypeForEdition;
  21405. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21406. "groupName": string;
  21407. /** options for the property */
  21408. "options": IEditablePropertyOption;
  21409. }
  21410. /**
  21411. * Decorator that flags a property in a node material block as being editable
  21412. */
  21413. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21414. }
  21415. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21416. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21417. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21418. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21419. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21420. import { Nullable } from "babylonjs/types";
  21421. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21422. import { Mesh } from "babylonjs/Meshes/mesh";
  21423. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21424. import { Effect } from "babylonjs/Materials/effect";
  21425. import { Scene } from "babylonjs/scene";
  21426. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21427. /**
  21428. * Block used to implement the refraction part of the sub surface module of the PBR material
  21429. */
  21430. export class RefractionBlock extends NodeMaterialBlock {
  21431. /** @hidden */
  21432. _define3DName: string;
  21433. /** @hidden */
  21434. _refractionMatrixName: string;
  21435. /** @hidden */
  21436. _defineLODRefractionAlpha: string;
  21437. /** @hidden */
  21438. _defineLinearSpecularRefraction: string;
  21439. /** @hidden */
  21440. _defineOppositeZ: string;
  21441. /** @hidden */
  21442. _cubeSamplerName: string;
  21443. /** @hidden */
  21444. _2DSamplerName: string;
  21445. /** @hidden */
  21446. _vRefractionMicrosurfaceInfosName: string;
  21447. /** @hidden */
  21448. _vRefractionInfosName: string;
  21449. private _scene;
  21450. /**
  21451. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21452. * Materials half opaque for instance using refraction could benefit from this control.
  21453. */
  21454. linkRefractionWithTransparency: boolean;
  21455. /**
  21456. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21457. */
  21458. invertRefractionY: boolean;
  21459. /**
  21460. * Gets or sets the texture associated with the node
  21461. */
  21462. texture: Nullable<BaseTexture>;
  21463. /**
  21464. * Create a new RefractionBlock
  21465. * @param name defines the block name
  21466. */
  21467. constructor(name: string);
  21468. /**
  21469. * Gets the current class name
  21470. * @returns the class name
  21471. */
  21472. getClassName(): string;
  21473. /**
  21474. * Gets the intensity input component
  21475. */
  21476. get intensity(): NodeMaterialConnectionPoint;
  21477. /**
  21478. * Gets the index of refraction input component
  21479. */
  21480. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21481. /**
  21482. * Gets the tint at distance input component
  21483. */
  21484. get tintAtDistance(): NodeMaterialConnectionPoint;
  21485. /**
  21486. * Gets the view input component
  21487. */
  21488. get view(): NodeMaterialConnectionPoint;
  21489. /**
  21490. * Gets the refraction object output component
  21491. */
  21492. get refraction(): NodeMaterialConnectionPoint;
  21493. /**
  21494. * Returns true if the block has a texture
  21495. */
  21496. get hasTexture(): boolean;
  21497. protected _getTexture(): Nullable<BaseTexture>;
  21498. autoConfigure(material: NodeMaterial): void;
  21499. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21500. isReady(): boolean;
  21501. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21502. /**
  21503. * Gets the main code of the block (fragment side)
  21504. * @param state current state of the node material building
  21505. * @returns the shader code
  21506. */
  21507. getCode(state: NodeMaterialBuildState): string;
  21508. protected _buildBlock(state: NodeMaterialBuildState): this;
  21509. protected _dumpPropertiesCode(): string;
  21510. serialize(): any;
  21511. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21512. }
  21513. }
  21514. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21515. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21516. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21517. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21518. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21520. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21521. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21522. import { Nullable } from "babylonjs/types";
  21523. import { Scene } from "babylonjs/scene";
  21524. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21525. /**
  21526. * Base block used as input for post process
  21527. */
  21528. export class CurrentScreenBlock extends NodeMaterialBlock {
  21529. private _samplerName;
  21530. private _linearDefineName;
  21531. private _gammaDefineName;
  21532. private _mainUVName;
  21533. private _tempTextureRead;
  21534. /**
  21535. * Gets or sets the texture associated with the node
  21536. */
  21537. texture: Nullable<BaseTexture>;
  21538. /**
  21539. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21540. */
  21541. convertToGammaSpace: boolean;
  21542. /**
  21543. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21544. */
  21545. convertToLinearSpace: boolean;
  21546. /**
  21547. * Create a new CurrentScreenBlock
  21548. * @param name defines the block name
  21549. */
  21550. constructor(name: string);
  21551. /**
  21552. * Gets the current class name
  21553. * @returns the class name
  21554. */
  21555. getClassName(): string;
  21556. /**
  21557. * Gets the uv input component
  21558. */
  21559. get uv(): NodeMaterialConnectionPoint;
  21560. /**
  21561. * Gets the rgba output component
  21562. */
  21563. get rgba(): NodeMaterialConnectionPoint;
  21564. /**
  21565. * Gets the rgb output component
  21566. */
  21567. get rgb(): NodeMaterialConnectionPoint;
  21568. /**
  21569. * Gets the r output component
  21570. */
  21571. get r(): NodeMaterialConnectionPoint;
  21572. /**
  21573. * Gets the g output component
  21574. */
  21575. get g(): NodeMaterialConnectionPoint;
  21576. /**
  21577. * Gets the b output component
  21578. */
  21579. get b(): NodeMaterialConnectionPoint;
  21580. /**
  21581. * Gets the a output component
  21582. */
  21583. get a(): NodeMaterialConnectionPoint;
  21584. /**
  21585. * Initialize the block and prepare the context for build
  21586. * @param state defines the state that will be used for the build
  21587. */
  21588. initialize(state: NodeMaterialBuildState): void;
  21589. get target(): NodeMaterialBlockTargets;
  21590. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21591. isReady(): boolean;
  21592. private _injectVertexCode;
  21593. private _writeTextureRead;
  21594. private _writeOutput;
  21595. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21596. serialize(): any;
  21597. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21598. }
  21599. }
  21600. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21601. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21602. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21603. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21605. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21606. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21607. import { Nullable } from "babylonjs/types";
  21608. import { Scene } from "babylonjs/scene";
  21609. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21610. /**
  21611. * Base block used for the particle texture
  21612. */
  21613. export class ParticleTextureBlock extends NodeMaterialBlock {
  21614. private _samplerName;
  21615. private _linearDefineName;
  21616. private _gammaDefineName;
  21617. private _tempTextureRead;
  21618. /**
  21619. * Gets or sets the texture associated with the node
  21620. */
  21621. texture: Nullable<BaseTexture>;
  21622. /**
  21623. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21624. */
  21625. convertToGammaSpace: boolean;
  21626. /**
  21627. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21628. */
  21629. convertToLinearSpace: boolean;
  21630. /**
  21631. * Create a new ParticleTextureBlock
  21632. * @param name defines the block name
  21633. */
  21634. constructor(name: string);
  21635. /**
  21636. * Gets the current class name
  21637. * @returns the class name
  21638. */
  21639. getClassName(): string;
  21640. /**
  21641. * Gets the uv input component
  21642. */
  21643. get uv(): NodeMaterialConnectionPoint;
  21644. /**
  21645. * Gets the rgba output component
  21646. */
  21647. get rgba(): NodeMaterialConnectionPoint;
  21648. /**
  21649. * Gets the rgb output component
  21650. */
  21651. get rgb(): NodeMaterialConnectionPoint;
  21652. /**
  21653. * Gets the r output component
  21654. */
  21655. get r(): NodeMaterialConnectionPoint;
  21656. /**
  21657. * Gets the g output component
  21658. */
  21659. get g(): NodeMaterialConnectionPoint;
  21660. /**
  21661. * Gets the b output component
  21662. */
  21663. get b(): NodeMaterialConnectionPoint;
  21664. /**
  21665. * Gets the a output component
  21666. */
  21667. get a(): NodeMaterialConnectionPoint;
  21668. /**
  21669. * Initialize the block and prepare the context for build
  21670. * @param state defines the state that will be used for the build
  21671. */
  21672. initialize(state: NodeMaterialBuildState): void;
  21673. autoConfigure(material: NodeMaterial): void;
  21674. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21675. isReady(): boolean;
  21676. private _writeOutput;
  21677. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21678. serialize(): any;
  21679. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21680. }
  21681. }
  21682. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  21683. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21684. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21685. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21686. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  21687. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  21688. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  21689. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  21690. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  21691. import { Scene } from "babylonjs/scene";
  21692. /**
  21693. * Class used to store shared data between 2 NodeMaterialBuildState
  21694. */
  21695. export class NodeMaterialBuildStateSharedData {
  21696. /**
  21697. * Gets the list of emitted varyings
  21698. */
  21699. temps: string[];
  21700. /**
  21701. * Gets the list of emitted varyings
  21702. */
  21703. varyings: string[];
  21704. /**
  21705. * Gets the varying declaration string
  21706. */
  21707. varyingDeclaration: string;
  21708. /**
  21709. * Input blocks
  21710. */
  21711. inputBlocks: InputBlock[];
  21712. /**
  21713. * Input blocks
  21714. */
  21715. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21716. /**
  21717. * Bindable blocks (Blocks that need to set data to the effect)
  21718. */
  21719. bindableBlocks: NodeMaterialBlock[];
  21720. /**
  21721. * List of blocks that can provide a compilation fallback
  21722. */
  21723. blocksWithFallbacks: NodeMaterialBlock[];
  21724. /**
  21725. * List of blocks that can provide a define update
  21726. */
  21727. blocksWithDefines: NodeMaterialBlock[];
  21728. /**
  21729. * List of blocks that can provide a repeatable content
  21730. */
  21731. repeatableContentBlocks: NodeMaterialBlock[];
  21732. /**
  21733. * List of blocks that can provide a dynamic list of uniforms
  21734. */
  21735. dynamicUniformBlocks: NodeMaterialBlock[];
  21736. /**
  21737. * List of blocks that can block the isReady function for the material
  21738. */
  21739. blockingBlocks: NodeMaterialBlock[];
  21740. /**
  21741. * Gets the list of animated inputs
  21742. */
  21743. animatedInputs: InputBlock[];
  21744. /**
  21745. * Build Id used to avoid multiple recompilations
  21746. */
  21747. buildId: number;
  21748. /** List of emitted variables */
  21749. variableNames: {
  21750. [key: string]: number;
  21751. };
  21752. /** List of emitted defines */
  21753. defineNames: {
  21754. [key: string]: number;
  21755. };
  21756. /** Should emit comments? */
  21757. emitComments: boolean;
  21758. /** Emit build activity */
  21759. verbose: boolean;
  21760. /** Gets or sets the hosting scene */
  21761. scene: Scene;
  21762. /**
  21763. * Gets the compilation hints emitted at compilation time
  21764. */
  21765. hints: {
  21766. needWorldViewMatrix: boolean;
  21767. needWorldViewProjectionMatrix: boolean;
  21768. needAlphaBlending: boolean;
  21769. needAlphaTesting: boolean;
  21770. };
  21771. /**
  21772. * List of compilation checks
  21773. */
  21774. checks: {
  21775. emitVertex: boolean;
  21776. emitFragment: boolean;
  21777. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21778. };
  21779. /**
  21780. * Is vertex program allowed to be empty?
  21781. */
  21782. allowEmptyVertexProgram: boolean;
  21783. /** Creates a new shared data */
  21784. constructor();
  21785. /**
  21786. * Emits console errors and exceptions if there is a failing check
  21787. */
  21788. emitErrors(): void;
  21789. }
  21790. }
  21791. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  21792. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21793. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21794. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  21795. /**
  21796. * Class used to store node based material build state
  21797. */
  21798. export class NodeMaterialBuildState {
  21799. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21800. supportUniformBuffers: boolean;
  21801. /**
  21802. * Gets the list of emitted attributes
  21803. */
  21804. attributes: string[];
  21805. /**
  21806. * Gets the list of emitted uniforms
  21807. */
  21808. uniforms: string[];
  21809. /**
  21810. * Gets the list of emitted constants
  21811. */
  21812. constants: string[];
  21813. /**
  21814. * Gets the list of emitted samplers
  21815. */
  21816. samplers: string[];
  21817. /**
  21818. * Gets the list of emitted functions
  21819. */
  21820. functions: {
  21821. [key: string]: string;
  21822. };
  21823. /**
  21824. * Gets the list of emitted extensions
  21825. */
  21826. extensions: {
  21827. [key: string]: string;
  21828. };
  21829. /**
  21830. * Gets the target of the compilation state
  21831. */
  21832. target: NodeMaterialBlockTargets;
  21833. /**
  21834. * Gets the list of emitted counters
  21835. */
  21836. counters: {
  21837. [key: string]: number;
  21838. };
  21839. /**
  21840. * Shared data between multiple NodeMaterialBuildState instances
  21841. */
  21842. sharedData: NodeMaterialBuildStateSharedData;
  21843. /** @hidden */
  21844. _vertexState: NodeMaterialBuildState;
  21845. /** @hidden */
  21846. _attributeDeclaration: string;
  21847. /** @hidden */
  21848. _uniformDeclaration: string;
  21849. /** @hidden */
  21850. _constantDeclaration: string;
  21851. /** @hidden */
  21852. _samplerDeclaration: string;
  21853. /** @hidden */
  21854. _varyingTransfer: string;
  21855. /** @hidden */
  21856. _injectAtEnd: string;
  21857. private _repeatableContentAnchorIndex;
  21858. /** @hidden */
  21859. _builtCompilationString: string;
  21860. /**
  21861. * Gets the emitted compilation strings
  21862. */
  21863. compilationString: string;
  21864. /**
  21865. * Finalize the compilation strings
  21866. * @param state defines the current compilation state
  21867. */
  21868. finalize(state: NodeMaterialBuildState): void;
  21869. /** @hidden */
  21870. get _repeatableContentAnchor(): string;
  21871. /** @hidden */
  21872. _getFreeVariableName(prefix: string): string;
  21873. /** @hidden */
  21874. _getFreeDefineName(prefix: string): string;
  21875. /** @hidden */
  21876. _excludeVariableName(name: string): void;
  21877. /** @hidden */
  21878. _emit2DSampler(name: string): void;
  21879. /** @hidden */
  21880. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21881. /** @hidden */
  21882. _emitExtension(name: string, extension: string, define?: string): void;
  21883. /** @hidden */
  21884. _emitFunction(name: string, code: string, comments: string): void;
  21885. /** @hidden */
  21886. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21887. replaceStrings?: {
  21888. search: RegExp;
  21889. replace: string;
  21890. }[];
  21891. repeatKey?: string;
  21892. }): string;
  21893. /** @hidden */
  21894. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21895. repeatKey?: string;
  21896. removeAttributes?: boolean;
  21897. removeUniforms?: boolean;
  21898. removeVaryings?: boolean;
  21899. removeIfDef?: boolean;
  21900. replaceStrings?: {
  21901. search: RegExp;
  21902. replace: string;
  21903. }[];
  21904. }, storeKey?: string): void;
  21905. /** @hidden */
  21906. _registerTempVariable(name: string): boolean;
  21907. /** @hidden */
  21908. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21909. /** @hidden */
  21910. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21911. /** @hidden */
  21912. _emitFloat(value: number): string;
  21913. }
  21914. }
  21915. declare module "babylonjs/Misc/uniqueIdGenerator" {
  21916. /**
  21917. * Helper class used to generate session unique ID
  21918. */
  21919. export class UniqueIdGenerator {
  21920. private static _UniqueIdCounter;
  21921. /**
  21922. * Gets an unique (relatively to the current scene) Id
  21923. */
  21924. static get UniqueId(): number;
  21925. }
  21926. }
  21927. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  21928. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21929. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21930. import { Nullable } from "babylonjs/types";
  21931. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21932. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21933. import { Effect } from "babylonjs/Materials/effect";
  21934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21935. import { Mesh } from "babylonjs/Meshes/mesh";
  21936. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21937. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21938. import { Scene } from "babylonjs/scene";
  21939. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  21940. /**
  21941. * Defines a block that can be used inside a node based material
  21942. */
  21943. export class NodeMaterialBlock {
  21944. private _buildId;
  21945. private _buildTarget;
  21946. private _target;
  21947. private _isFinalMerger;
  21948. private _isInput;
  21949. protected _isUnique: boolean;
  21950. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21951. inputsAreExclusive: boolean;
  21952. /** @hidden */
  21953. _codeVariableName: string;
  21954. /** @hidden */
  21955. _inputs: NodeMaterialConnectionPoint[];
  21956. /** @hidden */
  21957. _outputs: NodeMaterialConnectionPoint[];
  21958. /** @hidden */
  21959. _preparationId: number;
  21960. /**
  21961. * Gets or sets the name of the block
  21962. */
  21963. name: string;
  21964. /**
  21965. * Gets or sets the unique id of the node
  21966. */
  21967. uniqueId: number;
  21968. /**
  21969. * Gets or sets the comments associated with this block
  21970. */
  21971. comments: string;
  21972. /**
  21973. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21974. */
  21975. get isUnique(): boolean;
  21976. /**
  21977. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21978. */
  21979. get isFinalMerger(): boolean;
  21980. /**
  21981. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21982. */
  21983. get isInput(): boolean;
  21984. /**
  21985. * Gets or sets the build Id
  21986. */
  21987. get buildId(): number;
  21988. set buildId(value: number);
  21989. /**
  21990. * Gets or sets the target of the block
  21991. */
  21992. get target(): NodeMaterialBlockTargets;
  21993. set target(value: NodeMaterialBlockTargets);
  21994. /**
  21995. * Gets the list of input points
  21996. */
  21997. get inputs(): NodeMaterialConnectionPoint[];
  21998. /** Gets the list of output points */
  21999. get outputs(): NodeMaterialConnectionPoint[];
  22000. /**
  22001. * Find an input by its name
  22002. * @param name defines the name of the input to look for
  22003. * @returns the input or null if not found
  22004. */
  22005. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22006. /**
  22007. * Find an output by its name
  22008. * @param name defines the name of the outputto look for
  22009. * @returns the output or null if not found
  22010. */
  22011. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22012. /**
  22013. * Creates a new NodeMaterialBlock
  22014. * @param name defines the block name
  22015. * @param target defines the target of that block (Vertex by default)
  22016. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22017. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22018. */
  22019. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22020. /**
  22021. * Initialize the block and prepare the context for build
  22022. * @param state defines the state that will be used for the build
  22023. */
  22024. initialize(state: NodeMaterialBuildState): void;
  22025. /**
  22026. * Bind data to effect. Will only be called for blocks with isBindable === true
  22027. * @param effect defines the effect to bind data to
  22028. * @param nodeMaterial defines the hosting NodeMaterial
  22029. * @param mesh defines the mesh that will be rendered
  22030. * @param subMesh defines the submesh that will be rendered
  22031. */
  22032. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22033. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22034. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22035. protected _writeFloat(value: number): string;
  22036. /**
  22037. * Gets the current class name e.g. "NodeMaterialBlock"
  22038. * @returns the class name
  22039. */
  22040. getClassName(): string;
  22041. /**
  22042. * Register a new input. Must be called inside a block constructor
  22043. * @param name defines the connection point name
  22044. * @param type defines the connection point type
  22045. * @param isOptional defines a boolean indicating that this input can be omitted
  22046. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22047. * @param point an already created connection point. If not provided, create a new one
  22048. * @returns the current block
  22049. */
  22050. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22051. /**
  22052. * Register a new output. Must be called inside a block constructor
  22053. * @param name defines the connection point name
  22054. * @param type defines the connection point type
  22055. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22056. * @param point an already created connection point. If not provided, create a new one
  22057. * @returns the current block
  22058. */
  22059. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22060. /**
  22061. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22062. * @param forOutput defines an optional connection point to check compatibility with
  22063. * @returns the first available input or null
  22064. */
  22065. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22066. /**
  22067. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22068. * @param forBlock defines an optional block to check compatibility with
  22069. * @returns the first available input or null
  22070. */
  22071. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22072. /**
  22073. * Gets the sibling of the given output
  22074. * @param current defines the current output
  22075. * @returns the next output in the list or null
  22076. */
  22077. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22078. /**
  22079. * Connect current block with another block
  22080. * @param other defines the block to connect with
  22081. * @param options define the various options to help pick the right connections
  22082. * @returns the current block
  22083. */
  22084. connectTo(other: NodeMaterialBlock, options?: {
  22085. input?: string;
  22086. output?: string;
  22087. outputSwizzle?: string;
  22088. }): this | undefined;
  22089. protected _buildBlock(state: NodeMaterialBuildState): void;
  22090. /**
  22091. * Add uniforms, samplers and uniform buffers at compilation time
  22092. * @param state defines the state to update
  22093. * @param nodeMaterial defines the node material requesting the update
  22094. * @param defines defines the material defines to update
  22095. * @param uniformBuffers defines the list of uniform buffer names
  22096. */
  22097. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22098. /**
  22099. * Add potential fallbacks if shader compilation fails
  22100. * @param mesh defines the mesh to be rendered
  22101. * @param fallbacks defines the current prioritized list of fallbacks
  22102. */
  22103. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22104. /**
  22105. * Initialize defines for shader compilation
  22106. * @param mesh defines the mesh to be rendered
  22107. * @param nodeMaterial defines the node material requesting the update
  22108. * @param defines defines the material defines to update
  22109. * @param useInstances specifies that instances should be used
  22110. */
  22111. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22112. /**
  22113. * Update defines for shader compilation
  22114. * @param mesh defines the mesh to be rendered
  22115. * @param nodeMaterial defines the node material requesting the update
  22116. * @param defines defines the material defines to update
  22117. * @param useInstances specifies that instances should be used
  22118. * @param subMesh defines which submesh to render
  22119. */
  22120. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22121. /**
  22122. * Lets the block try to connect some inputs automatically
  22123. * @param material defines the hosting NodeMaterial
  22124. */
  22125. autoConfigure(material: NodeMaterial): void;
  22126. /**
  22127. * Function called when a block is declared as repeatable content generator
  22128. * @param vertexShaderState defines the current compilation state for the vertex shader
  22129. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22130. * @param mesh defines the mesh to be rendered
  22131. * @param defines defines the material defines to update
  22132. */
  22133. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22134. /**
  22135. * Checks if the block is ready
  22136. * @param mesh defines the mesh to be rendered
  22137. * @param nodeMaterial defines the node material requesting the update
  22138. * @param defines defines the material defines to update
  22139. * @param useInstances specifies that instances should be used
  22140. * @returns true if the block is ready
  22141. */
  22142. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22143. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22144. private _processBuild;
  22145. /**
  22146. * Compile the current node and generate the shader code
  22147. * @param state defines the current compilation state (uniforms, samplers, current string)
  22148. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22149. * @returns true if already built
  22150. */
  22151. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22152. protected _inputRename(name: string): string;
  22153. protected _outputRename(name: string): string;
  22154. protected _dumpPropertiesCode(): string;
  22155. /** @hidden */
  22156. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22157. /** @hidden */
  22158. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22159. /**
  22160. * Clone the current block to a new identical block
  22161. * @param scene defines the hosting scene
  22162. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22163. * @returns a copy of the current block
  22164. */
  22165. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22166. /**
  22167. * Serializes this block in a JSON representation
  22168. * @returns the serialized block object
  22169. */
  22170. serialize(): any;
  22171. /** @hidden */
  22172. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22173. private _deserializePortDisplayNamesAndExposedOnFrame;
  22174. /**
  22175. * Release resources
  22176. */
  22177. dispose(): void;
  22178. }
  22179. }
  22180. declare module "babylonjs/Materials/pushMaterial" {
  22181. import { Nullable } from "babylonjs/types";
  22182. import { Scene } from "babylonjs/scene";
  22183. import { Matrix } from "babylonjs/Maths/math.vector";
  22184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22185. import { Mesh } from "babylonjs/Meshes/mesh";
  22186. import { Material } from "babylonjs/Materials/material";
  22187. import { Effect } from "babylonjs/Materials/effect";
  22188. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22189. /**
  22190. * Base class of materials working in push mode in babylon JS
  22191. * @hidden
  22192. */
  22193. export class PushMaterial extends Material {
  22194. protected _activeEffect: Effect;
  22195. protected _normalMatrix: Matrix;
  22196. constructor(name: string, scene: Scene);
  22197. getEffect(): Effect;
  22198. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22199. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22200. /**
  22201. * Binds the given world matrix to the active effect
  22202. *
  22203. * @param world the matrix to bind
  22204. */
  22205. bindOnlyWorldMatrix(world: Matrix): void;
  22206. /**
  22207. * Binds the given normal matrix to the active effect
  22208. *
  22209. * @param normalMatrix the matrix to bind
  22210. */
  22211. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22212. bind(world: Matrix, mesh?: Mesh): void;
  22213. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22214. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22215. }
  22216. }
  22217. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22218. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22219. /**
  22220. * Root class for all node material optimizers
  22221. */
  22222. export class NodeMaterialOptimizer {
  22223. /**
  22224. * Function used to optimize a NodeMaterial graph
  22225. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22226. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22227. */
  22228. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22229. }
  22230. }
  22231. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22232. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22233. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22234. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22235. import { Scene } from "babylonjs/scene";
  22236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22237. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22238. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22239. /**
  22240. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22241. */
  22242. export class TransformBlock extends NodeMaterialBlock {
  22243. /**
  22244. * Defines the value to use to complement W value to transform it to a Vector4
  22245. */
  22246. complementW: number;
  22247. /**
  22248. * Defines the value to use to complement z value to transform it to a Vector4
  22249. */
  22250. complementZ: number;
  22251. /**
  22252. * Creates a new TransformBlock
  22253. * @param name defines the block name
  22254. */
  22255. constructor(name: string);
  22256. /**
  22257. * Gets the current class name
  22258. * @returns the class name
  22259. */
  22260. getClassName(): string;
  22261. /**
  22262. * Gets the vector input
  22263. */
  22264. get vector(): NodeMaterialConnectionPoint;
  22265. /**
  22266. * Gets the output component
  22267. */
  22268. get output(): NodeMaterialConnectionPoint;
  22269. /**
  22270. * Gets the xyz output component
  22271. */
  22272. get xyz(): NodeMaterialConnectionPoint;
  22273. /**
  22274. * Gets the matrix transform input
  22275. */
  22276. get transform(): NodeMaterialConnectionPoint;
  22277. protected _buildBlock(state: NodeMaterialBuildState): this;
  22278. /**
  22279. * Update defines for shader compilation
  22280. * @param mesh defines the mesh to be rendered
  22281. * @param nodeMaterial defines the node material requesting the update
  22282. * @param defines defines the material defines to update
  22283. * @param useInstances specifies that instances should be used
  22284. * @param subMesh defines which submesh to render
  22285. */
  22286. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22287. serialize(): any;
  22288. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22289. protected _dumpPropertiesCode(): string;
  22290. }
  22291. }
  22292. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22293. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22294. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22295. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22296. /**
  22297. * Block used to output the vertex position
  22298. */
  22299. export class VertexOutputBlock extends NodeMaterialBlock {
  22300. /**
  22301. * Creates a new VertexOutputBlock
  22302. * @param name defines the block name
  22303. */
  22304. constructor(name: string);
  22305. /**
  22306. * Gets the current class name
  22307. * @returns the class name
  22308. */
  22309. getClassName(): string;
  22310. /**
  22311. * Gets the vector input component
  22312. */
  22313. get vector(): NodeMaterialConnectionPoint;
  22314. protected _buildBlock(state: NodeMaterialBuildState): this;
  22315. }
  22316. }
  22317. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22318. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22319. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22320. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22321. /**
  22322. * Block used to output the final color
  22323. */
  22324. export class FragmentOutputBlock extends NodeMaterialBlock {
  22325. /**
  22326. * Create a new FragmentOutputBlock
  22327. * @param name defines the block name
  22328. */
  22329. constructor(name: string);
  22330. /**
  22331. * Gets the current class name
  22332. * @returns the class name
  22333. */
  22334. getClassName(): string;
  22335. /**
  22336. * Gets the rgba input component
  22337. */
  22338. get rgba(): NodeMaterialConnectionPoint;
  22339. /**
  22340. * Gets the rgb input component
  22341. */
  22342. get rgb(): NodeMaterialConnectionPoint;
  22343. /**
  22344. * Gets the a input component
  22345. */
  22346. get a(): NodeMaterialConnectionPoint;
  22347. protected _buildBlock(state: NodeMaterialBuildState): this;
  22348. }
  22349. }
  22350. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22351. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22352. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22353. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22354. /**
  22355. * Block used for the particle ramp gradient section
  22356. */
  22357. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22358. /**
  22359. * Create a new ParticleRampGradientBlock
  22360. * @param name defines the block name
  22361. */
  22362. constructor(name: string);
  22363. /**
  22364. * Gets the current class name
  22365. * @returns the class name
  22366. */
  22367. getClassName(): string;
  22368. /**
  22369. * Gets the color input component
  22370. */
  22371. get color(): NodeMaterialConnectionPoint;
  22372. /**
  22373. * Gets the rampColor output component
  22374. */
  22375. get rampColor(): NodeMaterialConnectionPoint;
  22376. /**
  22377. * Initialize the block and prepare the context for build
  22378. * @param state defines the state that will be used for the build
  22379. */
  22380. initialize(state: NodeMaterialBuildState): void;
  22381. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22382. }
  22383. }
  22384. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22385. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22386. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22387. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22388. /**
  22389. * Block used for the particle blend multiply section
  22390. */
  22391. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22392. /**
  22393. * Create a new ParticleBlendMultiplyBlock
  22394. * @param name defines the block name
  22395. */
  22396. constructor(name: string);
  22397. /**
  22398. * Gets the current class name
  22399. * @returns the class name
  22400. */
  22401. getClassName(): string;
  22402. /**
  22403. * Gets the color input component
  22404. */
  22405. get color(): NodeMaterialConnectionPoint;
  22406. /**
  22407. * Gets the alphaTexture input component
  22408. */
  22409. get alphaTexture(): NodeMaterialConnectionPoint;
  22410. /**
  22411. * Gets the alphaColor input component
  22412. */
  22413. get alphaColor(): NodeMaterialConnectionPoint;
  22414. /**
  22415. * Gets the blendColor output component
  22416. */
  22417. get blendColor(): NodeMaterialConnectionPoint;
  22418. /**
  22419. * Initialize the block and prepare the context for build
  22420. * @param state defines the state that will be used for the build
  22421. */
  22422. initialize(state: NodeMaterialBuildState): void;
  22423. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22424. }
  22425. }
  22426. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22427. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22428. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22429. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22430. /**
  22431. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22432. */
  22433. export class VectorMergerBlock extends NodeMaterialBlock {
  22434. /**
  22435. * Create a new VectorMergerBlock
  22436. * @param name defines the block name
  22437. */
  22438. constructor(name: string);
  22439. /**
  22440. * Gets the current class name
  22441. * @returns the class name
  22442. */
  22443. getClassName(): string;
  22444. /**
  22445. * Gets the xyz component (input)
  22446. */
  22447. get xyzIn(): NodeMaterialConnectionPoint;
  22448. /**
  22449. * Gets the xy component (input)
  22450. */
  22451. get xyIn(): NodeMaterialConnectionPoint;
  22452. /**
  22453. * Gets the x component (input)
  22454. */
  22455. get x(): NodeMaterialConnectionPoint;
  22456. /**
  22457. * Gets the y component (input)
  22458. */
  22459. get y(): NodeMaterialConnectionPoint;
  22460. /**
  22461. * Gets the z component (input)
  22462. */
  22463. get z(): NodeMaterialConnectionPoint;
  22464. /**
  22465. * Gets the w component (input)
  22466. */
  22467. get w(): NodeMaterialConnectionPoint;
  22468. /**
  22469. * Gets the xyzw component (output)
  22470. */
  22471. get xyzw(): NodeMaterialConnectionPoint;
  22472. /**
  22473. * Gets the xyz component (output)
  22474. */
  22475. get xyzOut(): NodeMaterialConnectionPoint;
  22476. /**
  22477. * Gets the xy component (output)
  22478. */
  22479. get xyOut(): NodeMaterialConnectionPoint;
  22480. /**
  22481. * Gets the xy component (output)
  22482. * @deprecated Please use xyOut instead.
  22483. */
  22484. get xy(): NodeMaterialConnectionPoint;
  22485. /**
  22486. * Gets the xyz component (output)
  22487. * @deprecated Please use xyzOut instead.
  22488. */
  22489. get xyz(): NodeMaterialConnectionPoint;
  22490. protected _buildBlock(state: NodeMaterialBuildState): this;
  22491. }
  22492. }
  22493. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22494. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22495. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22496. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22497. import { Vector2 } from "babylonjs/Maths/math.vector";
  22498. import { Scene } from "babylonjs/scene";
  22499. /**
  22500. * Block used to remap a float from a range to a new one
  22501. */
  22502. export class RemapBlock extends NodeMaterialBlock {
  22503. /**
  22504. * Gets or sets the source range
  22505. */
  22506. sourceRange: Vector2;
  22507. /**
  22508. * Gets or sets the target range
  22509. */
  22510. targetRange: Vector2;
  22511. /**
  22512. * Creates a new RemapBlock
  22513. * @param name defines the block name
  22514. */
  22515. constructor(name: string);
  22516. /**
  22517. * Gets the current class name
  22518. * @returns the class name
  22519. */
  22520. getClassName(): string;
  22521. /**
  22522. * Gets the input component
  22523. */
  22524. get input(): NodeMaterialConnectionPoint;
  22525. /**
  22526. * Gets the source min input component
  22527. */
  22528. get sourceMin(): NodeMaterialConnectionPoint;
  22529. /**
  22530. * Gets the source max input component
  22531. */
  22532. get sourceMax(): NodeMaterialConnectionPoint;
  22533. /**
  22534. * Gets the target min input component
  22535. */
  22536. get targetMin(): NodeMaterialConnectionPoint;
  22537. /**
  22538. * Gets the target max input component
  22539. */
  22540. get targetMax(): NodeMaterialConnectionPoint;
  22541. /**
  22542. * Gets the output component
  22543. */
  22544. get output(): NodeMaterialConnectionPoint;
  22545. protected _buildBlock(state: NodeMaterialBuildState): this;
  22546. protected _dumpPropertiesCode(): string;
  22547. serialize(): any;
  22548. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22549. }
  22550. }
  22551. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22552. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22553. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22554. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22555. /**
  22556. * Block used to multiply 2 values
  22557. */
  22558. export class MultiplyBlock extends NodeMaterialBlock {
  22559. /**
  22560. * Creates a new MultiplyBlock
  22561. * @param name defines the block name
  22562. */
  22563. constructor(name: string);
  22564. /**
  22565. * Gets the current class name
  22566. * @returns the class name
  22567. */
  22568. getClassName(): string;
  22569. /**
  22570. * Gets the left operand input component
  22571. */
  22572. get left(): NodeMaterialConnectionPoint;
  22573. /**
  22574. * Gets the right operand input component
  22575. */
  22576. get right(): NodeMaterialConnectionPoint;
  22577. /**
  22578. * Gets the output component
  22579. */
  22580. get output(): NodeMaterialConnectionPoint;
  22581. protected _buildBlock(state: NodeMaterialBuildState): this;
  22582. }
  22583. }
  22584. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22585. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22586. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22587. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22588. /**
  22589. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22590. */
  22591. export class ColorSplitterBlock extends NodeMaterialBlock {
  22592. /**
  22593. * Create a new ColorSplitterBlock
  22594. * @param name defines the block name
  22595. */
  22596. constructor(name: string);
  22597. /**
  22598. * Gets the current class name
  22599. * @returns the class name
  22600. */
  22601. getClassName(): string;
  22602. /**
  22603. * Gets the rgba component (input)
  22604. */
  22605. get rgba(): NodeMaterialConnectionPoint;
  22606. /**
  22607. * Gets the rgb component (input)
  22608. */
  22609. get rgbIn(): NodeMaterialConnectionPoint;
  22610. /**
  22611. * Gets the rgb component (output)
  22612. */
  22613. get rgbOut(): NodeMaterialConnectionPoint;
  22614. /**
  22615. * Gets the r component (output)
  22616. */
  22617. get r(): NodeMaterialConnectionPoint;
  22618. /**
  22619. * Gets the g component (output)
  22620. */
  22621. get g(): NodeMaterialConnectionPoint;
  22622. /**
  22623. * Gets the b component (output)
  22624. */
  22625. get b(): NodeMaterialConnectionPoint;
  22626. /**
  22627. * Gets the a component (output)
  22628. */
  22629. get a(): NodeMaterialConnectionPoint;
  22630. protected _inputRename(name: string): string;
  22631. protected _outputRename(name: string): string;
  22632. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22633. }
  22634. }
  22635. declare module "babylonjs/Materials/Node/nodeMaterial" {
  22636. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22637. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22638. import { Scene } from "babylonjs/scene";
  22639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22640. import { Matrix } from "babylonjs/Maths/math.vector";
  22641. import { Mesh } from "babylonjs/Meshes/mesh";
  22642. import { Engine } from "babylonjs/Engines/engine";
  22643. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22644. import { Observable } from "babylonjs/Misc/observable";
  22645. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22646. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22647. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  22648. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22649. import { Nullable } from "babylonjs/types";
  22650. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22651. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22652. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22653. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22654. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22655. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22656. import { Effect } from "babylonjs/Materials/effect";
  22657. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  22658. import { Camera } from "babylonjs/Cameras/camera";
  22659. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  22660. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22661. /**
  22662. * Interface used to configure the node material editor
  22663. */
  22664. export interface INodeMaterialEditorOptions {
  22665. /** Define the URl to load node editor script */
  22666. editorURL?: string;
  22667. }
  22668. /** @hidden */
  22669. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22670. NORMAL: boolean;
  22671. TANGENT: boolean;
  22672. UV1: boolean;
  22673. /** BONES */
  22674. NUM_BONE_INFLUENCERS: number;
  22675. BonesPerMesh: number;
  22676. BONETEXTURE: boolean;
  22677. /** MORPH TARGETS */
  22678. MORPHTARGETS: boolean;
  22679. MORPHTARGETS_NORMAL: boolean;
  22680. MORPHTARGETS_TANGENT: boolean;
  22681. MORPHTARGETS_UV: boolean;
  22682. NUM_MORPH_INFLUENCERS: number;
  22683. /** IMAGE PROCESSING */
  22684. IMAGEPROCESSING: boolean;
  22685. VIGNETTE: boolean;
  22686. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22687. VIGNETTEBLENDMODEOPAQUE: boolean;
  22688. TONEMAPPING: boolean;
  22689. TONEMAPPING_ACES: boolean;
  22690. CONTRAST: boolean;
  22691. EXPOSURE: boolean;
  22692. COLORCURVES: boolean;
  22693. COLORGRADING: boolean;
  22694. COLORGRADING3D: boolean;
  22695. SAMPLER3DGREENDEPTH: boolean;
  22696. SAMPLER3DBGRMAP: boolean;
  22697. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22698. /** MISC. */
  22699. BUMPDIRECTUV: number;
  22700. constructor();
  22701. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22702. }
  22703. /**
  22704. * Class used to configure NodeMaterial
  22705. */
  22706. export interface INodeMaterialOptions {
  22707. /**
  22708. * Defines if blocks should emit comments
  22709. */
  22710. emitComments: boolean;
  22711. }
  22712. /**
  22713. * Class used to create a node based material built by assembling shader blocks
  22714. */
  22715. export class NodeMaterial extends PushMaterial {
  22716. private static _BuildIdGenerator;
  22717. private _options;
  22718. private _vertexCompilationState;
  22719. private _fragmentCompilationState;
  22720. private _sharedData;
  22721. private _buildId;
  22722. private _buildWasSuccessful;
  22723. private _cachedWorldViewMatrix;
  22724. private _cachedWorldViewProjectionMatrix;
  22725. private _optimizers;
  22726. private _animationFrame;
  22727. /** Define the Url to load node editor script */
  22728. static EditorURL: string;
  22729. /** Define the Url to load snippets */
  22730. static SnippetUrl: string;
  22731. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22732. static IgnoreTexturesAtLoadTime: boolean;
  22733. private BJSNODEMATERIALEDITOR;
  22734. /** Get the inspector from bundle or global */
  22735. private _getGlobalNodeMaterialEditor;
  22736. /**
  22737. * Snippet ID if the material was created from the snippet server
  22738. */
  22739. snippetId: string;
  22740. /**
  22741. * Gets or sets data used by visual editor
  22742. * @see https://nme.babylonjs.com
  22743. */
  22744. editorData: any;
  22745. /**
  22746. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  22747. */
  22748. ignoreAlpha: boolean;
  22749. /**
  22750. * Defines the maximum number of lights that can be used in the material
  22751. */
  22752. maxSimultaneousLights: number;
  22753. /**
  22754. * Observable raised when the material is built
  22755. */
  22756. onBuildObservable: Observable<NodeMaterial>;
  22757. /**
  22758. * Gets or sets the root nodes of the material vertex shader
  22759. */
  22760. _vertexOutputNodes: NodeMaterialBlock[];
  22761. /**
  22762. * Gets or sets the root nodes of the material fragment (pixel) shader
  22763. */
  22764. _fragmentOutputNodes: NodeMaterialBlock[];
  22765. /** Gets or sets options to control the node material overall behavior */
  22766. get options(): INodeMaterialOptions;
  22767. set options(options: INodeMaterialOptions);
  22768. /**
  22769. * Default configuration related to image processing available in the standard Material.
  22770. */
  22771. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22772. /**
  22773. * Gets the image processing configuration used either in this material.
  22774. */
  22775. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22776. /**
  22777. * Sets the Default image processing configuration used either in the this material.
  22778. *
  22779. * If sets to null, the scene one is in use.
  22780. */
  22781. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22782. /**
  22783. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22784. */
  22785. attachedBlocks: NodeMaterialBlock[];
  22786. /**
  22787. * Specifies the mode of the node material
  22788. * @hidden
  22789. */
  22790. _mode: NodeMaterialModes;
  22791. /**
  22792. * Gets the mode property
  22793. */
  22794. get mode(): NodeMaterialModes;
  22795. /**
  22796. * Create a new node based material
  22797. * @param name defines the material name
  22798. * @param scene defines the hosting scene
  22799. * @param options defines creation option
  22800. */
  22801. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22802. /**
  22803. * Gets the current class name of the material e.g. "NodeMaterial"
  22804. * @returns the class name
  22805. */
  22806. getClassName(): string;
  22807. /**
  22808. * Keep track of the image processing observer to allow dispose and replace.
  22809. */
  22810. private _imageProcessingObserver;
  22811. /**
  22812. * Attaches a new image processing configuration to the Standard Material.
  22813. * @param configuration
  22814. */
  22815. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22816. /**
  22817. * Get a block by its name
  22818. * @param name defines the name of the block to retrieve
  22819. * @returns the required block or null if not found
  22820. */
  22821. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22822. /**
  22823. * Get a block by its name
  22824. * @param predicate defines the predicate used to find the good candidate
  22825. * @returns the required block or null if not found
  22826. */
  22827. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22828. /**
  22829. * Get an input block by its name
  22830. * @param predicate defines the predicate used to find the good candidate
  22831. * @returns the required input block or null if not found
  22832. */
  22833. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22834. /**
  22835. * Gets the list of input blocks attached to this material
  22836. * @returns an array of InputBlocks
  22837. */
  22838. getInputBlocks(): InputBlock[];
  22839. /**
  22840. * Adds a new optimizer to the list of optimizers
  22841. * @param optimizer defines the optimizers to add
  22842. * @returns the current material
  22843. */
  22844. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22845. /**
  22846. * Remove an optimizer from the list of optimizers
  22847. * @param optimizer defines the optimizers to remove
  22848. * @returns the current material
  22849. */
  22850. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22851. /**
  22852. * Add a new block to the list of output nodes
  22853. * @param node defines the node to add
  22854. * @returns the current material
  22855. */
  22856. addOutputNode(node: NodeMaterialBlock): this;
  22857. /**
  22858. * Remove a block from the list of root nodes
  22859. * @param node defines the node to remove
  22860. * @returns the current material
  22861. */
  22862. removeOutputNode(node: NodeMaterialBlock): this;
  22863. private _addVertexOutputNode;
  22864. private _removeVertexOutputNode;
  22865. private _addFragmentOutputNode;
  22866. private _removeFragmentOutputNode;
  22867. /**
  22868. * Specifies if the material will require alpha blending
  22869. * @returns a boolean specifying if alpha blending is needed
  22870. */
  22871. needAlphaBlending(): boolean;
  22872. /**
  22873. * Specifies if this material should be rendered in alpha test mode
  22874. * @returns a boolean specifying if an alpha test is needed.
  22875. */
  22876. needAlphaTesting(): boolean;
  22877. private _initializeBlock;
  22878. private _resetDualBlocks;
  22879. /**
  22880. * Remove a block from the current node material
  22881. * @param block defines the block to remove
  22882. */
  22883. removeBlock(block: NodeMaterialBlock): void;
  22884. /**
  22885. * Build the material and generates the inner effect
  22886. * @param verbose defines if the build should log activity
  22887. */
  22888. build(verbose?: boolean): void;
  22889. /**
  22890. * Runs an otpimization phase to try to improve the shader code
  22891. */
  22892. optimize(): void;
  22893. private _prepareDefinesForAttributes;
  22894. /**
  22895. * Create a post process from the material
  22896. * @param camera The camera to apply the render pass to.
  22897. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22898. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22899. * @param engine The engine which the post process will be applied. (default: current engine)
  22900. * @param reusable If the post process can be reused on the same frame. (default: false)
  22901. * @param textureType Type of textures used when performing the post process. (default: 0)
  22902. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22903. * @returns the post process created
  22904. */
  22905. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22906. /**
  22907. * Create the post process effect from the material
  22908. * @param postProcess The post process to create the effect for
  22909. */
  22910. createEffectForPostProcess(postProcess: PostProcess): void;
  22911. private _createEffectOrPostProcess;
  22912. private _createEffectForParticles;
  22913. /**
  22914. * Create the effect to be used as the custom effect for a particle system
  22915. * @param particleSystem Particle system to create the effect for
  22916. * @param onCompiled defines a function to call when the effect creation is successful
  22917. * @param onError defines a function to call when the effect creation has failed
  22918. */
  22919. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22920. private _processDefines;
  22921. /**
  22922. * Get if the submesh is ready to be used and all its information available.
  22923. * Child classes can use it to update shaders
  22924. * @param mesh defines the mesh to check
  22925. * @param subMesh defines which submesh to check
  22926. * @param useInstances specifies that instances should be used
  22927. * @returns a boolean indicating that the submesh is ready or not
  22928. */
  22929. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22930. /**
  22931. * Get a string representing the shaders built by the current node graph
  22932. */
  22933. get compiledShaders(): string;
  22934. /**
  22935. * Binds the world matrix to the material
  22936. * @param world defines the world transformation matrix
  22937. */
  22938. bindOnlyWorldMatrix(world: Matrix): void;
  22939. /**
  22940. * Binds the submesh to this material by preparing the effect and shader to draw
  22941. * @param world defines the world transformation matrix
  22942. * @param mesh defines the mesh containing the submesh
  22943. * @param subMesh defines the submesh to bind the material to
  22944. */
  22945. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22946. /**
  22947. * Gets the active textures from the material
  22948. * @returns an array of textures
  22949. */
  22950. getActiveTextures(): BaseTexture[];
  22951. /**
  22952. * Gets the list of texture blocks
  22953. * @returns an array of texture blocks
  22954. */
  22955. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22956. /**
  22957. * Specifies if the material uses a texture
  22958. * @param texture defines the texture to check against the material
  22959. * @returns a boolean specifying if the material uses the texture
  22960. */
  22961. hasTexture(texture: BaseTexture): boolean;
  22962. /**
  22963. * Disposes the material
  22964. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22965. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22966. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22967. */
  22968. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22969. /** Creates the node editor window. */
  22970. private _createNodeEditor;
  22971. /**
  22972. * Launch the node material editor
  22973. * @param config Define the configuration of the editor
  22974. * @return a promise fulfilled when the node editor is visible
  22975. */
  22976. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22977. /**
  22978. * Clear the current material
  22979. */
  22980. clear(): void;
  22981. /**
  22982. * Clear the current material and set it to a default state
  22983. */
  22984. setToDefault(): void;
  22985. /**
  22986. * Clear the current material and set it to a default state for post process
  22987. */
  22988. setToDefaultPostProcess(): void;
  22989. /**
  22990. * Clear the current material and set it to a default state for particle
  22991. */
  22992. setToDefaultParticle(): void;
  22993. /**
  22994. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22995. * @param url defines the url to load from
  22996. * @returns a promise that will fullfil when the material is fully loaded
  22997. */
  22998. loadAsync(url: string): Promise<void>;
  22999. private _gatherBlocks;
  23000. /**
  23001. * Generate a string containing the code declaration required to create an equivalent of this material
  23002. * @returns a string
  23003. */
  23004. generateCode(): string;
  23005. /**
  23006. * Serializes this material in a JSON representation
  23007. * @returns the serialized material object
  23008. */
  23009. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23010. private _restoreConnections;
  23011. /**
  23012. * Clear the current graph and load a new one from a serialization object
  23013. * @param source defines the JSON representation of the material
  23014. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23015. * @param merge defines whether or not the source must be merged or replace the current content
  23016. */
  23017. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23018. /**
  23019. * Makes a duplicate of the current material.
  23020. * @param name - name to use for the new material.
  23021. */
  23022. clone(name: string): NodeMaterial;
  23023. /**
  23024. * Creates a node material from parsed material data
  23025. * @param source defines the JSON representation of the material
  23026. * @param scene defines the hosting scene
  23027. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23028. * @returns a new node material
  23029. */
  23030. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23031. /**
  23032. * Creates a node material from a snippet saved in a remote file
  23033. * @param name defines the name of the material to create
  23034. * @param url defines the url to load from
  23035. * @param scene defines the hosting scene
  23036. * @returns a promise that will resolve to the new node material
  23037. */
  23038. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23039. /**
  23040. * Creates a node material from a snippet saved by the node material editor
  23041. * @param snippetId defines the snippet to load
  23042. * @param scene defines the hosting scene
  23043. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23044. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23045. * @returns a promise that will resolve to the new node material
  23046. */
  23047. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23048. /**
  23049. * Creates a new node material set to default basic configuration
  23050. * @param name defines the name of the material
  23051. * @param scene defines the hosting scene
  23052. * @returns a new NodeMaterial
  23053. */
  23054. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23055. }
  23056. }
  23057. declare module "babylonjs/PostProcesses/postProcess" {
  23058. import { Nullable } from "babylonjs/types";
  23059. import { SmartArray } from "babylonjs/Misc/smartArray";
  23060. import { Observable } from "babylonjs/Misc/observable";
  23061. import { Vector2 } from "babylonjs/Maths/math.vector";
  23062. import { Camera } from "babylonjs/Cameras/camera";
  23063. import { Effect } from "babylonjs/Materials/effect";
  23064. import "babylonjs/Shaders/postprocess.vertex";
  23065. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23066. import { Engine } from "babylonjs/Engines/engine";
  23067. import { Color4 } from "babylonjs/Maths/math.color";
  23068. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23069. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23070. import { Scene } from "babylonjs/scene";
  23071. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23072. /**
  23073. * Size options for a post process
  23074. */
  23075. export type PostProcessOptions = {
  23076. width: number;
  23077. height: number;
  23078. };
  23079. /**
  23080. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23081. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23082. */
  23083. export class PostProcess {
  23084. /** Name of the PostProcess. */
  23085. name: string;
  23086. /**
  23087. * Gets or sets the unique id of the post process
  23088. */
  23089. uniqueId: number;
  23090. /**
  23091. * Width of the texture to apply the post process on
  23092. */
  23093. width: number;
  23094. /**
  23095. * Height of the texture to apply the post process on
  23096. */
  23097. height: number;
  23098. /**
  23099. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23100. */
  23101. nodeMaterialSource: Nullable<NodeMaterial>;
  23102. /**
  23103. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23104. * @hidden
  23105. */
  23106. _outputTexture: Nullable<InternalTexture>;
  23107. /**
  23108. * Sampling mode used by the shader
  23109. * See https://doc.babylonjs.com/classes/3.1/texture
  23110. */
  23111. renderTargetSamplingMode: number;
  23112. /**
  23113. * Clear color to use when screen clearing
  23114. */
  23115. clearColor: Color4;
  23116. /**
  23117. * If the buffer needs to be cleared before applying the post process. (default: true)
  23118. * Should be set to false if shader will overwrite all previous pixels.
  23119. */
  23120. autoClear: boolean;
  23121. /**
  23122. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23123. */
  23124. alphaMode: number;
  23125. /**
  23126. * Sets the setAlphaBlendConstants of the babylon engine
  23127. */
  23128. alphaConstants: Color4;
  23129. /**
  23130. * Animations to be used for the post processing
  23131. */
  23132. animations: import("babylonjs/Animations/animation").Animation[];
  23133. /**
  23134. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23135. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23136. */
  23137. enablePixelPerfectMode: boolean;
  23138. /**
  23139. * Force the postprocess to be applied without taking in account viewport
  23140. */
  23141. forceFullscreenViewport: boolean;
  23142. /**
  23143. * List of inspectable custom properties (used by the Inspector)
  23144. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23145. */
  23146. inspectableCustomProperties: IInspectable[];
  23147. /**
  23148. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23149. *
  23150. * | Value | Type | Description |
  23151. * | ----- | ----------------------------------- | ----------- |
  23152. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23153. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23154. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23155. *
  23156. */
  23157. scaleMode: number;
  23158. /**
  23159. * Force textures to be a power of two (default: false)
  23160. */
  23161. alwaysForcePOT: boolean;
  23162. private _samples;
  23163. /**
  23164. * Number of sample textures (default: 1)
  23165. */
  23166. get samples(): number;
  23167. set samples(n: number);
  23168. /**
  23169. * Modify the scale of the post process to be the same as the viewport (default: false)
  23170. */
  23171. adaptScaleToCurrentViewport: boolean;
  23172. private _camera;
  23173. protected _scene: Scene;
  23174. private _engine;
  23175. private _options;
  23176. private _reusable;
  23177. private _textureType;
  23178. private _textureFormat;
  23179. /**
  23180. * Smart array of input and output textures for the post process.
  23181. * @hidden
  23182. */
  23183. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23184. /**
  23185. * The index in _textures that corresponds to the output texture.
  23186. * @hidden
  23187. */
  23188. _currentRenderTextureInd: number;
  23189. private _effect;
  23190. private _samplers;
  23191. private _fragmentUrl;
  23192. private _vertexUrl;
  23193. private _parameters;
  23194. private _scaleRatio;
  23195. protected _indexParameters: any;
  23196. private _shareOutputWithPostProcess;
  23197. private _texelSize;
  23198. private _forcedOutputTexture;
  23199. /**
  23200. * Returns the fragment url or shader name used in the post process.
  23201. * @returns the fragment url or name in the shader store.
  23202. */
  23203. getEffectName(): string;
  23204. /**
  23205. * An event triggered when the postprocess is activated.
  23206. */
  23207. onActivateObservable: Observable<Camera>;
  23208. private _onActivateObserver;
  23209. /**
  23210. * A function that is added to the onActivateObservable
  23211. */
  23212. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23213. /**
  23214. * An event triggered when the postprocess changes its size.
  23215. */
  23216. onSizeChangedObservable: Observable<PostProcess>;
  23217. private _onSizeChangedObserver;
  23218. /**
  23219. * A function that is added to the onSizeChangedObservable
  23220. */
  23221. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23222. /**
  23223. * An event triggered when the postprocess applies its effect.
  23224. */
  23225. onApplyObservable: Observable<Effect>;
  23226. private _onApplyObserver;
  23227. /**
  23228. * A function that is added to the onApplyObservable
  23229. */
  23230. set onApply(callback: (effect: Effect) => void);
  23231. /**
  23232. * An event triggered before rendering the postprocess
  23233. */
  23234. onBeforeRenderObservable: Observable<Effect>;
  23235. private _onBeforeRenderObserver;
  23236. /**
  23237. * A function that is added to the onBeforeRenderObservable
  23238. */
  23239. set onBeforeRender(callback: (effect: Effect) => void);
  23240. /**
  23241. * An event triggered after rendering the postprocess
  23242. */
  23243. onAfterRenderObservable: Observable<Effect>;
  23244. private _onAfterRenderObserver;
  23245. /**
  23246. * A function that is added to the onAfterRenderObservable
  23247. */
  23248. set onAfterRender(callback: (efect: Effect) => void);
  23249. /**
  23250. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  23251. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23252. */
  23253. get inputTexture(): InternalTexture;
  23254. set inputTexture(value: InternalTexture);
  23255. /**
  23256. * Gets the camera which post process is applied to.
  23257. * @returns The camera the post process is applied to.
  23258. */
  23259. getCamera(): Camera;
  23260. /**
  23261. * Gets the texel size of the postprocess.
  23262. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23263. */
  23264. get texelSize(): Vector2;
  23265. /**
  23266. * Creates a new instance PostProcess
  23267. * @param name The name of the PostProcess.
  23268. * @param fragmentUrl The url of the fragment shader to be used.
  23269. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23270. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23271. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23272. * @param camera The camera to apply the render pass to.
  23273. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23274. * @param engine The engine which the post process will be applied. (default: current engine)
  23275. * @param reusable If the post process can be reused on the same frame. (default: false)
  23276. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23277. * @param textureType Type of textures used when performing the post process. (default: 0)
  23278. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23279. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  23280. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  23281. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23282. */
  23283. constructor(
  23284. /** Name of the PostProcess. */
  23285. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  23286. /**
  23287. * Gets a string idenfifying the name of the class
  23288. * @returns "PostProcess" string
  23289. */
  23290. getClassName(): string;
  23291. /**
  23292. * Gets the engine which this post process belongs to.
  23293. * @returns The engine the post process was enabled with.
  23294. */
  23295. getEngine(): Engine;
  23296. /**
  23297. * The effect that is created when initializing the post process.
  23298. * @returns The created effect corresponding the the postprocess.
  23299. */
  23300. getEffect(): Effect;
  23301. /**
  23302. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23303. * @param postProcess The post process to share the output with.
  23304. * @returns This post process.
  23305. */
  23306. shareOutputWith(postProcess: PostProcess): PostProcess;
  23307. /**
  23308. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23309. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23310. */
  23311. useOwnOutput(): void;
  23312. /**
  23313. * Updates the effect with the current post process compile time values and recompiles the shader.
  23314. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23315. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23316. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23317. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  23318. * @param onCompiled Called when the shader has been compiled.
  23319. * @param onError Called if there is an error when compiling a shader.
  23320. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23321. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23322. */
  23323. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, vertexUrl?: string, fragmentUrl?: string): void;
  23324. /**
  23325. * The post process is reusable if it can be used multiple times within one frame.
  23326. * @returns If the post process is reusable
  23327. */
  23328. isReusable(): boolean;
  23329. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23330. markTextureDirty(): void;
  23331. /**
  23332. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23333. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  23334. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23335. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23336. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23337. * @returns The target texture that was bound to be written to.
  23338. */
  23339. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23340. /**
  23341. * If the post process is supported.
  23342. */
  23343. get isSupported(): boolean;
  23344. /**
  23345. * The aspect ratio of the output texture.
  23346. */
  23347. get aspectRatio(): number;
  23348. /**
  23349. * Get a value indicating if the post-process is ready to be used
  23350. * @returns true if the post-process is ready (shader is compiled)
  23351. */
  23352. isReady(): boolean;
  23353. /**
  23354. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23355. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23356. */
  23357. apply(): Nullable<Effect>;
  23358. private _disposeTextures;
  23359. /**
  23360. * Disposes the post process.
  23361. * @param camera The camera to dispose the post process on.
  23362. */
  23363. dispose(camera?: Camera): void;
  23364. }
  23365. }
  23366. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23367. /** @hidden */
  23368. export var kernelBlurVaryingDeclaration: {
  23369. name: string;
  23370. shader: string;
  23371. };
  23372. }
  23373. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23374. /** @hidden */
  23375. export var kernelBlurFragment: {
  23376. name: string;
  23377. shader: string;
  23378. };
  23379. }
  23380. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23381. /** @hidden */
  23382. export var kernelBlurFragment2: {
  23383. name: string;
  23384. shader: string;
  23385. };
  23386. }
  23387. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23388. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23389. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23390. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23391. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23392. /** @hidden */
  23393. export var kernelBlurPixelShader: {
  23394. name: string;
  23395. shader: string;
  23396. };
  23397. }
  23398. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23399. /** @hidden */
  23400. export var kernelBlurVertex: {
  23401. name: string;
  23402. shader: string;
  23403. };
  23404. }
  23405. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23406. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23407. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23408. /** @hidden */
  23409. export var kernelBlurVertexShader: {
  23410. name: string;
  23411. shader: string;
  23412. };
  23413. }
  23414. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23415. import { Vector2 } from "babylonjs/Maths/math.vector";
  23416. import { Nullable } from "babylonjs/types";
  23417. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23418. import { Camera } from "babylonjs/Cameras/camera";
  23419. import { Effect } from "babylonjs/Materials/effect";
  23420. import { Engine } from "babylonjs/Engines/engine";
  23421. import "babylonjs/Shaders/kernelBlur.fragment";
  23422. import "babylonjs/Shaders/kernelBlur.vertex";
  23423. /**
  23424. * The Blur Post Process which blurs an image based on a kernel and direction.
  23425. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23426. */
  23427. export class BlurPostProcess extends PostProcess {
  23428. /** The direction in which to blur the image. */
  23429. direction: Vector2;
  23430. private blockCompilation;
  23431. protected _kernel: number;
  23432. protected _idealKernel: number;
  23433. protected _packedFloat: boolean;
  23434. private _staticDefines;
  23435. /**
  23436. * Sets the length in pixels of the blur sample region
  23437. */
  23438. set kernel(v: number);
  23439. /**
  23440. * Gets the length in pixels of the blur sample region
  23441. */
  23442. get kernel(): number;
  23443. /**
  23444. * Sets wether or not the blur needs to unpack/repack floats
  23445. */
  23446. set packedFloat(v: boolean);
  23447. /**
  23448. * Gets wether or not the blur is unpacking/repacking floats
  23449. */
  23450. get packedFloat(): boolean;
  23451. /**
  23452. * Creates a new instance BlurPostProcess
  23453. * @param name The name of the effect.
  23454. * @param direction The direction in which to blur the image.
  23455. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  23456. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23457. * @param camera The camera to apply the render pass to.
  23458. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23459. * @param engine The engine which the post process will be applied. (default: current engine)
  23460. * @param reusable If the post process can be reused on the same frame. (default: false)
  23461. * @param textureType Type of textures used when performing the post process. (default: 0)
  23462. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  23463. */
  23464. constructor(name: string,
  23465. /** The direction in which to blur the image. */
  23466. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23467. /**
  23468. * Updates the effect with the current post process compile time values and recompiles the shader.
  23469. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23470. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23471. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23472. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  23473. * @param onCompiled Called when the shader has been compiled.
  23474. * @param onError Called if there is an error when compiling a shader.
  23475. */
  23476. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23477. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23478. /**
  23479. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23480. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23481. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23482. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23483. * The gaps between physical kernels are compensated for in the weighting of the samples
  23484. * @param idealKernel Ideal blur kernel.
  23485. * @return Nearest best kernel.
  23486. */
  23487. protected _nearestBestKernel(idealKernel: number): number;
  23488. /**
  23489. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23490. * @param x The point on the Gaussian distribution to sample.
  23491. * @return the value of the Gaussian function at x.
  23492. */
  23493. protected _gaussianWeight(x: number): number;
  23494. /**
  23495. * Generates a string that can be used as a floating point number in GLSL.
  23496. * @param x Value to print.
  23497. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23498. * @return GLSL float string.
  23499. */
  23500. protected _glslFloat(x: number, decimalFigures?: number): string;
  23501. }
  23502. }
  23503. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23504. import { Scene } from "babylonjs/scene";
  23505. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23506. import { Plane } from "babylonjs/Maths/math.plane";
  23507. /**
  23508. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23509. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23510. * You can then easily use it as a reflectionTexture on a flat surface.
  23511. * In case the surface is not a plane, please consider relying on reflection probes.
  23512. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23513. */
  23514. export class MirrorTexture extends RenderTargetTexture {
  23515. private scene;
  23516. /**
  23517. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23518. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  23519. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23520. */
  23521. mirrorPlane: Plane;
  23522. /**
  23523. * Define the blur ratio used to blur the reflection if needed.
  23524. */
  23525. set blurRatio(value: number);
  23526. get blurRatio(): number;
  23527. /**
  23528. * Define the adaptive blur kernel used to blur the reflection if needed.
  23529. * This will autocompute the closest best match for the `blurKernel`
  23530. */
  23531. set adaptiveBlurKernel(value: number);
  23532. /**
  23533. * Define the blur kernel used to blur the reflection if needed.
  23534. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23535. */
  23536. set blurKernel(value: number);
  23537. /**
  23538. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23539. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23540. */
  23541. set blurKernelX(value: number);
  23542. get blurKernelX(): number;
  23543. /**
  23544. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23545. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23546. */
  23547. set blurKernelY(value: number);
  23548. get blurKernelY(): number;
  23549. private _autoComputeBlurKernel;
  23550. protected _onRatioRescale(): void;
  23551. private _updateGammaSpace;
  23552. private _imageProcessingConfigChangeObserver;
  23553. private _transformMatrix;
  23554. private _mirrorMatrix;
  23555. private _savedViewMatrix;
  23556. private _blurX;
  23557. private _blurY;
  23558. private _adaptiveBlurKernel;
  23559. private _blurKernelX;
  23560. private _blurKernelY;
  23561. private _blurRatio;
  23562. /**
  23563. * Instantiates a Mirror Texture.
  23564. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23565. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23566. * You can then easily use it as a reflectionTexture on a flat surface.
  23567. * In case the surface is not a plane, please consider relying on reflection probes.
  23568. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23569. * @param name
  23570. * @param size
  23571. * @param scene
  23572. * @param generateMipMaps
  23573. * @param type
  23574. * @param samplingMode
  23575. * @param generateDepthBuffer
  23576. */
  23577. constructor(name: string, size: number | {
  23578. width: number;
  23579. height: number;
  23580. } | {
  23581. ratio: number;
  23582. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23583. private _preparePostProcesses;
  23584. /**
  23585. * Clone the mirror texture.
  23586. * @returns the cloned texture
  23587. */
  23588. clone(): MirrorTexture;
  23589. /**
  23590. * Serialize the texture to a JSON representation you could use in Parse later on
  23591. * @returns the serialized JSON representation
  23592. */
  23593. serialize(): any;
  23594. /**
  23595. * Dispose the texture and release its associated resources.
  23596. */
  23597. dispose(): void;
  23598. }
  23599. }
  23600. declare module "babylonjs/Materials/Textures/texture" {
  23601. import { Observable } from "babylonjs/Misc/observable";
  23602. import { Nullable } from "babylonjs/types";
  23603. import { Matrix } from "babylonjs/Maths/math.vector";
  23604. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23605. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23606. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23607. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  23608. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  23609. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23610. import { Scene } from "babylonjs/scene";
  23611. /**
  23612. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23613. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23614. */
  23615. export class Texture extends BaseTexture {
  23616. /**
  23617. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23618. */
  23619. static SerializeBuffers: boolean;
  23620. /** @hidden */
  23621. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23622. /** @hidden */
  23623. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23624. /** @hidden */
  23625. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23626. /** nearest is mag = nearest and min = nearest and mip = linear */
  23627. static readonly NEAREST_SAMPLINGMODE: number;
  23628. /** nearest is mag = nearest and min = nearest and mip = linear */
  23629. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23630. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23631. static readonly BILINEAR_SAMPLINGMODE: number;
  23632. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23633. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23634. /** Trilinear is mag = linear and min = linear and mip = linear */
  23635. static readonly TRILINEAR_SAMPLINGMODE: number;
  23636. /** Trilinear is mag = linear and min = linear and mip = linear */
  23637. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23638. /** mag = nearest and min = nearest and mip = nearest */
  23639. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23640. /** mag = nearest and min = linear and mip = nearest */
  23641. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23642. /** mag = nearest and min = linear and mip = linear */
  23643. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23644. /** mag = nearest and min = linear and mip = none */
  23645. static readonly NEAREST_LINEAR: number;
  23646. /** mag = nearest and min = nearest and mip = none */
  23647. static readonly NEAREST_NEAREST: number;
  23648. /** mag = linear and min = nearest and mip = nearest */
  23649. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23650. /** mag = linear and min = nearest and mip = linear */
  23651. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23652. /** mag = linear and min = linear and mip = none */
  23653. static readonly LINEAR_LINEAR: number;
  23654. /** mag = linear and min = nearest and mip = none */
  23655. static readonly LINEAR_NEAREST: number;
  23656. /** Explicit coordinates mode */
  23657. static readonly EXPLICIT_MODE: number;
  23658. /** Spherical coordinates mode */
  23659. static readonly SPHERICAL_MODE: number;
  23660. /** Planar coordinates mode */
  23661. static readonly PLANAR_MODE: number;
  23662. /** Cubic coordinates mode */
  23663. static readonly CUBIC_MODE: number;
  23664. /** Projection coordinates mode */
  23665. static readonly PROJECTION_MODE: number;
  23666. /** Inverse Cubic coordinates mode */
  23667. static readonly SKYBOX_MODE: number;
  23668. /** Inverse Cubic coordinates mode */
  23669. static readonly INVCUBIC_MODE: number;
  23670. /** Equirectangular coordinates mode */
  23671. static readonly EQUIRECTANGULAR_MODE: number;
  23672. /** Equirectangular Fixed coordinates mode */
  23673. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23674. /** Equirectangular Fixed Mirrored coordinates mode */
  23675. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23676. /** Texture is not repeating outside of 0..1 UVs */
  23677. static readonly CLAMP_ADDRESSMODE: number;
  23678. /** Texture is repeating outside of 0..1 UVs */
  23679. static readonly WRAP_ADDRESSMODE: number;
  23680. /** Texture is repeating and mirrored */
  23681. static readonly MIRROR_ADDRESSMODE: number;
  23682. /**
  23683. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  23684. */
  23685. static UseSerializedUrlIfAny: boolean;
  23686. /**
  23687. * Define the url of the texture.
  23688. */
  23689. url: Nullable<string>;
  23690. /**
  23691. * Define an offset on the texture to offset the u coordinates of the UVs
  23692. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23693. */
  23694. uOffset: number;
  23695. /**
  23696. * Define an offset on the texture to offset the v coordinates of the UVs
  23697. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23698. */
  23699. vOffset: number;
  23700. /**
  23701. * Define an offset on the texture to scale the u coordinates of the UVs
  23702. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23703. */
  23704. uScale: number;
  23705. /**
  23706. * Define an offset on the texture to scale the v coordinates of the UVs
  23707. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23708. */
  23709. vScale: number;
  23710. /**
  23711. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23712. * @see https://doc.babylonjs.com/how_to/more_materials
  23713. */
  23714. uAng: number;
  23715. /**
  23716. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23717. * @see https://doc.babylonjs.com/how_to/more_materials
  23718. */
  23719. vAng: number;
  23720. /**
  23721. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23722. * @see https://doc.babylonjs.com/how_to/more_materials
  23723. */
  23724. wAng: number;
  23725. /**
  23726. * Defines the center of rotation (U)
  23727. */
  23728. uRotationCenter: number;
  23729. /**
  23730. * Defines the center of rotation (V)
  23731. */
  23732. vRotationCenter: number;
  23733. /**
  23734. * Defines the center of rotation (W)
  23735. */
  23736. wRotationCenter: number;
  23737. /**
  23738. * Are mip maps generated for this texture or not.
  23739. */
  23740. get noMipmap(): boolean;
  23741. /**
  23742. * List of inspectable custom properties (used by the Inspector)
  23743. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23744. */
  23745. inspectableCustomProperties: Nullable<IInspectable[]>;
  23746. private _noMipmap;
  23747. /** @hidden */
  23748. _invertY: boolean;
  23749. private _rowGenerationMatrix;
  23750. private _cachedTextureMatrix;
  23751. private _projectionModeMatrix;
  23752. private _t0;
  23753. private _t1;
  23754. private _t2;
  23755. private _cachedUOffset;
  23756. private _cachedVOffset;
  23757. private _cachedUScale;
  23758. private _cachedVScale;
  23759. private _cachedUAng;
  23760. private _cachedVAng;
  23761. private _cachedWAng;
  23762. private _cachedProjectionMatrixId;
  23763. private _cachedCoordinatesMode;
  23764. /** @hidden */
  23765. protected _initialSamplingMode: number;
  23766. /** @hidden */
  23767. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23768. private _deleteBuffer;
  23769. protected _format: Nullable<number>;
  23770. private _delayedOnLoad;
  23771. private _delayedOnError;
  23772. private _mimeType?;
  23773. /**
  23774. * Observable triggered once the texture has been loaded.
  23775. */
  23776. onLoadObservable: Observable<Texture>;
  23777. protected _isBlocking: boolean;
  23778. /**
  23779. * Is the texture preventing material to render while loading.
  23780. * If false, a default texture will be used instead of the loading one during the preparation step.
  23781. */
  23782. set isBlocking(value: boolean);
  23783. get isBlocking(): boolean;
  23784. /**
  23785. * Get the current sampling mode associated with the texture.
  23786. */
  23787. get samplingMode(): number;
  23788. /**
  23789. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23790. */
  23791. get invertY(): boolean;
  23792. /**
  23793. * Instantiates a new texture.
  23794. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23795. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23796. * @param url defines the url of the picture to load as a texture
  23797. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23798. * @param noMipmap defines if the texture will require mip maps or not
  23799. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23800. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23801. * @param onLoad defines a callback triggered when the texture has been loaded
  23802. * @param onError defines a callback triggered when an error occurred during the loading session
  23803. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23804. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23805. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23806. * @param mimeType defines an optional mime type information
  23807. */
  23808. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  23809. /**
  23810. * Update the url (and optional buffer) of this texture if url was null during construction.
  23811. * @param url the url of the texture
  23812. * @param buffer the buffer of the texture (defaults to null)
  23813. * @param onLoad callback called when the texture is loaded (defaults to null)
  23814. */
  23815. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23816. /**
  23817. * Finish the loading sequence of a texture flagged as delayed load.
  23818. * @hidden
  23819. */
  23820. delayLoad(): void;
  23821. private _prepareRowForTextureGeneration;
  23822. /**
  23823. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23824. * @returns the transform matrix of the texture.
  23825. */
  23826. getTextureMatrix(uBase?: number): Matrix;
  23827. /**
  23828. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23829. * @returns The reflection texture transform
  23830. */
  23831. getReflectionTextureMatrix(): Matrix;
  23832. /**
  23833. * Clones the texture.
  23834. * @returns the cloned texture
  23835. */
  23836. clone(): Texture;
  23837. /**
  23838. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23839. * @returns The JSON representation of the texture
  23840. */
  23841. serialize(): any;
  23842. /**
  23843. * Get the current class name of the texture useful for serialization or dynamic coding.
  23844. * @returns "Texture"
  23845. */
  23846. getClassName(): string;
  23847. /**
  23848. * Dispose the texture and release its associated resources.
  23849. */
  23850. dispose(): void;
  23851. /**
  23852. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23853. * @param parsedTexture Define the JSON representation of the texture
  23854. * @param scene Define the scene the parsed texture should be instantiated in
  23855. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23856. * @returns The parsed texture if successful
  23857. */
  23858. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23859. /**
  23860. * Creates a texture from its base 64 representation.
  23861. * @param data Define the base64 payload without the data: prefix
  23862. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23863. * @param scene Define the scene the texture should belong to
  23864. * @param noMipmap Forces the texture to not create mip map information if true
  23865. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23866. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23867. * @param onLoad define a callback triggered when the texture has been loaded
  23868. * @param onError define a callback triggered when an error occurred during the loading session
  23869. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23870. * @returns the created texture
  23871. */
  23872. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23873. /**
  23874. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23875. * @param data Define the base64 payload without the data: prefix
  23876. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23877. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23878. * @param scene Define the scene the texture should belong to
  23879. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23880. * @param noMipmap Forces the texture to not create mip map information if true
  23881. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23882. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23883. * @param onLoad define a callback triggered when the texture has been loaded
  23884. * @param onError define a callback triggered when an error occurred during the loading session
  23885. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23886. * @returns the created texture
  23887. */
  23888. static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number): Texture;
  23889. }
  23890. }
  23891. declare module "babylonjs/PostProcesses/postProcessManager" {
  23892. import { Nullable } from "babylonjs/types";
  23893. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23894. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  23895. import { Scene } from "babylonjs/scene";
  23896. /**
  23897. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23898. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23899. */
  23900. export class PostProcessManager {
  23901. private _scene;
  23902. private _indexBuffer;
  23903. private _vertexBuffers;
  23904. /**
  23905. * Creates a new instance PostProcess
  23906. * @param scene The scene that the post process is associated with.
  23907. */
  23908. constructor(scene: Scene);
  23909. private _prepareBuffers;
  23910. private _buildIndexBuffer;
  23911. /**
  23912. * Rebuilds the vertex buffers of the manager.
  23913. * @hidden
  23914. */
  23915. _rebuild(): void;
  23916. /**
  23917. * Prepares a frame to be run through a post process.
  23918. * @param sourceTexture The input texture to the post procesess. (default: null)
  23919. * @param postProcesses An array of post processes to be run. (default: null)
  23920. * @returns True if the post processes were able to be run.
  23921. * @hidden
  23922. */
  23923. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23924. /**
  23925. * Manually render a set of post processes to a texture.
  23926. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23927. * @param postProcesses An array of post processes to be run.
  23928. * @param targetTexture The target texture to render to.
  23929. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23930. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23931. * @param lodLevel defines which lod of the texture to render to
  23932. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  23933. */
  23934. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  23935. /**
  23936. * Finalize the result of the output of the postprocesses.
  23937. * @param doNotPresent If true the result will not be displayed to the screen.
  23938. * @param targetTexture The target texture to render to.
  23939. * @param faceIndex The index of the face to bind the target texture to.
  23940. * @param postProcesses The array of post processes to render.
  23941. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23942. * @hidden
  23943. */
  23944. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23945. /**
  23946. * Disposes of the post process manager.
  23947. */
  23948. dispose(): void;
  23949. }
  23950. }
  23951. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  23952. import { Observable } from "babylonjs/Misc/observable";
  23953. import { SmartArray } from "babylonjs/Misc/smartArray";
  23954. import { Nullable, Immutable } from "babylonjs/types";
  23955. import { Camera } from "babylonjs/Cameras/camera";
  23956. import { Scene } from "babylonjs/scene";
  23957. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  23958. import { Color4 } from "babylonjs/Maths/math.color";
  23959. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  23960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23961. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23962. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23963. import { Texture } from "babylonjs/Materials/Textures/texture";
  23964. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  23965. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  23966. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23967. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  23968. import { Engine } from "babylonjs/Engines/engine";
  23969. /**
  23970. * This Helps creating a texture that will be created from a camera in your scene.
  23971. * It is basically a dynamic texture that could be used to create special effects for instance.
  23972. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23973. */
  23974. export class RenderTargetTexture extends Texture {
  23975. isCube: boolean;
  23976. /**
  23977. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23978. */
  23979. static readonly REFRESHRATE_RENDER_ONCE: number;
  23980. /**
  23981. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23982. */
  23983. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23984. /**
  23985. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23986. * the central point of your effect and can save a lot of performances.
  23987. */
  23988. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23989. /**
  23990. * Use this predicate to dynamically define the list of mesh you want to render.
  23991. * If set, the renderList property will be overwritten.
  23992. */
  23993. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23994. private _renderList;
  23995. /**
  23996. * Use this list to define the list of mesh you want to render.
  23997. */
  23998. get renderList(): Nullable<Array<AbstractMesh>>;
  23999. set renderList(value: Nullable<Array<AbstractMesh>>);
  24000. /**
  24001. * Use this function to overload the renderList array at rendering time.
  24002. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24003. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24004. * the cube (if the RTT is a cube, else layerOrFace=0).
  24005. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24006. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24007. * hold dummy elements!
  24008. */
  24009. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24010. private _hookArray;
  24011. /**
  24012. * Define if particles should be rendered in your texture.
  24013. */
  24014. renderParticles: boolean;
  24015. /**
  24016. * Define if sprites should be rendered in your texture.
  24017. */
  24018. renderSprites: boolean;
  24019. /**
  24020. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  24021. */
  24022. coordinatesMode: number;
  24023. /**
  24024. * Define the camera used to render the texture.
  24025. */
  24026. activeCamera: Nullable<Camera>;
  24027. /**
  24028. * Override the mesh isReady function with your own one.
  24029. */
  24030. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24031. /**
  24032. * Override the render function of the texture with your own one.
  24033. */
  24034. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24035. /**
  24036. * Define if camera post processes should be use while rendering the texture.
  24037. */
  24038. useCameraPostProcesses: boolean;
  24039. /**
  24040. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24041. */
  24042. ignoreCameraViewport: boolean;
  24043. private _postProcessManager;
  24044. private _postProcesses;
  24045. private _resizeObserver;
  24046. /**
  24047. * An event triggered when the texture is unbind.
  24048. */
  24049. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24050. /**
  24051. * An event triggered when the texture is unbind.
  24052. */
  24053. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24054. private _onAfterUnbindObserver;
  24055. /**
  24056. * Set a after unbind callback in the texture.
  24057. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24058. */
  24059. set onAfterUnbind(callback: () => void);
  24060. /**
  24061. * An event triggered before rendering the texture
  24062. */
  24063. onBeforeRenderObservable: Observable<number>;
  24064. private _onBeforeRenderObserver;
  24065. /**
  24066. * Set a before render callback in the texture.
  24067. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24068. */
  24069. set onBeforeRender(callback: (faceIndex: number) => void);
  24070. /**
  24071. * An event triggered after rendering the texture
  24072. */
  24073. onAfterRenderObservable: Observable<number>;
  24074. private _onAfterRenderObserver;
  24075. /**
  24076. * Set a after render callback in the texture.
  24077. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24078. */
  24079. set onAfterRender(callback: (faceIndex: number) => void);
  24080. /**
  24081. * An event triggered after the texture clear
  24082. */
  24083. onClearObservable: Observable<Engine>;
  24084. private _onClearObserver;
  24085. /**
  24086. * Set a clear callback in the texture.
  24087. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24088. */
  24089. set onClear(callback: (Engine: Engine) => void);
  24090. /**
  24091. * An event triggered when the texture is resized.
  24092. */
  24093. onResizeObservable: Observable<RenderTargetTexture>;
  24094. /**
  24095. * Define the clear color of the Render Target if it should be different from the scene.
  24096. */
  24097. clearColor: Color4;
  24098. protected _size: number | {
  24099. width: number;
  24100. height: number;
  24101. layers?: number;
  24102. };
  24103. protected _initialSizeParameter: number | {
  24104. width: number;
  24105. height: number;
  24106. } | {
  24107. ratio: number;
  24108. };
  24109. protected _sizeRatio: Nullable<number>;
  24110. /** @hidden */
  24111. _generateMipMaps: boolean;
  24112. protected _renderingManager: RenderingManager;
  24113. /** @hidden */
  24114. _waitingRenderList: string[];
  24115. protected _doNotChangeAspectRatio: boolean;
  24116. protected _currentRefreshId: number;
  24117. protected _refreshRate: number;
  24118. protected _textureMatrix: Matrix;
  24119. protected _samples: number;
  24120. protected _renderTargetOptions: RenderTargetCreationOptions;
  24121. /**
  24122. * Gets render target creation options that were used.
  24123. */
  24124. get renderTargetOptions(): RenderTargetCreationOptions;
  24125. protected _onRatioRescale(): void;
  24126. /**
  24127. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24128. * It must define where the camera used to render the texture is set
  24129. */
  24130. boundingBoxPosition: Vector3;
  24131. private _boundingBoxSize;
  24132. /**
  24133. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24134. * When defined, the cubemap will switch to local mode
  24135. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24136. * @example https://www.babylonjs-playground.com/#RNASML
  24137. */
  24138. set boundingBoxSize(value: Vector3);
  24139. get boundingBoxSize(): Vector3;
  24140. /**
  24141. * In case the RTT has been created with a depth texture, get the associated
  24142. * depth texture.
  24143. * Otherwise, return null.
  24144. */
  24145. get depthStencilTexture(): Nullable<InternalTexture>;
  24146. /**
  24147. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24148. * or used a shadow, depth texture...
  24149. * @param name The friendly name of the texture
  24150. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  24151. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24152. * @param generateMipMaps True if mip maps need to be generated after render.
  24153. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24154. * @param type The type of the buffer in the RTT (int, half float, float...)
  24155. * @param isCube True if a cube texture needs to be created
  24156. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24157. * @param generateDepthBuffer True to generate a depth buffer
  24158. * @param generateStencilBuffer True to generate a stencil buffer
  24159. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24160. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24161. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24162. */
  24163. constructor(name: string, size: number | {
  24164. width: number;
  24165. height: number;
  24166. layers?: number;
  24167. } | {
  24168. ratio: number;
  24169. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24170. /**
  24171. * Creates a depth stencil texture.
  24172. * This is only available in WebGL 2 or with the depth texture extension available.
  24173. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24174. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24175. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24176. */
  24177. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24178. private _processSizeParameter;
  24179. /**
  24180. * Define the number of samples to use in case of MSAA.
  24181. * It defaults to one meaning no MSAA has been enabled.
  24182. */
  24183. get samples(): number;
  24184. set samples(value: number);
  24185. /**
  24186. * Resets the refresh counter of the texture and start bak from scratch.
  24187. * Could be useful to regenerate the texture if it is setup to render only once.
  24188. */
  24189. resetRefreshCounter(): void;
  24190. /**
  24191. * Define the refresh rate of the texture or the rendering frequency.
  24192. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24193. */
  24194. get refreshRate(): number;
  24195. set refreshRate(value: number);
  24196. /**
  24197. * Adds a post process to the render target rendering passes.
  24198. * @param postProcess define the post process to add
  24199. */
  24200. addPostProcess(postProcess: PostProcess): void;
  24201. /**
  24202. * Clear all the post processes attached to the render target
  24203. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24204. */
  24205. clearPostProcesses(dispose?: boolean): void;
  24206. /**
  24207. * Remove one of the post process from the list of attached post processes to the texture
  24208. * @param postProcess define the post process to remove from the list
  24209. */
  24210. removePostProcess(postProcess: PostProcess): void;
  24211. /** @hidden */
  24212. _shouldRender(): boolean;
  24213. /**
  24214. * Gets the actual render size of the texture.
  24215. * @returns the width of the render size
  24216. */
  24217. getRenderSize(): number;
  24218. /**
  24219. * Gets the actual render width of the texture.
  24220. * @returns the width of the render size
  24221. */
  24222. getRenderWidth(): number;
  24223. /**
  24224. * Gets the actual render height of the texture.
  24225. * @returns the height of the render size
  24226. */
  24227. getRenderHeight(): number;
  24228. /**
  24229. * Gets the actual number of layers of the texture.
  24230. * @returns the number of layers
  24231. */
  24232. getRenderLayers(): number;
  24233. /**
  24234. * Get if the texture can be rescaled or not.
  24235. */
  24236. get canRescale(): boolean;
  24237. /**
  24238. * Resize the texture using a ratio.
  24239. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24240. */
  24241. scale(ratio: number): void;
  24242. /**
  24243. * Get the texture reflection matrix used to rotate/transform the reflection.
  24244. * @returns the reflection matrix
  24245. */
  24246. getReflectionTextureMatrix(): Matrix;
  24247. /**
  24248. * Resize the texture to a new desired size.
  24249. * Be carrefull as it will recreate all the data in the new texture.
  24250. * @param size Define the new size. It can be:
  24251. * - a number for squared texture,
  24252. * - an object containing { width: number, height: number }
  24253. * - or an object containing a ratio { ratio: number }
  24254. */
  24255. resize(size: number | {
  24256. width: number;
  24257. height: number;
  24258. } | {
  24259. ratio: number;
  24260. }): void;
  24261. private _defaultRenderListPrepared;
  24262. /**
  24263. * Renders all the objects from the render list into the texture.
  24264. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24265. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24266. */
  24267. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24268. private _bestReflectionRenderTargetDimension;
  24269. private _prepareRenderingManager;
  24270. /**
  24271. * @hidden
  24272. * @param faceIndex face index to bind to if this is a cubetexture
  24273. * @param layer defines the index of the texture to bind in the array
  24274. */
  24275. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24276. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24277. private renderToTarget;
  24278. /**
  24279. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24280. * This allowed control for front to back rendering or reversly depending of the special needs.
  24281. *
  24282. * @param renderingGroupId The rendering group id corresponding to its index
  24283. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24284. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24285. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24286. */
  24287. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  24288. /**
  24289. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24290. *
  24291. * @param renderingGroupId The rendering group id corresponding to its index
  24292. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24293. */
  24294. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24295. /**
  24296. * Clones the texture.
  24297. * @returns the cloned texture
  24298. */
  24299. clone(): RenderTargetTexture;
  24300. /**
  24301. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24302. * @returns The JSON representation of the texture
  24303. */
  24304. serialize(): any;
  24305. /**
  24306. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24307. */
  24308. disposeFramebufferObjects(): void;
  24309. /**
  24310. * Dispose the texture and release its associated resources.
  24311. */
  24312. dispose(): void;
  24313. /** @hidden */
  24314. _rebuild(): void;
  24315. /**
  24316. * Clear the info related to rendering groups preventing retention point in material dispose.
  24317. */
  24318. freeRenderingGroups(): void;
  24319. /**
  24320. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24321. * @returns the view count
  24322. */
  24323. getViewCount(): number;
  24324. }
  24325. }
  24326. declare module "babylonjs/Misc/guid" {
  24327. /**
  24328. * Class used to manipulate GUIDs
  24329. */
  24330. export class GUID {
  24331. /**
  24332. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24333. * Be aware Math.random() could cause collisions, but:
  24334. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  24335. * @returns a pseudo random id
  24336. */
  24337. static RandomId(): string;
  24338. }
  24339. }
  24340. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24341. import { Nullable } from "babylonjs/types";
  24342. import { Scene } from "babylonjs/scene";
  24343. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24344. import { Material } from "babylonjs/Materials/material";
  24345. import { Effect } from "babylonjs/Materials/effect";
  24346. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24347. /**
  24348. * Options to be used when creating a shadow depth material
  24349. */
  24350. export interface IIOptionShadowDepthMaterial {
  24351. /** Variables in the vertex shader code that need to have their names remapped.
  24352. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24353. * "var_name" should be either: worldPos or vNormalW
  24354. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24355. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24356. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24357. */
  24358. remappedVariables?: string[];
  24359. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24360. standalone?: boolean;
  24361. }
  24362. /**
  24363. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24364. */
  24365. export class ShadowDepthWrapper {
  24366. private _scene;
  24367. private _options?;
  24368. private _baseMaterial;
  24369. private _onEffectCreatedObserver;
  24370. private _subMeshToEffect;
  24371. private _subMeshToDepthEffect;
  24372. private _meshes;
  24373. /** @hidden */
  24374. _matriceNames: any;
  24375. /** Gets the standalone status of the wrapper */
  24376. get standalone(): boolean;
  24377. /** Gets the base material the wrapper is built upon */
  24378. get baseMaterial(): Material;
  24379. /**
  24380. * Instantiate a new shadow depth wrapper.
  24381. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24382. * generate the shadow depth map. For more information, please refer to the documentation:
  24383. * https://doc.babylonjs.com/babylon101/shadows
  24384. * @param baseMaterial Material to wrap
  24385. * @param scene Define the scene the material belongs to
  24386. * @param options Options used to create the wrapper
  24387. */
  24388. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24389. /**
  24390. * Gets the effect to use to generate the depth map
  24391. * @param subMesh subMesh to get the effect for
  24392. * @param shadowGenerator shadow generator to get the effect for
  24393. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24394. */
  24395. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24396. /**
  24397. * Specifies that the submesh is ready to be used for depth rendering
  24398. * @param subMesh submesh to check
  24399. * @param defines the list of defines to take into account when checking the effect
  24400. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24401. * @param useInstances specifies that instances should be used
  24402. * @returns a boolean indicating that the submesh is ready or not
  24403. */
  24404. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24405. /**
  24406. * Disposes the resources
  24407. */
  24408. dispose(): void;
  24409. private _makeEffect;
  24410. }
  24411. }
  24412. declare module "babylonjs/Materials/material" {
  24413. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24414. import { SmartArray } from "babylonjs/Misc/smartArray";
  24415. import { Observable } from "babylonjs/Misc/observable";
  24416. import { Nullable } from "babylonjs/types";
  24417. import { Scene } from "babylonjs/scene";
  24418. import { Matrix } from "babylonjs/Maths/math.vector";
  24419. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24421. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  24422. import { Effect } from "babylonjs/Materials/effect";
  24423. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24424. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24425. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  24426. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24427. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  24428. import { Mesh } from "babylonjs/Meshes/mesh";
  24429. import { Animation } from "babylonjs/Animations/animation";
  24430. /**
  24431. * Options for compiling materials.
  24432. */
  24433. export interface IMaterialCompilationOptions {
  24434. /**
  24435. * Defines whether clip planes are enabled.
  24436. */
  24437. clipPlane: boolean;
  24438. /**
  24439. * Defines whether instances are enabled.
  24440. */
  24441. useInstances: boolean;
  24442. }
  24443. /**
  24444. * Options passed when calling customShaderNameResolve
  24445. */
  24446. export interface ICustomShaderNameResolveOptions {
  24447. /**
  24448. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  24449. */
  24450. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24451. }
  24452. /**
  24453. * Base class for the main features of a material in Babylon.js
  24454. */
  24455. export class Material implements IAnimatable {
  24456. /**
  24457. * Returns the triangle fill mode
  24458. */
  24459. static readonly TriangleFillMode: number;
  24460. /**
  24461. * Returns the wireframe mode
  24462. */
  24463. static readonly WireFrameFillMode: number;
  24464. /**
  24465. * Returns the point fill mode
  24466. */
  24467. static readonly PointFillMode: number;
  24468. /**
  24469. * Returns the point list draw mode
  24470. */
  24471. static readonly PointListDrawMode: number;
  24472. /**
  24473. * Returns the line list draw mode
  24474. */
  24475. static readonly LineListDrawMode: number;
  24476. /**
  24477. * Returns the line loop draw mode
  24478. */
  24479. static readonly LineLoopDrawMode: number;
  24480. /**
  24481. * Returns the line strip draw mode
  24482. */
  24483. static readonly LineStripDrawMode: number;
  24484. /**
  24485. * Returns the triangle strip draw mode
  24486. */
  24487. static readonly TriangleStripDrawMode: number;
  24488. /**
  24489. * Returns the triangle fan draw mode
  24490. */
  24491. static readonly TriangleFanDrawMode: number;
  24492. /**
  24493. * Stores the clock-wise side orientation
  24494. */
  24495. static readonly ClockWiseSideOrientation: number;
  24496. /**
  24497. * Stores the counter clock-wise side orientation
  24498. */
  24499. static readonly CounterClockWiseSideOrientation: number;
  24500. /**
  24501. * The dirty texture flag value
  24502. */
  24503. static readonly TextureDirtyFlag: number;
  24504. /**
  24505. * The dirty light flag value
  24506. */
  24507. static readonly LightDirtyFlag: number;
  24508. /**
  24509. * The dirty fresnel flag value
  24510. */
  24511. static readonly FresnelDirtyFlag: number;
  24512. /**
  24513. * The dirty attribute flag value
  24514. */
  24515. static readonly AttributesDirtyFlag: number;
  24516. /**
  24517. * The dirty misc flag value
  24518. */
  24519. static readonly MiscDirtyFlag: number;
  24520. /**
  24521. * The all dirty flag value
  24522. */
  24523. static readonly AllDirtyFlag: number;
  24524. /**
  24525. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24526. */
  24527. static readonly MATERIAL_OPAQUE: number;
  24528. /**
  24529. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24530. */
  24531. static readonly MATERIAL_ALPHATEST: number;
  24532. /**
  24533. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24534. */
  24535. static readonly MATERIAL_ALPHABLEND: number;
  24536. /**
  24537. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24538. * They are also discarded below the alpha cutoff threshold to improve performances.
  24539. */
  24540. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24541. /**
  24542. * The Whiteout method is used to blend normals.
  24543. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24544. */
  24545. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24546. /**
  24547. * The Reoriented Normal Mapping method is used to blend normals.
  24548. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24549. */
  24550. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24551. /**
  24552. * Custom callback helping to override the default shader used in the material.
  24553. */
  24554. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24555. /**
  24556. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24557. */
  24558. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24559. /**
  24560. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24561. * This means that the material can keep using a previous shader while a new one is being compiled.
  24562. * This is mostly used when shader parallel compilation is supported (true by default)
  24563. */
  24564. allowShaderHotSwapping: boolean;
  24565. /**
  24566. * The ID of the material
  24567. */
  24568. id: string;
  24569. /**
  24570. * Gets or sets the unique id of the material
  24571. */
  24572. uniqueId: number;
  24573. /**
  24574. * The name of the material
  24575. */
  24576. name: string;
  24577. /**
  24578. * Gets or sets user defined metadata
  24579. */
  24580. metadata: any;
  24581. /**
  24582. * For internal use only. Please do not use.
  24583. */
  24584. reservedDataStore: any;
  24585. /**
  24586. * Specifies if the ready state should be checked on each call
  24587. */
  24588. checkReadyOnEveryCall: boolean;
  24589. /**
  24590. * Specifies if the ready state should be checked once
  24591. */
  24592. checkReadyOnlyOnce: boolean;
  24593. /**
  24594. * The state of the material
  24595. */
  24596. state: string;
  24597. /**
  24598. * If the material should be rendered to several textures with MRT extension
  24599. */
  24600. get shouldRenderToMRT(): boolean;
  24601. /**
  24602. * The alpha value of the material
  24603. */
  24604. protected _alpha: number;
  24605. /**
  24606. * List of inspectable custom properties (used by the Inspector)
  24607. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24608. */
  24609. inspectableCustomProperties: IInspectable[];
  24610. /**
  24611. * Sets the alpha value of the material
  24612. */
  24613. set alpha(value: number);
  24614. /**
  24615. * Gets the alpha value of the material
  24616. */
  24617. get alpha(): number;
  24618. /**
  24619. * Specifies if back face culling is enabled
  24620. */
  24621. protected _backFaceCulling: boolean;
  24622. /**
  24623. * Sets the back-face culling state
  24624. */
  24625. set backFaceCulling(value: boolean);
  24626. /**
  24627. * Gets the back-face culling state
  24628. */
  24629. get backFaceCulling(): boolean;
  24630. /**
  24631. * Stores the value for side orientation
  24632. */
  24633. sideOrientation: number;
  24634. /**
  24635. * Callback triggered when the material is compiled
  24636. */
  24637. onCompiled: Nullable<(effect: Effect) => void>;
  24638. /**
  24639. * Callback triggered when an error occurs
  24640. */
  24641. onError: Nullable<(effect: Effect, errors: string) => void>;
  24642. /**
  24643. * Callback triggered to get the render target textures
  24644. */
  24645. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24646. /**
  24647. * Gets a boolean indicating that current material needs to register RTT
  24648. */
  24649. get hasRenderTargetTextures(): boolean;
  24650. /**
  24651. * Specifies if the material should be serialized
  24652. */
  24653. doNotSerialize: boolean;
  24654. /**
  24655. * @hidden
  24656. */
  24657. _storeEffectOnSubMeshes: boolean;
  24658. /**
  24659. * Stores the animations for the material
  24660. */
  24661. animations: Nullable<Array<Animation>>;
  24662. /**
  24663. * An event triggered when the material is disposed
  24664. */
  24665. onDisposeObservable: Observable<Material>;
  24666. /**
  24667. * An observer which watches for dispose events
  24668. */
  24669. private _onDisposeObserver;
  24670. private _onUnBindObservable;
  24671. /**
  24672. * Called during a dispose event
  24673. */
  24674. set onDispose(callback: () => void);
  24675. private _onBindObservable;
  24676. /**
  24677. * An event triggered when the material is bound
  24678. */
  24679. get onBindObservable(): Observable<AbstractMesh>;
  24680. /**
  24681. * An observer which watches for bind events
  24682. */
  24683. private _onBindObserver;
  24684. /**
  24685. * Called during a bind event
  24686. */
  24687. set onBind(callback: (Mesh: AbstractMesh) => void);
  24688. /**
  24689. * An event triggered when the material is unbound
  24690. */
  24691. get onUnBindObservable(): Observable<Material>;
  24692. protected _onEffectCreatedObservable: Nullable<Observable<{
  24693. effect: Effect;
  24694. subMesh: Nullable<SubMesh>;
  24695. }>>;
  24696. /**
  24697. * An event triggered when the effect is (re)created
  24698. */
  24699. get onEffectCreatedObservable(): Observable<{
  24700. effect: Effect;
  24701. subMesh: Nullable<SubMesh>;
  24702. }>;
  24703. /**
  24704. * Stores the value of the alpha mode
  24705. */
  24706. private _alphaMode;
  24707. /**
  24708. * Sets the value of the alpha mode.
  24709. *
  24710. * | Value | Type | Description |
  24711. * | --- | --- | --- |
  24712. * | 0 | ALPHA_DISABLE | |
  24713. * | 1 | ALPHA_ADD | |
  24714. * | 2 | ALPHA_COMBINE | |
  24715. * | 3 | ALPHA_SUBTRACT | |
  24716. * | 4 | ALPHA_MULTIPLY | |
  24717. * | 5 | ALPHA_MAXIMIZED | |
  24718. * | 6 | ALPHA_ONEONE | |
  24719. * | 7 | ALPHA_PREMULTIPLIED | |
  24720. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24721. * | 9 | ALPHA_INTERPOLATE | |
  24722. * | 10 | ALPHA_SCREENMODE | |
  24723. *
  24724. */
  24725. set alphaMode(value: number);
  24726. /**
  24727. * Gets the value of the alpha mode
  24728. */
  24729. get alphaMode(): number;
  24730. /**
  24731. * Stores the state of the need depth pre-pass value
  24732. */
  24733. private _needDepthPrePass;
  24734. /**
  24735. * Sets the need depth pre-pass value
  24736. */
  24737. set needDepthPrePass(value: boolean);
  24738. /**
  24739. * Gets the depth pre-pass value
  24740. */
  24741. get needDepthPrePass(): boolean;
  24742. /**
  24743. * Specifies if depth writing should be disabled
  24744. */
  24745. disableDepthWrite: boolean;
  24746. /**
  24747. * Specifies if color writing should be disabled
  24748. */
  24749. disableColorWrite: boolean;
  24750. /**
  24751. * Specifies if depth writing should be forced
  24752. */
  24753. forceDepthWrite: boolean;
  24754. /**
  24755. * Specifies the depth function that should be used. 0 means the default engine function
  24756. */
  24757. depthFunction: number;
  24758. /**
  24759. * Specifies if there should be a separate pass for culling
  24760. */
  24761. separateCullingPass: boolean;
  24762. /**
  24763. * Stores the state specifing if fog should be enabled
  24764. */
  24765. private _fogEnabled;
  24766. /**
  24767. * Sets the state for enabling fog
  24768. */
  24769. set fogEnabled(value: boolean);
  24770. /**
  24771. * Gets the value of the fog enabled state
  24772. */
  24773. get fogEnabled(): boolean;
  24774. /**
  24775. * Stores the size of points
  24776. */
  24777. pointSize: number;
  24778. /**
  24779. * Stores the z offset value
  24780. */
  24781. zOffset: number;
  24782. get wireframe(): boolean;
  24783. /**
  24784. * Sets the state of wireframe mode
  24785. */
  24786. set wireframe(value: boolean);
  24787. /**
  24788. * Gets the value specifying if point clouds are enabled
  24789. */
  24790. get pointsCloud(): boolean;
  24791. /**
  24792. * Sets the state of point cloud mode
  24793. */
  24794. set pointsCloud(value: boolean);
  24795. /**
  24796. * Gets the material fill mode
  24797. */
  24798. get fillMode(): number;
  24799. /**
  24800. * Sets the material fill mode
  24801. */
  24802. set fillMode(value: number);
  24803. /**
  24804. * @hidden
  24805. * Stores the effects for the material
  24806. */
  24807. _effect: Nullable<Effect>;
  24808. /**
  24809. * Specifies if uniform buffers should be used
  24810. */
  24811. private _useUBO;
  24812. /**
  24813. * Stores a reference to the scene
  24814. */
  24815. private _scene;
  24816. /**
  24817. * Stores the fill mode state
  24818. */
  24819. private _fillMode;
  24820. /**
  24821. * Specifies if the depth write state should be cached
  24822. */
  24823. private _cachedDepthWriteState;
  24824. /**
  24825. * Specifies if the color write state should be cached
  24826. */
  24827. private _cachedColorWriteState;
  24828. /**
  24829. * Specifies if the depth function state should be cached
  24830. */
  24831. private _cachedDepthFunctionState;
  24832. /**
  24833. * Stores the uniform buffer
  24834. */
  24835. protected _uniformBuffer: UniformBuffer;
  24836. /** @hidden */
  24837. _indexInSceneMaterialArray: number;
  24838. /** @hidden */
  24839. meshMap: Nullable<{
  24840. [id: string]: AbstractMesh | undefined;
  24841. }>;
  24842. /**
  24843. * Creates a material instance
  24844. * @param name defines the name of the material
  24845. * @param scene defines the scene to reference
  24846. * @param doNotAdd specifies if the material should be added to the scene
  24847. */
  24848. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24849. /**
  24850. * Returns a string representation of the current material
  24851. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24852. * @returns a string with material information
  24853. */
  24854. toString(fullDetails?: boolean): string;
  24855. /**
  24856. * Gets the class name of the material
  24857. * @returns a string with the class name of the material
  24858. */
  24859. getClassName(): string;
  24860. /**
  24861. * Specifies if updates for the material been locked
  24862. */
  24863. get isFrozen(): boolean;
  24864. /**
  24865. * Locks updates for the material
  24866. */
  24867. freeze(): void;
  24868. /**
  24869. * Unlocks updates for the material
  24870. */
  24871. unfreeze(): void;
  24872. /**
  24873. * Specifies if the material is ready to be used
  24874. * @param mesh defines the mesh to check
  24875. * @param useInstances specifies if instances should be used
  24876. * @returns a boolean indicating if the material is ready to be used
  24877. */
  24878. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24879. /**
  24880. * Specifies that the submesh is ready to be used
  24881. * @param mesh defines the mesh to check
  24882. * @param subMesh defines which submesh to check
  24883. * @param useInstances specifies that instances should be used
  24884. * @returns a boolean indicating that the submesh is ready or not
  24885. */
  24886. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24887. /**
  24888. * Returns the material effect
  24889. * @returns the effect associated with the material
  24890. */
  24891. getEffect(): Nullable<Effect>;
  24892. /**
  24893. * Returns the current scene
  24894. * @returns a Scene
  24895. */
  24896. getScene(): Scene;
  24897. /**
  24898. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24899. */
  24900. protected _forceAlphaTest: boolean;
  24901. /**
  24902. * The transparency mode of the material.
  24903. */
  24904. protected _transparencyMode: Nullable<number>;
  24905. /**
  24906. * Gets the current transparency mode.
  24907. */
  24908. get transparencyMode(): Nullable<number>;
  24909. /**
  24910. * Sets the transparency mode of the material.
  24911. *
  24912. * | Value | Type | Description |
  24913. * | ----- | ----------------------------------- | ----------- |
  24914. * | 0 | OPAQUE | |
  24915. * | 1 | ALPHATEST | |
  24916. * | 2 | ALPHABLEND | |
  24917. * | 3 | ALPHATESTANDBLEND | |
  24918. *
  24919. */
  24920. set transparencyMode(value: Nullable<number>);
  24921. /**
  24922. * Returns true if alpha blending should be disabled.
  24923. */
  24924. protected get _disableAlphaBlending(): boolean;
  24925. /**
  24926. * Specifies whether or not this material should be rendered in alpha blend mode.
  24927. * @returns a boolean specifying if alpha blending is needed
  24928. */
  24929. needAlphaBlending(): boolean;
  24930. /**
  24931. * Specifies if the mesh will require alpha blending
  24932. * @param mesh defines the mesh to check
  24933. * @returns a boolean specifying if alpha blending is needed for the mesh
  24934. */
  24935. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24936. /**
  24937. * Specifies whether or not this material should be rendered in alpha test mode.
  24938. * @returns a boolean specifying if an alpha test is needed.
  24939. */
  24940. needAlphaTesting(): boolean;
  24941. /**
  24942. * Specifies if material alpha testing should be turned on for the mesh
  24943. * @param mesh defines the mesh to check
  24944. */
  24945. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24946. /**
  24947. * Gets the texture used for the alpha test
  24948. * @returns the texture to use for alpha testing
  24949. */
  24950. getAlphaTestTexture(): Nullable<BaseTexture>;
  24951. /**
  24952. * Marks the material to indicate that it needs to be re-calculated
  24953. */
  24954. markDirty(): void;
  24955. /** @hidden */
  24956. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24957. /**
  24958. * Binds the material to the mesh
  24959. * @param world defines the world transformation matrix
  24960. * @param mesh defines the mesh to bind the material to
  24961. */
  24962. bind(world: Matrix, mesh?: Mesh): void;
  24963. /**
  24964. * Binds the submesh to the material
  24965. * @param world defines the world transformation matrix
  24966. * @param mesh defines the mesh containing the submesh
  24967. * @param subMesh defines the submesh to bind the material to
  24968. */
  24969. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24970. /**
  24971. * Binds the world matrix to the material
  24972. * @param world defines the world transformation matrix
  24973. */
  24974. bindOnlyWorldMatrix(world: Matrix): void;
  24975. /**
  24976. * Binds the scene's uniform buffer to the effect.
  24977. * @param effect defines the effect to bind to the scene uniform buffer
  24978. * @param sceneUbo defines the uniform buffer storing scene data
  24979. */
  24980. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24981. /**
  24982. * Binds the view matrix to the effect
  24983. * @param effect defines the effect to bind the view matrix to
  24984. */
  24985. bindView(effect: Effect): void;
  24986. /**
  24987. * Binds the view projection matrix to the effect
  24988. * @param effect defines the effect to bind the view projection matrix to
  24989. */
  24990. bindViewProjection(effect: Effect): void;
  24991. /**
  24992. * Processes to execute after binding the material to a mesh
  24993. * @param mesh defines the rendered mesh
  24994. */
  24995. protected _afterBind(mesh?: Mesh): void;
  24996. /**
  24997. * Unbinds the material from the mesh
  24998. */
  24999. unbind(): void;
  25000. /**
  25001. * Gets the active textures from the material
  25002. * @returns an array of textures
  25003. */
  25004. getActiveTextures(): BaseTexture[];
  25005. /**
  25006. * Specifies if the material uses a texture
  25007. * @param texture defines the texture to check against the material
  25008. * @returns a boolean specifying if the material uses the texture
  25009. */
  25010. hasTexture(texture: BaseTexture): boolean;
  25011. /**
  25012. * Makes a duplicate of the material, and gives it a new name
  25013. * @param name defines the new name for the duplicated material
  25014. * @returns the cloned material
  25015. */
  25016. clone(name: string): Nullable<Material>;
  25017. /**
  25018. * Gets the meshes bound to the material
  25019. * @returns an array of meshes bound to the material
  25020. */
  25021. getBindedMeshes(): AbstractMesh[];
  25022. /**
  25023. * Force shader compilation
  25024. * @param mesh defines the mesh associated with this material
  25025. * @param onCompiled defines a function to execute once the material is compiled
  25026. * @param options defines the options to configure the compilation
  25027. * @param onError defines a function to execute if the material fails compiling
  25028. */
  25029. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25030. /**
  25031. * Force shader compilation
  25032. * @param mesh defines the mesh that will use this material
  25033. * @param options defines additional options for compiling the shaders
  25034. * @returns a promise that resolves when the compilation completes
  25035. */
  25036. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25037. private static readonly _AllDirtyCallBack;
  25038. private static readonly _ImageProcessingDirtyCallBack;
  25039. private static readonly _TextureDirtyCallBack;
  25040. private static readonly _FresnelDirtyCallBack;
  25041. private static readonly _MiscDirtyCallBack;
  25042. private static readonly _LightsDirtyCallBack;
  25043. private static readonly _AttributeDirtyCallBack;
  25044. private static _FresnelAndMiscDirtyCallBack;
  25045. private static _TextureAndMiscDirtyCallBack;
  25046. private static readonly _DirtyCallbackArray;
  25047. private static readonly _RunDirtyCallBacks;
  25048. /**
  25049. * Marks a define in the material to indicate that it needs to be re-computed
  25050. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25051. */
  25052. markAsDirty(flag: number): void;
  25053. /**
  25054. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25055. * @param func defines a function which checks material defines against the submeshes
  25056. */
  25057. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25058. /**
  25059. * Indicates that the scene should check if the rendering now needs a prepass
  25060. */
  25061. protected _markScenePrePassDirty(): void;
  25062. /**
  25063. * Indicates that we need to re-calculated for all submeshes
  25064. */
  25065. protected _markAllSubMeshesAsAllDirty(): void;
  25066. /**
  25067. * Indicates that image processing needs to be re-calculated for all submeshes
  25068. */
  25069. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25070. /**
  25071. * Indicates that textures need to be re-calculated for all submeshes
  25072. */
  25073. protected _markAllSubMeshesAsTexturesDirty(): void;
  25074. /**
  25075. * Indicates that fresnel needs to be re-calculated for all submeshes
  25076. */
  25077. protected _markAllSubMeshesAsFresnelDirty(): void;
  25078. /**
  25079. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25080. */
  25081. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25082. /**
  25083. * Indicates that lights need to be re-calculated for all submeshes
  25084. */
  25085. protected _markAllSubMeshesAsLightsDirty(): void;
  25086. /**
  25087. * Indicates that attributes need to be re-calculated for all submeshes
  25088. */
  25089. protected _markAllSubMeshesAsAttributesDirty(): void;
  25090. /**
  25091. * Indicates that misc needs to be re-calculated for all submeshes
  25092. */
  25093. protected _markAllSubMeshesAsMiscDirty(): void;
  25094. /**
  25095. * Indicates that textures and misc need to be re-calculated for all submeshes
  25096. */
  25097. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25098. /**
  25099. * Disposes the material
  25100. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25101. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25102. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25103. */
  25104. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25105. /** @hidden */
  25106. private releaseVertexArrayObject;
  25107. /**
  25108. * Serializes this material
  25109. * @returns the serialized material object
  25110. */
  25111. serialize(): any;
  25112. /**
  25113. * Creates a material from parsed material data
  25114. * @param parsedMaterial defines parsed material data
  25115. * @param scene defines the hosting scene
  25116. * @param rootUrl defines the root URL to use to load textures
  25117. * @returns a new material
  25118. */
  25119. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25120. }
  25121. }
  25122. declare module "babylonjs/Materials/multiMaterial" {
  25123. import { Nullable } from "babylonjs/types";
  25124. import { Scene } from "babylonjs/scene";
  25125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25126. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25127. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25128. import { Material } from "babylonjs/Materials/material";
  25129. /**
  25130. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25131. * separate meshes. This can be use to improve performances.
  25132. * @see https://doc.babylonjs.com/how_to/multi_materials
  25133. */
  25134. export class MultiMaterial extends Material {
  25135. private _subMaterials;
  25136. /**
  25137. * Gets or Sets the list of Materials used within the multi material.
  25138. * They need to be ordered according to the submeshes order in the associated mesh
  25139. */
  25140. get subMaterials(): Nullable<Material>[];
  25141. set subMaterials(value: Nullable<Material>[]);
  25142. /**
  25143. * Function used to align with Node.getChildren()
  25144. * @returns the list of Materials used within the multi material
  25145. */
  25146. getChildren(): Nullable<Material>[];
  25147. /**
  25148. * Instantiates a new Multi Material
  25149. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25150. * separate meshes. This can be use to improve performances.
  25151. * @see https://doc.babylonjs.com/how_to/multi_materials
  25152. * @param name Define the name in the scene
  25153. * @param scene Define the scene the material belongs to
  25154. */
  25155. constructor(name: string, scene: Scene);
  25156. private _hookArray;
  25157. /**
  25158. * Get one of the submaterial by its index in the submaterials array
  25159. * @param index The index to look the sub material at
  25160. * @returns The Material if the index has been defined
  25161. */
  25162. getSubMaterial(index: number): Nullable<Material>;
  25163. /**
  25164. * Get the list of active textures for the whole sub materials list.
  25165. * @returns All the textures that will be used during the rendering
  25166. */
  25167. getActiveTextures(): BaseTexture[];
  25168. /**
  25169. * Gets the current class name of the material e.g. "MultiMaterial"
  25170. * Mainly use in serialization.
  25171. * @returns the class name
  25172. */
  25173. getClassName(): string;
  25174. /**
  25175. * Checks if the material is ready to render the requested sub mesh
  25176. * @param mesh Define the mesh the submesh belongs to
  25177. * @param subMesh Define the sub mesh to look readyness for
  25178. * @param useInstances Define whether or not the material is used with instances
  25179. * @returns true if ready, otherwise false
  25180. */
  25181. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25182. /**
  25183. * Clones the current material and its related sub materials
  25184. * @param name Define the name of the newly cloned material
  25185. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25186. * @returns the cloned material
  25187. */
  25188. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25189. /**
  25190. * Serializes the materials into a JSON representation.
  25191. * @returns the JSON representation
  25192. */
  25193. serialize(): any;
  25194. /**
  25195. * Dispose the material and release its associated resources
  25196. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  25197. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  25198. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  25199. */
  25200. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25201. /**
  25202. * Creates a MultiMaterial from parsed MultiMaterial data.
  25203. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25204. * @param scene defines the hosting scene
  25205. * @returns a new MultiMaterial
  25206. */
  25207. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25208. }
  25209. }
  25210. declare module "babylonjs/Meshes/subMesh" {
  25211. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  25212. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25213. import { Engine } from "babylonjs/Engines/engine";
  25214. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  25215. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25216. import { Effect } from "babylonjs/Materials/effect";
  25217. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25218. import { Plane } from "babylonjs/Maths/math.plane";
  25219. import { Collider } from "babylonjs/Collisions/collider";
  25220. import { Material } from "babylonjs/Materials/material";
  25221. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25223. import { Mesh } from "babylonjs/Meshes/mesh";
  25224. import { Ray } from "babylonjs/Culling/ray";
  25225. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25226. /**
  25227. * Defines a subdivision inside a mesh
  25228. */
  25229. export class SubMesh implements ICullable {
  25230. /** the material index to use */
  25231. materialIndex: number;
  25232. /** vertex index start */
  25233. verticesStart: number;
  25234. /** vertices count */
  25235. verticesCount: number;
  25236. /** index start */
  25237. indexStart: number;
  25238. /** indices count */
  25239. indexCount: number;
  25240. /** @hidden */
  25241. _materialDefines: Nullable<MaterialDefines>;
  25242. /** @hidden */
  25243. _materialEffect: Nullable<Effect>;
  25244. /** @hidden */
  25245. _effectOverride: Nullable<Effect>;
  25246. /**
  25247. * Gets material defines used by the effect associated to the sub mesh
  25248. */
  25249. get materialDefines(): Nullable<MaterialDefines>;
  25250. /**
  25251. * Sets material defines used by the effect associated to the sub mesh
  25252. */
  25253. set materialDefines(defines: Nullable<MaterialDefines>);
  25254. /**
  25255. * Gets associated effect
  25256. */
  25257. get effect(): Nullable<Effect>;
  25258. /**
  25259. * Sets associated effect (effect used to render this submesh)
  25260. * @param effect defines the effect to associate with
  25261. * @param defines defines the set of defines used to compile this effect
  25262. */
  25263. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25264. /** @hidden */
  25265. _linesIndexCount: number;
  25266. private _mesh;
  25267. private _renderingMesh;
  25268. private _boundingInfo;
  25269. private _linesIndexBuffer;
  25270. /** @hidden */
  25271. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25272. /** @hidden */
  25273. _trianglePlanes: Plane[];
  25274. /** @hidden */
  25275. _lastColliderTransformMatrix: Nullable<Matrix>;
  25276. /** @hidden */
  25277. _renderId: number;
  25278. /** @hidden */
  25279. _alphaIndex: number;
  25280. /** @hidden */
  25281. _distanceToCamera: number;
  25282. /** @hidden */
  25283. _id: number;
  25284. private _currentMaterial;
  25285. /**
  25286. * Add a new submesh to a mesh
  25287. * @param materialIndex defines the material index to use
  25288. * @param verticesStart defines vertex index start
  25289. * @param verticesCount defines vertices count
  25290. * @param indexStart defines index start
  25291. * @param indexCount defines indices count
  25292. * @param mesh defines the parent mesh
  25293. * @param renderingMesh defines an optional rendering mesh
  25294. * @param createBoundingBox defines if bounding box should be created for this submesh
  25295. * @returns the new submesh
  25296. */
  25297. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25298. /**
  25299. * Creates a new submesh
  25300. * @param materialIndex defines the material index to use
  25301. * @param verticesStart defines vertex index start
  25302. * @param verticesCount defines vertices count
  25303. * @param indexStart defines index start
  25304. * @param indexCount defines indices count
  25305. * @param mesh defines the parent mesh
  25306. * @param renderingMesh defines an optional rendering mesh
  25307. * @param createBoundingBox defines if bounding box should be created for this submesh
  25308. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25309. */
  25310. constructor(
  25311. /** the material index to use */
  25312. materialIndex: number,
  25313. /** vertex index start */
  25314. verticesStart: number,
  25315. /** vertices count */
  25316. verticesCount: number,
  25317. /** index start */
  25318. indexStart: number,
  25319. /** indices count */
  25320. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25321. /**
  25322. * Returns true if this submesh covers the entire parent mesh
  25323. * @ignorenaming
  25324. */
  25325. get IsGlobal(): boolean;
  25326. /**
  25327. * Returns the submesh BoudingInfo object
  25328. * @returns current bounding info (or mesh's one if the submesh is global)
  25329. */
  25330. getBoundingInfo(): BoundingInfo;
  25331. /**
  25332. * Sets the submesh BoundingInfo
  25333. * @param boundingInfo defines the new bounding info to use
  25334. * @returns the SubMesh
  25335. */
  25336. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25337. /**
  25338. * Returns the mesh of the current submesh
  25339. * @return the parent mesh
  25340. */
  25341. getMesh(): AbstractMesh;
  25342. /**
  25343. * Returns the rendering mesh of the submesh
  25344. * @returns the rendering mesh (could be different from parent mesh)
  25345. */
  25346. getRenderingMesh(): Mesh;
  25347. /**
  25348. * Returns the replacement mesh of the submesh
  25349. * @returns the replacement mesh (could be different from parent mesh)
  25350. */
  25351. getReplacementMesh(): Nullable<AbstractMesh>;
  25352. /**
  25353. * Returns the effective mesh of the submesh
  25354. * @returns the effective mesh (could be different from parent mesh)
  25355. */
  25356. getEffectiveMesh(): AbstractMesh;
  25357. /**
  25358. * Returns the submesh material
  25359. * @returns null or the current material
  25360. */
  25361. getMaterial(): Nullable<Material>;
  25362. private _IsMultiMaterial;
  25363. /**
  25364. * Sets a new updated BoundingInfo object to the submesh
  25365. * @param data defines an optional position array to use to determine the bounding info
  25366. * @returns the SubMesh
  25367. */
  25368. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25369. /** @hidden */
  25370. _checkCollision(collider: Collider): boolean;
  25371. /**
  25372. * Updates the submesh BoundingInfo
  25373. * @param world defines the world matrix to use to update the bounding info
  25374. * @returns the submesh
  25375. */
  25376. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25377. /**
  25378. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25379. * @param frustumPlanes defines the frustum planes
  25380. * @returns true if the submesh is intersecting with the frustum
  25381. */
  25382. isInFrustum(frustumPlanes: Plane[]): boolean;
  25383. /**
  25384. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25385. * @param frustumPlanes defines the frustum planes
  25386. * @returns true if the submesh is inside the frustum
  25387. */
  25388. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25389. /**
  25390. * Renders the submesh
  25391. * @param enableAlphaMode defines if alpha needs to be used
  25392. * @returns the submesh
  25393. */
  25394. render(enableAlphaMode: boolean): SubMesh;
  25395. /**
  25396. * @hidden
  25397. */
  25398. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25399. /**
  25400. * Checks if the submesh intersects with a ray
  25401. * @param ray defines the ray to test
  25402. * @returns true is the passed ray intersects the submesh bounding box
  25403. */
  25404. canIntersects(ray: Ray): boolean;
  25405. /**
  25406. * Intersects current submesh with a ray
  25407. * @param ray defines the ray to test
  25408. * @param positions defines mesh's positions array
  25409. * @param indices defines mesh's indices array
  25410. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25411. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25412. * @returns intersection info or null if no intersection
  25413. */
  25414. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25415. /** @hidden */
  25416. private _intersectLines;
  25417. /** @hidden */
  25418. private _intersectUnIndexedLines;
  25419. /** @hidden */
  25420. private _intersectTriangles;
  25421. /** @hidden */
  25422. private _intersectUnIndexedTriangles;
  25423. /** @hidden */
  25424. _rebuild(): void;
  25425. /**
  25426. * Creates a new submesh from the passed mesh
  25427. * @param newMesh defines the new hosting mesh
  25428. * @param newRenderingMesh defines an optional rendering mesh
  25429. * @returns the new submesh
  25430. */
  25431. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25432. /**
  25433. * Release associated resources
  25434. */
  25435. dispose(): void;
  25436. /**
  25437. * Gets the class name
  25438. * @returns the string "SubMesh".
  25439. */
  25440. getClassName(): string;
  25441. /**
  25442. * Creates a new submesh from indices data
  25443. * @param materialIndex the index of the main mesh material
  25444. * @param startIndex the index where to start the copy in the mesh indices array
  25445. * @param indexCount the number of indices to copy then from the startIndex
  25446. * @param mesh the main mesh to create the submesh from
  25447. * @param renderingMesh the optional rendering mesh
  25448. * @returns a new submesh
  25449. */
  25450. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25451. }
  25452. }
  25453. declare module "babylonjs/Loading/sceneLoaderFlags" {
  25454. /**
  25455. * Class used to represent data loading progression
  25456. */
  25457. export class SceneLoaderFlags {
  25458. private static _ForceFullSceneLoadingForIncremental;
  25459. private static _ShowLoadingScreen;
  25460. private static _CleanBoneMatrixWeights;
  25461. private static _loggingLevel;
  25462. /**
  25463. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25464. */
  25465. static get ForceFullSceneLoadingForIncremental(): boolean;
  25466. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25467. /**
  25468. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25469. */
  25470. static get ShowLoadingScreen(): boolean;
  25471. static set ShowLoadingScreen(value: boolean);
  25472. /**
  25473. * Defines the current logging level (while loading the scene)
  25474. * @ignorenaming
  25475. */
  25476. static get loggingLevel(): number;
  25477. static set loggingLevel(value: number);
  25478. /**
  25479. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25480. */
  25481. static get CleanBoneMatrixWeights(): boolean;
  25482. static set CleanBoneMatrixWeights(value: boolean);
  25483. }
  25484. }
  25485. declare module "babylonjs/Meshes/geometry" {
  25486. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  25487. import { Scene } from "babylonjs/scene";
  25488. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  25489. import { Engine } from "babylonjs/Engines/engine";
  25490. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  25491. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25492. import { Effect } from "babylonjs/Materials/effect";
  25493. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25494. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25495. import { Mesh } from "babylonjs/Meshes/mesh";
  25496. /**
  25497. * Class used to store geometry data (vertex buffers + index buffer)
  25498. */
  25499. export class Geometry implements IGetSetVerticesData {
  25500. /**
  25501. * Gets or sets the ID of the geometry
  25502. */
  25503. id: string;
  25504. /**
  25505. * Gets or sets the unique ID of the geometry
  25506. */
  25507. uniqueId: number;
  25508. /**
  25509. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25510. */
  25511. delayLoadState: number;
  25512. /**
  25513. * Gets the file containing the data to load when running in delay load state
  25514. */
  25515. delayLoadingFile: Nullable<string>;
  25516. /**
  25517. * Callback called when the geometry is updated
  25518. */
  25519. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25520. private _scene;
  25521. private _engine;
  25522. private _meshes;
  25523. private _totalVertices;
  25524. /** @hidden */
  25525. _indices: IndicesArray;
  25526. /** @hidden */
  25527. _vertexBuffers: {
  25528. [key: string]: VertexBuffer;
  25529. };
  25530. private _isDisposed;
  25531. private _extend;
  25532. private _boundingBias;
  25533. /** @hidden */
  25534. _delayInfo: Array<string>;
  25535. private _indexBuffer;
  25536. private _indexBufferIsUpdatable;
  25537. /** @hidden */
  25538. _boundingInfo: Nullable<BoundingInfo>;
  25539. /** @hidden */
  25540. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25541. /** @hidden */
  25542. _softwareSkinningFrameId: number;
  25543. private _vertexArrayObjects;
  25544. private _updatable;
  25545. /** @hidden */
  25546. _positions: Nullable<Vector3[]>;
  25547. /**
  25548. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  25549. */
  25550. get boundingBias(): Vector2;
  25551. /**
  25552. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  25553. */
  25554. set boundingBias(value: Vector2);
  25555. /**
  25556. * Static function used to attach a new empty geometry to a mesh
  25557. * @param mesh defines the mesh to attach the geometry to
  25558. * @returns the new Geometry
  25559. */
  25560. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25561. /** Get the list of meshes using this geometry */
  25562. get meshes(): Mesh[];
  25563. /**
  25564. * Creates a new geometry
  25565. * @param id defines the unique ID
  25566. * @param scene defines the hosting scene
  25567. * @param vertexData defines the VertexData used to get geometry data
  25568. * @param updatable defines if geometry must be updatable (false by default)
  25569. * @param mesh defines the mesh that will be associated with the geometry
  25570. */
  25571. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25572. /**
  25573. * Gets the current extend of the geometry
  25574. */
  25575. get extend(): {
  25576. minimum: Vector3;
  25577. maximum: Vector3;
  25578. };
  25579. /**
  25580. * Gets the hosting scene
  25581. * @returns the hosting Scene
  25582. */
  25583. getScene(): Scene;
  25584. /**
  25585. * Gets the hosting engine
  25586. * @returns the hosting Engine
  25587. */
  25588. getEngine(): Engine;
  25589. /**
  25590. * Defines if the geometry is ready to use
  25591. * @returns true if the geometry is ready to be used
  25592. */
  25593. isReady(): boolean;
  25594. /**
  25595. * Gets a value indicating that the geometry should not be serialized
  25596. */
  25597. get doNotSerialize(): boolean;
  25598. /** @hidden */
  25599. _rebuild(): void;
  25600. /**
  25601. * Affects all geometry data in one call
  25602. * @param vertexData defines the geometry data
  25603. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25604. */
  25605. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25606. /**
  25607. * Set specific vertex data
  25608. * @param kind defines the data kind (Position, normal, etc...)
  25609. * @param data defines the vertex data to use
  25610. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25611. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25612. */
  25613. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25614. /**
  25615. * Removes a specific vertex data
  25616. * @param kind defines the data kind (Position, normal, etc...)
  25617. */
  25618. removeVerticesData(kind: string): void;
  25619. /**
  25620. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25621. * @param buffer defines the vertex buffer to use
  25622. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25623. */
  25624. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25625. /**
  25626. * Update a specific vertex buffer
  25627. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25628. * It will do nothing if the buffer is not updatable
  25629. * @param kind defines the data kind (Position, normal, etc...)
  25630. * @param data defines the data to use
  25631. * @param offset defines the offset in the target buffer where to store the data
  25632. * @param useBytes set to true if the offset is in bytes
  25633. */
  25634. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25635. /**
  25636. * Update a specific vertex buffer
  25637. * This function will create a new buffer if the current one is not updatable
  25638. * @param kind defines the data kind (Position, normal, etc...)
  25639. * @param data defines the data to use
  25640. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25641. */
  25642. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25643. private _updateBoundingInfo;
  25644. /** @hidden */
  25645. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25646. /**
  25647. * Gets total number of vertices
  25648. * @returns the total number of vertices
  25649. */
  25650. getTotalVertices(): number;
  25651. /**
  25652. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25653. * @param kind defines the data kind (Position, normal, etc...)
  25654. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25655. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25656. * @returns a float array containing vertex data
  25657. */
  25658. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25659. /**
  25660. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25661. * @param kind defines the data kind (Position, normal, etc...)
  25662. * @returns true if the vertex buffer with the specified kind is updatable
  25663. */
  25664. isVertexBufferUpdatable(kind: string): boolean;
  25665. /**
  25666. * Gets a specific vertex buffer
  25667. * @param kind defines the data kind (Position, normal, etc...)
  25668. * @returns a VertexBuffer
  25669. */
  25670. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25671. /**
  25672. * Returns all vertex buffers
  25673. * @return an object holding all vertex buffers indexed by kind
  25674. */
  25675. getVertexBuffers(): Nullable<{
  25676. [key: string]: VertexBuffer;
  25677. }>;
  25678. /**
  25679. * Gets a boolean indicating if specific vertex buffer is present
  25680. * @param kind defines the data kind (Position, normal, etc...)
  25681. * @returns true if data is present
  25682. */
  25683. isVerticesDataPresent(kind: string): boolean;
  25684. /**
  25685. * Gets a list of all attached data kinds (Position, normal, etc...)
  25686. * @returns a list of string containing all kinds
  25687. */
  25688. getVerticesDataKinds(): string[];
  25689. /**
  25690. * Update index buffer
  25691. * @param indices defines the indices to store in the index buffer
  25692. * @param offset defines the offset in the target buffer where to store the data
  25693. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  25694. */
  25695. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25696. /**
  25697. * Creates a new index buffer
  25698. * @param indices defines the indices to store in the index buffer
  25699. * @param totalVertices defines the total number of vertices (could be null)
  25700. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25701. */
  25702. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25703. /**
  25704. * Return the total number of indices
  25705. * @returns the total number of indices
  25706. */
  25707. getTotalIndices(): number;
  25708. /**
  25709. * Gets the index buffer array
  25710. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25711. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25712. * @returns the index buffer array
  25713. */
  25714. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25715. /**
  25716. * Gets the index buffer
  25717. * @return the index buffer
  25718. */
  25719. getIndexBuffer(): Nullable<DataBuffer>;
  25720. /** @hidden */
  25721. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25722. /**
  25723. * Release the associated resources for a specific mesh
  25724. * @param mesh defines the source mesh
  25725. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25726. */
  25727. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25728. /**
  25729. * Apply current geometry to a given mesh
  25730. * @param mesh defines the mesh to apply geometry to
  25731. */
  25732. applyToMesh(mesh: Mesh): void;
  25733. private _updateExtend;
  25734. private _applyToMesh;
  25735. private notifyUpdate;
  25736. /**
  25737. * Load the geometry if it was flagged as delay loaded
  25738. * @param scene defines the hosting scene
  25739. * @param onLoaded defines a callback called when the geometry is loaded
  25740. */
  25741. load(scene: Scene, onLoaded?: () => void): void;
  25742. private _queueLoad;
  25743. /**
  25744. * Invert the geometry to move from a right handed system to a left handed one.
  25745. */
  25746. toLeftHanded(): void;
  25747. /** @hidden */
  25748. _resetPointsArrayCache(): void;
  25749. /** @hidden */
  25750. _generatePointsArray(): boolean;
  25751. /**
  25752. * Gets a value indicating if the geometry is disposed
  25753. * @returns true if the geometry was disposed
  25754. */
  25755. isDisposed(): boolean;
  25756. private _disposeVertexArrayObjects;
  25757. /**
  25758. * Free all associated resources
  25759. */
  25760. dispose(): void;
  25761. /**
  25762. * Clone the current geometry into a new geometry
  25763. * @param id defines the unique ID of the new geometry
  25764. * @returns a new geometry object
  25765. */
  25766. copy(id: string): Geometry;
  25767. /**
  25768. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25769. * @return a JSON representation of the current geometry data (without the vertices data)
  25770. */
  25771. serialize(): any;
  25772. private toNumberArray;
  25773. /**
  25774. * Serialize all vertices data into a JSON oject
  25775. * @returns a JSON representation of the current geometry data
  25776. */
  25777. serializeVerticeData(): any;
  25778. /**
  25779. * Extracts a clone of a mesh geometry
  25780. * @param mesh defines the source mesh
  25781. * @param id defines the unique ID of the new geometry object
  25782. * @returns the new geometry object
  25783. */
  25784. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25785. /**
  25786. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25787. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25788. * Be aware Math.random() could cause collisions, but:
  25789. * "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"
  25790. * @returns a string containing a new GUID
  25791. */
  25792. static RandomId(): string;
  25793. /** @hidden */
  25794. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25795. private static _CleanMatricesWeights;
  25796. /**
  25797. * Create a new geometry from persisted data (Using .babylon file format)
  25798. * @param parsedVertexData defines the persisted data
  25799. * @param scene defines the hosting scene
  25800. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25801. * @returns the new geometry object
  25802. */
  25803. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25804. }
  25805. }
  25806. declare module "babylonjs/Meshes/mesh.vertexData" {
  25807. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  25808. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25809. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  25810. import { Geometry } from "babylonjs/Meshes/geometry";
  25811. import { Mesh } from "babylonjs/Meshes/mesh";
  25812. /**
  25813. * Define an interface for all classes that will get and set the data on vertices
  25814. */
  25815. export interface IGetSetVerticesData {
  25816. /**
  25817. * Gets a boolean indicating if specific vertex data is present
  25818. * @param kind defines the vertex data kind to use
  25819. * @returns true is data kind is present
  25820. */
  25821. isVerticesDataPresent(kind: string): boolean;
  25822. /**
  25823. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25824. * @param kind defines the data kind (Position, normal, etc...)
  25825. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25826. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25827. * @returns a float array containing vertex data
  25828. */
  25829. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25830. /**
  25831. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25832. * @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.
  25833. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25834. * @returns the indices array or an empty array if the mesh has no geometry
  25835. */
  25836. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25837. /**
  25838. * Set specific vertex data
  25839. * @param kind defines the data kind (Position, normal, etc...)
  25840. * @param data defines the vertex data to use
  25841. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25842. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25843. */
  25844. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25845. /**
  25846. * Update a specific associated vertex buffer
  25847. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25848. * - VertexBuffer.PositionKind
  25849. * - VertexBuffer.UVKind
  25850. * - VertexBuffer.UV2Kind
  25851. * - VertexBuffer.UV3Kind
  25852. * - VertexBuffer.UV4Kind
  25853. * - VertexBuffer.UV5Kind
  25854. * - VertexBuffer.UV6Kind
  25855. * - VertexBuffer.ColorKind
  25856. * - VertexBuffer.MatricesIndicesKind
  25857. * - VertexBuffer.MatricesIndicesExtraKind
  25858. * - VertexBuffer.MatricesWeightsKind
  25859. * - VertexBuffer.MatricesWeightsExtraKind
  25860. * @param data defines the data source
  25861. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25862. * @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)
  25863. */
  25864. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25865. /**
  25866. * Creates a new index buffer
  25867. * @param indices defines the indices to store in the index buffer
  25868. * @param totalVertices defines the total number of vertices (could be null)
  25869. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25870. */
  25871. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25872. }
  25873. /**
  25874. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25875. */
  25876. export class VertexData {
  25877. /**
  25878. * Mesh side orientation : usually the external or front surface
  25879. */
  25880. static readonly FRONTSIDE: number;
  25881. /**
  25882. * Mesh side orientation : usually the internal or back surface
  25883. */
  25884. static readonly BACKSIDE: number;
  25885. /**
  25886. * Mesh side orientation : both internal and external or front and back surfaces
  25887. */
  25888. static readonly DOUBLESIDE: number;
  25889. /**
  25890. * Mesh side orientation : by default, `FRONTSIDE`
  25891. */
  25892. static readonly DEFAULTSIDE: number;
  25893. /**
  25894. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25895. */
  25896. positions: Nullable<FloatArray>;
  25897. /**
  25898. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25899. */
  25900. normals: Nullable<FloatArray>;
  25901. /**
  25902. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25903. */
  25904. tangents: Nullable<FloatArray>;
  25905. /**
  25906. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25907. */
  25908. uvs: Nullable<FloatArray>;
  25909. /**
  25910. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25911. */
  25912. uvs2: Nullable<FloatArray>;
  25913. /**
  25914. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25915. */
  25916. uvs3: Nullable<FloatArray>;
  25917. /**
  25918. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25919. */
  25920. uvs4: Nullable<FloatArray>;
  25921. /**
  25922. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25923. */
  25924. uvs5: Nullable<FloatArray>;
  25925. /**
  25926. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25927. */
  25928. uvs6: Nullable<FloatArray>;
  25929. /**
  25930. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25931. */
  25932. colors: Nullable<FloatArray>;
  25933. /**
  25934. * 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).
  25935. */
  25936. matricesIndices: Nullable<FloatArray>;
  25937. /**
  25938. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25939. */
  25940. matricesWeights: Nullable<FloatArray>;
  25941. /**
  25942. * An array extending the number of possible indices
  25943. */
  25944. matricesIndicesExtra: Nullable<FloatArray>;
  25945. /**
  25946. * An array extending the number of possible weights when the number of indices is extended
  25947. */
  25948. matricesWeightsExtra: Nullable<FloatArray>;
  25949. /**
  25950. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25951. */
  25952. indices: Nullable<IndicesArray>;
  25953. /**
  25954. * Uses the passed data array to set the set the values for the specified kind of data
  25955. * @param data a linear array of floating numbers
  25956. * @param kind the type of data that is being set, eg positions, colors etc
  25957. */
  25958. set(data: FloatArray, kind: string): void;
  25959. /**
  25960. * Associates the vertexData to the passed Mesh.
  25961. * Sets it as updatable or not (default `false`)
  25962. * @param mesh the mesh the vertexData is applied to
  25963. * @param updatable when used and having the value true allows new data to update the vertexData
  25964. * @returns the VertexData
  25965. */
  25966. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25967. /**
  25968. * Associates the vertexData to the passed Geometry.
  25969. * Sets it as updatable or not (default `false`)
  25970. * @param geometry the geometry the vertexData is applied to
  25971. * @param updatable when used and having the value true allows new data to update the vertexData
  25972. * @returns VertexData
  25973. */
  25974. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25975. /**
  25976. * Updates the associated mesh
  25977. * @param mesh the mesh to be updated
  25978. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25979. * @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
  25980. * @returns VertexData
  25981. */
  25982. updateMesh(mesh: Mesh): VertexData;
  25983. /**
  25984. * Updates the associated geometry
  25985. * @param geometry the geometry to be updated
  25986. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25987. * @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
  25988. * @returns VertexData.
  25989. */
  25990. updateGeometry(geometry: Geometry): VertexData;
  25991. private _applyTo;
  25992. private _update;
  25993. /**
  25994. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25995. * @param matrix the transforming matrix
  25996. * @returns the VertexData
  25997. */
  25998. transform(matrix: Matrix): VertexData;
  25999. /**
  26000. * Merges the passed VertexData into the current one
  26001. * @param other the VertexData to be merged into the current one
  26002. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26003. * @returns the modified VertexData
  26004. */
  26005. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26006. private _mergeElement;
  26007. private _validate;
  26008. /**
  26009. * Serializes the VertexData
  26010. * @returns a serialized object
  26011. */
  26012. serialize(): any;
  26013. /**
  26014. * Extracts the vertexData from a mesh
  26015. * @param mesh the mesh from which to extract the VertexData
  26016. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26017. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26018. * @returns the object VertexData associated to the passed mesh
  26019. */
  26020. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26021. /**
  26022. * Extracts the vertexData from the geometry
  26023. * @param geometry the geometry from which to extract the VertexData
  26024. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26025. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26026. * @returns the object VertexData associated to the passed mesh
  26027. */
  26028. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26029. private static _ExtractFrom;
  26030. /**
  26031. * Creates the VertexData for a Ribbon
  26032. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26033. * * pathArray array of paths, each of which an array of successive Vector3
  26034. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26035. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26036. * * 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
  26037. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26038. * * 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)
  26039. * * 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)
  26040. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26041. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26042. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26043. * @returns the VertexData of the ribbon
  26044. */
  26045. static CreateRibbon(options: {
  26046. pathArray: Vector3[][];
  26047. closeArray?: boolean;
  26048. closePath?: boolean;
  26049. offset?: number;
  26050. sideOrientation?: number;
  26051. frontUVs?: Vector4;
  26052. backUVs?: Vector4;
  26053. invertUV?: boolean;
  26054. uvs?: Vector2[];
  26055. colors?: Color4[];
  26056. }): VertexData;
  26057. /**
  26058. * Creates the VertexData for a box
  26059. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26060. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26061. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26062. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26063. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26064. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26065. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26066. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26067. * * 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)
  26068. * * 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)
  26069. * @returns the VertexData of the box
  26070. */
  26071. static CreateBox(options: {
  26072. size?: number;
  26073. width?: number;
  26074. height?: number;
  26075. depth?: number;
  26076. faceUV?: Vector4[];
  26077. faceColors?: Color4[];
  26078. sideOrientation?: number;
  26079. frontUVs?: Vector4;
  26080. backUVs?: Vector4;
  26081. }): VertexData;
  26082. /**
  26083. * Creates the VertexData for a tiled box
  26084. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26085. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26086. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26087. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26088. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26089. * @returns the VertexData of the box
  26090. */
  26091. static CreateTiledBox(options: {
  26092. pattern?: number;
  26093. width?: number;
  26094. height?: number;
  26095. depth?: number;
  26096. tileSize?: number;
  26097. tileWidth?: number;
  26098. tileHeight?: number;
  26099. alignHorizontal?: number;
  26100. alignVertical?: number;
  26101. faceUV?: Vector4[];
  26102. faceColors?: Color4[];
  26103. sideOrientation?: number;
  26104. }): VertexData;
  26105. /**
  26106. * Creates the VertexData for a tiled plane
  26107. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26108. * * pattern a limited pattern arrangement depending on the number
  26109. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26110. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26111. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26112. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26113. * * 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)
  26114. * * 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)
  26115. * @returns the VertexData of the tiled plane
  26116. */
  26117. static CreateTiledPlane(options: {
  26118. pattern?: number;
  26119. tileSize?: number;
  26120. tileWidth?: number;
  26121. tileHeight?: number;
  26122. size?: number;
  26123. width?: number;
  26124. height?: number;
  26125. alignHorizontal?: number;
  26126. alignVertical?: number;
  26127. sideOrientation?: number;
  26128. frontUVs?: Vector4;
  26129. backUVs?: Vector4;
  26130. }): VertexData;
  26131. /**
  26132. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26133. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26134. * * segments sets the number of horizontal strips optional, default 32
  26135. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26136. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26137. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26138. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26139. * * 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
  26140. * * 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
  26141. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26142. * * 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)
  26143. * * 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)
  26144. * @returns the VertexData of the ellipsoid
  26145. */
  26146. static CreateSphere(options: {
  26147. segments?: number;
  26148. diameter?: number;
  26149. diameterX?: number;
  26150. diameterY?: number;
  26151. diameterZ?: number;
  26152. arc?: number;
  26153. slice?: number;
  26154. sideOrientation?: number;
  26155. frontUVs?: Vector4;
  26156. backUVs?: Vector4;
  26157. }): VertexData;
  26158. /**
  26159. * Creates the VertexData for a cylinder, cone or prism
  26160. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26161. * * height sets the height (y direction) of the cylinder, optional, default 2
  26162. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26163. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26164. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26165. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26166. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26167. * * 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
  26168. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26169. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26170. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26171. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26172. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26173. * * 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)
  26174. * * 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)
  26175. * @returns the VertexData of the cylinder, cone or prism
  26176. */
  26177. static CreateCylinder(options: {
  26178. height?: number;
  26179. diameterTop?: number;
  26180. diameterBottom?: number;
  26181. diameter?: number;
  26182. tessellation?: number;
  26183. subdivisions?: number;
  26184. arc?: number;
  26185. faceColors?: Color4[];
  26186. faceUV?: Vector4[];
  26187. hasRings?: boolean;
  26188. enclose?: boolean;
  26189. sideOrientation?: number;
  26190. frontUVs?: Vector4;
  26191. backUVs?: Vector4;
  26192. }): VertexData;
  26193. /**
  26194. * Creates the VertexData for a torus
  26195. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26196. * * diameter the diameter of the torus, optional default 1
  26197. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26198. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26199. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26200. * * 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)
  26201. * * 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)
  26202. * @returns the VertexData of the torus
  26203. */
  26204. static CreateTorus(options: {
  26205. diameter?: number;
  26206. thickness?: number;
  26207. tessellation?: number;
  26208. sideOrientation?: number;
  26209. frontUVs?: Vector4;
  26210. backUVs?: Vector4;
  26211. }): VertexData;
  26212. /**
  26213. * Creates the VertexData of the LineSystem
  26214. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26215. * - lines an array of lines, each line being an array of successive Vector3
  26216. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26217. * @returns the VertexData of the LineSystem
  26218. */
  26219. static CreateLineSystem(options: {
  26220. lines: Vector3[][];
  26221. colors?: Nullable<Color4[][]>;
  26222. }): VertexData;
  26223. /**
  26224. * Create the VertexData for a DashedLines
  26225. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26226. * - points an array successive Vector3
  26227. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26228. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26229. * - dashNb the intended total number of dashes, optional, default 200
  26230. * @returns the VertexData for the DashedLines
  26231. */
  26232. static CreateDashedLines(options: {
  26233. points: Vector3[];
  26234. dashSize?: number;
  26235. gapSize?: number;
  26236. dashNb?: number;
  26237. }): VertexData;
  26238. /**
  26239. * Creates the VertexData for a Ground
  26240. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26241. * - width the width (x direction) of the ground, optional, default 1
  26242. * - height the height (z direction) of the ground, optional, default 1
  26243. * - subdivisions the number of subdivisions per side, optional, default 1
  26244. * @returns the VertexData of the Ground
  26245. */
  26246. static CreateGround(options: {
  26247. width?: number;
  26248. height?: number;
  26249. subdivisions?: number;
  26250. subdivisionsX?: number;
  26251. subdivisionsY?: number;
  26252. }): VertexData;
  26253. /**
  26254. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26255. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26256. * * xmin the ground minimum X coordinate, optional, default -1
  26257. * * zmin the ground minimum Z coordinate, optional, default -1
  26258. * * xmax the ground maximum X coordinate, optional, default 1
  26259. * * zmax the ground maximum Z coordinate, optional, default 1
  26260. * * 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}
  26261. * * 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}
  26262. * @returns the VertexData of the TiledGround
  26263. */
  26264. static CreateTiledGround(options: {
  26265. xmin: number;
  26266. zmin: number;
  26267. xmax: number;
  26268. zmax: number;
  26269. subdivisions?: {
  26270. w: number;
  26271. h: number;
  26272. };
  26273. precision?: {
  26274. w: number;
  26275. h: number;
  26276. };
  26277. }): VertexData;
  26278. /**
  26279. * Creates the VertexData of the Ground designed from a heightmap
  26280. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26281. * * width the width (x direction) of the ground
  26282. * * height the height (z direction) of the ground
  26283. * * subdivisions the number of subdivisions per side
  26284. * * minHeight the minimum altitude on the ground, optional, default 0
  26285. * * maxHeight the maximum altitude on the ground, optional default 1
  26286. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26287. * * buffer the array holding the image color data
  26288. * * bufferWidth the width of image
  26289. * * bufferHeight the height of image
  26290. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26291. * @returns the VertexData of the Ground designed from a heightmap
  26292. */
  26293. static CreateGroundFromHeightMap(options: {
  26294. width: number;
  26295. height: number;
  26296. subdivisions: number;
  26297. minHeight: number;
  26298. maxHeight: number;
  26299. colorFilter: Color3;
  26300. buffer: Uint8Array;
  26301. bufferWidth: number;
  26302. bufferHeight: number;
  26303. alphaFilter: number;
  26304. }): VertexData;
  26305. /**
  26306. * Creates the VertexData for a Plane
  26307. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26308. * * size sets the width and height of the plane to the value of size, optional default 1
  26309. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26310. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26311. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26312. * * 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)
  26313. * * 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)
  26314. * @returns the VertexData of the box
  26315. */
  26316. static CreatePlane(options: {
  26317. size?: number;
  26318. width?: number;
  26319. height?: number;
  26320. sideOrientation?: number;
  26321. frontUVs?: Vector4;
  26322. backUVs?: Vector4;
  26323. }): VertexData;
  26324. /**
  26325. * Creates the VertexData of the Disc or regular Polygon
  26326. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26327. * * radius the radius of the disc, optional default 0.5
  26328. * * tessellation the number of polygon sides, optional, default 64
  26329. * * 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
  26330. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26331. * * 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)
  26332. * * 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)
  26333. * @returns the VertexData of the box
  26334. */
  26335. static CreateDisc(options: {
  26336. radius?: number;
  26337. tessellation?: number;
  26338. arc?: number;
  26339. sideOrientation?: number;
  26340. frontUVs?: Vector4;
  26341. backUVs?: Vector4;
  26342. }): VertexData;
  26343. /**
  26344. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26345. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26346. * @param polygon a mesh built from polygonTriangulation.build()
  26347. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26348. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26349. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26350. * @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)
  26351. * @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)
  26352. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26353. * @returns the VertexData of the Polygon
  26354. */
  26355. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26356. /**
  26357. * Creates the VertexData of the IcoSphere
  26358. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26359. * * radius the radius of the IcoSphere, optional default 1
  26360. * * radiusX allows stretching in the x direction, optional, default radius
  26361. * * radiusY allows stretching in the y direction, optional, default radius
  26362. * * radiusZ allows stretching in the z direction, optional, default radius
  26363. * * flat when true creates a flat shaded mesh, optional, default true
  26364. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26365. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26366. * * 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)
  26367. * * 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)
  26368. * @returns the VertexData of the IcoSphere
  26369. */
  26370. static CreateIcoSphere(options: {
  26371. radius?: number;
  26372. radiusX?: number;
  26373. radiusY?: number;
  26374. radiusZ?: number;
  26375. flat?: boolean;
  26376. subdivisions?: number;
  26377. sideOrientation?: number;
  26378. frontUVs?: Vector4;
  26379. backUVs?: Vector4;
  26380. }): VertexData;
  26381. /**
  26382. * Creates the VertexData for a Polyhedron
  26383. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26384. * * type provided types are:
  26385. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26386. * * 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)
  26387. * * size the size of the IcoSphere, optional default 1
  26388. * * sizeX allows stretching in the x direction, optional, default size
  26389. * * sizeY allows stretching in the y direction, optional, default size
  26390. * * sizeZ allows stretching in the z direction, optional, default size
  26391. * * 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
  26392. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26393. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26394. * * flat when true creates a flat shaded mesh, optional, default true
  26395. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26396. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26397. * * 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)
  26398. * * 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)
  26399. * @returns the VertexData of the Polyhedron
  26400. */
  26401. static CreatePolyhedron(options: {
  26402. type?: number;
  26403. size?: number;
  26404. sizeX?: number;
  26405. sizeY?: number;
  26406. sizeZ?: number;
  26407. custom?: any;
  26408. faceUV?: Vector4[];
  26409. faceColors?: Color4[];
  26410. flat?: boolean;
  26411. sideOrientation?: number;
  26412. frontUVs?: Vector4;
  26413. backUVs?: Vector4;
  26414. }): VertexData;
  26415. /**
  26416. * Creates the VertexData for a TorusKnot
  26417. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26418. * * radius the radius of the torus knot, optional, default 2
  26419. * * tube the thickness of the tube, optional, default 0.5
  26420. * * radialSegments the number of sides on each tube segments, optional, default 32
  26421. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26422. * * p the number of windings around the z axis, optional, default 2
  26423. * * q the number of windings around the x axis, optional, default 3
  26424. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26425. * * 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)
  26426. * * 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)
  26427. * @returns the VertexData of the Torus Knot
  26428. */
  26429. static CreateTorusKnot(options: {
  26430. radius?: number;
  26431. tube?: number;
  26432. radialSegments?: number;
  26433. tubularSegments?: number;
  26434. p?: number;
  26435. q?: number;
  26436. sideOrientation?: number;
  26437. frontUVs?: Vector4;
  26438. backUVs?: Vector4;
  26439. }): VertexData;
  26440. /**
  26441. * Compute normals for given positions and indices
  26442. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26443. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26444. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26445. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26446. * * facetNormals : optional array of facet normals (vector3)
  26447. * * facetPositions : optional array of facet positions (vector3)
  26448. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26449. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26450. * * bInfo : optional bounding info, required for facetPartitioning computation
  26451. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26452. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26453. * * useRightHandedSystem: optional boolean to for right handed system computation
  26454. * * depthSort : optional boolean to enable the facet depth sort computation
  26455. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26456. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26457. */
  26458. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26459. facetNormals?: any;
  26460. facetPositions?: any;
  26461. facetPartitioning?: any;
  26462. ratio?: number;
  26463. bInfo?: any;
  26464. bbSize?: Vector3;
  26465. subDiv?: any;
  26466. useRightHandedSystem?: boolean;
  26467. depthSort?: boolean;
  26468. distanceTo?: Vector3;
  26469. depthSortedFacets?: any;
  26470. }): void;
  26471. /** @hidden */
  26472. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26473. /**
  26474. * Applies VertexData created from the imported parameters to the geometry
  26475. * @param parsedVertexData the parsed data from an imported file
  26476. * @param geometry the geometry to apply the VertexData to
  26477. */
  26478. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26479. }
  26480. }
  26481. declare module "babylonjs/Morph/morphTarget" {
  26482. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26483. import { Observable } from "babylonjs/Misc/observable";
  26484. import { Nullable, FloatArray } from "babylonjs/types";
  26485. import { Scene } from "babylonjs/scene";
  26486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26487. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26488. /**
  26489. * Defines a target to use with MorphTargetManager
  26490. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26491. */
  26492. export class MorphTarget implements IAnimatable {
  26493. /** defines the name of the target */
  26494. name: string;
  26495. /**
  26496. * Gets or sets the list of animations
  26497. */
  26498. animations: import("babylonjs/Animations/animation").Animation[];
  26499. private _scene;
  26500. private _positions;
  26501. private _normals;
  26502. private _tangents;
  26503. private _uvs;
  26504. private _influence;
  26505. private _uniqueId;
  26506. /**
  26507. * Observable raised when the influence changes
  26508. */
  26509. onInfluenceChanged: Observable<boolean>;
  26510. /** @hidden */
  26511. _onDataLayoutChanged: Observable<void>;
  26512. /**
  26513. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26514. */
  26515. get influence(): number;
  26516. set influence(influence: number);
  26517. /**
  26518. * Gets or sets the id of the morph Target
  26519. */
  26520. id: string;
  26521. private _animationPropertiesOverride;
  26522. /**
  26523. * Gets or sets the animation properties override
  26524. */
  26525. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26526. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26527. /**
  26528. * Creates a new MorphTarget
  26529. * @param name defines the name of the target
  26530. * @param influence defines the influence to use
  26531. * @param scene defines the scene the morphtarget belongs to
  26532. */
  26533. constructor(
  26534. /** defines the name of the target */
  26535. name: string, influence?: number, scene?: Nullable<Scene>);
  26536. /**
  26537. * Gets the unique ID of this manager
  26538. */
  26539. get uniqueId(): number;
  26540. /**
  26541. * Gets a boolean defining if the target contains position data
  26542. */
  26543. get hasPositions(): boolean;
  26544. /**
  26545. * Gets a boolean defining if the target contains normal data
  26546. */
  26547. get hasNormals(): boolean;
  26548. /**
  26549. * Gets a boolean defining if the target contains tangent data
  26550. */
  26551. get hasTangents(): boolean;
  26552. /**
  26553. * Gets a boolean defining if the target contains texture coordinates data
  26554. */
  26555. get hasUVs(): boolean;
  26556. /**
  26557. * Affects position data to this target
  26558. * @param data defines the position data to use
  26559. */
  26560. setPositions(data: Nullable<FloatArray>): void;
  26561. /**
  26562. * Gets the position data stored in this target
  26563. * @returns a FloatArray containing the position data (or null if not present)
  26564. */
  26565. getPositions(): Nullable<FloatArray>;
  26566. /**
  26567. * Affects normal data to this target
  26568. * @param data defines the normal data to use
  26569. */
  26570. setNormals(data: Nullable<FloatArray>): void;
  26571. /**
  26572. * Gets the normal data stored in this target
  26573. * @returns a FloatArray containing the normal data (or null if not present)
  26574. */
  26575. getNormals(): Nullable<FloatArray>;
  26576. /**
  26577. * Affects tangent data to this target
  26578. * @param data defines the tangent data to use
  26579. */
  26580. setTangents(data: Nullable<FloatArray>): void;
  26581. /**
  26582. * Gets the tangent data stored in this target
  26583. * @returns a FloatArray containing the tangent data (or null if not present)
  26584. */
  26585. getTangents(): Nullable<FloatArray>;
  26586. /**
  26587. * Affects texture coordinates data to this target
  26588. * @param data defines the texture coordinates data to use
  26589. */
  26590. setUVs(data: Nullable<FloatArray>): void;
  26591. /**
  26592. * Gets the texture coordinates data stored in this target
  26593. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26594. */
  26595. getUVs(): Nullable<FloatArray>;
  26596. /**
  26597. * Clone the current target
  26598. * @returns a new MorphTarget
  26599. */
  26600. clone(): MorphTarget;
  26601. /**
  26602. * Serializes the current target into a Serialization object
  26603. * @returns the serialized object
  26604. */
  26605. serialize(): any;
  26606. /**
  26607. * Returns the string "MorphTarget"
  26608. * @returns "MorphTarget"
  26609. */
  26610. getClassName(): string;
  26611. /**
  26612. * Creates a new target from serialized data
  26613. * @param serializationObject defines the serialized data to use
  26614. * @returns a new MorphTarget
  26615. */
  26616. static Parse(serializationObject: any): MorphTarget;
  26617. /**
  26618. * Creates a MorphTarget from mesh data
  26619. * @param mesh defines the source mesh
  26620. * @param name defines the name to use for the new target
  26621. * @param influence defines the influence to attach to the target
  26622. * @returns a new MorphTarget
  26623. */
  26624. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26625. }
  26626. }
  26627. declare module "babylonjs/Morph/morphTargetManager" {
  26628. import { Nullable } from "babylonjs/types";
  26629. import { Scene } from "babylonjs/scene";
  26630. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  26631. /**
  26632. * This class is used to deform meshes using morphing between different targets
  26633. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26634. */
  26635. export class MorphTargetManager {
  26636. private _targets;
  26637. private _targetInfluenceChangedObservers;
  26638. private _targetDataLayoutChangedObservers;
  26639. private _activeTargets;
  26640. private _scene;
  26641. private _influences;
  26642. private _supportsNormals;
  26643. private _supportsTangents;
  26644. private _supportsUVs;
  26645. private _vertexCount;
  26646. private _uniqueId;
  26647. private _tempInfluences;
  26648. /**
  26649. * Gets or sets a boolean indicating if normals must be morphed
  26650. */
  26651. enableNormalMorphing: boolean;
  26652. /**
  26653. * Gets or sets a boolean indicating if tangents must be morphed
  26654. */
  26655. enableTangentMorphing: boolean;
  26656. /**
  26657. * Gets or sets a boolean indicating if UV must be morphed
  26658. */
  26659. enableUVMorphing: boolean;
  26660. /**
  26661. * Creates a new MorphTargetManager
  26662. * @param scene defines the current scene
  26663. */
  26664. constructor(scene?: Nullable<Scene>);
  26665. /**
  26666. * Gets the unique ID of this manager
  26667. */
  26668. get uniqueId(): number;
  26669. /**
  26670. * Gets the number of vertices handled by this manager
  26671. */
  26672. get vertexCount(): number;
  26673. /**
  26674. * Gets a boolean indicating if this manager supports morphing of normals
  26675. */
  26676. get supportsNormals(): boolean;
  26677. /**
  26678. * Gets a boolean indicating if this manager supports morphing of tangents
  26679. */
  26680. get supportsTangents(): boolean;
  26681. /**
  26682. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26683. */
  26684. get supportsUVs(): boolean;
  26685. /**
  26686. * Gets the number of targets stored in this manager
  26687. */
  26688. get numTargets(): number;
  26689. /**
  26690. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26691. */
  26692. get numInfluencers(): number;
  26693. /**
  26694. * Gets the list of influences (one per target)
  26695. */
  26696. get influences(): Float32Array;
  26697. /**
  26698. * Gets the active target at specified index. An active target is a target with an influence > 0
  26699. * @param index defines the index to check
  26700. * @returns the requested target
  26701. */
  26702. getActiveTarget(index: number): MorphTarget;
  26703. /**
  26704. * Gets the target at specified index
  26705. * @param index defines the index to check
  26706. * @returns the requested target
  26707. */
  26708. getTarget(index: number): MorphTarget;
  26709. /**
  26710. * Add a new target to this manager
  26711. * @param target defines the target to add
  26712. */
  26713. addTarget(target: MorphTarget): void;
  26714. /**
  26715. * Removes a target from the manager
  26716. * @param target defines the target to remove
  26717. */
  26718. removeTarget(target: MorphTarget): void;
  26719. /**
  26720. * Clone the current manager
  26721. * @returns a new MorphTargetManager
  26722. */
  26723. clone(): MorphTargetManager;
  26724. /**
  26725. * Serializes the current manager into a Serialization object
  26726. * @returns the serialized object
  26727. */
  26728. serialize(): any;
  26729. private _syncActiveTargets;
  26730. /**
  26731. * Syncrhonize the targets with all the meshes using this morph target manager
  26732. */
  26733. synchronize(): void;
  26734. /**
  26735. * Creates a new MorphTargetManager from serialized data
  26736. * @param serializationObject defines the serialized data
  26737. * @param scene defines the hosting scene
  26738. * @returns the new MorphTargetManager
  26739. */
  26740. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26741. }
  26742. }
  26743. declare module "babylonjs/Meshes/meshLODLevel" {
  26744. import { Mesh } from "babylonjs/Meshes/mesh";
  26745. import { Nullable } from "babylonjs/types";
  26746. /**
  26747. * Class used to represent a specific level of detail of a mesh
  26748. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26749. */
  26750. export class MeshLODLevel {
  26751. /** Defines the distance where this level should start being displayed */
  26752. distance: number;
  26753. /** Defines the mesh to use to render this level */
  26754. mesh: Nullable<Mesh>;
  26755. /**
  26756. * Creates a new LOD level
  26757. * @param distance defines the distance where this level should star being displayed
  26758. * @param mesh defines the mesh to use to render this level
  26759. */
  26760. constructor(
  26761. /** Defines the distance where this level should start being displayed */
  26762. distance: number,
  26763. /** Defines the mesh to use to render this level */
  26764. mesh: Nullable<Mesh>);
  26765. }
  26766. }
  26767. declare module "babylonjs/Misc/canvasGenerator" {
  26768. /**
  26769. * Helper class used to generate a canvas to manipulate images
  26770. */
  26771. export class CanvasGenerator {
  26772. /**
  26773. * Create a new canvas (or offscreen canvas depending on the context)
  26774. * @param width defines the expected width
  26775. * @param height defines the expected height
  26776. * @return a new canvas or offscreen canvas
  26777. */
  26778. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  26779. }
  26780. }
  26781. declare module "babylonjs/Meshes/groundMesh" {
  26782. import { Scene } from "babylonjs/scene";
  26783. import { Vector3 } from "babylonjs/Maths/math.vector";
  26784. import { Mesh } from "babylonjs/Meshes/mesh";
  26785. /**
  26786. * Mesh representing the gorund
  26787. */
  26788. export class GroundMesh extends Mesh {
  26789. /** If octree should be generated */
  26790. generateOctree: boolean;
  26791. private _heightQuads;
  26792. /** @hidden */
  26793. _subdivisionsX: number;
  26794. /** @hidden */
  26795. _subdivisionsY: number;
  26796. /** @hidden */
  26797. _width: number;
  26798. /** @hidden */
  26799. _height: number;
  26800. /** @hidden */
  26801. _minX: number;
  26802. /** @hidden */
  26803. _maxX: number;
  26804. /** @hidden */
  26805. _minZ: number;
  26806. /** @hidden */
  26807. _maxZ: number;
  26808. constructor(name: string, scene: Scene);
  26809. /**
  26810. * "GroundMesh"
  26811. * @returns "GroundMesh"
  26812. */
  26813. getClassName(): string;
  26814. /**
  26815. * The minimum of x and y subdivisions
  26816. */
  26817. get subdivisions(): number;
  26818. /**
  26819. * X subdivisions
  26820. */
  26821. get subdivisionsX(): number;
  26822. /**
  26823. * Y subdivisions
  26824. */
  26825. get subdivisionsY(): number;
  26826. /**
  26827. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26828. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26829. * @param chunksCount the number of subdivisions for x and y
  26830. * @param octreeBlocksSize (Default: 32)
  26831. */
  26832. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26833. /**
  26834. * Returns a height (y) value in the Worl system :
  26835. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26836. * @param x x coordinate
  26837. * @param z z coordinate
  26838. * @returns the ground y position if (x, z) are outside the ground surface.
  26839. */
  26840. getHeightAtCoordinates(x: number, z: number): number;
  26841. /**
  26842. * Returns a normalized vector (Vector3) orthogonal to the ground
  26843. * at the ground coordinates (x, z) expressed in the World system.
  26844. * @param x x coordinate
  26845. * @param z z coordinate
  26846. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26847. */
  26848. getNormalAtCoordinates(x: number, z: number): Vector3;
  26849. /**
  26850. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26851. * at the ground coordinates (x, z) expressed in the World system.
  26852. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26853. * @param x x coordinate
  26854. * @param z z coordinate
  26855. * @param ref vector to store the result
  26856. * @returns the GroundMesh.
  26857. */
  26858. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26859. /**
  26860. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26861. * if the ground has been updated.
  26862. * This can be used in the render loop.
  26863. * @returns the GroundMesh.
  26864. */
  26865. updateCoordinateHeights(): GroundMesh;
  26866. private _getFacetAt;
  26867. private _initHeightQuads;
  26868. private _computeHeightQuads;
  26869. /**
  26870. * Serializes this ground mesh
  26871. * @param serializationObject object to write serialization to
  26872. */
  26873. serialize(serializationObject: any): void;
  26874. /**
  26875. * Parses a serialized ground mesh
  26876. * @param parsedMesh the serialized mesh
  26877. * @param scene the scene to create the ground mesh in
  26878. * @returns the created ground mesh
  26879. */
  26880. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26881. }
  26882. }
  26883. declare module "babylonjs/Physics/physicsJoint" {
  26884. import { Vector3 } from "babylonjs/Maths/math.vector";
  26885. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  26886. /**
  26887. * Interface for Physics-Joint data
  26888. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26889. */
  26890. export interface PhysicsJointData {
  26891. /**
  26892. * The main pivot of the joint
  26893. */
  26894. mainPivot?: Vector3;
  26895. /**
  26896. * The connected pivot of the joint
  26897. */
  26898. connectedPivot?: Vector3;
  26899. /**
  26900. * The main axis of the joint
  26901. */
  26902. mainAxis?: Vector3;
  26903. /**
  26904. * The connected axis of the joint
  26905. */
  26906. connectedAxis?: Vector3;
  26907. /**
  26908. * The collision of the joint
  26909. */
  26910. collision?: boolean;
  26911. /**
  26912. * Native Oimo/Cannon/Energy data
  26913. */
  26914. nativeParams?: any;
  26915. }
  26916. /**
  26917. * This is a holder class for the physics joint created by the physics plugin
  26918. * It holds a set of functions to control the underlying joint
  26919. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26920. */
  26921. export class PhysicsJoint {
  26922. /**
  26923. * The type of the physics joint
  26924. */
  26925. type: number;
  26926. /**
  26927. * The data for the physics joint
  26928. */
  26929. jointData: PhysicsJointData;
  26930. private _physicsJoint;
  26931. protected _physicsPlugin: IPhysicsEnginePlugin;
  26932. /**
  26933. * Initializes the physics joint
  26934. * @param type The type of the physics joint
  26935. * @param jointData The data for the physics joint
  26936. */
  26937. constructor(
  26938. /**
  26939. * The type of the physics joint
  26940. */
  26941. type: number,
  26942. /**
  26943. * The data for the physics joint
  26944. */
  26945. jointData: PhysicsJointData);
  26946. /**
  26947. * Gets the physics joint
  26948. */
  26949. get physicsJoint(): any;
  26950. /**
  26951. * Sets the physics joint
  26952. */
  26953. set physicsJoint(newJoint: any);
  26954. /**
  26955. * Sets the physics plugin
  26956. */
  26957. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26958. /**
  26959. * Execute a function that is physics-plugin specific.
  26960. * @param {Function} func the function that will be executed.
  26961. * It accepts two parameters: the physics world and the physics joint
  26962. */
  26963. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26964. /**
  26965. * Distance-Joint type
  26966. */
  26967. static DistanceJoint: number;
  26968. /**
  26969. * Hinge-Joint type
  26970. */
  26971. static HingeJoint: number;
  26972. /**
  26973. * Ball-and-Socket joint type
  26974. */
  26975. static BallAndSocketJoint: number;
  26976. /**
  26977. * Wheel-Joint type
  26978. */
  26979. static WheelJoint: number;
  26980. /**
  26981. * Slider-Joint type
  26982. */
  26983. static SliderJoint: number;
  26984. /**
  26985. * Prismatic-Joint type
  26986. */
  26987. static PrismaticJoint: number;
  26988. /**
  26989. * Universal-Joint type
  26990. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26991. */
  26992. static UniversalJoint: number;
  26993. /**
  26994. * Hinge-Joint 2 type
  26995. */
  26996. static Hinge2Joint: number;
  26997. /**
  26998. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26999. */
  27000. static PointToPointJoint: number;
  27001. /**
  27002. * Spring-Joint type
  27003. */
  27004. static SpringJoint: number;
  27005. /**
  27006. * Lock-Joint type
  27007. */
  27008. static LockJoint: number;
  27009. }
  27010. /**
  27011. * A class representing a physics distance joint
  27012. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27013. */
  27014. export class DistanceJoint extends PhysicsJoint {
  27015. /**
  27016. *
  27017. * @param jointData The data for the Distance-Joint
  27018. */
  27019. constructor(jointData: DistanceJointData);
  27020. /**
  27021. * Update the predefined distance.
  27022. * @param maxDistance The maximum preferred distance
  27023. * @param minDistance The minimum preferred distance
  27024. */
  27025. updateDistance(maxDistance: number, minDistance?: number): void;
  27026. }
  27027. /**
  27028. * Represents a Motor-Enabled Joint
  27029. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27030. */
  27031. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27032. /**
  27033. * Initializes the Motor-Enabled Joint
  27034. * @param type The type of the joint
  27035. * @param jointData The physica joint data for the joint
  27036. */
  27037. constructor(type: number, jointData: PhysicsJointData);
  27038. /**
  27039. * Set the motor values.
  27040. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27041. * @param force the force to apply
  27042. * @param maxForce max force for this motor.
  27043. */
  27044. setMotor(force?: number, maxForce?: number): void;
  27045. /**
  27046. * Set the motor's limits.
  27047. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27048. * @param upperLimit The upper limit of the motor
  27049. * @param lowerLimit The lower limit of the motor
  27050. */
  27051. setLimit(upperLimit: number, lowerLimit?: number): void;
  27052. }
  27053. /**
  27054. * This class represents a single physics Hinge-Joint
  27055. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27056. */
  27057. export class HingeJoint extends MotorEnabledJoint {
  27058. /**
  27059. * Initializes the Hinge-Joint
  27060. * @param jointData The joint data for the Hinge-Joint
  27061. */
  27062. constructor(jointData: PhysicsJointData);
  27063. /**
  27064. * Set the motor values.
  27065. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27066. * @param {number} force the force to apply
  27067. * @param {number} maxForce max force for this motor.
  27068. */
  27069. setMotor(force?: number, maxForce?: number): void;
  27070. /**
  27071. * Set the motor's limits.
  27072. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27073. * @param upperLimit The upper limit of the motor
  27074. * @param lowerLimit The lower limit of the motor
  27075. */
  27076. setLimit(upperLimit: number, lowerLimit?: number): void;
  27077. }
  27078. /**
  27079. * This class represents a dual hinge physics joint (same as wheel joint)
  27080. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27081. */
  27082. export class Hinge2Joint extends MotorEnabledJoint {
  27083. /**
  27084. * Initializes the Hinge2-Joint
  27085. * @param jointData The joint data for the Hinge2-Joint
  27086. */
  27087. constructor(jointData: PhysicsJointData);
  27088. /**
  27089. * Set the motor values.
  27090. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27091. * @param {number} targetSpeed the speed the motor is to reach
  27092. * @param {number} maxForce max force for this motor.
  27093. * @param {motorIndex} the motor's index, 0 or 1.
  27094. */
  27095. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27096. /**
  27097. * Set the motor limits.
  27098. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27099. * @param {number} upperLimit the upper limit
  27100. * @param {number} lowerLimit lower limit
  27101. * @param {motorIndex} the motor's index, 0 or 1.
  27102. */
  27103. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27104. }
  27105. /**
  27106. * Interface for a motor enabled joint
  27107. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27108. */
  27109. export interface IMotorEnabledJoint {
  27110. /**
  27111. * Physics joint
  27112. */
  27113. physicsJoint: any;
  27114. /**
  27115. * Sets the motor of the motor-enabled joint
  27116. * @param force The force of the motor
  27117. * @param maxForce The maximum force of the motor
  27118. * @param motorIndex The index of the motor
  27119. */
  27120. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27121. /**
  27122. * Sets the limit of the motor
  27123. * @param upperLimit The upper limit of the motor
  27124. * @param lowerLimit The lower limit of the motor
  27125. * @param motorIndex The index of the motor
  27126. */
  27127. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27128. }
  27129. /**
  27130. * Joint data for a Distance-Joint
  27131. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27132. */
  27133. export interface DistanceJointData extends PhysicsJointData {
  27134. /**
  27135. * Max distance the 2 joint objects can be apart
  27136. */
  27137. maxDistance: number;
  27138. }
  27139. /**
  27140. * Joint data from a spring joint
  27141. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27142. */
  27143. export interface SpringJointData extends PhysicsJointData {
  27144. /**
  27145. * Length of the spring
  27146. */
  27147. length: number;
  27148. /**
  27149. * Stiffness of the spring
  27150. */
  27151. stiffness: number;
  27152. /**
  27153. * Damping of the spring
  27154. */
  27155. damping: number;
  27156. /** this callback will be called when applying the force to the impostors. */
  27157. forceApplicationCallback: () => void;
  27158. }
  27159. }
  27160. declare module "babylonjs/Physics/physicsRaycastResult" {
  27161. import { Vector3 } from "babylonjs/Maths/math.vector";
  27162. /**
  27163. * Holds the data for the raycast result
  27164. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27165. */
  27166. export class PhysicsRaycastResult {
  27167. private _hasHit;
  27168. private _hitDistance;
  27169. private _hitNormalWorld;
  27170. private _hitPointWorld;
  27171. private _rayFromWorld;
  27172. private _rayToWorld;
  27173. /**
  27174. * Gets if there was a hit
  27175. */
  27176. get hasHit(): boolean;
  27177. /**
  27178. * Gets the distance from the hit
  27179. */
  27180. get hitDistance(): number;
  27181. /**
  27182. * Gets the hit normal/direction in the world
  27183. */
  27184. get hitNormalWorld(): Vector3;
  27185. /**
  27186. * Gets the hit point in the world
  27187. */
  27188. get hitPointWorld(): Vector3;
  27189. /**
  27190. * Gets the ray "start point" of the ray in the world
  27191. */
  27192. get rayFromWorld(): Vector3;
  27193. /**
  27194. * Gets the ray "end point" of the ray in the world
  27195. */
  27196. get rayToWorld(): Vector3;
  27197. /**
  27198. * Sets the hit data (normal & point in world space)
  27199. * @param hitNormalWorld defines the normal in world space
  27200. * @param hitPointWorld defines the point in world space
  27201. */
  27202. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27203. /**
  27204. * Sets the distance from the start point to the hit point
  27205. * @param distance
  27206. */
  27207. setHitDistance(distance: number): void;
  27208. /**
  27209. * Calculates the distance manually
  27210. */
  27211. calculateHitDistance(): void;
  27212. /**
  27213. * Resets all the values to default
  27214. * @param from The from point on world space
  27215. * @param to The to point on world space
  27216. */
  27217. reset(from?: Vector3, to?: Vector3): void;
  27218. }
  27219. /**
  27220. * Interface for the size containing width and height
  27221. */
  27222. interface IXYZ {
  27223. /**
  27224. * X
  27225. */
  27226. x: number;
  27227. /**
  27228. * Y
  27229. */
  27230. y: number;
  27231. /**
  27232. * Z
  27233. */
  27234. z: number;
  27235. }
  27236. }
  27237. declare module "babylonjs/Physics/IPhysicsEngine" {
  27238. import { Nullable } from "babylonjs/types";
  27239. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  27240. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27241. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  27242. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  27243. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  27244. /**
  27245. * Interface used to describe a physics joint
  27246. */
  27247. export interface PhysicsImpostorJoint {
  27248. /** Defines the main impostor to which the joint is linked */
  27249. mainImpostor: PhysicsImpostor;
  27250. /** Defines the impostor that is connected to the main impostor using this joint */
  27251. connectedImpostor: PhysicsImpostor;
  27252. /** Defines the joint itself */
  27253. joint: PhysicsJoint;
  27254. }
  27255. /** @hidden */
  27256. export interface IPhysicsEnginePlugin {
  27257. world: any;
  27258. name: string;
  27259. setGravity(gravity: Vector3): void;
  27260. setTimeStep(timeStep: number): void;
  27261. getTimeStep(): number;
  27262. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27263. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27264. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27265. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27266. removePhysicsBody(impostor: PhysicsImpostor): void;
  27267. generateJoint(joint: PhysicsImpostorJoint): void;
  27268. removeJoint(joint: PhysicsImpostorJoint): void;
  27269. isSupported(): boolean;
  27270. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27271. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27272. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27273. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27274. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27275. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27276. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27277. getBodyMass(impostor: PhysicsImpostor): number;
  27278. getBodyFriction(impostor: PhysicsImpostor): number;
  27279. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27280. getBodyRestitution(impostor: PhysicsImpostor): number;
  27281. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27282. getBodyPressure?(impostor: PhysicsImpostor): number;
  27283. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27284. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27285. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27286. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27287. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27288. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27289. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27290. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27291. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27292. sleepBody(impostor: PhysicsImpostor): void;
  27293. wakeUpBody(impostor: PhysicsImpostor): void;
  27294. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27295. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27296. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27297. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27298. getRadius(impostor: PhysicsImpostor): number;
  27299. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27300. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27301. dispose(): void;
  27302. }
  27303. /**
  27304. * Interface used to define a physics engine
  27305. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27306. */
  27307. export interface IPhysicsEngine {
  27308. /**
  27309. * Gets the gravity vector used by the simulation
  27310. */
  27311. gravity: Vector3;
  27312. /**
  27313. * Sets the gravity vector used by the simulation
  27314. * @param gravity defines the gravity vector to use
  27315. */
  27316. setGravity(gravity: Vector3): void;
  27317. /**
  27318. * Set the time step of the physics engine.
  27319. * Default is 1/60.
  27320. * To slow it down, enter 1/600 for example.
  27321. * To speed it up, 1/30
  27322. * @param newTimeStep the new timestep to apply to this world.
  27323. */
  27324. setTimeStep(newTimeStep: number): void;
  27325. /**
  27326. * Get the time step of the physics engine.
  27327. * @returns the current time step
  27328. */
  27329. getTimeStep(): number;
  27330. /**
  27331. * Set the sub time step of the physics engine.
  27332. * Default is 0 meaning there is no sub steps
  27333. * To increase physics resolution precision, set a small value (like 1 ms)
  27334. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27335. */
  27336. setSubTimeStep(subTimeStep: number): void;
  27337. /**
  27338. * Get the sub time step of the physics engine.
  27339. * @returns the current sub time step
  27340. */
  27341. getSubTimeStep(): number;
  27342. /**
  27343. * Release all resources
  27344. */
  27345. dispose(): void;
  27346. /**
  27347. * Gets the name of the current physics plugin
  27348. * @returns the name of the plugin
  27349. */
  27350. getPhysicsPluginName(): string;
  27351. /**
  27352. * Adding a new impostor for the impostor tracking.
  27353. * This will be done by the impostor itself.
  27354. * @param impostor the impostor to add
  27355. */
  27356. addImpostor(impostor: PhysicsImpostor): void;
  27357. /**
  27358. * Remove an impostor from the engine.
  27359. * This impostor and its mesh will not longer be updated by the physics engine.
  27360. * @param impostor the impostor to remove
  27361. */
  27362. removeImpostor(impostor: PhysicsImpostor): void;
  27363. /**
  27364. * Add a joint to the physics engine
  27365. * @param mainImpostor defines the main impostor to which the joint is added.
  27366. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27367. * @param joint defines the joint that will connect both impostors.
  27368. */
  27369. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27370. /**
  27371. * Removes a joint from the simulation
  27372. * @param mainImpostor defines the impostor used with the joint
  27373. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27374. * @param joint defines the joint to remove
  27375. */
  27376. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27377. /**
  27378. * Gets the current plugin used to run the simulation
  27379. * @returns current plugin
  27380. */
  27381. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27382. /**
  27383. * Gets the list of physic impostors
  27384. * @returns an array of PhysicsImpostor
  27385. */
  27386. getImpostors(): Array<PhysicsImpostor>;
  27387. /**
  27388. * Gets the impostor for a physics enabled object
  27389. * @param object defines the object impersonated by the impostor
  27390. * @returns the PhysicsImpostor or null if not found
  27391. */
  27392. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27393. /**
  27394. * Gets the impostor for a physics body object
  27395. * @param body defines physics body used by the impostor
  27396. * @returns the PhysicsImpostor or null if not found
  27397. */
  27398. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27399. /**
  27400. * Does a raycast in the physics world
  27401. * @param from when should the ray start?
  27402. * @param to when should the ray end?
  27403. * @returns PhysicsRaycastResult
  27404. */
  27405. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27406. /**
  27407. * Called by the scene. No need to call it.
  27408. * @param delta defines the timespam between frames
  27409. */
  27410. _step(delta: number): void;
  27411. }
  27412. }
  27413. declare module "babylonjs/Physics/physicsImpostor" {
  27414. import { Nullable, IndicesArray } from "babylonjs/types";
  27415. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  27416. import { TransformNode } from "babylonjs/Meshes/transformNode";
  27417. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27418. import { Scene } from "babylonjs/scene";
  27419. import { Bone } from "babylonjs/Bones/bone";
  27420. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  27421. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  27422. import { Space } from "babylonjs/Maths/math.axis";
  27423. /**
  27424. * The interface for the physics imposter parameters
  27425. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27426. */
  27427. export interface PhysicsImpostorParameters {
  27428. /**
  27429. * The mass of the physics imposter
  27430. */
  27431. mass: number;
  27432. /**
  27433. * The friction of the physics imposter
  27434. */
  27435. friction?: number;
  27436. /**
  27437. * The coefficient of restitution of the physics imposter
  27438. */
  27439. restitution?: number;
  27440. /**
  27441. * The native options of the physics imposter
  27442. */
  27443. nativeOptions?: any;
  27444. /**
  27445. * Specifies if the parent should be ignored
  27446. */
  27447. ignoreParent?: boolean;
  27448. /**
  27449. * Specifies if bi-directional transformations should be disabled
  27450. */
  27451. disableBidirectionalTransformation?: boolean;
  27452. /**
  27453. * The pressure inside the physics imposter, soft object only
  27454. */
  27455. pressure?: number;
  27456. /**
  27457. * The stiffness the physics imposter, soft object only
  27458. */
  27459. stiffness?: number;
  27460. /**
  27461. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27462. */
  27463. velocityIterations?: number;
  27464. /**
  27465. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27466. */
  27467. positionIterations?: number;
  27468. /**
  27469. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27470. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27471. * Add to fix multiple points
  27472. */
  27473. fixedPoints?: number;
  27474. /**
  27475. * The collision margin around a soft object
  27476. */
  27477. margin?: number;
  27478. /**
  27479. * The collision margin around a soft object
  27480. */
  27481. damping?: number;
  27482. /**
  27483. * The path for a rope based on an extrusion
  27484. */
  27485. path?: any;
  27486. /**
  27487. * The shape of an extrusion used for a rope based on an extrusion
  27488. */
  27489. shape?: any;
  27490. }
  27491. /**
  27492. * Interface for a physics-enabled object
  27493. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27494. */
  27495. export interface IPhysicsEnabledObject {
  27496. /**
  27497. * The position of the physics-enabled object
  27498. */
  27499. position: Vector3;
  27500. /**
  27501. * The rotation of the physics-enabled object
  27502. */
  27503. rotationQuaternion: Nullable<Quaternion>;
  27504. /**
  27505. * The scale of the physics-enabled object
  27506. */
  27507. scaling: Vector3;
  27508. /**
  27509. * The rotation of the physics-enabled object
  27510. */
  27511. rotation?: Vector3;
  27512. /**
  27513. * The parent of the physics-enabled object
  27514. */
  27515. parent?: any;
  27516. /**
  27517. * The bounding info of the physics-enabled object
  27518. * @returns The bounding info of the physics-enabled object
  27519. */
  27520. getBoundingInfo(): BoundingInfo;
  27521. /**
  27522. * Computes the world matrix
  27523. * @param force Specifies if the world matrix should be computed by force
  27524. * @returns A world matrix
  27525. */
  27526. computeWorldMatrix(force: boolean): Matrix;
  27527. /**
  27528. * Gets the world matrix
  27529. * @returns A world matrix
  27530. */
  27531. getWorldMatrix?(): Matrix;
  27532. /**
  27533. * Gets the child meshes
  27534. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27535. * @returns An array of abstract meshes
  27536. */
  27537. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27538. /**
  27539. * Gets the vertex data
  27540. * @param kind The type of vertex data
  27541. * @returns A nullable array of numbers, or a float32 array
  27542. */
  27543. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27544. /**
  27545. * Gets the indices from the mesh
  27546. * @returns A nullable array of index arrays
  27547. */
  27548. getIndices?(): Nullable<IndicesArray>;
  27549. /**
  27550. * Gets the scene from the mesh
  27551. * @returns the indices array or null
  27552. */
  27553. getScene?(): Scene;
  27554. /**
  27555. * Gets the absolute position from the mesh
  27556. * @returns the absolute position
  27557. */
  27558. getAbsolutePosition(): Vector3;
  27559. /**
  27560. * Gets the absolute pivot point from the mesh
  27561. * @returns the absolute pivot point
  27562. */
  27563. getAbsolutePivotPoint(): Vector3;
  27564. /**
  27565. * Rotates the mesh
  27566. * @param axis The axis of rotation
  27567. * @param amount The amount of rotation
  27568. * @param space The space of the rotation
  27569. * @returns The rotation transform node
  27570. */
  27571. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27572. /**
  27573. * Translates the mesh
  27574. * @param axis The axis of translation
  27575. * @param distance The distance of translation
  27576. * @param space The space of the translation
  27577. * @returns The transform node
  27578. */
  27579. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27580. /**
  27581. * Sets the absolute position of the mesh
  27582. * @param absolutePosition The absolute position of the mesh
  27583. * @returns The transform node
  27584. */
  27585. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27586. /**
  27587. * Gets the class name of the mesh
  27588. * @returns The class name
  27589. */
  27590. getClassName(): string;
  27591. }
  27592. /**
  27593. * Represents a physics imposter
  27594. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27595. */
  27596. export class PhysicsImpostor {
  27597. /**
  27598. * The physics-enabled object used as the physics imposter
  27599. */
  27600. object: IPhysicsEnabledObject;
  27601. /**
  27602. * The type of the physics imposter
  27603. */
  27604. type: number;
  27605. private _options;
  27606. private _scene?;
  27607. /**
  27608. * The default object size of the imposter
  27609. */
  27610. static DEFAULT_OBJECT_SIZE: Vector3;
  27611. /**
  27612. * The identity quaternion of the imposter
  27613. */
  27614. static IDENTITY_QUATERNION: Quaternion;
  27615. /** @hidden */
  27616. _pluginData: any;
  27617. private _physicsEngine;
  27618. private _physicsBody;
  27619. private _bodyUpdateRequired;
  27620. private _onBeforePhysicsStepCallbacks;
  27621. private _onAfterPhysicsStepCallbacks;
  27622. /** @hidden */
  27623. _onPhysicsCollideCallbacks: Array<{
  27624. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27625. otherImpostors: Array<PhysicsImpostor>;
  27626. }>;
  27627. private _deltaPosition;
  27628. private _deltaRotation;
  27629. private _deltaRotationConjugated;
  27630. /** @hidden */
  27631. _isFromLine: boolean;
  27632. private _parent;
  27633. private _isDisposed;
  27634. private static _tmpVecs;
  27635. private static _tmpQuat;
  27636. /**
  27637. * Specifies if the physics imposter is disposed
  27638. */
  27639. get isDisposed(): boolean;
  27640. /**
  27641. * Gets the mass of the physics imposter
  27642. */
  27643. get mass(): number;
  27644. set mass(value: number);
  27645. /**
  27646. * Gets the coefficient of friction
  27647. */
  27648. get friction(): number;
  27649. /**
  27650. * Sets the coefficient of friction
  27651. */
  27652. set friction(value: number);
  27653. /**
  27654. * Gets the coefficient of restitution
  27655. */
  27656. get restitution(): number;
  27657. /**
  27658. * Sets the coefficient of restitution
  27659. */
  27660. set restitution(value: number);
  27661. /**
  27662. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27663. */
  27664. get pressure(): number;
  27665. /**
  27666. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27667. */
  27668. set pressure(value: number);
  27669. /**
  27670. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27671. */
  27672. get stiffness(): number;
  27673. /**
  27674. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27675. */
  27676. set stiffness(value: number);
  27677. /**
  27678. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27679. */
  27680. get velocityIterations(): number;
  27681. /**
  27682. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27683. */
  27684. set velocityIterations(value: number);
  27685. /**
  27686. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27687. */
  27688. get positionIterations(): number;
  27689. /**
  27690. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27691. */
  27692. set positionIterations(value: number);
  27693. /**
  27694. * The unique id of the physics imposter
  27695. * set by the physics engine when adding this impostor to the array
  27696. */
  27697. uniqueId: number;
  27698. /**
  27699. * @hidden
  27700. */
  27701. soft: boolean;
  27702. /**
  27703. * @hidden
  27704. */
  27705. segments: number;
  27706. private _joints;
  27707. /**
  27708. * Initializes the physics imposter
  27709. * @param object The physics-enabled object used as the physics imposter
  27710. * @param type The type of the physics imposter
  27711. * @param _options The options for the physics imposter
  27712. * @param _scene The Babylon scene
  27713. */
  27714. constructor(
  27715. /**
  27716. * The physics-enabled object used as the physics imposter
  27717. */
  27718. object: IPhysicsEnabledObject,
  27719. /**
  27720. * The type of the physics imposter
  27721. */
  27722. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27723. /**
  27724. * This function will completly initialize this impostor.
  27725. * It will create a new body - but only if this mesh has no parent.
  27726. * If it has, this impostor will not be used other than to define the impostor
  27727. * of the child mesh.
  27728. * @hidden
  27729. */
  27730. _init(): void;
  27731. private _getPhysicsParent;
  27732. /**
  27733. * Should a new body be generated.
  27734. * @returns boolean specifying if body initialization is required
  27735. */
  27736. isBodyInitRequired(): boolean;
  27737. /**
  27738. * Sets the updated scaling
  27739. * @param updated Specifies if the scaling is updated
  27740. */
  27741. setScalingUpdated(): void;
  27742. /**
  27743. * Force a regeneration of this or the parent's impostor's body.
  27744. * Use under cautious - This will remove all joints already implemented.
  27745. */
  27746. forceUpdate(): void;
  27747. /**
  27748. * Gets the body that holds this impostor. Either its own, or its parent.
  27749. */
  27750. get physicsBody(): any;
  27751. /**
  27752. * Get the parent of the physics imposter
  27753. * @returns Physics imposter or null
  27754. */
  27755. get parent(): Nullable<PhysicsImpostor>;
  27756. /**
  27757. * Sets the parent of the physics imposter
  27758. */
  27759. set parent(value: Nullable<PhysicsImpostor>);
  27760. /**
  27761. * Set the physics body. Used mainly by the physics engine/plugin
  27762. */
  27763. set physicsBody(physicsBody: any);
  27764. /**
  27765. * Resets the update flags
  27766. */
  27767. resetUpdateFlags(): void;
  27768. /**
  27769. * Gets the object extend size
  27770. * @returns the object extend size
  27771. */
  27772. getObjectExtendSize(): Vector3;
  27773. /**
  27774. * Gets the object center
  27775. * @returns The object center
  27776. */
  27777. getObjectCenter(): Vector3;
  27778. /**
  27779. * Get a specific parameter from the options parameters
  27780. * @param paramName The object parameter name
  27781. * @returns The object parameter
  27782. */
  27783. getParam(paramName: string): any;
  27784. /**
  27785. * Sets a specific parameter in the options given to the physics plugin
  27786. * @param paramName The parameter name
  27787. * @param value The value of the parameter
  27788. */
  27789. setParam(paramName: string, value: number): void;
  27790. /**
  27791. * Specifically change the body's mass option. Won't recreate the physics body object
  27792. * @param mass The mass of the physics imposter
  27793. */
  27794. setMass(mass: number): void;
  27795. /**
  27796. * Gets the linear velocity
  27797. * @returns linear velocity or null
  27798. */
  27799. getLinearVelocity(): Nullable<Vector3>;
  27800. /**
  27801. * Sets the linear velocity
  27802. * @param velocity linear velocity or null
  27803. */
  27804. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27805. /**
  27806. * Gets the angular velocity
  27807. * @returns angular velocity or null
  27808. */
  27809. getAngularVelocity(): Nullable<Vector3>;
  27810. /**
  27811. * Sets the angular velocity
  27812. * @param velocity The velocity or null
  27813. */
  27814. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27815. /**
  27816. * Execute a function with the physics plugin native code
  27817. * Provide a function the will have two variables - the world object and the physics body object
  27818. * @param func The function to execute with the physics plugin native code
  27819. */
  27820. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27821. /**
  27822. * Register a function that will be executed before the physics world is stepping forward
  27823. * @param func The function to execute before the physics world is stepped forward
  27824. */
  27825. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27826. /**
  27827. * Unregister a function that will be executed before the physics world is stepping forward
  27828. * @param func The function to execute before the physics world is stepped forward
  27829. */
  27830. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27831. /**
  27832. * Register a function that will be executed after the physics step
  27833. * @param func The function to execute after physics step
  27834. */
  27835. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27836. /**
  27837. * Unregisters a function that will be executed after the physics step
  27838. * @param func The function to execute after physics step
  27839. */
  27840. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27841. /**
  27842. * register a function that will be executed when this impostor collides against a different body
  27843. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27844. * @param func Callback that is executed on collision
  27845. */
  27846. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27847. /**
  27848. * Unregisters the physics imposter on contact
  27849. * @param collideAgainst The physics object to collide against
  27850. * @param func Callback to execute on collision
  27851. */
  27852. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27853. private _tmpQuat;
  27854. private _tmpQuat2;
  27855. /**
  27856. * Get the parent rotation
  27857. * @returns The parent rotation
  27858. */
  27859. getParentsRotation(): Quaternion;
  27860. /**
  27861. * this function is executed by the physics engine.
  27862. */
  27863. beforeStep: () => void;
  27864. /**
  27865. * this function is executed by the physics engine
  27866. */
  27867. afterStep: () => void;
  27868. /**
  27869. * Legacy collision detection event support
  27870. */
  27871. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27872. /**
  27873. * event and body object due to cannon's event-based architecture.
  27874. */
  27875. onCollide: (e: {
  27876. body: any;
  27877. }) => void;
  27878. /**
  27879. * Apply a force
  27880. * @param force The force to apply
  27881. * @param contactPoint The contact point for the force
  27882. * @returns The physics imposter
  27883. */
  27884. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27885. /**
  27886. * Apply an impulse
  27887. * @param force The impulse force
  27888. * @param contactPoint The contact point for the impulse force
  27889. * @returns The physics imposter
  27890. */
  27891. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27892. /**
  27893. * A help function to create a joint
  27894. * @param otherImpostor A physics imposter used to create a joint
  27895. * @param jointType The type of joint
  27896. * @param jointData The data for the joint
  27897. * @returns The physics imposter
  27898. */
  27899. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27900. /**
  27901. * Add a joint to this impostor with a different impostor
  27902. * @param otherImpostor A physics imposter used to add a joint
  27903. * @param joint The joint to add
  27904. * @returns The physics imposter
  27905. */
  27906. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27907. /**
  27908. * Add an anchor to a cloth impostor
  27909. * @param otherImpostor rigid impostor to anchor to
  27910. * @param width ratio across width from 0 to 1
  27911. * @param height ratio up height from 0 to 1
  27912. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27913. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27914. * @returns impostor the soft imposter
  27915. */
  27916. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27917. /**
  27918. * Add a hook to a rope impostor
  27919. * @param otherImpostor rigid impostor to anchor to
  27920. * @param length ratio across rope from 0 to 1
  27921. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27922. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27923. * @returns impostor the rope imposter
  27924. */
  27925. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27926. /**
  27927. * Will keep this body still, in a sleep mode.
  27928. * @returns the physics imposter
  27929. */
  27930. sleep(): PhysicsImpostor;
  27931. /**
  27932. * Wake the body up.
  27933. * @returns The physics imposter
  27934. */
  27935. wakeUp(): PhysicsImpostor;
  27936. /**
  27937. * Clones the physics imposter
  27938. * @param newObject The physics imposter clones to this physics-enabled object
  27939. * @returns A nullable physics imposter
  27940. */
  27941. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27942. /**
  27943. * Disposes the physics imposter
  27944. */
  27945. dispose(): void;
  27946. /**
  27947. * Sets the delta position
  27948. * @param position The delta position amount
  27949. */
  27950. setDeltaPosition(position: Vector3): void;
  27951. /**
  27952. * Sets the delta rotation
  27953. * @param rotation The delta rotation amount
  27954. */
  27955. setDeltaRotation(rotation: Quaternion): void;
  27956. /**
  27957. * Gets the box size of the physics imposter and stores the result in the input parameter
  27958. * @param result Stores the box size
  27959. * @returns The physics imposter
  27960. */
  27961. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27962. /**
  27963. * Gets the radius of the physics imposter
  27964. * @returns Radius of the physics imposter
  27965. */
  27966. getRadius(): number;
  27967. /**
  27968. * Sync a bone with this impostor
  27969. * @param bone The bone to sync to the impostor.
  27970. * @param boneMesh The mesh that the bone is influencing.
  27971. * @param jointPivot The pivot of the joint / bone in local space.
  27972. * @param distToJoint Optional distance from the impostor to the joint.
  27973. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27974. */
  27975. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27976. /**
  27977. * Sync impostor to a bone
  27978. * @param bone The bone that the impostor will be synced to.
  27979. * @param boneMesh The mesh that the bone is influencing.
  27980. * @param jointPivot The pivot of the joint / bone in local space.
  27981. * @param distToJoint Optional distance from the impostor to the joint.
  27982. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27983. * @param boneAxis Optional vector3 axis the bone is aligned with
  27984. */
  27985. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27986. /**
  27987. * No-Imposter type
  27988. */
  27989. static NoImpostor: number;
  27990. /**
  27991. * Sphere-Imposter type
  27992. */
  27993. static SphereImpostor: number;
  27994. /**
  27995. * Box-Imposter type
  27996. */
  27997. static BoxImpostor: number;
  27998. /**
  27999. * Plane-Imposter type
  28000. */
  28001. static PlaneImpostor: number;
  28002. /**
  28003. * Mesh-imposter type
  28004. */
  28005. static MeshImpostor: number;
  28006. /**
  28007. * Capsule-Impostor type (Ammo.js plugin only)
  28008. */
  28009. static CapsuleImpostor: number;
  28010. /**
  28011. * Cylinder-Imposter type
  28012. */
  28013. static CylinderImpostor: number;
  28014. /**
  28015. * Particle-Imposter type
  28016. */
  28017. static ParticleImpostor: number;
  28018. /**
  28019. * Heightmap-Imposter type
  28020. */
  28021. static HeightmapImpostor: number;
  28022. /**
  28023. * ConvexHull-Impostor type (Ammo.js plugin only)
  28024. */
  28025. static ConvexHullImpostor: number;
  28026. /**
  28027. * Custom-Imposter type (Ammo.js plugin only)
  28028. */
  28029. static CustomImpostor: number;
  28030. /**
  28031. * Rope-Imposter type
  28032. */
  28033. static RopeImpostor: number;
  28034. /**
  28035. * Cloth-Imposter type
  28036. */
  28037. static ClothImpostor: number;
  28038. /**
  28039. * Softbody-Imposter type
  28040. */
  28041. static SoftbodyImpostor: number;
  28042. }
  28043. }
  28044. declare module "babylonjs/Meshes/mesh" {
  28045. import { Observable } from "babylonjs/Misc/observable";
  28046. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28047. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  28048. import { Camera } from "babylonjs/Cameras/camera";
  28049. import { Scene } from "babylonjs/scene";
  28050. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  28051. import { Color4 } from "babylonjs/Maths/math.color";
  28052. import { Engine } from "babylonjs/Engines/engine";
  28053. import { Node } from "babylonjs/node";
  28054. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28055. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28056. import { Buffer } from "babylonjs/Meshes/buffer";
  28057. import { Geometry } from "babylonjs/Meshes/geometry";
  28058. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28059. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28060. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  28061. import { Effect } from "babylonjs/Materials/effect";
  28062. import { Material } from "babylonjs/Materials/material";
  28063. import { Skeleton } from "babylonjs/Bones/skeleton";
  28064. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  28065. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  28066. import { Path3D } from "babylonjs/Maths/math.path";
  28067. import { Plane } from "babylonjs/Maths/math.plane";
  28068. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28069. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  28070. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  28071. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  28072. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28073. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  28074. /**
  28075. * @hidden
  28076. **/
  28077. export class _CreationDataStorage {
  28078. closePath?: boolean;
  28079. closeArray?: boolean;
  28080. idx: number[];
  28081. dashSize: number;
  28082. gapSize: number;
  28083. path3D: Path3D;
  28084. pathArray: Vector3[][];
  28085. arc: number;
  28086. radius: number;
  28087. cap: number;
  28088. tessellation: number;
  28089. }
  28090. /**
  28091. * @hidden
  28092. **/
  28093. class _InstanceDataStorage {
  28094. visibleInstances: any;
  28095. batchCache: _InstancesBatch;
  28096. instancesBufferSize: number;
  28097. instancesBuffer: Nullable<Buffer>;
  28098. instancesData: Float32Array;
  28099. overridenInstanceCount: number;
  28100. isFrozen: boolean;
  28101. previousBatch: Nullable<_InstancesBatch>;
  28102. hardwareInstancedRendering: boolean;
  28103. sideOrientation: number;
  28104. manualUpdate: boolean;
  28105. }
  28106. /**
  28107. * @hidden
  28108. **/
  28109. export class _InstancesBatch {
  28110. mustReturn: boolean;
  28111. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  28112. renderSelf: boolean[];
  28113. hardwareInstancedRendering: boolean[];
  28114. }
  28115. /**
  28116. * @hidden
  28117. **/
  28118. class _ThinInstanceDataStorage {
  28119. instancesCount: number;
  28120. matrixBuffer: Nullable<Buffer>;
  28121. matrixBufferSize: number;
  28122. matrixData: Nullable<Float32Array>;
  28123. boundingVectors: Array<Vector3>;
  28124. }
  28125. /**
  28126. * Class used to represent renderable models
  28127. */
  28128. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28129. /**
  28130. * Mesh side orientation : usually the external or front surface
  28131. */
  28132. static readonly FRONTSIDE: number;
  28133. /**
  28134. * Mesh side orientation : usually the internal or back surface
  28135. */
  28136. static readonly BACKSIDE: number;
  28137. /**
  28138. * Mesh side orientation : both internal and external or front and back surfaces
  28139. */
  28140. static readonly DOUBLESIDE: number;
  28141. /**
  28142. * Mesh side orientation : by default, `FRONTSIDE`
  28143. */
  28144. static readonly DEFAULTSIDE: number;
  28145. /**
  28146. * Mesh cap setting : no cap
  28147. */
  28148. static readonly NO_CAP: number;
  28149. /**
  28150. * Mesh cap setting : one cap at the beginning of the mesh
  28151. */
  28152. static readonly CAP_START: number;
  28153. /**
  28154. * Mesh cap setting : one cap at the end of the mesh
  28155. */
  28156. static readonly CAP_END: number;
  28157. /**
  28158. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28159. */
  28160. static readonly CAP_ALL: number;
  28161. /**
  28162. * Mesh pattern setting : no flip or rotate
  28163. */
  28164. static readonly NO_FLIP: number;
  28165. /**
  28166. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28167. */
  28168. static readonly FLIP_TILE: number;
  28169. /**
  28170. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28171. */
  28172. static readonly ROTATE_TILE: number;
  28173. /**
  28174. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28175. */
  28176. static readonly FLIP_ROW: number;
  28177. /**
  28178. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28179. */
  28180. static readonly ROTATE_ROW: number;
  28181. /**
  28182. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28183. */
  28184. static readonly FLIP_N_ROTATE_TILE: number;
  28185. /**
  28186. * Mesh pattern setting : rotate pattern and rotate
  28187. */
  28188. static readonly FLIP_N_ROTATE_ROW: number;
  28189. /**
  28190. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28191. */
  28192. static readonly CENTER: number;
  28193. /**
  28194. * Mesh tile positioning : part tiles on left
  28195. */
  28196. static readonly LEFT: number;
  28197. /**
  28198. * Mesh tile positioning : part tiles on right
  28199. */
  28200. static readonly RIGHT: number;
  28201. /**
  28202. * Mesh tile positioning : part tiles on top
  28203. */
  28204. static readonly TOP: number;
  28205. /**
  28206. * Mesh tile positioning : part tiles on bottom
  28207. */
  28208. static readonly BOTTOM: number;
  28209. /**
  28210. * Gets the default side orientation.
  28211. * @param orientation the orientation to value to attempt to get
  28212. * @returns the default orientation
  28213. * @hidden
  28214. */
  28215. static _GetDefaultSideOrientation(orientation?: number): number;
  28216. private _internalMeshDataInfo;
  28217. /**
  28218. * An event triggered before rendering the mesh
  28219. */
  28220. get onBeforeRenderObservable(): Observable<Mesh>;
  28221. /**
  28222. * An event triggered before binding the mesh
  28223. */
  28224. get onBeforeBindObservable(): Observable<Mesh>;
  28225. /**
  28226. * An event triggered after rendering the mesh
  28227. */
  28228. get onAfterRenderObservable(): Observable<Mesh>;
  28229. /**
  28230. * An event triggered before drawing the mesh
  28231. */
  28232. get onBeforeDrawObservable(): Observable<Mesh>;
  28233. private _onBeforeDrawObserver;
  28234. /**
  28235. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28236. */
  28237. set onBeforeDraw(callback: () => void);
  28238. get hasInstances(): boolean;
  28239. get hasThinInstances(): boolean;
  28240. /**
  28241. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28242. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28243. */
  28244. delayLoadState: number;
  28245. /**
  28246. * Gets the list of instances created from this mesh
  28247. * it is not supposed to be modified manually.
  28248. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28249. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28250. */
  28251. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  28252. /**
  28253. * Gets the file containing delay loading data for this mesh
  28254. */
  28255. delayLoadingFile: string;
  28256. /** @hidden */
  28257. _binaryInfo: any;
  28258. /**
  28259. * User defined function used to change how LOD level selection is done
  28260. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28261. */
  28262. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28263. /**
  28264. * Gets or sets the morph target manager
  28265. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28266. */
  28267. get morphTargetManager(): Nullable<MorphTargetManager>;
  28268. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28269. /** @hidden */
  28270. _creationDataStorage: Nullable<_CreationDataStorage>;
  28271. /** @hidden */
  28272. _geometry: Nullable<Geometry>;
  28273. /** @hidden */
  28274. _delayInfo: Array<string>;
  28275. /** @hidden */
  28276. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28277. /** @hidden */
  28278. _instanceDataStorage: _InstanceDataStorage;
  28279. /** @hidden */
  28280. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28281. private _effectiveMaterial;
  28282. /** @hidden */
  28283. _shouldGenerateFlatShading: boolean;
  28284. /** @hidden */
  28285. _originalBuilderSideOrientation: number;
  28286. /**
  28287. * Use this property to change the original side orientation defined at construction time
  28288. */
  28289. overrideMaterialSideOrientation: Nullable<number>;
  28290. /**
  28291. * Gets the source mesh (the one used to clone this one from)
  28292. */
  28293. get source(): Nullable<Mesh>;
  28294. /**
  28295. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28296. */
  28297. get isUnIndexed(): boolean;
  28298. set isUnIndexed(value: boolean);
  28299. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28300. get worldMatrixInstancedBuffer(): Float32Array;
  28301. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28302. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28303. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28304. /**
  28305. * @constructor
  28306. * @param name The value used by scene.getMeshByName() to do a lookup.
  28307. * @param scene The scene to add this mesh to.
  28308. * @param parent The parent of this mesh, if it has one
  28309. * @param source An optional Mesh from which geometry is shared, cloned.
  28310. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28311. * When false, achieved by calling a clone(), also passing False.
  28312. * This will make creation of children, recursive.
  28313. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28314. */
  28315. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28316. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28317. doNotInstantiate: boolean;
  28318. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28319. /**
  28320. * Gets the class name
  28321. * @returns the string "Mesh".
  28322. */
  28323. getClassName(): string;
  28324. /** @hidden */
  28325. get _isMesh(): boolean;
  28326. /**
  28327. * Returns a description of this mesh
  28328. * @param fullDetails define if full details about this mesh must be used
  28329. * @returns a descriptive string representing this mesh
  28330. */
  28331. toString(fullDetails?: boolean): string;
  28332. /** @hidden */
  28333. _unBindEffect(): void;
  28334. /**
  28335. * Gets a boolean indicating if this mesh has LOD
  28336. */
  28337. get hasLODLevels(): boolean;
  28338. /**
  28339. * Gets the list of MeshLODLevel associated with the current mesh
  28340. * @returns an array of MeshLODLevel
  28341. */
  28342. getLODLevels(): MeshLODLevel[];
  28343. private _sortLODLevels;
  28344. /**
  28345. * Add a mesh as LOD level triggered at the given distance.
  28346. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28347. * @param distance The distance from the center of the object to show this level
  28348. * @param mesh The mesh to be added as LOD level (can be null)
  28349. * @return This mesh (for chaining)
  28350. */
  28351. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28352. /**
  28353. * Returns the LOD level mesh at the passed distance or null if not found.
  28354. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28355. * @param distance The distance from the center of the object to show this level
  28356. * @returns a Mesh or `null`
  28357. */
  28358. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28359. /**
  28360. * Remove a mesh from the LOD array
  28361. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28362. * @param mesh defines the mesh to be removed
  28363. * @return This mesh (for chaining)
  28364. */
  28365. removeLODLevel(mesh: Mesh): Mesh;
  28366. /**
  28367. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28368. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28369. * @param camera defines the camera to use to compute distance
  28370. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28371. * @return This mesh (for chaining)
  28372. */
  28373. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28374. /**
  28375. * Gets the mesh internal Geometry object
  28376. */
  28377. get geometry(): Nullable<Geometry>;
  28378. /**
  28379. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28380. * @returns the total number of vertices
  28381. */
  28382. getTotalVertices(): number;
  28383. /**
  28384. * Returns the content of an associated vertex buffer
  28385. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28386. * - VertexBuffer.PositionKind
  28387. * - VertexBuffer.UVKind
  28388. * - VertexBuffer.UV2Kind
  28389. * - VertexBuffer.UV3Kind
  28390. * - VertexBuffer.UV4Kind
  28391. * - VertexBuffer.UV5Kind
  28392. * - VertexBuffer.UV6Kind
  28393. * - VertexBuffer.ColorKind
  28394. * - VertexBuffer.MatricesIndicesKind
  28395. * - VertexBuffer.MatricesIndicesExtraKind
  28396. * - VertexBuffer.MatricesWeightsKind
  28397. * - VertexBuffer.MatricesWeightsExtraKind
  28398. * @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
  28399. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28400. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28401. */
  28402. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28403. /**
  28404. * Returns the mesh VertexBuffer object from the requested `kind`
  28405. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28406. * - VertexBuffer.PositionKind
  28407. * - VertexBuffer.NormalKind
  28408. * - VertexBuffer.UVKind
  28409. * - VertexBuffer.UV2Kind
  28410. * - VertexBuffer.UV3Kind
  28411. * - VertexBuffer.UV4Kind
  28412. * - VertexBuffer.UV5Kind
  28413. * - VertexBuffer.UV6Kind
  28414. * - VertexBuffer.ColorKind
  28415. * - VertexBuffer.MatricesIndicesKind
  28416. * - VertexBuffer.MatricesIndicesExtraKind
  28417. * - VertexBuffer.MatricesWeightsKind
  28418. * - VertexBuffer.MatricesWeightsExtraKind
  28419. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28420. */
  28421. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28422. /**
  28423. * Tests if a specific vertex buffer is associated with this mesh
  28424. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28425. * - VertexBuffer.PositionKind
  28426. * - VertexBuffer.NormalKind
  28427. * - VertexBuffer.UVKind
  28428. * - VertexBuffer.UV2Kind
  28429. * - VertexBuffer.UV3Kind
  28430. * - VertexBuffer.UV4Kind
  28431. * - VertexBuffer.UV5Kind
  28432. * - VertexBuffer.UV6Kind
  28433. * - VertexBuffer.ColorKind
  28434. * - VertexBuffer.MatricesIndicesKind
  28435. * - VertexBuffer.MatricesIndicesExtraKind
  28436. * - VertexBuffer.MatricesWeightsKind
  28437. * - VertexBuffer.MatricesWeightsExtraKind
  28438. * @returns a boolean
  28439. */
  28440. isVerticesDataPresent(kind: string): boolean;
  28441. /**
  28442. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28443. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28444. * - VertexBuffer.PositionKind
  28445. * - VertexBuffer.UVKind
  28446. * - VertexBuffer.UV2Kind
  28447. * - VertexBuffer.UV3Kind
  28448. * - VertexBuffer.UV4Kind
  28449. * - VertexBuffer.UV5Kind
  28450. * - VertexBuffer.UV6Kind
  28451. * - VertexBuffer.ColorKind
  28452. * - VertexBuffer.MatricesIndicesKind
  28453. * - VertexBuffer.MatricesIndicesExtraKind
  28454. * - VertexBuffer.MatricesWeightsKind
  28455. * - VertexBuffer.MatricesWeightsExtraKind
  28456. * @returns a boolean
  28457. */
  28458. isVertexBufferUpdatable(kind: string): boolean;
  28459. /**
  28460. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28461. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28462. * - VertexBuffer.PositionKind
  28463. * - VertexBuffer.NormalKind
  28464. * - VertexBuffer.UVKind
  28465. * - VertexBuffer.UV2Kind
  28466. * - VertexBuffer.UV3Kind
  28467. * - VertexBuffer.UV4Kind
  28468. * - VertexBuffer.UV5Kind
  28469. * - VertexBuffer.UV6Kind
  28470. * - VertexBuffer.ColorKind
  28471. * - VertexBuffer.MatricesIndicesKind
  28472. * - VertexBuffer.MatricesIndicesExtraKind
  28473. * - VertexBuffer.MatricesWeightsKind
  28474. * - VertexBuffer.MatricesWeightsExtraKind
  28475. * @returns an array of strings
  28476. */
  28477. getVerticesDataKinds(): string[];
  28478. /**
  28479. * Returns a positive integer : the total number of indices in this mesh geometry.
  28480. * @returns the numner of indices or zero if the mesh has no geometry.
  28481. */
  28482. getTotalIndices(): number;
  28483. /**
  28484. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28485. * @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.
  28486. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28487. * @returns the indices array or an empty array if the mesh has no geometry
  28488. */
  28489. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28490. get isBlocked(): boolean;
  28491. /**
  28492. * Determine if the current mesh is ready to be rendered
  28493. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28494. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28495. * @returns true if all associated assets are ready (material, textures, shaders)
  28496. */
  28497. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28498. /**
  28499. * 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.
  28500. */
  28501. get areNormalsFrozen(): boolean;
  28502. /**
  28503. * 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.
  28504. * @returns the current mesh
  28505. */
  28506. freezeNormals(): Mesh;
  28507. /**
  28508. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  28509. * @returns the current mesh
  28510. */
  28511. unfreezeNormals(): Mesh;
  28512. /**
  28513. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28514. */
  28515. set overridenInstanceCount(count: number);
  28516. /** @hidden */
  28517. _preActivate(): Mesh;
  28518. /** @hidden */
  28519. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28520. /** @hidden */
  28521. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28522. protected _afterComputeWorldMatrix(): void;
  28523. /** @hidden */
  28524. _postActivate(): void;
  28525. /**
  28526. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28527. * This means the mesh underlying bounding box and sphere are recomputed.
  28528. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28529. * @returns the current mesh
  28530. */
  28531. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28532. /** @hidden */
  28533. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28534. /**
  28535. * This function will subdivide the mesh into multiple submeshes
  28536. * @param count defines the expected number of submeshes
  28537. */
  28538. subdivide(count: number): void;
  28539. /**
  28540. * Copy a FloatArray into a specific associated vertex buffer
  28541. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28542. * - VertexBuffer.PositionKind
  28543. * - VertexBuffer.UVKind
  28544. * - VertexBuffer.UV2Kind
  28545. * - VertexBuffer.UV3Kind
  28546. * - VertexBuffer.UV4Kind
  28547. * - VertexBuffer.UV5Kind
  28548. * - VertexBuffer.UV6Kind
  28549. * - VertexBuffer.ColorKind
  28550. * - VertexBuffer.MatricesIndicesKind
  28551. * - VertexBuffer.MatricesIndicesExtraKind
  28552. * - VertexBuffer.MatricesWeightsKind
  28553. * - VertexBuffer.MatricesWeightsExtraKind
  28554. * @param data defines the data source
  28555. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28556. * @param stride defines the data stride size (can be null)
  28557. * @returns the current mesh
  28558. */
  28559. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28560. /**
  28561. * Delete a vertex buffer associated with this mesh
  28562. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28563. * - VertexBuffer.PositionKind
  28564. * - VertexBuffer.UVKind
  28565. * - VertexBuffer.UV2Kind
  28566. * - VertexBuffer.UV3Kind
  28567. * - VertexBuffer.UV4Kind
  28568. * - VertexBuffer.UV5Kind
  28569. * - VertexBuffer.UV6Kind
  28570. * - VertexBuffer.ColorKind
  28571. * - VertexBuffer.MatricesIndicesKind
  28572. * - VertexBuffer.MatricesIndicesExtraKind
  28573. * - VertexBuffer.MatricesWeightsKind
  28574. * - VertexBuffer.MatricesWeightsExtraKind
  28575. */
  28576. removeVerticesData(kind: string): void;
  28577. /**
  28578. * Flags an associated vertex buffer as updatable
  28579. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28580. * - VertexBuffer.PositionKind
  28581. * - VertexBuffer.UVKind
  28582. * - VertexBuffer.UV2Kind
  28583. * - VertexBuffer.UV3Kind
  28584. * - VertexBuffer.UV4Kind
  28585. * - VertexBuffer.UV5Kind
  28586. * - VertexBuffer.UV6Kind
  28587. * - VertexBuffer.ColorKind
  28588. * - VertexBuffer.MatricesIndicesKind
  28589. * - VertexBuffer.MatricesIndicesExtraKind
  28590. * - VertexBuffer.MatricesWeightsKind
  28591. * - VertexBuffer.MatricesWeightsExtraKind
  28592. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28593. */
  28594. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28595. /**
  28596. * Sets the mesh global Vertex Buffer
  28597. * @param buffer defines the buffer to use
  28598. * @returns the current mesh
  28599. */
  28600. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28601. /**
  28602. * Update a specific associated vertex buffer
  28603. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28604. * - VertexBuffer.PositionKind
  28605. * - VertexBuffer.UVKind
  28606. * - VertexBuffer.UV2Kind
  28607. * - VertexBuffer.UV3Kind
  28608. * - VertexBuffer.UV4Kind
  28609. * - VertexBuffer.UV5Kind
  28610. * - VertexBuffer.UV6Kind
  28611. * - VertexBuffer.ColorKind
  28612. * - VertexBuffer.MatricesIndicesKind
  28613. * - VertexBuffer.MatricesIndicesExtraKind
  28614. * - VertexBuffer.MatricesWeightsKind
  28615. * - VertexBuffer.MatricesWeightsExtraKind
  28616. * @param data defines the data source
  28617. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28618. * @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)
  28619. * @returns the current mesh
  28620. */
  28621. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28622. /**
  28623. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28624. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28625. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28626. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28627. * @returns the current mesh
  28628. */
  28629. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28630. /**
  28631. * Creates a un-shared specific occurence of the geometry for the mesh.
  28632. * @returns the current mesh
  28633. */
  28634. makeGeometryUnique(): Mesh;
  28635. /**
  28636. * Set the index buffer of this mesh
  28637. * @param indices defines the source data
  28638. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28639. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28640. * @returns the current mesh
  28641. */
  28642. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28643. /**
  28644. * Update the current index buffer
  28645. * @param indices defines the source data
  28646. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28647. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  28648. * @returns the current mesh
  28649. */
  28650. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28651. /**
  28652. * Invert the geometry to move from a right handed system to a left handed one.
  28653. * @returns the current mesh
  28654. */
  28655. toLeftHanded(): Mesh;
  28656. /** @hidden */
  28657. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28658. /** @hidden */
  28659. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28660. /**
  28661. * Registers for this mesh a javascript function called just before the rendering process
  28662. * @param func defines the function to call before rendering this mesh
  28663. * @returns the current mesh
  28664. */
  28665. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28666. /**
  28667. * Disposes a previously registered javascript function called before the rendering
  28668. * @param func defines the function to remove
  28669. * @returns the current mesh
  28670. */
  28671. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28672. /**
  28673. * Registers for this mesh a javascript function called just after the rendering is complete
  28674. * @param func defines the function to call after rendering this mesh
  28675. * @returns the current mesh
  28676. */
  28677. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28678. /**
  28679. * Disposes a previously registered javascript function called after the rendering.
  28680. * @param func defines the function to remove
  28681. * @returns the current mesh
  28682. */
  28683. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28684. /** @hidden */
  28685. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28686. /** @hidden */
  28687. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28688. /** @hidden */
  28689. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28690. /** @hidden */
  28691. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28692. /** @hidden */
  28693. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28694. /** @hidden */
  28695. _rebuild(): void;
  28696. /** @hidden */
  28697. _freeze(): void;
  28698. /** @hidden */
  28699. _unFreeze(): void;
  28700. /**
  28701. * 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
  28702. * @param subMesh defines the subMesh to render
  28703. * @param enableAlphaMode defines if alpha mode can be changed
  28704. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28705. * @returns the current mesh
  28706. */
  28707. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28708. private _onBeforeDraw;
  28709. /**
  28710. * Renormalize the mesh and patch it up if there are no weights
  28711. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28712. * However in the case of zero weights then we set just a single influence to 1.
  28713. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28714. */
  28715. cleanMatrixWeights(): void;
  28716. private normalizeSkinFourWeights;
  28717. private normalizeSkinWeightsAndExtra;
  28718. /**
  28719. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28720. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28721. * the user know there was an issue with importing the mesh
  28722. * @returns a validation object with skinned, valid and report string
  28723. */
  28724. validateSkinning(): {
  28725. skinned: boolean;
  28726. valid: boolean;
  28727. report: string;
  28728. };
  28729. /** @hidden */
  28730. _checkDelayState(): Mesh;
  28731. private _queueLoad;
  28732. /**
  28733. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28734. * A mesh is in the frustum if its bounding box intersects the frustum
  28735. * @param frustumPlanes defines the frustum to test
  28736. * @returns true if the mesh is in the frustum planes
  28737. */
  28738. isInFrustum(frustumPlanes: Plane[]): boolean;
  28739. /**
  28740. * Sets the mesh material by the material or multiMaterial `id` property
  28741. * @param id is a string identifying the material or the multiMaterial
  28742. * @returns the current mesh
  28743. */
  28744. setMaterialByID(id: string): Mesh;
  28745. /**
  28746. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28747. * @returns an array of IAnimatable
  28748. */
  28749. getAnimatables(): IAnimatable[];
  28750. /**
  28751. * Modifies the mesh geometry according to the passed transformation matrix.
  28752. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28753. * The mesh normals are modified using the same transformation.
  28754. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28755. * @param transform defines the transform matrix to use
  28756. * @see https://doc.babylonjs.com/resources/baking_transformations
  28757. * @returns the current mesh
  28758. */
  28759. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28760. /**
  28761. * Modifies the mesh geometry according to its own current World Matrix.
  28762. * The mesh World Matrix is then reset.
  28763. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28764. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28765. * @see https://doc.babylonjs.com/resources/baking_transformations
  28766. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28767. * @returns the current mesh
  28768. */
  28769. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28770. /** @hidden */
  28771. get _positions(): Nullable<Vector3[]>;
  28772. /** @hidden */
  28773. _resetPointsArrayCache(): Mesh;
  28774. /** @hidden */
  28775. _generatePointsArray(): boolean;
  28776. /**
  28777. * Returns a new Mesh object generated from the current mesh properties.
  28778. * This method must not get confused with createInstance()
  28779. * @param name is a string, the name given to the new mesh
  28780. * @param newParent can be any Node object (default `null`)
  28781. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28782. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28783. * @returns a new mesh
  28784. */
  28785. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28786. /**
  28787. * Releases resources associated with this mesh.
  28788. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28789. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28790. */
  28791. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28792. /** @hidden */
  28793. _disposeInstanceSpecificData(): void;
  28794. /** @hidden */
  28795. _disposeThinInstanceSpecificData(): void;
  28796. /**
  28797. * Modifies the mesh geometry according to a displacement map.
  28798. * 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.
  28799. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28800. * @param url is a string, the URL from the image file is to be downloaded.
  28801. * @param minHeight is the lower limit of the displacement.
  28802. * @param maxHeight is the upper limit of the displacement.
  28803. * @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.
  28804. * @param uvOffset is an optional vector2 used to offset UV.
  28805. * @param uvScale is an optional vector2 used to scale UV.
  28806. * @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.
  28807. * @returns the Mesh.
  28808. */
  28809. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28810. /**
  28811. * Modifies the mesh geometry according to a displacementMap buffer.
  28812. * 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.
  28813. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28814. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28815. * @param heightMapWidth is the width of the buffer image.
  28816. * @param heightMapHeight is the height of the buffer image.
  28817. * @param minHeight is the lower limit of the displacement.
  28818. * @param maxHeight is the upper limit of the displacement.
  28819. * @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.
  28820. * @param uvOffset is an optional vector2 used to offset UV.
  28821. * @param uvScale is an optional vector2 used to scale UV.
  28822. * @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.
  28823. * @returns the Mesh.
  28824. */
  28825. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28826. /**
  28827. * Modify the mesh to get a flat shading rendering.
  28828. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28829. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28830. * @returns current mesh
  28831. */
  28832. convertToFlatShadedMesh(): Mesh;
  28833. /**
  28834. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28835. * In other words, more vertices, no more indices and a single bigger VBO.
  28836. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28837. * @returns current mesh
  28838. */
  28839. convertToUnIndexedMesh(): Mesh;
  28840. /**
  28841. * Inverses facet orientations.
  28842. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28843. * @param flipNormals will also inverts the normals
  28844. * @returns current mesh
  28845. */
  28846. flipFaces(flipNormals?: boolean): Mesh;
  28847. /**
  28848. * Increase the number of facets and hence vertices in a mesh
  28849. * Vertex normals are interpolated from existing vertex normals
  28850. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28851. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28852. */
  28853. increaseVertices(numberPerEdge: number): void;
  28854. /**
  28855. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28856. * This will undo any application of covertToFlatShadedMesh
  28857. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28858. */
  28859. forceSharedVertices(): void;
  28860. /** @hidden */
  28861. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28862. /** @hidden */
  28863. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28864. /**
  28865. * Creates a new InstancedMesh object from the mesh model.
  28866. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28867. * @param name defines the name of the new instance
  28868. * @returns a new InstancedMesh
  28869. */
  28870. createInstance(name: string): InstancedMesh;
  28871. /**
  28872. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28873. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28874. * @returns the current mesh
  28875. */
  28876. synchronizeInstances(): Mesh;
  28877. /**
  28878. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28879. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28880. * This should be used together with the simplification to avoid disappearing triangles.
  28881. * @param successCallback an optional success callback to be called after the optimization finished.
  28882. * @returns the current mesh
  28883. */
  28884. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28885. /**
  28886. * Serialize current mesh
  28887. * @param serializationObject defines the object which will receive the serialization data
  28888. */
  28889. serialize(serializationObject: any): void;
  28890. /** @hidden */
  28891. _syncGeometryWithMorphTargetManager(): void;
  28892. /** @hidden */
  28893. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28894. /**
  28895. * Returns a new Mesh object parsed from the source provided.
  28896. * @param parsedMesh is the source
  28897. * @param scene defines the hosting scene
  28898. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28899. * @returns a new Mesh
  28900. */
  28901. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28902. /**
  28903. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28904. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28905. * @param name defines the name of the mesh to create
  28906. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28907. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28908. * @param closePath creates a seam between the first and the last points of each path of the path array
  28909. * @param offset is taken in account only if the `pathArray` is containing a single path
  28910. * @param scene defines the hosting scene
  28911. * @param updatable defines if the mesh must be flagged as updatable
  28912. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28913. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  28914. * @returns a new Mesh
  28915. */
  28916. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28917. /**
  28918. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28919. * @param name defines the name of the mesh to create
  28920. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28921. * @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
  28922. * @param scene defines the hosting scene
  28923. * @param updatable defines if the mesh must be flagged as updatable
  28924. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28925. * @returns a new Mesh
  28926. */
  28927. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28928. /**
  28929. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28930. * @param name defines the name of the mesh to create
  28931. * @param size sets the size (float) of each box side (default 1)
  28932. * @param scene defines the hosting scene
  28933. * @param updatable defines if the mesh must be flagged as updatable
  28934. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28935. * @returns a new Mesh
  28936. */
  28937. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28938. /**
  28939. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28940. * @param name defines the name of the mesh to create
  28941. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28942. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28943. * @param scene defines the hosting scene
  28944. * @param updatable defines if the mesh must be flagged as updatable
  28945. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28946. * @returns a new Mesh
  28947. */
  28948. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28949. /**
  28950. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28951. * @param name defines the name of the mesh to create
  28952. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28953. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28954. * @param scene defines the hosting scene
  28955. * @returns a new Mesh
  28956. */
  28957. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28958. /**
  28959. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28960. * @param name defines the name of the mesh to create
  28961. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28962. * @param diameterTop set the top cap diameter (floats, default 1)
  28963. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28964. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28965. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28966. * @param scene defines the hosting scene
  28967. * @param updatable defines if the mesh must be flagged as updatable
  28968. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28969. * @returns a new Mesh
  28970. */
  28971. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28972. /**
  28973. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28974. * @param name defines the name of the mesh to create
  28975. * @param diameter sets the diameter size (float) of the torus (default 1)
  28976. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28977. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28978. * @param scene defines the hosting scene
  28979. * @param updatable defines if the mesh must be flagged as updatable
  28980. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28981. * @returns a new Mesh
  28982. */
  28983. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28984. /**
  28985. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28986. * @param name defines the name of the mesh to create
  28987. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28988. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28989. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28990. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28991. * @param p the number of windings on X axis (positive integers, default 2)
  28992. * @param q the number of windings on Y axis (positive integers, default 3)
  28993. * @param scene defines the hosting scene
  28994. * @param updatable defines if the mesh must be flagged as updatable
  28995. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28996. * @returns a new Mesh
  28997. */
  28998. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28999. /**
  29000. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  29001. * @param name defines the name of the mesh to create
  29002. * @param points is an array successive Vector3
  29003. * @param scene defines the hosting scene
  29004. * @param updatable defines if the mesh must be flagged as updatable
  29005. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  29006. * @returns a new Mesh
  29007. */
  29008. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29009. /**
  29010. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29011. * @param name defines the name of the mesh to create
  29012. * @param points is an array successive Vector3
  29013. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29014. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29015. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29016. * @param scene defines the hosting scene
  29017. * @param updatable defines if the mesh must be flagged as updatable
  29018. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  29019. * @returns a new Mesh
  29020. */
  29021. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29022. /**
  29023. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29024. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29025. * 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.
  29026. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29027. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29028. * Remember you can only change the shape positions, not their number when updating a polygon.
  29029. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29030. * @param name defines the name of the mesh to create
  29031. * @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
  29032. * @param scene defines the hosting scene
  29033. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29034. * @param updatable defines if the mesh must be flagged as updatable
  29035. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29036. * @param earcutInjection can be used to inject your own earcut reference
  29037. * @returns a new Mesh
  29038. */
  29039. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29040. /**
  29041. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29042. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29043. * @param name defines the name of the mesh to create
  29044. * @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
  29045. * @param depth defines the height of extrusion
  29046. * @param scene defines the hosting scene
  29047. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29048. * @param updatable defines if the mesh must be flagged as updatable
  29049. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29050. * @param earcutInjection can be used to inject your own earcut reference
  29051. * @returns a new Mesh
  29052. */
  29053. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29054. /**
  29055. * Creates an extruded shape mesh.
  29056. * 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
  29057. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29058. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29059. * @param name defines the name of the mesh to create
  29060. * @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
  29061. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29062. * @param scale is the value to scale the shape
  29063. * @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
  29064. * @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
  29065. * @param scene defines the hosting scene
  29066. * @param updatable defines if the mesh must be flagged as updatable
  29067. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29068. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  29069. * @returns a new Mesh
  29070. */
  29071. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29072. /**
  29073. * Creates an custom extruded shape mesh.
  29074. * The custom extrusion is a parametric shape.
  29075. * It has no predefined shape. Its final shape will depend on the input parameters.
  29076. * Please consider using the same method from the MeshBuilder class instead
  29077. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29078. * @param name defines the name of the mesh to create
  29079. * @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
  29080. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29081. * @param scaleFunction is a custom Javascript function called on each path point
  29082. * @param rotationFunction is a custom Javascript function called on each path point
  29083. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29084. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29085. * @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
  29086. * @param scene defines the hosting scene
  29087. * @param updatable defines if the mesh must be flagged as updatable
  29088. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29089. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  29090. * @returns a new Mesh
  29091. */
  29092. 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;
  29093. /**
  29094. * Creates lathe mesh.
  29095. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29096. * Please consider using the same method from the MeshBuilder class instead
  29097. * @param name defines the name of the mesh to create
  29098. * @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
  29099. * @param radius is the radius value of the lathe
  29100. * @param tessellation is the side number of the lathe.
  29101. * @param scene defines the hosting scene
  29102. * @param updatable defines if the mesh must be flagged as updatable
  29103. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29104. * @returns a new Mesh
  29105. */
  29106. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29107. /**
  29108. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29109. * @param name defines the name of the mesh to create
  29110. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29111. * @param scene defines the hosting scene
  29112. * @param updatable defines if the mesh must be flagged as updatable
  29113. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29114. * @returns a new Mesh
  29115. */
  29116. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29117. /**
  29118. * Creates a ground mesh.
  29119. * Please consider using the same method from the MeshBuilder class instead
  29120. * @param name defines the name of the mesh to create
  29121. * @param width set the width of the ground
  29122. * @param height set the height of the ground
  29123. * @param subdivisions sets the number of subdivisions per side
  29124. * @param scene defines the hosting scene
  29125. * @param updatable defines if the mesh must be flagged as updatable
  29126. * @returns a new Mesh
  29127. */
  29128. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29129. /**
  29130. * Creates a tiled ground mesh.
  29131. * Please consider using the same method from the MeshBuilder class instead
  29132. * @param name defines the name of the mesh to create
  29133. * @param xmin set the ground minimum X coordinate
  29134. * @param zmin set the ground minimum Y coordinate
  29135. * @param xmax set the ground maximum X coordinate
  29136. * @param zmax set the ground maximum Z coordinate
  29137. * @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
  29138. * @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
  29139. * @param scene defines the hosting scene
  29140. * @param updatable defines if the mesh must be flagged as updatable
  29141. * @returns a new Mesh
  29142. */
  29143. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29144. w: number;
  29145. h: number;
  29146. }, precision: {
  29147. w: number;
  29148. h: number;
  29149. }, scene: Scene, updatable?: boolean): Mesh;
  29150. /**
  29151. * Creates a ground mesh from a height map.
  29152. * Please consider using the same method from the MeshBuilder class instead
  29153. * @see https://doc.babylonjs.com/babylon101/height_map
  29154. * @param name defines the name of the mesh to create
  29155. * @param url sets the URL of the height map image resource
  29156. * @param width set the ground width size
  29157. * @param height set the ground height size
  29158. * @param subdivisions sets the number of subdivision per side
  29159. * @param minHeight is the minimum altitude on the ground
  29160. * @param maxHeight is the maximum altitude on the ground
  29161. * @param scene defines the hosting scene
  29162. * @param updatable defines if the mesh must be flagged as updatable
  29163. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29164. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29165. * @returns a new Mesh
  29166. */
  29167. 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;
  29168. /**
  29169. * Creates a tube mesh.
  29170. * The tube is a parametric shape.
  29171. * It has no predefined shape. Its final shape will depend on the input parameters.
  29172. * Please consider using the same method from the MeshBuilder class instead
  29173. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29174. * @param name defines the name of the mesh to create
  29175. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29176. * @param radius sets the tube radius size
  29177. * @param tessellation is the number of sides on the tubular surface
  29178. * @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
  29179. * @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
  29180. * @param scene defines the hosting scene
  29181. * @param updatable defines if the mesh must be flagged as updatable
  29182. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29183. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  29184. * @returns a new Mesh
  29185. */
  29186. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29187. (i: number, distance: number): number;
  29188. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29189. /**
  29190. * Creates a polyhedron mesh.
  29191. * Please consider using the same method from the MeshBuilder class instead.
  29192. * * 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
  29193. * * The parameter `size` (positive float, default 1) sets the polygon size
  29194. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29195. * * 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`
  29196. * * 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
  29197. * * 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)`)
  29198. * * 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
  29199. * * 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
  29200. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29201. * * 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
  29202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29203. * @param name defines the name of the mesh to create
  29204. * @param options defines the options used to create the mesh
  29205. * @param scene defines the hosting scene
  29206. * @returns a new Mesh
  29207. */
  29208. static CreatePolyhedron(name: string, options: {
  29209. type?: number;
  29210. size?: number;
  29211. sizeX?: number;
  29212. sizeY?: number;
  29213. sizeZ?: number;
  29214. custom?: any;
  29215. faceUV?: Vector4[];
  29216. faceColors?: Color4[];
  29217. updatable?: boolean;
  29218. sideOrientation?: number;
  29219. }, scene: Scene): Mesh;
  29220. /**
  29221. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29222. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29223. * * 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`)
  29224. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29225. * * 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
  29226. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29227. * * 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
  29228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29229. * @param name defines the name of the mesh
  29230. * @param options defines the options used to create the mesh
  29231. * @param scene defines the hosting scene
  29232. * @returns a new Mesh
  29233. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29234. */
  29235. static CreateIcoSphere(name: string, options: {
  29236. radius?: number;
  29237. flat?: boolean;
  29238. subdivisions?: number;
  29239. sideOrientation?: number;
  29240. updatable?: boolean;
  29241. }, scene: Scene): Mesh;
  29242. /**
  29243. * Creates a decal mesh.
  29244. * Please consider using the same method from the MeshBuilder class instead.
  29245. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29246. * @param name defines the name of the mesh
  29247. * @param sourceMesh defines the mesh receiving the decal
  29248. * @param position sets the position of the decal in world coordinates
  29249. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29250. * @param size sets the decal scaling
  29251. * @param angle sets the angle to rotate the decal
  29252. * @returns a new Mesh
  29253. */
  29254. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29255. /**
  29256. * Prepare internal position array for software CPU skinning
  29257. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29258. */
  29259. setPositionsForCPUSkinning(): Float32Array;
  29260. /**
  29261. * Prepare internal normal array for software CPU skinning
  29262. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29263. */
  29264. setNormalsForCPUSkinning(): Float32Array;
  29265. /**
  29266. * Updates the vertex buffer by applying transformation from the bones
  29267. * @param skeleton defines the skeleton to apply to current mesh
  29268. * @returns the current mesh
  29269. */
  29270. applySkeleton(skeleton: Skeleton): Mesh;
  29271. /**
  29272. * 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
  29273. * @param meshes defines the list of meshes to scan
  29274. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29275. */
  29276. static MinMax(meshes: AbstractMesh[]): {
  29277. min: Vector3;
  29278. max: Vector3;
  29279. };
  29280. /**
  29281. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29282. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29283. * @returns a vector3
  29284. */
  29285. static Center(meshesOrMinMaxVector: {
  29286. min: Vector3;
  29287. max: Vector3;
  29288. } | AbstractMesh[]): Vector3;
  29289. /**
  29290. * Merge the array of meshes into a single mesh for performance reasons.
  29291. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29292. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29293. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29294. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29295. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29296. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29297. * @returns a new mesh
  29298. */
  29299. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29300. /** @hidden */
  29301. addInstance(instance: InstancedMesh): void;
  29302. /** @hidden */
  29303. removeInstance(instance: InstancedMesh): void;
  29304. }
  29305. }
  29306. declare module "babylonjs/Cameras/camera" {
  29307. import { SmartArray } from "babylonjs/Misc/smartArray";
  29308. import { Observable } from "babylonjs/Misc/observable";
  29309. import { Nullable } from "babylonjs/types";
  29310. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  29311. import { Scene } from "babylonjs/scene";
  29312. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  29313. import { Node } from "babylonjs/node";
  29314. import { Mesh } from "babylonjs/Meshes/mesh";
  29315. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29316. import { ICullable } from "babylonjs/Culling/boundingInfo";
  29317. import { Viewport } from "babylonjs/Maths/math.viewport";
  29318. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29319. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29320. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  29321. import { Ray } from "babylonjs/Culling/ray";
  29322. /**
  29323. * This is the base class of all the camera used in the application.
  29324. * @see https://doc.babylonjs.com/features/cameras
  29325. */
  29326. export class Camera extends Node {
  29327. /** @hidden */
  29328. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29329. /**
  29330. * This is the default projection mode used by the cameras.
  29331. * It helps recreating a feeling of perspective and better appreciate depth.
  29332. * This is the best way to simulate real life cameras.
  29333. */
  29334. static readonly PERSPECTIVE_CAMERA: number;
  29335. /**
  29336. * This helps creating camera with an orthographic mode.
  29337. * 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.
  29338. */
  29339. static readonly ORTHOGRAPHIC_CAMERA: number;
  29340. /**
  29341. * This is the default FOV mode for perspective cameras.
  29342. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29343. */
  29344. static readonly FOVMODE_VERTICAL_FIXED: number;
  29345. /**
  29346. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29347. */
  29348. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29349. /**
  29350. * This specifies ther is no need for a camera rig.
  29351. * Basically only one eye is rendered corresponding to the camera.
  29352. */
  29353. static readonly RIG_MODE_NONE: number;
  29354. /**
  29355. * Simulates a camera Rig with one blue eye and one red eye.
  29356. * This can be use with 3d blue and red glasses.
  29357. */
  29358. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29359. /**
  29360. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29361. */
  29362. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29363. /**
  29364. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29365. */
  29366. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29367. /**
  29368. * Defines that both eyes of the camera will be rendered over under each other.
  29369. */
  29370. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29371. /**
  29372. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29373. */
  29374. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29375. /**
  29376. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29377. */
  29378. static readonly RIG_MODE_VR: number;
  29379. /**
  29380. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29381. */
  29382. static readonly RIG_MODE_WEBVR: number;
  29383. /**
  29384. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29385. */
  29386. static readonly RIG_MODE_CUSTOM: number;
  29387. /**
  29388. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29389. */
  29390. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29391. /**
  29392. * Define the input manager associated with the camera.
  29393. */
  29394. inputs: CameraInputsManager<Camera>;
  29395. /** @hidden */
  29396. _position: Vector3;
  29397. /**
  29398. * Define the current local position of the camera in the scene
  29399. */
  29400. get position(): Vector3;
  29401. set position(newPosition: Vector3);
  29402. /**
  29403. * The vector the camera should consider as up.
  29404. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29405. */
  29406. upVector: Vector3;
  29407. /**
  29408. * Define the current limit on the left side for an orthographic camera
  29409. * In scene unit
  29410. */
  29411. orthoLeft: Nullable<number>;
  29412. /**
  29413. * Define the current limit on the right side for an orthographic camera
  29414. * In scene unit
  29415. */
  29416. orthoRight: Nullable<number>;
  29417. /**
  29418. * Define the current limit on the bottom side for an orthographic camera
  29419. * In scene unit
  29420. */
  29421. orthoBottom: Nullable<number>;
  29422. /**
  29423. * Define the current limit on the top side for an orthographic camera
  29424. * In scene unit
  29425. */
  29426. orthoTop: Nullable<number>;
  29427. /**
  29428. * Field Of View is set in Radians. (default is 0.8)
  29429. */
  29430. fov: number;
  29431. /**
  29432. * Define the minimum distance the camera can see from.
  29433. * This is important to note that the depth buffer are not infinite and the closer it starts
  29434. * the more your scene might encounter depth fighting issue.
  29435. */
  29436. minZ: number;
  29437. /**
  29438. * Define the maximum distance the camera can see to.
  29439. * This is important to note that the depth buffer are not infinite and the further it end
  29440. * the more your scene might encounter depth fighting issue.
  29441. */
  29442. maxZ: number;
  29443. /**
  29444. * Define the default inertia of the camera.
  29445. * This helps giving a smooth feeling to the camera movement.
  29446. */
  29447. inertia: number;
  29448. /**
  29449. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29450. */
  29451. mode: number;
  29452. /**
  29453. * Define whether the camera is intermediate.
  29454. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29455. */
  29456. isIntermediate: boolean;
  29457. /**
  29458. * Define the viewport of the camera.
  29459. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29460. */
  29461. viewport: Viewport;
  29462. /**
  29463. * Restricts the camera to viewing objects with the same layerMask.
  29464. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29465. */
  29466. layerMask: number;
  29467. /**
  29468. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29469. */
  29470. fovMode: number;
  29471. /**
  29472. * Rig mode of the camera.
  29473. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29474. * This is normally controlled byt the camera themselves as internal use.
  29475. */
  29476. cameraRigMode: number;
  29477. /**
  29478. * Defines the distance between both "eyes" in case of a RIG
  29479. */
  29480. interaxialDistance: number;
  29481. /**
  29482. * Defines if stereoscopic rendering is done side by side or over under.
  29483. */
  29484. isStereoscopicSideBySide: boolean;
  29485. /**
  29486. * 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
  29487. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29488. * else in the scene. (Eg. security camera)
  29489. *
  29490. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  29491. */
  29492. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  29493. /**
  29494. * When set, the camera will render to this render target instead of the default canvas
  29495. *
  29496. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29497. */
  29498. outputRenderTarget: Nullable<RenderTargetTexture>;
  29499. /**
  29500. * Observable triggered when the camera view matrix has changed.
  29501. */
  29502. onViewMatrixChangedObservable: Observable<Camera>;
  29503. /**
  29504. * Observable triggered when the camera Projection matrix has changed.
  29505. */
  29506. onProjectionMatrixChangedObservable: Observable<Camera>;
  29507. /**
  29508. * Observable triggered when the inputs have been processed.
  29509. */
  29510. onAfterCheckInputsObservable: Observable<Camera>;
  29511. /**
  29512. * Observable triggered when reset has been called and applied to the camera.
  29513. */
  29514. onRestoreStateObservable: Observable<Camera>;
  29515. /**
  29516. * Is this camera a part of a rig system?
  29517. */
  29518. isRigCamera: boolean;
  29519. /**
  29520. * If isRigCamera set to true this will be set with the parent camera.
  29521. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29522. */
  29523. rigParent?: Camera;
  29524. /** @hidden */
  29525. _cameraRigParams: any;
  29526. /** @hidden */
  29527. _rigCameras: Camera[];
  29528. /** @hidden */
  29529. _rigPostProcess: Nullable<PostProcess>;
  29530. protected _webvrViewMatrix: Matrix;
  29531. /** @hidden */
  29532. _skipRendering: boolean;
  29533. /** @hidden */
  29534. _projectionMatrix: Matrix;
  29535. /** @hidden */
  29536. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  29537. /** @hidden */
  29538. _activeMeshes: SmartArray<AbstractMesh>;
  29539. protected _globalPosition: Vector3;
  29540. /** @hidden */
  29541. _computedViewMatrix: Matrix;
  29542. private _doNotComputeProjectionMatrix;
  29543. private _transformMatrix;
  29544. private _frustumPlanes;
  29545. private _refreshFrustumPlanes;
  29546. private _storedFov;
  29547. private _stateStored;
  29548. /**
  29549. * Instantiates a new camera object.
  29550. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29551. * @see https://doc.babylonjs.com/features/cameras
  29552. * @param name Defines the name of the camera in the scene
  29553. * @param position Defines the position of the camera
  29554. * @param scene Defines the scene the camera belongs too
  29555. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29556. */
  29557. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29558. /**
  29559. * Store current camera state (fov, position, etc..)
  29560. * @returns the camera
  29561. */
  29562. storeState(): Camera;
  29563. /**
  29564. * Restores the camera state values if it has been stored. You must call storeState() first
  29565. */
  29566. protected _restoreStateValues(): boolean;
  29567. /**
  29568. * Restored camera state. You must call storeState() first.
  29569. * @returns true if restored and false otherwise
  29570. */
  29571. restoreState(): boolean;
  29572. /**
  29573. * Gets the class name of the camera.
  29574. * @returns the class name
  29575. */
  29576. getClassName(): string;
  29577. /** @hidden */
  29578. readonly _isCamera: boolean;
  29579. /**
  29580. * Gets a string representation of the camera useful for debug purpose.
  29581. * @param fullDetails Defines that a more verboe level of logging is required
  29582. * @returns the string representation
  29583. */
  29584. toString(fullDetails?: boolean): string;
  29585. /**
  29586. * Gets the current world space position of the camera.
  29587. */
  29588. get globalPosition(): Vector3;
  29589. /**
  29590. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29591. * @returns the active meshe list
  29592. */
  29593. getActiveMeshes(): SmartArray<AbstractMesh>;
  29594. /**
  29595. * Check whether a mesh is part of the current active mesh list of the camera
  29596. * @param mesh Defines the mesh to check
  29597. * @returns true if active, false otherwise
  29598. */
  29599. isActiveMesh(mesh: Mesh): boolean;
  29600. /**
  29601. * Is this camera ready to be used/rendered
  29602. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29603. * @return true if the camera is ready
  29604. */
  29605. isReady(completeCheck?: boolean): boolean;
  29606. /** @hidden */
  29607. _initCache(): void;
  29608. /** @hidden */
  29609. _updateCache(ignoreParentClass?: boolean): void;
  29610. /** @hidden */
  29611. _isSynchronized(): boolean;
  29612. /** @hidden */
  29613. _isSynchronizedViewMatrix(): boolean;
  29614. /** @hidden */
  29615. _isSynchronizedProjectionMatrix(): boolean;
  29616. /**
  29617. * Attach the input controls to a specific dom element to get the input from.
  29618. * @param element Defines the element the controls should be listened from
  29619. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29620. */
  29621. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29622. /**
  29623. * Detach the current controls from the specified dom element.
  29624. * @param element Defines the element to stop listening the inputs from
  29625. */
  29626. detachControl(element: HTMLElement): void;
  29627. /**
  29628. * Update the camera state according to the different inputs gathered during the frame.
  29629. */
  29630. update(): void;
  29631. /** @hidden */
  29632. _checkInputs(): void;
  29633. /** @hidden */
  29634. get rigCameras(): Camera[];
  29635. /**
  29636. * Gets the post process used by the rig cameras
  29637. */
  29638. get rigPostProcess(): Nullable<PostProcess>;
  29639. /**
  29640. * Internal, gets the first post proces.
  29641. * @returns the first post process to be run on this camera.
  29642. */
  29643. _getFirstPostProcess(): Nullable<PostProcess>;
  29644. private _cascadePostProcessesToRigCams;
  29645. /**
  29646. * Attach a post process to the camera.
  29647. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29648. * @param postProcess The post process to attach to the camera
  29649. * @param insertAt The position of the post process in case several of them are in use in the scene
  29650. * @returns the position the post process has been inserted at
  29651. */
  29652. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29653. /**
  29654. * Detach a post process to the camera.
  29655. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29656. * @param postProcess The post process to detach from the camera
  29657. */
  29658. detachPostProcess(postProcess: PostProcess): void;
  29659. /**
  29660. * Gets the current world matrix of the camera
  29661. */
  29662. getWorldMatrix(): Matrix;
  29663. /** @hidden */
  29664. _getViewMatrix(): Matrix;
  29665. /**
  29666. * Gets the current view matrix of the camera.
  29667. * @param force forces the camera to recompute the matrix without looking at the cached state
  29668. * @returns the view matrix
  29669. */
  29670. getViewMatrix(force?: boolean): Matrix;
  29671. /**
  29672. * Freeze the projection matrix.
  29673. * It will prevent the cache check of the camera projection compute and can speed up perf
  29674. * if no parameter of the camera are meant to change
  29675. * @param projection Defines manually a projection if necessary
  29676. */
  29677. freezeProjectionMatrix(projection?: Matrix): void;
  29678. /**
  29679. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29680. */
  29681. unfreezeProjectionMatrix(): void;
  29682. /**
  29683. * Gets the current projection matrix of the camera.
  29684. * @param force forces the camera to recompute the matrix without looking at the cached state
  29685. * @returns the projection matrix
  29686. */
  29687. getProjectionMatrix(force?: boolean): Matrix;
  29688. /**
  29689. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29690. * @returns a Matrix
  29691. */
  29692. getTransformationMatrix(): Matrix;
  29693. private _updateFrustumPlanes;
  29694. /**
  29695. * Checks if a cullable object (mesh...) is in the camera frustum
  29696. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29697. * @param target The object to check
  29698. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29699. * @returns true if the object is in frustum otherwise false
  29700. */
  29701. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29702. /**
  29703. * Checks if a cullable object (mesh...) is in the camera frustum
  29704. * Unlike isInFrustum this cheks the full bounding box
  29705. * @param target The object to check
  29706. * @returns true if the object is in frustum otherwise false
  29707. */
  29708. isCompletelyInFrustum(target: ICullable): boolean;
  29709. /**
  29710. * Gets a ray in the forward direction from the camera.
  29711. * @param length Defines the length of the ray to create
  29712. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29713. * @param origin Defines the start point of the ray which defaults to the camera position
  29714. * @returns the forward ray
  29715. */
  29716. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29717. /**
  29718. * Releases resources associated with this node.
  29719. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29720. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29721. */
  29722. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29723. /** @hidden */
  29724. _isLeftCamera: boolean;
  29725. /**
  29726. * Gets the left camera of a rig setup in case of Rigged Camera
  29727. */
  29728. get isLeftCamera(): boolean;
  29729. /** @hidden */
  29730. _isRightCamera: boolean;
  29731. /**
  29732. * Gets the right camera of a rig setup in case of Rigged Camera
  29733. */
  29734. get isRightCamera(): boolean;
  29735. /**
  29736. * Gets the left camera of a rig setup in case of Rigged Camera
  29737. */
  29738. get leftCamera(): Nullable<FreeCamera>;
  29739. /**
  29740. * Gets the right camera of a rig setup in case of Rigged Camera
  29741. */
  29742. get rightCamera(): Nullable<FreeCamera>;
  29743. /**
  29744. * Gets the left camera target of a rig setup in case of Rigged Camera
  29745. * @returns the target position
  29746. */
  29747. getLeftTarget(): Nullable<Vector3>;
  29748. /**
  29749. * Gets the right camera target of a rig setup in case of Rigged Camera
  29750. * @returns the target position
  29751. */
  29752. getRightTarget(): Nullable<Vector3>;
  29753. /**
  29754. * @hidden
  29755. */
  29756. setCameraRigMode(mode: number, rigParams: any): void;
  29757. /** @hidden */
  29758. static _setStereoscopicRigMode(camera: Camera): void;
  29759. /** @hidden */
  29760. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29761. /** @hidden */
  29762. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29763. /** @hidden */
  29764. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29765. /** @hidden */
  29766. _getVRProjectionMatrix(): Matrix;
  29767. protected _updateCameraRotationMatrix(): void;
  29768. protected _updateWebVRCameraRotationMatrix(): void;
  29769. /**
  29770. * This function MUST be overwritten by the different WebVR cameras available.
  29771. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29772. * @hidden
  29773. */
  29774. _getWebVRProjectionMatrix(): Matrix;
  29775. /**
  29776. * This function MUST be overwritten by the different WebVR cameras available.
  29777. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29778. * @hidden
  29779. */
  29780. _getWebVRViewMatrix(): Matrix;
  29781. /** @hidden */
  29782. setCameraRigParameter(name: string, value: any): void;
  29783. /**
  29784. * needs to be overridden by children so sub has required properties to be copied
  29785. * @hidden
  29786. */
  29787. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29788. /**
  29789. * May need to be overridden by children
  29790. * @hidden
  29791. */
  29792. _updateRigCameras(): void;
  29793. /** @hidden */
  29794. _setupInputs(): void;
  29795. /**
  29796. * Serialiaze the camera setup to a json represention
  29797. * @returns the JSON representation
  29798. */
  29799. serialize(): any;
  29800. /**
  29801. * Clones the current camera.
  29802. * @param name The cloned camera name
  29803. * @returns the cloned camera
  29804. */
  29805. clone(name: string): Camera;
  29806. /**
  29807. * Gets the direction of the camera relative to a given local axis.
  29808. * @param localAxis Defines the reference axis to provide a relative direction.
  29809. * @return the direction
  29810. */
  29811. getDirection(localAxis: Vector3): Vector3;
  29812. /**
  29813. * Returns the current camera absolute rotation
  29814. */
  29815. get absoluteRotation(): Quaternion;
  29816. /**
  29817. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29818. * @param localAxis Defines the reference axis to provide a relative direction.
  29819. * @param result Defines the vector to store the result in
  29820. */
  29821. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29822. /**
  29823. * Gets a camera constructor for a given camera type
  29824. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29825. * @param name The name of the camera the result will be able to instantiate
  29826. * @param scene The scene the result will construct the camera in
  29827. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29828. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29829. * @returns a factory method to construc the camera
  29830. */
  29831. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29832. /**
  29833. * Compute the world matrix of the camera.
  29834. * @returns the camera world matrix
  29835. */
  29836. computeWorldMatrix(): Matrix;
  29837. /**
  29838. * Parse a JSON and creates the camera from the parsed information
  29839. * @param parsedCamera The JSON to parse
  29840. * @param scene The scene to instantiate the camera in
  29841. * @returns the newly constructed camera
  29842. */
  29843. static Parse(parsedCamera: any, scene: Scene): Camera;
  29844. }
  29845. }
  29846. declare module "babylonjs/Meshes/Builders/discBuilder" {
  29847. import { Nullable } from "babylonjs/types";
  29848. import { Scene } from "babylonjs/scene";
  29849. import { Vector4 } from "babylonjs/Maths/math.vector";
  29850. import { Mesh } from "babylonjs/Meshes/mesh";
  29851. /**
  29852. * Class containing static functions to help procedurally build meshes
  29853. */
  29854. export class DiscBuilder {
  29855. /**
  29856. * Creates a plane polygonal mesh. By default, this is a disc
  29857. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29858. * * 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
  29859. * * 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
  29860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29861. * * 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
  29862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29863. * @param name defines the name of the mesh
  29864. * @param options defines the options used to create the mesh
  29865. * @param scene defines the hosting scene
  29866. * @returns the plane polygonal mesh
  29867. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29868. */
  29869. static CreateDisc(name: string, options: {
  29870. radius?: number;
  29871. tessellation?: number;
  29872. arc?: number;
  29873. updatable?: boolean;
  29874. sideOrientation?: number;
  29875. frontUVs?: Vector4;
  29876. backUVs?: Vector4;
  29877. }, scene?: Nullable<Scene>): Mesh;
  29878. }
  29879. }
  29880. declare module "babylonjs/Materials/fresnelParameters" {
  29881. import { DeepImmutable } from "babylonjs/types";
  29882. import { Color3 } from "babylonjs/Maths/math.color";
  29883. /**
  29884. * Options to be used when creating a FresnelParameters.
  29885. */
  29886. export type IFresnelParametersCreationOptions = {
  29887. /**
  29888. * Define the color used on edges (grazing angle)
  29889. */
  29890. leftColor?: Color3;
  29891. /**
  29892. * Define the color used on center
  29893. */
  29894. rightColor?: Color3;
  29895. /**
  29896. * Define bias applied to computed fresnel term
  29897. */
  29898. bias?: number;
  29899. /**
  29900. * Defined the power exponent applied to fresnel term
  29901. */
  29902. power?: number;
  29903. /**
  29904. * Define if the fresnel effect is enable or not.
  29905. */
  29906. isEnabled?: boolean;
  29907. };
  29908. /**
  29909. * Serialized format for FresnelParameters.
  29910. */
  29911. export type IFresnelParametersSerialized = {
  29912. /**
  29913. * Define the color used on edges (grazing angle) [as an array]
  29914. */
  29915. leftColor: number[];
  29916. /**
  29917. * Define the color used on center [as an array]
  29918. */
  29919. rightColor: number[];
  29920. /**
  29921. * Define bias applied to computed fresnel term
  29922. */
  29923. bias: number;
  29924. /**
  29925. * Defined the power exponent applied to fresnel term
  29926. */
  29927. power?: number;
  29928. /**
  29929. * Define if the fresnel effect is enable or not.
  29930. */
  29931. isEnabled: boolean;
  29932. };
  29933. /**
  29934. * This represents all the required information to add a fresnel effect on a material:
  29935. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29936. */
  29937. export class FresnelParameters {
  29938. private _isEnabled;
  29939. /**
  29940. * Define if the fresnel effect is enable or not.
  29941. */
  29942. get isEnabled(): boolean;
  29943. set isEnabled(value: boolean);
  29944. /**
  29945. * Define the color used on edges (grazing angle)
  29946. */
  29947. leftColor: Color3;
  29948. /**
  29949. * Define the color used on center
  29950. */
  29951. rightColor: Color3;
  29952. /**
  29953. * Define bias applied to computed fresnel term
  29954. */
  29955. bias: number;
  29956. /**
  29957. * Defined the power exponent applied to fresnel term
  29958. */
  29959. power: number;
  29960. /**
  29961. * Creates a new FresnelParameters object.
  29962. *
  29963. * @param options provide your own settings to optionally to override defaults
  29964. */
  29965. constructor(options?: IFresnelParametersCreationOptions);
  29966. /**
  29967. * Clones the current fresnel and its valuues
  29968. * @returns a clone fresnel configuration
  29969. */
  29970. clone(): FresnelParameters;
  29971. /**
  29972. * Determines equality between FresnelParameters objects
  29973. * @param otherFresnelParameters defines the second operand
  29974. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29975. */
  29976. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29977. /**
  29978. * Serializes the current fresnel parameters to a JSON representation.
  29979. * @return the JSON serialization
  29980. */
  29981. serialize(): IFresnelParametersSerialized;
  29982. /**
  29983. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29984. * @param parsedFresnelParameters Define the JSON representation
  29985. * @returns the parsed parameters
  29986. */
  29987. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29988. }
  29989. }
  29990. declare module "babylonjs/Materials/materialFlags" {
  29991. /**
  29992. * This groups all the flags used to control the materials channel.
  29993. */
  29994. export class MaterialFlags {
  29995. private static _DiffuseTextureEnabled;
  29996. /**
  29997. * Are diffuse textures enabled in the application.
  29998. */
  29999. static get DiffuseTextureEnabled(): boolean;
  30000. static set DiffuseTextureEnabled(value: boolean);
  30001. private static _DetailTextureEnabled;
  30002. /**
  30003. * Are detail textures enabled in the application.
  30004. */
  30005. static get DetailTextureEnabled(): boolean;
  30006. static set DetailTextureEnabled(value: boolean);
  30007. private static _AmbientTextureEnabled;
  30008. /**
  30009. * Are ambient textures enabled in the application.
  30010. */
  30011. static get AmbientTextureEnabled(): boolean;
  30012. static set AmbientTextureEnabled(value: boolean);
  30013. private static _OpacityTextureEnabled;
  30014. /**
  30015. * Are opacity textures enabled in the application.
  30016. */
  30017. static get OpacityTextureEnabled(): boolean;
  30018. static set OpacityTextureEnabled(value: boolean);
  30019. private static _ReflectionTextureEnabled;
  30020. /**
  30021. * Are reflection textures enabled in the application.
  30022. */
  30023. static get ReflectionTextureEnabled(): boolean;
  30024. static set ReflectionTextureEnabled(value: boolean);
  30025. private static _EmissiveTextureEnabled;
  30026. /**
  30027. * Are emissive textures enabled in the application.
  30028. */
  30029. static get EmissiveTextureEnabled(): boolean;
  30030. static set EmissiveTextureEnabled(value: boolean);
  30031. private static _SpecularTextureEnabled;
  30032. /**
  30033. * Are specular textures enabled in the application.
  30034. */
  30035. static get SpecularTextureEnabled(): boolean;
  30036. static set SpecularTextureEnabled(value: boolean);
  30037. private static _BumpTextureEnabled;
  30038. /**
  30039. * Are bump textures enabled in the application.
  30040. */
  30041. static get BumpTextureEnabled(): boolean;
  30042. static set BumpTextureEnabled(value: boolean);
  30043. private static _LightmapTextureEnabled;
  30044. /**
  30045. * Are lightmap textures enabled in the application.
  30046. */
  30047. static get LightmapTextureEnabled(): boolean;
  30048. static set LightmapTextureEnabled(value: boolean);
  30049. private static _RefractionTextureEnabled;
  30050. /**
  30051. * Are refraction textures enabled in the application.
  30052. */
  30053. static get RefractionTextureEnabled(): boolean;
  30054. static set RefractionTextureEnabled(value: boolean);
  30055. private static _ColorGradingTextureEnabled;
  30056. /**
  30057. * Are color grading textures enabled in the application.
  30058. */
  30059. static get ColorGradingTextureEnabled(): boolean;
  30060. static set ColorGradingTextureEnabled(value: boolean);
  30061. private static _FresnelEnabled;
  30062. /**
  30063. * Are fresnels enabled in the application.
  30064. */
  30065. static get FresnelEnabled(): boolean;
  30066. static set FresnelEnabled(value: boolean);
  30067. private static _ClearCoatTextureEnabled;
  30068. /**
  30069. * Are clear coat textures enabled in the application.
  30070. */
  30071. static get ClearCoatTextureEnabled(): boolean;
  30072. static set ClearCoatTextureEnabled(value: boolean);
  30073. private static _ClearCoatBumpTextureEnabled;
  30074. /**
  30075. * Are clear coat bump textures enabled in the application.
  30076. */
  30077. static get ClearCoatBumpTextureEnabled(): boolean;
  30078. static set ClearCoatBumpTextureEnabled(value: boolean);
  30079. private static _ClearCoatTintTextureEnabled;
  30080. /**
  30081. * Are clear coat tint textures enabled in the application.
  30082. */
  30083. static get ClearCoatTintTextureEnabled(): boolean;
  30084. static set ClearCoatTintTextureEnabled(value: boolean);
  30085. private static _SheenTextureEnabled;
  30086. /**
  30087. * Are sheen textures enabled in the application.
  30088. */
  30089. static get SheenTextureEnabled(): boolean;
  30090. static set SheenTextureEnabled(value: boolean);
  30091. private static _AnisotropicTextureEnabled;
  30092. /**
  30093. * Are anisotropic textures enabled in the application.
  30094. */
  30095. static get AnisotropicTextureEnabled(): boolean;
  30096. static set AnisotropicTextureEnabled(value: boolean);
  30097. private static _ThicknessTextureEnabled;
  30098. /**
  30099. * Are thickness textures enabled in the application.
  30100. */
  30101. static get ThicknessTextureEnabled(): boolean;
  30102. static set ThicknessTextureEnabled(value: boolean);
  30103. }
  30104. }
  30105. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  30106. /** @hidden */
  30107. export var defaultFragmentDeclaration: {
  30108. name: string;
  30109. shader: string;
  30110. };
  30111. }
  30112. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  30113. /** @hidden */
  30114. export var defaultUboDeclaration: {
  30115. name: string;
  30116. shader: string;
  30117. };
  30118. }
  30119. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  30120. /** @hidden */
  30121. export var lightFragmentDeclaration: {
  30122. name: string;
  30123. shader: string;
  30124. };
  30125. }
  30126. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  30127. /** @hidden */
  30128. export var lightUboDeclaration: {
  30129. name: string;
  30130. shader: string;
  30131. };
  30132. }
  30133. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  30134. /** @hidden */
  30135. export var lightsFragmentFunctions: {
  30136. name: string;
  30137. shader: string;
  30138. };
  30139. }
  30140. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  30141. /** @hidden */
  30142. export var shadowsFragmentFunctions: {
  30143. name: string;
  30144. shader: string;
  30145. };
  30146. }
  30147. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  30148. /** @hidden */
  30149. export var fresnelFunction: {
  30150. name: string;
  30151. shader: string;
  30152. };
  30153. }
  30154. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  30155. /** @hidden */
  30156. export var bumpFragmentMainFunctions: {
  30157. name: string;
  30158. shader: string;
  30159. };
  30160. }
  30161. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  30162. /** @hidden */
  30163. export var bumpFragmentFunctions: {
  30164. name: string;
  30165. shader: string;
  30166. };
  30167. }
  30168. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  30169. /** @hidden */
  30170. export var logDepthDeclaration: {
  30171. name: string;
  30172. shader: string;
  30173. };
  30174. }
  30175. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  30176. /** @hidden */
  30177. export var bumpFragment: {
  30178. name: string;
  30179. shader: string;
  30180. };
  30181. }
  30182. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  30183. /** @hidden */
  30184. export var depthPrePass: {
  30185. name: string;
  30186. shader: string;
  30187. };
  30188. }
  30189. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  30190. /** @hidden */
  30191. export var lightFragment: {
  30192. name: string;
  30193. shader: string;
  30194. };
  30195. }
  30196. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  30197. /** @hidden */
  30198. export var logDepthFragment: {
  30199. name: string;
  30200. shader: string;
  30201. };
  30202. }
  30203. declare module "babylonjs/Shaders/default.fragment" {
  30204. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  30205. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30206. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30207. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30208. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30209. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  30210. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  30211. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  30212. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  30213. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  30214. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  30215. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  30216. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  30217. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  30218. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30219. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  30220. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  30221. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  30222. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  30223. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  30224. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  30225. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  30226. /** @hidden */
  30227. export var defaultPixelShader: {
  30228. name: string;
  30229. shader: string;
  30230. };
  30231. }
  30232. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  30233. /** @hidden */
  30234. export var defaultVertexDeclaration: {
  30235. name: string;
  30236. shader: string;
  30237. };
  30238. }
  30239. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  30240. /** @hidden */
  30241. export var bumpVertexDeclaration: {
  30242. name: string;
  30243. shader: string;
  30244. };
  30245. }
  30246. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  30247. /** @hidden */
  30248. export var bumpVertex: {
  30249. name: string;
  30250. shader: string;
  30251. };
  30252. }
  30253. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  30254. /** @hidden */
  30255. export var fogVertex: {
  30256. name: string;
  30257. shader: string;
  30258. };
  30259. }
  30260. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  30261. /** @hidden */
  30262. export var shadowsVertex: {
  30263. name: string;
  30264. shader: string;
  30265. };
  30266. }
  30267. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  30268. /** @hidden */
  30269. export var pointCloudVertex: {
  30270. name: string;
  30271. shader: string;
  30272. };
  30273. }
  30274. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  30275. /** @hidden */
  30276. export var logDepthVertex: {
  30277. name: string;
  30278. shader: string;
  30279. };
  30280. }
  30281. declare module "babylonjs/Shaders/default.vertex" {
  30282. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  30283. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30284. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30285. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  30286. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  30287. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  30288. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  30289. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  30290. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30291. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30292. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  30293. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  30294. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30295. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  30296. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  30297. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  30298. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  30299. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  30300. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  30301. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  30302. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  30303. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  30304. /** @hidden */
  30305. export var defaultVertexShader: {
  30306. name: string;
  30307. shader: string;
  30308. };
  30309. }
  30310. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  30311. import { Nullable } from "babylonjs/types";
  30312. import { Scene } from "babylonjs/scene";
  30313. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30314. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30315. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30316. /**
  30317. * @hidden
  30318. */
  30319. export interface IMaterialDetailMapDefines {
  30320. DETAIL: boolean;
  30321. DETAILDIRECTUV: number;
  30322. DETAIL_NORMALBLENDMETHOD: number;
  30323. /** @hidden */
  30324. _areTexturesDirty: boolean;
  30325. }
  30326. /**
  30327. * Define the code related to the detail map parameters of a material
  30328. *
  30329. * Inspired from:
  30330. * Unity: https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@9.0/manual/Mask-Map-and-Detail-Map.html and https://docs.unity3d.com/Manual/StandardShaderMaterialParameterDetail.html
  30331. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30332. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30333. */
  30334. export class DetailMapConfiguration {
  30335. private _texture;
  30336. /**
  30337. * The detail texture of the material.
  30338. */
  30339. texture: Nullable<BaseTexture>;
  30340. /**
  30341. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30342. * Bigger values mean stronger blending
  30343. */
  30344. diffuseBlendLevel: number;
  30345. /**
  30346. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30347. * Bigger values mean stronger blending. Only used with PBR materials
  30348. */
  30349. roughnessBlendLevel: number;
  30350. /**
  30351. * Defines how strong the bump effect from the detail map is
  30352. * Bigger values mean stronger effect
  30353. */
  30354. bumpLevel: number;
  30355. private _normalBlendMethod;
  30356. /**
  30357. * The method used to blend the bump and detail normals together
  30358. */
  30359. normalBlendMethod: number;
  30360. private _isEnabled;
  30361. /**
  30362. * Enable or disable the detail map on this material
  30363. */
  30364. isEnabled: boolean;
  30365. /** @hidden */
  30366. private _internalMarkAllSubMeshesAsTexturesDirty;
  30367. /** @hidden */
  30368. _markAllSubMeshesAsTexturesDirty(): void;
  30369. /**
  30370. * Instantiate a new detail map
  30371. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30372. */
  30373. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30374. /**
  30375. * Gets whether the submesh is ready to be used or not.
  30376. * @param defines the list of "defines" to update.
  30377. * @param scene defines the scene the material belongs to.
  30378. * @returns - boolean indicating that the submesh is ready or not.
  30379. */
  30380. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30381. /**
  30382. * Update the defines for detail map usage
  30383. * @param defines the list of "defines" to update.
  30384. * @param scene defines the scene the material belongs to.
  30385. */
  30386. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30387. /**
  30388. * Binds the material data.
  30389. * @param uniformBuffer defines the Uniform buffer to fill in.
  30390. * @param scene defines the scene the material belongs to.
  30391. * @param isFrozen defines whether the material is frozen or not.
  30392. */
  30393. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30394. /**
  30395. * Checks to see if a texture is used in the material.
  30396. * @param texture - Base texture to use.
  30397. * @returns - Boolean specifying if a texture is used in the material.
  30398. */
  30399. hasTexture(texture: BaseTexture): boolean;
  30400. /**
  30401. * Returns an array of the actively used textures.
  30402. * @param activeTextures Array of BaseTextures
  30403. */
  30404. getActiveTextures(activeTextures: BaseTexture[]): void;
  30405. /**
  30406. * Returns the animatable textures.
  30407. * @param animatables Array of animatable textures.
  30408. */
  30409. getAnimatables(animatables: IAnimatable[]): void;
  30410. /**
  30411. * Disposes the resources of the material.
  30412. * @param forceDisposeTextures - Forces the disposal of all textures.
  30413. */
  30414. dispose(forceDisposeTextures?: boolean): void;
  30415. /**
  30416. * Get the current class name useful for serialization or dynamic coding.
  30417. * @returns "DetailMap"
  30418. */
  30419. getClassName(): string;
  30420. /**
  30421. * Add the required uniforms to the current list.
  30422. * @param uniforms defines the current uniform list.
  30423. */
  30424. static AddUniforms(uniforms: string[]): void;
  30425. /**
  30426. * Add the required samplers to the current list.
  30427. * @param samplers defines the current sampler list.
  30428. */
  30429. static AddSamplers(samplers: string[]): void;
  30430. /**
  30431. * Add the required uniforms to the current buffer.
  30432. * @param uniformBuffer defines the current uniform buffer.
  30433. */
  30434. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30435. /**
  30436. * Makes a duplicate of the current instance into another one.
  30437. * @param detailMap define the instance where to copy the info
  30438. */
  30439. copyTo(detailMap: DetailMapConfiguration): void;
  30440. /**
  30441. * Serializes this detail map instance
  30442. * @returns - An object with the serialized instance.
  30443. */
  30444. serialize(): any;
  30445. /**
  30446. * Parses a detail map setting from a serialized object.
  30447. * @param source - Serialized object.
  30448. * @param scene Defines the scene we are parsing for
  30449. * @param rootUrl Defines the rootUrl to load from
  30450. */
  30451. parse(source: any, scene: Scene, rootUrl: string): void;
  30452. }
  30453. }
  30454. declare module "babylonjs/Materials/standardMaterial" {
  30455. import { SmartArray } from "babylonjs/Misc/smartArray";
  30456. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30457. import { Nullable } from "babylonjs/types";
  30458. import { Scene } from "babylonjs/scene";
  30459. import { Matrix } from "babylonjs/Maths/math.vector";
  30460. import { Color3 } from "babylonjs/Maths/math.color";
  30461. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30462. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30463. import { Mesh } from "babylonjs/Meshes/mesh";
  30464. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  30465. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30466. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  30467. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30468. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  30469. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30470. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30471. import "babylonjs/Shaders/default.fragment";
  30472. import "babylonjs/Shaders/default.vertex";
  30473. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  30474. /** @hidden */
  30475. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30476. MAINUV1: boolean;
  30477. MAINUV2: boolean;
  30478. DIFFUSE: boolean;
  30479. DIFFUSEDIRECTUV: number;
  30480. DETAIL: boolean;
  30481. DETAILDIRECTUV: number;
  30482. DETAIL_NORMALBLENDMETHOD: number;
  30483. AMBIENT: boolean;
  30484. AMBIENTDIRECTUV: number;
  30485. OPACITY: boolean;
  30486. OPACITYDIRECTUV: number;
  30487. OPACITYRGB: boolean;
  30488. REFLECTION: boolean;
  30489. EMISSIVE: boolean;
  30490. EMISSIVEDIRECTUV: number;
  30491. SPECULAR: boolean;
  30492. SPECULARDIRECTUV: number;
  30493. BUMP: boolean;
  30494. BUMPDIRECTUV: number;
  30495. PARALLAX: boolean;
  30496. PARALLAXOCCLUSION: boolean;
  30497. SPECULAROVERALPHA: boolean;
  30498. CLIPPLANE: boolean;
  30499. CLIPPLANE2: boolean;
  30500. CLIPPLANE3: boolean;
  30501. CLIPPLANE4: boolean;
  30502. CLIPPLANE5: boolean;
  30503. CLIPPLANE6: boolean;
  30504. ALPHATEST: boolean;
  30505. DEPTHPREPASS: boolean;
  30506. ALPHAFROMDIFFUSE: boolean;
  30507. POINTSIZE: boolean;
  30508. FOG: boolean;
  30509. SPECULARTERM: boolean;
  30510. DIFFUSEFRESNEL: boolean;
  30511. OPACITYFRESNEL: boolean;
  30512. REFLECTIONFRESNEL: boolean;
  30513. REFRACTIONFRESNEL: boolean;
  30514. EMISSIVEFRESNEL: boolean;
  30515. FRESNEL: boolean;
  30516. NORMAL: boolean;
  30517. UV1: boolean;
  30518. UV2: boolean;
  30519. VERTEXCOLOR: boolean;
  30520. VERTEXALPHA: boolean;
  30521. NUM_BONE_INFLUENCERS: number;
  30522. BonesPerMesh: number;
  30523. BONETEXTURE: boolean;
  30524. INSTANCES: boolean;
  30525. THIN_INSTANCES: boolean;
  30526. GLOSSINESS: boolean;
  30527. ROUGHNESS: boolean;
  30528. EMISSIVEASILLUMINATION: boolean;
  30529. LINKEMISSIVEWITHDIFFUSE: boolean;
  30530. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30531. LIGHTMAP: boolean;
  30532. LIGHTMAPDIRECTUV: number;
  30533. OBJECTSPACE_NORMALMAP: boolean;
  30534. USELIGHTMAPASSHADOWMAP: boolean;
  30535. REFLECTIONMAP_3D: boolean;
  30536. REFLECTIONMAP_SPHERICAL: boolean;
  30537. REFLECTIONMAP_PLANAR: boolean;
  30538. REFLECTIONMAP_CUBIC: boolean;
  30539. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30540. REFLECTIONMAP_PROJECTION: boolean;
  30541. REFLECTIONMAP_SKYBOX: boolean;
  30542. REFLECTIONMAP_EXPLICIT: boolean;
  30543. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30544. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30545. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30546. INVERTCUBICMAP: boolean;
  30547. LOGARITHMICDEPTH: boolean;
  30548. REFRACTION: boolean;
  30549. REFRACTIONMAP_3D: boolean;
  30550. REFLECTIONOVERALPHA: boolean;
  30551. TWOSIDEDLIGHTING: boolean;
  30552. SHADOWFLOAT: boolean;
  30553. MORPHTARGETS: boolean;
  30554. MORPHTARGETS_NORMAL: boolean;
  30555. MORPHTARGETS_TANGENT: boolean;
  30556. MORPHTARGETS_UV: boolean;
  30557. NUM_MORPH_INFLUENCERS: number;
  30558. NONUNIFORMSCALING: boolean;
  30559. PREMULTIPLYALPHA: boolean;
  30560. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30561. ALPHABLEND: boolean;
  30562. PREPASS: boolean;
  30563. SCENE_MRT_COUNT: number;
  30564. RGBDLIGHTMAP: boolean;
  30565. RGBDREFLECTION: boolean;
  30566. RGBDREFRACTION: boolean;
  30567. IMAGEPROCESSING: boolean;
  30568. VIGNETTE: boolean;
  30569. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30570. VIGNETTEBLENDMODEOPAQUE: boolean;
  30571. TONEMAPPING: boolean;
  30572. TONEMAPPING_ACES: boolean;
  30573. CONTRAST: boolean;
  30574. COLORCURVES: boolean;
  30575. COLORGRADING: boolean;
  30576. COLORGRADING3D: boolean;
  30577. SAMPLER3DGREENDEPTH: boolean;
  30578. SAMPLER3DBGRMAP: boolean;
  30579. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30580. MULTIVIEW: boolean;
  30581. /**
  30582. * If the reflection texture on this material is in linear color space
  30583. * @hidden
  30584. */
  30585. IS_REFLECTION_LINEAR: boolean;
  30586. /**
  30587. * If the refraction texture on this material is in linear color space
  30588. * @hidden
  30589. */
  30590. IS_REFRACTION_LINEAR: boolean;
  30591. EXPOSURE: boolean;
  30592. constructor();
  30593. setReflectionMode(modeToEnable: string): void;
  30594. }
  30595. /**
  30596. * This is the default material used in Babylon. It is the best trade off between quality
  30597. * and performances.
  30598. * @see https://doc.babylonjs.com/babylon101/materials
  30599. */
  30600. export class StandardMaterial extends PushMaterial {
  30601. private _diffuseTexture;
  30602. /**
  30603. * The basic texture of the material as viewed under a light.
  30604. */
  30605. diffuseTexture: Nullable<BaseTexture>;
  30606. private _ambientTexture;
  30607. /**
  30608. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30609. */
  30610. ambientTexture: Nullable<BaseTexture>;
  30611. private _opacityTexture;
  30612. /**
  30613. * Define the transparency of the material from a texture.
  30614. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30615. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30616. */
  30617. opacityTexture: Nullable<BaseTexture>;
  30618. private _reflectionTexture;
  30619. /**
  30620. * Define the texture used to display the reflection.
  30621. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30622. */
  30623. reflectionTexture: Nullable<BaseTexture>;
  30624. private _emissiveTexture;
  30625. /**
  30626. * Define texture of the material as if self lit.
  30627. * This will be mixed in the final result even in the absence of light.
  30628. */
  30629. emissiveTexture: Nullable<BaseTexture>;
  30630. private _specularTexture;
  30631. /**
  30632. * Define how the color and intensity of the highlight given by the light in the material.
  30633. */
  30634. specularTexture: Nullable<BaseTexture>;
  30635. private _bumpTexture;
  30636. /**
  30637. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30638. * 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.
  30639. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  30640. */
  30641. bumpTexture: Nullable<BaseTexture>;
  30642. private _lightmapTexture;
  30643. /**
  30644. * Complex lighting can be computationally expensive to compute at runtime.
  30645. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30646. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  30647. */
  30648. lightmapTexture: Nullable<BaseTexture>;
  30649. private _refractionTexture;
  30650. /**
  30651. * Define the texture used to display the refraction.
  30652. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30653. */
  30654. refractionTexture: Nullable<BaseTexture>;
  30655. /**
  30656. * The color of the material lit by the environmental background lighting.
  30657. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30658. */
  30659. ambientColor: Color3;
  30660. /**
  30661. * The basic color of the material as viewed under a light.
  30662. */
  30663. diffuseColor: Color3;
  30664. /**
  30665. * Define how the color and intensity of the highlight given by the light in the material.
  30666. */
  30667. specularColor: Color3;
  30668. /**
  30669. * Define the color of the material as if self lit.
  30670. * This will be mixed in the final result even in the absence of light.
  30671. */
  30672. emissiveColor: Color3;
  30673. /**
  30674. * Defines how sharp are the highlights in the material.
  30675. * The bigger the value the sharper giving a more glossy feeling to the result.
  30676. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30677. */
  30678. specularPower: number;
  30679. private _useAlphaFromDiffuseTexture;
  30680. /**
  30681. * Does the transparency come from the diffuse texture alpha channel.
  30682. */
  30683. useAlphaFromDiffuseTexture: boolean;
  30684. private _useEmissiveAsIllumination;
  30685. /**
  30686. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30687. */
  30688. useEmissiveAsIllumination: boolean;
  30689. private _linkEmissiveWithDiffuse;
  30690. /**
  30691. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30692. * the emissive level when the final color is close to one.
  30693. */
  30694. linkEmissiveWithDiffuse: boolean;
  30695. private _useSpecularOverAlpha;
  30696. /**
  30697. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30698. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30699. */
  30700. useSpecularOverAlpha: boolean;
  30701. private _useReflectionOverAlpha;
  30702. /**
  30703. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30704. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30705. */
  30706. useReflectionOverAlpha: boolean;
  30707. private _disableLighting;
  30708. /**
  30709. * Does lights from the scene impacts this material.
  30710. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30711. */
  30712. disableLighting: boolean;
  30713. private _useObjectSpaceNormalMap;
  30714. /**
  30715. * Allows using an object space normal map (instead of tangent space).
  30716. */
  30717. useObjectSpaceNormalMap: boolean;
  30718. private _useParallax;
  30719. /**
  30720. * Is parallax enabled or not.
  30721. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30722. */
  30723. useParallax: boolean;
  30724. private _useParallaxOcclusion;
  30725. /**
  30726. * Is parallax occlusion enabled or not.
  30727. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30728. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30729. */
  30730. useParallaxOcclusion: boolean;
  30731. /**
  30732. * 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.
  30733. */
  30734. parallaxScaleBias: number;
  30735. private _roughness;
  30736. /**
  30737. * Helps to define how blurry the reflections should appears in the material.
  30738. */
  30739. roughness: number;
  30740. /**
  30741. * In case of refraction, define the value of the index of refraction.
  30742. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30743. */
  30744. indexOfRefraction: number;
  30745. /**
  30746. * Invert the refraction texture alongside the y axis.
  30747. * It can be useful with procedural textures or probe for instance.
  30748. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30749. */
  30750. invertRefractionY: boolean;
  30751. /**
  30752. * Defines the alpha limits in alpha test mode.
  30753. */
  30754. alphaCutOff: number;
  30755. private _useLightmapAsShadowmap;
  30756. /**
  30757. * In case of light mapping, define whether the map contains light or shadow informations.
  30758. */
  30759. useLightmapAsShadowmap: boolean;
  30760. private _diffuseFresnelParameters;
  30761. /**
  30762. * Define the diffuse fresnel parameters of the material.
  30763. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30764. */
  30765. diffuseFresnelParameters: FresnelParameters;
  30766. private _opacityFresnelParameters;
  30767. /**
  30768. * Define the opacity fresnel parameters of the material.
  30769. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30770. */
  30771. opacityFresnelParameters: FresnelParameters;
  30772. private _reflectionFresnelParameters;
  30773. /**
  30774. * Define the reflection fresnel parameters of the material.
  30775. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30776. */
  30777. reflectionFresnelParameters: FresnelParameters;
  30778. private _refractionFresnelParameters;
  30779. /**
  30780. * Define the refraction fresnel parameters of the material.
  30781. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30782. */
  30783. refractionFresnelParameters: FresnelParameters;
  30784. private _emissiveFresnelParameters;
  30785. /**
  30786. * Define the emissive fresnel parameters of the material.
  30787. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30788. */
  30789. emissiveFresnelParameters: FresnelParameters;
  30790. private _useReflectionFresnelFromSpecular;
  30791. /**
  30792. * If true automatically deducts the fresnels values from the material specularity.
  30793. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30794. */
  30795. useReflectionFresnelFromSpecular: boolean;
  30796. private _useGlossinessFromSpecularMapAlpha;
  30797. /**
  30798. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30799. */
  30800. useGlossinessFromSpecularMapAlpha: boolean;
  30801. private _maxSimultaneousLights;
  30802. /**
  30803. * Defines the maximum number of lights that can be used in the material
  30804. */
  30805. maxSimultaneousLights: number;
  30806. private _invertNormalMapX;
  30807. /**
  30808. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30809. */
  30810. invertNormalMapX: boolean;
  30811. private _invertNormalMapY;
  30812. /**
  30813. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30814. */
  30815. invertNormalMapY: boolean;
  30816. private _twoSidedLighting;
  30817. /**
  30818. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30819. */
  30820. twoSidedLighting: boolean;
  30821. /**
  30822. * Default configuration related to image processing available in the standard Material.
  30823. */
  30824. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30825. /**
  30826. * Gets the image processing configuration used either in this material.
  30827. */
  30828. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30829. /**
  30830. * Sets the Default image processing configuration used either in the this material.
  30831. *
  30832. * If sets to null, the scene one is in use.
  30833. */
  30834. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30835. /**
  30836. * Keep track of the image processing observer to allow dispose and replace.
  30837. */
  30838. private _imageProcessingObserver;
  30839. /**
  30840. * Attaches a new image processing configuration to the Standard Material.
  30841. * @param configuration
  30842. */
  30843. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30844. /**
  30845. * Gets wether the color curves effect is enabled.
  30846. */
  30847. get cameraColorCurvesEnabled(): boolean;
  30848. /**
  30849. * Sets wether the color curves effect is enabled.
  30850. */
  30851. set cameraColorCurvesEnabled(value: boolean);
  30852. /**
  30853. * Gets wether the color grading effect is enabled.
  30854. */
  30855. get cameraColorGradingEnabled(): boolean;
  30856. /**
  30857. * Gets wether the color grading effect is enabled.
  30858. */
  30859. set cameraColorGradingEnabled(value: boolean);
  30860. /**
  30861. * Gets wether tonemapping is enabled or not.
  30862. */
  30863. get cameraToneMappingEnabled(): boolean;
  30864. /**
  30865. * Sets wether tonemapping is enabled or not
  30866. */
  30867. set cameraToneMappingEnabled(value: boolean);
  30868. /**
  30869. * The camera exposure used on this material.
  30870. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30871. * This corresponds to a photographic exposure.
  30872. */
  30873. get cameraExposure(): number;
  30874. /**
  30875. * The camera exposure used on this material.
  30876. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30877. * This corresponds to a photographic exposure.
  30878. */
  30879. set cameraExposure(value: number);
  30880. /**
  30881. * Gets The camera contrast used on this material.
  30882. */
  30883. get cameraContrast(): number;
  30884. /**
  30885. * Sets The camera contrast used on this material.
  30886. */
  30887. set cameraContrast(value: number);
  30888. /**
  30889. * Gets the Color Grading 2D Lookup Texture.
  30890. */
  30891. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30892. /**
  30893. * Sets the Color Grading 2D Lookup Texture.
  30894. */
  30895. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30896. /**
  30897. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30898. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30899. * 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;
  30900. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30901. */
  30902. get cameraColorCurves(): Nullable<ColorCurves>;
  30903. /**
  30904. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30905. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30906. * 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;
  30907. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30908. */
  30909. set cameraColorCurves(value: Nullable<ColorCurves>);
  30910. /**
  30911. * Defines the detail map parameters for the material.
  30912. */
  30913. readonly detailMap: DetailMapConfiguration;
  30914. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30915. protected _worldViewProjectionMatrix: Matrix;
  30916. protected _globalAmbientColor: Color3;
  30917. protected _useLogarithmicDepth: boolean;
  30918. protected _rebuildInParallel: boolean;
  30919. /**
  30920. * Instantiates a new standard material.
  30921. * This is the default material used in Babylon. It is the best trade off between quality
  30922. * and performances.
  30923. * @see https://doc.babylonjs.com/babylon101/materials
  30924. * @param name Define the name of the material in the scene
  30925. * @param scene Define the scene the material belong to
  30926. */
  30927. constructor(name: string, scene: Scene);
  30928. /**
  30929. * Gets a boolean indicating that current material needs to register RTT
  30930. */
  30931. get hasRenderTargetTextures(): boolean;
  30932. /**
  30933. * Gets the current class name of the material e.g. "StandardMaterial"
  30934. * Mainly use in serialization.
  30935. * @returns the class name
  30936. */
  30937. getClassName(): string;
  30938. /**
  30939. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30940. * You can try switching to logarithmic depth.
  30941. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30942. */
  30943. get useLogarithmicDepth(): boolean;
  30944. set useLogarithmicDepth(value: boolean);
  30945. /**
  30946. * Specifies if the material will require alpha blending
  30947. * @returns a boolean specifying if alpha blending is needed
  30948. */
  30949. needAlphaBlending(): boolean;
  30950. /**
  30951. * Specifies if this material should be rendered in alpha test mode
  30952. * @returns a boolean specifying if an alpha test is needed.
  30953. */
  30954. needAlphaTesting(): boolean;
  30955. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30956. /**
  30957. * Get the texture used for alpha test purpose.
  30958. * @returns the diffuse texture in case of the standard material.
  30959. */
  30960. getAlphaTestTexture(): Nullable<BaseTexture>;
  30961. /**
  30962. * Get if the submesh is ready to be used and all its information available.
  30963. * Child classes can use it to update shaders
  30964. * @param mesh defines the mesh to check
  30965. * @param subMesh defines which submesh to check
  30966. * @param useInstances specifies that instances should be used
  30967. * @returns a boolean indicating that the submesh is ready or not
  30968. */
  30969. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30970. /**
  30971. * Builds the material UBO layouts.
  30972. * Used internally during the effect preparation.
  30973. */
  30974. buildUniformLayout(): void;
  30975. /**
  30976. * Unbinds the material from the mesh
  30977. */
  30978. unbind(): void;
  30979. /**
  30980. * Binds the submesh to this material by preparing the effect and shader to draw
  30981. * @param world defines the world transformation matrix
  30982. * @param mesh defines the mesh containing the submesh
  30983. * @param subMesh defines the submesh to bind the material to
  30984. */
  30985. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30986. /**
  30987. * Get the list of animatables in the material.
  30988. * @returns the list of animatables object used in the material
  30989. */
  30990. getAnimatables(): IAnimatable[];
  30991. /**
  30992. * Gets the active textures from the material
  30993. * @returns an array of textures
  30994. */
  30995. getActiveTextures(): BaseTexture[];
  30996. /**
  30997. * Specifies if the material uses a texture
  30998. * @param texture defines the texture to check against the material
  30999. * @returns a boolean specifying if the material uses the texture
  31000. */
  31001. hasTexture(texture: BaseTexture): boolean;
  31002. /**
  31003. * Disposes the material
  31004. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31005. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31006. */
  31007. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31008. /**
  31009. * Makes a duplicate of the material, and gives it a new name
  31010. * @param name defines the new name for the duplicated material
  31011. * @returns the cloned material
  31012. */
  31013. clone(name: string): StandardMaterial;
  31014. /**
  31015. * Serializes this material in a JSON representation
  31016. * @returns the serialized material object
  31017. */
  31018. serialize(): any;
  31019. /**
  31020. * Creates a standard material from parsed material data
  31021. * @param source defines the JSON representation of the material
  31022. * @param scene defines the hosting scene
  31023. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  31024. * @returns a new standard material
  31025. */
  31026. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  31027. /**
  31028. * Are diffuse textures enabled in the application.
  31029. */
  31030. static get DiffuseTextureEnabled(): boolean;
  31031. static set DiffuseTextureEnabled(value: boolean);
  31032. /**
  31033. * Are detail textures enabled in the application.
  31034. */
  31035. static get DetailTextureEnabled(): boolean;
  31036. static set DetailTextureEnabled(value: boolean);
  31037. /**
  31038. * Are ambient textures enabled in the application.
  31039. */
  31040. static get AmbientTextureEnabled(): boolean;
  31041. static set AmbientTextureEnabled(value: boolean);
  31042. /**
  31043. * Are opacity textures enabled in the application.
  31044. */
  31045. static get OpacityTextureEnabled(): boolean;
  31046. static set OpacityTextureEnabled(value: boolean);
  31047. /**
  31048. * Are reflection textures enabled in the application.
  31049. */
  31050. static get ReflectionTextureEnabled(): boolean;
  31051. static set ReflectionTextureEnabled(value: boolean);
  31052. /**
  31053. * Are emissive textures enabled in the application.
  31054. */
  31055. static get EmissiveTextureEnabled(): boolean;
  31056. static set EmissiveTextureEnabled(value: boolean);
  31057. /**
  31058. * Are specular textures enabled in the application.
  31059. */
  31060. static get SpecularTextureEnabled(): boolean;
  31061. static set SpecularTextureEnabled(value: boolean);
  31062. /**
  31063. * Are bump textures enabled in the application.
  31064. */
  31065. static get BumpTextureEnabled(): boolean;
  31066. static set BumpTextureEnabled(value: boolean);
  31067. /**
  31068. * Are lightmap textures enabled in the application.
  31069. */
  31070. static get LightmapTextureEnabled(): boolean;
  31071. static set LightmapTextureEnabled(value: boolean);
  31072. /**
  31073. * Are refraction textures enabled in the application.
  31074. */
  31075. static get RefractionTextureEnabled(): boolean;
  31076. static set RefractionTextureEnabled(value: boolean);
  31077. /**
  31078. * Are color grading textures enabled in the application.
  31079. */
  31080. static get ColorGradingTextureEnabled(): boolean;
  31081. static set ColorGradingTextureEnabled(value: boolean);
  31082. /**
  31083. * Are fresnels enabled in the application.
  31084. */
  31085. static get FresnelEnabled(): boolean;
  31086. static set FresnelEnabled(value: boolean);
  31087. }
  31088. }
  31089. declare module "babylonjs/Particles/solidParticleSystem" {
  31090. import { Nullable } from "babylonjs/types";
  31091. import { Mesh } from "babylonjs/Meshes/mesh";
  31092. import { Scene, IDisposable } from "babylonjs/scene";
  31093. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  31094. import { Material } from "babylonjs/Materials/material";
  31095. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31096. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31097. /**
  31098. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31099. *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.
  31100. * The SPS is also a particle system. It provides some methods to manage the particles.
  31101. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31102. *
  31103. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  31104. */
  31105. export class SolidParticleSystem implements IDisposable {
  31106. /**
  31107. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31108. * Example : var p = SPS.particles[i];
  31109. */
  31110. particles: SolidParticle[];
  31111. /**
  31112. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31113. */
  31114. nbParticles: number;
  31115. /**
  31116. * If the particles must ever face the camera (default false). Useful for planar particles.
  31117. */
  31118. billboard: boolean;
  31119. /**
  31120. * Recompute normals when adding a shape
  31121. */
  31122. recomputeNormals: boolean;
  31123. /**
  31124. * This a counter ofr your own usage. It's not set by any SPS functions.
  31125. */
  31126. counter: number;
  31127. /**
  31128. * The SPS name. This name is also given to the underlying mesh.
  31129. */
  31130. name: string;
  31131. /**
  31132. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31133. */
  31134. mesh: Mesh;
  31135. /**
  31136. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31137. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31138. */
  31139. vars: any;
  31140. /**
  31141. * This array is populated when the SPS is set as 'pickable'.
  31142. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31143. * Each element of this array is an object `{idx: int, faceId: int}`.
  31144. * `idx` is the picked particle index in the `SPS.particles` array
  31145. * `faceId` is the picked face index counted within this particle.
  31146. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31147. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31148. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31149. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31150. */
  31151. pickedParticles: {
  31152. idx: number;
  31153. faceId: number;
  31154. }[];
  31155. /**
  31156. * This array is populated when the SPS is set as 'pickable'
  31157. * Each key of this array is a submesh index.
  31158. * Each element of this array is a second array defined like this :
  31159. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31160. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31161. * `idx` is the picked particle index in the `SPS.particles` array
  31162. * `faceId` is the picked face index counted within this particle.
  31163. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31164. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31165. */
  31166. pickedBySubMesh: {
  31167. idx: number;
  31168. faceId: number;
  31169. }[][];
  31170. /**
  31171. * This array is populated when `enableDepthSort` is set to true.
  31172. * Each element of this array is an instance of the class DepthSortedParticle.
  31173. */
  31174. depthSortedParticles: DepthSortedParticle[];
  31175. /**
  31176. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31177. * @hidden
  31178. */
  31179. _bSphereOnly: boolean;
  31180. /**
  31181. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31182. * @hidden
  31183. */
  31184. _bSphereRadiusFactor: number;
  31185. private _scene;
  31186. private _positions;
  31187. private _indices;
  31188. private _normals;
  31189. private _colors;
  31190. private _uvs;
  31191. private _indices32;
  31192. private _positions32;
  31193. private _normals32;
  31194. private _fixedNormal32;
  31195. private _colors32;
  31196. private _uvs32;
  31197. private _index;
  31198. private _updatable;
  31199. private _pickable;
  31200. private _isVisibilityBoxLocked;
  31201. private _alwaysVisible;
  31202. private _depthSort;
  31203. private _expandable;
  31204. private _shapeCounter;
  31205. private _copy;
  31206. private _color;
  31207. private _computeParticleColor;
  31208. private _computeParticleTexture;
  31209. private _computeParticleRotation;
  31210. private _computeParticleVertex;
  31211. private _computeBoundingBox;
  31212. private _depthSortParticles;
  31213. private _camera;
  31214. private _mustUnrotateFixedNormals;
  31215. private _particlesIntersect;
  31216. private _needs32Bits;
  31217. private _isNotBuilt;
  31218. private _lastParticleId;
  31219. private _idxOfId;
  31220. private _multimaterialEnabled;
  31221. private _useModelMaterial;
  31222. private _indicesByMaterial;
  31223. private _materialIndexes;
  31224. private _depthSortFunction;
  31225. private _materialSortFunction;
  31226. private _materials;
  31227. private _multimaterial;
  31228. private _materialIndexesById;
  31229. private _defaultMaterial;
  31230. private _autoUpdateSubMeshes;
  31231. private _tmpVertex;
  31232. /**
  31233. * Creates a SPS (Solid Particle System) object.
  31234. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31235. * @param scene (Scene) is the scene in which the SPS is added.
  31236. * @param options defines the options of the sps e.g.
  31237. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31238. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31239. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31240. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  31241. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31242. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31243. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31244. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31245. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31246. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31247. */
  31248. constructor(name: string, scene: Scene, options?: {
  31249. updatable?: boolean;
  31250. isPickable?: boolean;
  31251. enableDepthSort?: boolean;
  31252. particleIntersection?: boolean;
  31253. boundingSphereOnly?: boolean;
  31254. bSphereRadiusFactor?: number;
  31255. expandable?: boolean;
  31256. useModelMaterial?: boolean;
  31257. enableMultiMaterial?: boolean;
  31258. });
  31259. /**
  31260. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31261. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31262. * @returns the created mesh
  31263. */
  31264. buildMesh(): Mesh;
  31265. /**
  31266. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31267. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31268. * Thus the particles generated from `digest()` have their property `position` set yet.
  31269. * @param mesh ( Mesh ) is the mesh to be digested
  31270. * @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
  31271. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31272. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31273. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31274. * @returns the current SPS
  31275. */
  31276. digest(mesh: Mesh, options?: {
  31277. facetNb?: number;
  31278. number?: number;
  31279. delta?: number;
  31280. storage?: [];
  31281. }): SolidParticleSystem;
  31282. /**
  31283. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31284. * @hidden
  31285. */
  31286. private _unrotateFixedNormals;
  31287. /**
  31288. * Resets the temporary working copy particle
  31289. * @hidden
  31290. */
  31291. private _resetCopy;
  31292. /**
  31293. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31294. * @param p the current index in the positions array to be updated
  31295. * @param ind the current index in the indices array
  31296. * @param shape a Vector3 array, the shape geometry
  31297. * @param positions the positions array to be updated
  31298. * @param meshInd the shape indices array
  31299. * @param indices the indices array to be updated
  31300. * @param meshUV the shape uv array
  31301. * @param uvs the uv array to be updated
  31302. * @param meshCol the shape color array
  31303. * @param colors the color array to be updated
  31304. * @param meshNor the shape normals array
  31305. * @param normals the normals array to be updated
  31306. * @param idx the particle index
  31307. * @param idxInShape the particle index in its shape
  31308. * @param options the addShape() method passed options
  31309. * @model the particle model
  31310. * @hidden
  31311. */
  31312. private _meshBuilder;
  31313. /**
  31314. * Returns a shape Vector3 array from positions float array
  31315. * @param positions float array
  31316. * @returns a vector3 array
  31317. * @hidden
  31318. */
  31319. private _posToShape;
  31320. /**
  31321. * Returns a shapeUV array from a float uvs (array deep copy)
  31322. * @param uvs as a float array
  31323. * @returns a shapeUV array
  31324. * @hidden
  31325. */
  31326. private _uvsToShapeUV;
  31327. /**
  31328. * Adds a new particle object in the particles array
  31329. * @param idx particle index in particles array
  31330. * @param id particle id
  31331. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31332. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31333. * @param model particle ModelShape object
  31334. * @param shapeId model shape identifier
  31335. * @param idxInShape index of the particle in the current model
  31336. * @param bInfo model bounding info object
  31337. * @param storage target storage array, if any
  31338. * @hidden
  31339. */
  31340. private _addParticle;
  31341. /**
  31342. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31343. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31344. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31345. * @param nb (positive integer) the number of particles to be created from this model
  31346. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31347. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31348. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31349. * @returns the number of shapes in the system
  31350. */
  31351. addShape(mesh: Mesh, nb: number, options?: {
  31352. positionFunction?: any;
  31353. vertexFunction?: any;
  31354. storage?: [];
  31355. }): number;
  31356. /**
  31357. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31358. * @hidden
  31359. */
  31360. private _rebuildParticle;
  31361. /**
  31362. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31363. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  31364. * @returns the SPS.
  31365. */
  31366. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31367. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31368. * Returns an array with the removed particles.
  31369. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  31370. * The SPS can't be empty so at least one particle needs to remain in place.
  31371. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31372. * @param start index of the first particle to remove
  31373. * @param end index of the last particle to remove (included)
  31374. * @returns an array populated with the removed particles
  31375. */
  31376. removeParticles(start: number, end: number): SolidParticle[];
  31377. /**
  31378. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31379. * @param solidParticleArray an array populated with Solid Particles objects
  31380. * @returns the SPS
  31381. */
  31382. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31383. /**
  31384. * Creates a new particle and modifies the SPS mesh geometry :
  31385. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31386. * - calls _addParticle() to populate the particle array
  31387. * factorized code from addShape() and insertParticlesFromArray()
  31388. * @param idx particle index in the particles array
  31389. * @param i particle index in its shape
  31390. * @param modelShape particle ModelShape object
  31391. * @param shape shape vertex array
  31392. * @param meshInd shape indices array
  31393. * @param meshUV shape uv array
  31394. * @param meshCol shape color array
  31395. * @param meshNor shape normals array
  31396. * @param bbInfo shape bounding info
  31397. * @param storage target particle storage
  31398. * @options addShape() passed options
  31399. * @hidden
  31400. */
  31401. private _insertNewParticle;
  31402. /**
  31403. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31404. * This method calls `updateParticle()` for each particle of the SPS.
  31405. * For an animated SPS, it is usually called within the render loop.
  31406. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  31407. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31408. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31409. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31410. * @returns the SPS.
  31411. */
  31412. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31413. /**
  31414. * Disposes the SPS.
  31415. */
  31416. dispose(): void;
  31417. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31418. * idx is the particle index in the SPS
  31419. * faceId is the picked face index counted within this particle.
  31420. * Returns null if the pickInfo can't identify a picked particle.
  31421. * @param pickingInfo (PickingInfo object)
  31422. * @returns {idx: number, faceId: number} or null
  31423. */
  31424. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31425. idx: number;
  31426. faceId: number;
  31427. }>;
  31428. /**
  31429. * Returns a SolidParticle object from its identifier : particle.id
  31430. * @param id (integer) the particle Id
  31431. * @returns the searched particle or null if not found in the SPS.
  31432. */
  31433. getParticleById(id: number): Nullable<SolidParticle>;
  31434. /**
  31435. * Returns a new array populated with the particles having the passed shapeId.
  31436. * @param shapeId (integer) the shape identifier
  31437. * @returns a new solid particle array
  31438. */
  31439. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31440. /**
  31441. * Populates the passed array "ref" with the particles having the passed shapeId.
  31442. * @param shapeId the shape identifier
  31443. * @returns the SPS
  31444. * @param ref
  31445. */
  31446. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31447. /**
  31448. * Computes the required SubMeshes according the materials assigned to the particles.
  31449. * @returns the solid particle system.
  31450. * Does nothing if called before the SPS mesh is built.
  31451. */
  31452. computeSubMeshes(): SolidParticleSystem;
  31453. /**
  31454. * Sorts the solid particles by material when MultiMaterial is enabled.
  31455. * Updates the indices32 array.
  31456. * Updates the indicesByMaterial array.
  31457. * Updates the mesh indices array.
  31458. * @returns the SPS
  31459. * @hidden
  31460. */
  31461. private _sortParticlesByMaterial;
  31462. /**
  31463. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31464. * @hidden
  31465. */
  31466. private _setMaterialIndexesById;
  31467. /**
  31468. * Returns an array with unique values of Materials from the passed array
  31469. * @param array the material array to be checked and filtered
  31470. * @hidden
  31471. */
  31472. private _filterUniqueMaterialId;
  31473. /**
  31474. * Sets a new Standard Material as _defaultMaterial if not already set.
  31475. * @hidden
  31476. */
  31477. private _setDefaultMaterial;
  31478. /**
  31479. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31480. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31481. * @returns the SPS.
  31482. */
  31483. refreshVisibleSize(): SolidParticleSystem;
  31484. /**
  31485. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31486. * @param size the size (float) of the visibility box
  31487. * note : this doesn't lock the SPS mesh bounding box.
  31488. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31489. */
  31490. setVisibilityBox(size: number): void;
  31491. /**
  31492. * Gets whether the SPS as always visible or not
  31493. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31494. */
  31495. get isAlwaysVisible(): boolean;
  31496. /**
  31497. * Sets the SPS as always visible or not
  31498. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31499. */
  31500. set isAlwaysVisible(val: boolean);
  31501. /**
  31502. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31503. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31504. */
  31505. set isVisibilityBoxLocked(val: boolean);
  31506. /**
  31507. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31508. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31509. */
  31510. get isVisibilityBoxLocked(): boolean;
  31511. /**
  31512. * Tells to `setParticles()` to compute the particle rotations or not.
  31513. * Default value : true. The SPS is faster when it's set to false.
  31514. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31515. */
  31516. set computeParticleRotation(val: boolean);
  31517. /**
  31518. * Tells to `setParticles()` to compute the particle colors or not.
  31519. * Default value : true. The SPS is faster when it's set to false.
  31520. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31521. */
  31522. set computeParticleColor(val: boolean);
  31523. set computeParticleTexture(val: boolean);
  31524. /**
  31525. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31526. * Default value : false. The SPS is faster when it's set to false.
  31527. * Note : the particle custom vertex positions aren't stored values.
  31528. */
  31529. set computeParticleVertex(val: boolean);
  31530. /**
  31531. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31532. */
  31533. set computeBoundingBox(val: boolean);
  31534. /**
  31535. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31536. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31537. * Default : `true`
  31538. */
  31539. set depthSortParticles(val: boolean);
  31540. /**
  31541. * Gets if `setParticles()` computes the particle rotations or not.
  31542. * Default value : true. The SPS is faster when it's set to false.
  31543. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31544. */
  31545. get computeParticleRotation(): boolean;
  31546. /**
  31547. * Gets if `setParticles()` computes the particle colors or not.
  31548. * Default value : true. The SPS is faster when it's set to false.
  31549. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31550. */
  31551. get computeParticleColor(): boolean;
  31552. /**
  31553. * Gets if `setParticles()` computes the particle textures or not.
  31554. * Default value : true. The SPS is faster when it's set to false.
  31555. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31556. */
  31557. get computeParticleTexture(): boolean;
  31558. /**
  31559. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31560. * Default value : false. The SPS is faster when it's set to false.
  31561. * Note : the particle custom vertex positions aren't stored values.
  31562. */
  31563. get computeParticleVertex(): boolean;
  31564. /**
  31565. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31566. */
  31567. get computeBoundingBox(): boolean;
  31568. /**
  31569. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31570. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31571. * Default : `true`
  31572. */
  31573. get depthSortParticles(): boolean;
  31574. /**
  31575. * Gets if the SPS is created as expandable at construction time.
  31576. * Default : `false`
  31577. */
  31578. get expandable(): boolean;
  31579. /**
  31580. * Gets if the SPS supports the Multi Materials
  31581. */
  31582. get multimaterialEnabled(): boolean;
  31583. /**
  31584. * Gets if the SPS uses the model materials for its own multimaterial.
  31585. */
  31586. get useModelMaterial(): boolean;
  31587. /**
  31588. * The SPS used material array.
  31589. */
  31590. get materials(): Material[];
  31591. /**
  31592. * Sets the SPS MultiMaterial from the passed materials.
  31593. * Note : the passed array is internally copied and not used then by reference.
  31594. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31595. */
  31596. setMultiMaterial(materials: Material[]): void;
  31597. /**
  31598. * The SPS computed multimaterial object
  31599. */
  31600. get multimaterial(): MultiMaterial;
  31601. set multimaterial(mm: MultiMaterial);
  31602. /**
  31603. * If the subMeshes must be updated on the next call to setParticles()
  31604. */
  31605. get autoUpdateSubMeshes(): boolean;
  31606. set autoUpdateSubMeshes(val: boolean);
  31607. /**
  31608. * This function does nothing. It may be overwritten to set all the particle first values.
  31609. * The SPS doesn't call this function, you may have to call it by your own.
  31610. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31611. */
  31612. initParticles(): void;
  31613. /**
  31614. * This function does nothing. It may be overwritten to recycle a particle.
  31615. * The SPS doesn't call this function, you may have to call it by your own.
  31616. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31617. * @param particle The particle to recycle
  31618. * @returns the recycled particle
  31619. */
  31620. recycleParticle(particle: SolidParticle): SolidParticle;
  31621. /**
  31622. * Updates a particle : this function should be overwritten by the user.
  31623. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31624. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31625. * @example : just set a particle position or velocity and recycle conditions
  31626. * @param particle The particle to update
  31627. * @returns the updated particle
  31628. */
  31629. updateParticle(particle: SolidParticle): SolidParticle;
  31630. /**
  31631. * Updates a vertex of a particle : it can be overwritten by the user.
  31632. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31633. * @param particle the current particle
  31634. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31635. * @param pt the index of the current vertex in the particle shape
  31636. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31637. * @example : just set a vertex particle position or color
  31638. * @returns the sps
  31639. */
  31640. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31641. /**
  31642. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31643. * This does nothing and may be overwritten by the user.
  31644. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31645. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31646. * @param update the boolean update value actually passed to setParticles()
  31647. */
  31648. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31649. /**
  31650. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31651. * This will be passed three parameters.
  31652. * This does nothing and may be overwritten by the user.
  31653. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31654. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31655. * @param update the boolean update value actually passed to setParticles()
  31656. */
  31657. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31658. }
  31659. }
  31660. declare module "babylonjs/Particles/solidParticle" {
  31661. import { Nullable } from "babylonjs/types";
  31662. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  31663. import { Color4 } from "babylonjs/Maths/math.color";
  31664. import { Mesh } from "babylonjs/Meshes/mesh";
  31665. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31666. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  31667. import { Plane } from "babylonjs/Maths/math.plane";
  31668. import { Material } from "babylonjs/Materials/material";
  31669. /**
  31670. * Represents one particle of a solid particle system.
  31671. */
  31672. export class SolidParticle {
  31673. /**
  31674. * particle global index
  31675. */
  31676. idx: number;
  31677. /**
  31678. * particle identifier
  31679. */
  31680. id: number;
  31681. /**
  31682. * The color of the particle
  31683. */
  31684. color: Nullable<Color4>;
  31685. /**
  31686. * The world space position of the particle.
  31687. */
  31688. position: Vector3;
  31689. /**
  31690. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31691. */
  31692. rotation: Vector3;
  31693. /**
  31694. * The world space rotation quaternion of the particle.
  31695. */
  31696. rotationQuaternion: Nullable<Quaternion>;
  31697. /**
  31698. * The scaling of the particle.
  31699. */
  31700. scaling: Vector3;
  31701. /**
  31702. * The uvs of the particle.
  31703. */
  31704. uvs: Vector4;
  31705. /**
  31706. * The current speed of the particle.
  31707. */
  31708. velocity: Vector3;
  31709. /**
  31710. * The pivot point in the particle local space.
  31711. */
  31712. pivot: Vector3;
  31713. /**
  31714. * Must the particle be translated from its pivot point in its local space ?
  31715. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31716. * Default : false
  31717. */
  31718. translateFromPivot: boolean;
  31719. /**
  31720. * Is the particle active or not ?
  31721. */
  31722. alive: boolean;
  31723. /**
  31724. * Is the particle visible or not ?
  31725. */
  31726. isVisible: boolean;
  31727. /**
  31728. * Index of this particle in the global "positions" array (Internal use)
  31729. * @hidden
  31730. */
  31731. _pos: number;
  31732. /**
  31733. * @hidden Index of this particle in the global "indices" array (Internal use)
  31734. */
  31735. _ind: number;
  31736. /**
  31737. * @hidden ModelShape of this particle (Internal use)
  31738. */
  31739. _model: ModelShape;
  31740. /**
  31741. * ModelShape id of this particle
  31742. */
  31743. shapeId: number;
  31744. /**
  31745. * Index of the particle in its shape id
  31746. */
  31747. idxInShape: number;
  31748. /**
  31749. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31750. */
  31751. _modelBoundingInfo: BoundingInfo;
  31752. /**
  31753. * @hidden Particle BoundingInfo object (Internal use)
  31754. */
  31755. _boundingInfo: BoundingInfo;
  31756. /**
  31757. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31758. */
  31759. _sps: SolidParticleSystem;
  31760. /**
  31761. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31762. */
  31763. _stillInvisible: boolean;
  31764. /**
  31765. * @hidden Last computed particle rotation matrix
  31766. */
  31767. _rotationMatrix: number[];
  31768. /**
  31769. * Parent particle Id, if any.
  31770. * Default null.
  31771. */
  31772. parentId: Nullable<number>;
  31773. /**
  31774. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31775. */
  31776. materialIndex: Nullable<number>;
  31777. /**
  31778. * Custom object or properties.
  31779. */
  31780. props: Nullable<any>;
  31781. /**
  31782. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31783. * The possible values are :
  31784. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31785. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31786. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31787. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31788. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31789. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31790. * */
  31791. cullingStrategy: number;
  31792. /**
  31793. * @hidden Internal global position in the SPS.
  31794. */
  31795. _globalPosition: Vector3;
  31796. /**
  31797. * Creates a Solid Particle object.
  31798. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31799. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31800. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31801. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31802. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31803. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31804. * @param shapeId (integer) is the model shape identifier in the SPS.
  31805. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31806. * @param sps defines the sps it is associated to
  31807. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31808. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31809. */
  31810. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31811. /**
  31812. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31813. * @param target the particle target
  31814. * @returns the current particle
  31815. */
  31816. copyToRef(target: SolidParticle): SolidParticle;
  31817. /**
  31818. * Legacy support, changed scale to scaling
  31819. */
  31820. get scale(): Vector3;
  31821. /**
  31822. * Legacy support, changed scale to scaling
  31823. */
  31824. set scale(scale: Vector3);
  31825. /**
  31826. * Legacy support, changed quaternion to rotationQuaternion
  31827. */
  31828. get quaternion(): Nullable<Quaternion>;
  31829. /**
  31830. * Legacy support, changed quaternion to rotationQuaternion
  31831. */
  31832. set quaternion(q: Nullable<Quaternion>);
  31833. /**
  31834. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31835. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31836. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31837. * @returns true if it intersects
  31838. */
  31839. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31840. /**
  31841. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31842. * A particle is in the frustum if its bounding box intersects the frustum
  31843. * @param frustumPlanes defines the frustum to test
  31844. * @returns true if the particle is in the frustum planes
  31845. */
  31846. isInFrustum(frustumPlanes: Plane[]): boolean;
  31847. /**
  31848. * get the rotation matrix of the particle
  31849. * @hidden
  31850. */
  31851. getRotationMatrix(m: Matrix): void;
  31852. }
  31853. /**
  31854. * Represents the shape of the model used by one particle of a solid particle system.
  31855. * SPS internal tool, don't use it manually.
  31856. */
  31857. export class ModelShape {
  31858. /**
  31859. * The shape id
  31860. * @hidden
  31861. */
  31862. shapeID: number;
  31863. /**
  31864. * flat array of model positions (internal use)
  31865. * @hidden
  31866. */
  31867. _shape: Vector3[];
  31868. /**
  31869. * flat array of model UVs (internal use)
  31870. * @hidden
  31871. */
  31872. _shapeUV: number[];
  31873. /**
  31874. * color array of the model
  31875. * @hidden
  31876. */
  31877. _shapeColors: number[];
  31878. /**
  31879. * indices array of the model
  31880. * @hidden
  31881. */
  31882. _indices: number[];
  31883. /**
  31884. * normals array of the model
  31885. * @hidden
  31886. */
  31887. _normals: number[];
  31888. /**
  31889. * length of the shape in the model indices array (internal use)
  31890. * @hidden
  31891. */
  31892. _indicesLength: number;
  31893. /**
  31894. * Custom position function (internal use)
  31895. * @hidden
  31896. */
  31897. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31898. /**
  31899. * Custom vertex function (internal use)
  31900. * @hidden
  31901. */
  31902. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31903. /**
  31904. * Model material (internal use)
  31905. * @hidden
  31906. */
  31907. _material: Nullable<Material>;
  31908. /**
  31909. * 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.
  31910. * SPS internal tool, don't use it manually.
  31911. * @hidden
  31912. */
  31913. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  31914. }
  31915. /**
  31916. * Represents a Depth Sorted Particle in the solid particle system.
  31917. * @hidden
  31918. */
  31919. export class DepthSortedParticle {
  31920. /**
  31921. * Particle index
  31922. */
  31923. idx: number;
  31924. /**
  31925. * Index of the particle in the "indices" array
  31926. */
  31927. ind: number;
  31928. /**
  31929. * Length of the particle shape in the "indices" array
  31930. */
  31931. indicesLength: number;
  31932. /**
  31933. * Squared distance from the particle to the camera
  31934. */
  31935. sqDistance: number;
  31936. /**
  31937. * Material index when used with MultiMaterials
  31938. */
  31939. materialIndex: number;
  31940. /**
  31941. * Creates a new sorted particle
  31942. * @param materialIndex
  31943. */
  31944. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31945. }
  31946. /**
  31947. * Represents a solid particle vertex
  31948. */
  31949. export class SolidParticleVertex {
  31950. /**
  31951. * Vertex position
  31952. */
  31953. position: Vector3;
  31954. /**
  31955. * Vertex color
  31956. */
  31957. color: Color4;
  31958. /**
  31959. * Vertex UV
  31960. */
  31961. uv: Vector2;
  31962. /**
  31963. * Creates a new solid particle vertex
  31964. */
  31965. constructor();
  31966. /** Vertex x coordinate */
  31967. get x(): number;
  31968. set x(val: number);
  31969. /** Vertex y coordinate */
  31970. get y(): number;
  31971. set y(val: number);
  31972. /** Vertex z coordinate */
  31973. get z(): number;
  31974. set z(val: number);
  31975. }
  31976. }
  31977. declare module "babylonjs/Collisions/meshCollisionData" {
  31978. import { Collider } from "babylonjs/Collisions/collider";
  31979. import { Vector3 } from "babylonjs/Maths/math.vector";
  31980. import { Nullable } from "babylonjs/types";
  31981. import { Observer } from "babylonjs/Misc/observable";
  31982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31983. /**
  31984. * @hidden
  31985. */
  31986. export class _MeshCollisionData {
  31987. _checkCollisions: boolean;
  31988. _collisionMask: number;
  31989. _collisionGroup: number;
  31990. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31991. _collider: Nullable<Collider>;
  31992. _oldPositionForCollisions: Vector3;
  31993. _diffPositionForCollisions: Vector3;
  31994. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31995. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31996. }
  31997. }
  31998. declare module "babylonjs/Meshes/abstractMesh" {
  31999. import { Observable } from "babylonjs/Misc/observable";
  32000. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  32001. import { Camera } from "babylonjs/Cameras/camera";
  32002. import { Scene, IDisposable } from "babylonjs/scene";
  32003. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  32004. import { Node } from "babylonjs/node";
  32005. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  32006. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32007. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32008. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32009. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32010. import { Material } from "babylonjs/Materials/material";
  32011. import { Light } from "babylonjs/Lights/light";
  32012. import { Skeleton } from "babylonjs/Bones/skeleton";
  32013. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  32014. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  32015. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32016. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  32017. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  32018. import { Plane } from "babylonjs/Maths/math.plane";
  32019. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32020. import { Ray } from "babylonjs/Culling/ray";
  32021. import { Collider } from "babylonjs/Collisions/collider";
  32022. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32023. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  32024. /** @hidden */
  32025. class _FacetDataStorage {
  32026. facetPositions: Vector3[];
  32027. facetNormals: Vector3[];
  32028. facetPartitioning: number[][];
  32029. facetNb: number;
  32030. partitioningSubdivisions: number;
  32031. partitioningBBoxRatio: number;
  32032. facetDataEnabled: boolean;
  32033. facetParameters: any;
  32034. bbSize: Vector3;
  32035. subDiv: {
  32036. max: number;
  32037. X: number;
  32038. Y: number;
  32039. Z: number;
  32040. };
  32041. facetDepthSort: boolean;
  32042. facetDepthSortEnabled: boolean;
  32043. depthSortedIndices: IndicesArray;
  32044. depthSortedFacets: {
  32045. ind: number;
  32046. sqDistance: number;
  32047. }[];
  32048. facetDepthSortFunction: (f1: {
  32049. ind: number;
  32050. sqDistance: number;
  32051. }, f2: {
  32052. ind: number;
  32053. sqDistance: number;
  32054. }) => number;
  32055. facetDepthSortFrom: Vector3;
  32056. facetDepthSortOrigin: Vector3;
  32057. invertedMatrix: Matrix;
  32058. }
  32059. /**
  32060. * @hidden
  32061. **/
  32062. class _InternalAbstractMeshDataInfo {
  32063. _hasVertexAlpha: boolean;
  32064. _useVertexColors: boolean;
  32065. _numBoneInfluencers: number;
  32066. _applyFog: boolean;
  32067. _receiveShadows: boolean;
  32068. _facetData: _FacetDataStorage;
  32069. _visibility: number;
  32070. _skeleton: Nullable<Skeleton>;
  32071. _layerMask: number;
  32072. _computeBonesUsingShaders: boolean;
  32073. _isActive: boolean;
  32074. _onlyForInstances: boolean;
  32075. _isActiveIntermediate: boolean;
  32076. _onlyForInstancesIntermediate: boolean;
  32077. _actAsRegularMesh: boolean;
  32078. }
  32079. /**
  32080. * Class used to store all common mesh properties
  32081. */
  32082. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  32083. /** No occlusion */
  32084. static OCCLUSION_TYPE_NONE: number;
  32085. /** Occlusion set to optimisitic */
  32086. static OCCLUSION_TYPE_OPTIMISTIC: number;
  32087. /** Occlusion set to strict */
  32088. static OCCLUSION_TYPE_STRICT: number;
  32089. /** Use an accurante occlusion algorithm */
  32090. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  32091. /** Use a conservative occlusion algorithm */
  32092. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  32093. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  32094. * Test order :
  32095. * Is the bounding sphere outside the frustum ?
  32096. * If not, are the bounding box vertices outside the frustum ?
  32097. * It not, then the cullable object is in the frustum.
  32098. */
  32099. static readonly CULLINGSTRATEGY_STANDARD: number;
  32100. /** Culling strategy : Bounding Sphere Only.
  32101. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  32102. * It's also less accurate than the standard because some not visible objects can still be selected.
  32103. * Test : is the bounding sphere outside the frustum ?
  32104. * If not, then the cullable object is in the frustum.
  32105. */
  32106. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  32107. /** Culling strategy : Optimistic Inclusion.
  32108. * This in an inclusion test first, then the standard exclusion test.
  32109. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  32110. * 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.
  32111. * Anyway, it's as accurate as the standard strategy.
  32112. * Test :
  32113. * Is the cullable object bounding sphere center in the frustum ?
  32114. * If not, apply the default culling strategy.
  32115. */
  32116. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  32117. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  32118. * This in an inclusion test first, then the bounding sphere only exclusion test.
  32119. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  32120. * 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.
  32121. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  32122. * Test :
  32123. * Is the cullable object bounding sphere center in the frustum ?
  32124. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  32125. */
  32126. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  32127. /**
  32128. * No billboard
  32129. */
  32130. static get BILLBOARDMODE_NONE(): number;
  32131. /** Billboard on X axis */
  32132. static get BILLBOARDMODE_X(): number;
  32133. /** Billboard on Y axis */
  32134. static get BILLBOARDMODE_Y(): number;
  32135. /** Billboard on Z axis */
  32136. static get BILLBOARDMODE_Z(): number;
  32137. /** Billboard on all axes */
  32138. static get BILLBOARDMODE_ALL(): number;
  32139. /** Billboard on using position instead of orientation */
  32140. static get BILLBOARDMODE_USE_POSITION(): number;
  32141. /** @hidden */
  32142. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32143. /**
  32144. * The culling strategy to use to check whether the mesh must be rendered or not.
  32145. * This value can be changed at any time and will be used on the next render mesh selection.
  32146. * The possible values are :
  32147. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32148. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32149. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32150. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32151. * Please read each static variable documentation to get details about the culling process.
  32152. * */
  32153. cullingStrategy: number;
  32154. /**
  32155. * Gets the number of facets in the mesh
  32156. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32157. */
  32158. get facetNb(): number;
  32159. /**
  32160. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32161. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32162. */
  32163. get partitioningSubdivisions(): number;
  32164. set partitioningSubdivisions(nb: number);
  32165. /**
  32166. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32167. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32168. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32169. */
  32170. get partitioningBBoxRatio(): number;
  32171. set partitioningBBoxRatio(ratio: number);
  32172. /**
  32173. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32174. * Works only for updatable meshes.
  32175. * Doesn't work with multi-materials
  32176. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32177. */
  32178. get mustDepthSortFacets(): boolean;
  32179. set mustDepthSortFacets(sort: boolean);
  32180. /**
  32181. * The location (Vector3) where the facet depth sort must be computed from.
  32182. * By default, the active camera position.
  32183. * Used only when facet depth sort is enabled
  32184. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32185. */
  32186. get facetDepthSortFrom(): Vector3;
  32187. set facetDepthSortFrom(location: Vector3);
  32188. /**
  32189. * gets a boolean indicating if facetData is enabled
  32190. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32191. */
  32192. get isFacetDataEnabled(): boolean;
  32193. /** @hidden */
  32194. _updateNonUniformScalingState(value: boolean): boolean;
  32195. /**
  32196. * An event triggered when this mesh collides with another one
  32197. */
  32198. onCollideObservable: Observable<AbstractMesh>;
  32199. /** Set a function to call when this mesh collides with another one */
  32200. set onCollide(callback: () => void);
  32201. /**
  32202. * An event triggered when the collision's position changes
  32203. */
  32204. onCollisionPositionChangeObservable: Observable<Vector3>;
  32205. /** Set a function to call when the collision's position changes */
  32206. set onCollisionPositionChange(callback: () => void);
  32207. /**
  32208. * An event triggered when material is changed
  32209. */
  32210. onMaterialChangedObservable: Observable<AbstractMesh>;
  32211. /**
  32212. * Gets or sets the orientation for POV movement & rotation
  32213. */
  32214. definedFacingForward: boolean;
  32215. /** @hidden */
  32216. _occlusionQuery: Nullable<WebGLQuery>;
  32217. /** @hidden */
  32218. _renderingGroup: Nullable<RenderingGroup>;
  32219. /**
  32220. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32221. */
  32222. get visibility(): number;
  32223. /**
  32224. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32225. */
  32226. set visibility(value: number);
  32227. /** Gets or sets the alpha index used to sort transparent meshes
  32228. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32229. */
  32230. alphaIndex: number;
  32231. /**
  32232. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32233. */
  32234. isVisible: boolean;
  32235. /**
  32236. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32237. */
  32238. isPickable: boolean;
  32239. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32240. showSubMeshesBoundingBox: boolean;
  32241. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32242. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32243. */
  32244. isBlocker: boolean;
  32245. /**
  32246. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32247. */
  32248. enablePointerMoveEvents: boolean;
  32249. /**
  32250. * Specifies the rendering group id for this mesh (0 by default)
  32251. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32252. */
  32253. renderingGroupId: number;
  32254. private _material;
  32255. /** Gets or sets current material */
  32256. get material(): Nullable<Material>;
  32257. set material(value: Nullable<Material>);
  32258. /**
  32259. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32260. * @see https://doc.babylonjs.com/babylon101/shadows
  32261. */
  32262. get receiveShadows(): boolean;
  32263. set receiveShadows(value: boolean);
  32264. /** Defines color to use when rendering outline */
  32265. outlineColor: Color3;
  32266. /** Define width to use when rendering outline */
  32267. outlineWidth: number;
  32268. /** Defines color to use when rendering overlay */
  32269. overlayColor: Color3;
  32270. /** Defines alpha to use when rendering overlay */
  32271. overlayAlpha: number;
  32272. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32273. get hasVertexAlpha(): boolean;
  32274. set hasVertexAlpha(value: boolean);
  32275. /** 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) */
  32276. get useVertexColors(): boolean;
  32277. set useVertexColors(value: boolean);
  32278. /**
  32279. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32280. */
  32281. get computeBonesUsingShaders(): boolean;
  32282. set computeBonesUsingShaders(value: boolean);
  32283. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32284. get numBoneInfluencers(): number;
  32285. set numBoneInfluencers(value: number);
  32286. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32287. get applyFog(): boolean;
  32288. set applyFog(value: boolean);
  32289. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32290. useOctreeForRenderingSelection: boolean;
  32291. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32292. useOctreeForPicking: boolean;
  32293. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32294. useOctreeForCollisions: boolean;
  32295. /**
  32296. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32297. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32298. */
  32299. get layerMask(): number;
  32300. set layerMask(value: number);
  32301. /**
  32302. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32303. */
  32304. alwaysSelectAsActiveMesh: boolean;
  32305. /**
  32306. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32307. */
  32308. doNotSyncBoundingInfo: boolean;
  32309. /**
  32310. * Gets or sets the current action manager
  32311. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32312. */
  32313. actionManager: Nullable<AbstractActionManager>;
  32314. private _meshCollisionData;
  32315. /**
  32316. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32317. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32318. */
  32319. ellipsoid: Vector3;
  32320. /**
  32321. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32322. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32323. */
  32324. ellipsoidOffset: Vector3;
  32325. /**
  32326. * Gets or sets a collision mask used to mask collisions (default is -1).
  32327. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32328. */
  32329. get collisionMask(): number;
  32330. set collisionMask(mask: number);
  32331. /**
  32332. * Gets or sets the current collision group mask (-1 by default).
  32333. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32334. */
  32335. get collisionGroup(): number;
  32336. set collisionGroup(mask: number);
  32337. /**
  32338. * Gets or sets current surrounding meshes (null by default).
  32339. *
  32340. * By default collision detection is tested against every mesh in the scene.
  32341. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32342. * meshes will be tested for the collision.
  32343. *
  32344. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32345. */
  32346. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32347. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32348. /**
  32349. * Defines edge width used when edgesRenderer is enabled
  32350. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32351. */
  32352. edgesWidth: number;
  32353. /**
  32354. * Defines edge color used when edgesRenderer is enabled
  32355. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32356. */
  32357. edgesColor: Color4;
  32358. /** @hidden */
  32359. _edgesRenderer: Nullable<IEdgesRenderer>;
  32360. /** @hidden */
  32361. _masterMesh: Nullable<AbstractMesh>;
  32362. /** @hidden */
  32363. _boundingInfo: Nullable<BoundingInfo>;
  32364. /** @hidden */
  32365. _renderId: number;
  32366. /**
  32367. * Gets or sets the list of subMeshes
  32368. * @see https://doc.babylonjs.com/how_to/multi_materials
  32369. */
  32370. subMeshes: SubMesh[];
  32371. /** @hidden */
  32372. _intersectionsInProgress: AbstractMesh[];
  32373. /** @hidden */
  32374. _unIndexed: boolean;
  32375. /** @hidden */
  32376. _lightSources: Light[];
  32377. /** Gets the list of lights affecting that mesh */
  32378. get lightSources(): Light[];
  32379. /** @hidden */
  32380. get _positions(): Nullable<Vector3[]>;
  32381. /** @hidden */
  32382. _waitingData: {
  32383. lods: Nullable<any>;
  32384. actions: Nullable<any>;
  32385. freezeWorldMatrix: Nullable<boolean>;
  32386. };
  32387. /** @hidden */
  32388. _bonesTransformMatrices: Nullable<Float32Array>;
  32389. /** @hidden */
  32390. _transformMatrixTexture: Nullable<RawTexture>;
  32391. /**
  32392. * Gets or sets a skeleton to apply skining transformations
  32393. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32394. */
  32395. set skeleton(value: Nullable<Skeleton>);
  32396. get skeleton(): Nullable<Skeleton>;
  32397. /**
  32398. * An event triggered when the mesh is rebuilt.
  32399. */
  32400. onRebuildObservable: Observable<AbstractMesh>;
  32401. /**
  32402. * Creates a new AbstractMesh
  32403. * @param name defines the name of the mesh
  32404. * @param scene defines the hosting scene
  32405. */
  32406. constructor(name: string, scene?: Nullable<Scene>);
  32407. /**
  32408. * Returns the string "AbstractMesh"
  32409. * @returns "AbstractMesh"
  32410. */
  32411. getClassName(): string;
  32412. /**
  32413. * Gets a string representation of the current mesh
  32414. * @param fullDetails defines a boolean indicating if full details must be included
  32415. * @returns a string representation of the current mesh
  32416. */
  32417. toString(fullDetails?: boolean): string;
  32418. /**
  32419. * @hidden
  32420. */
  32421. protected _getEffectiveParent(): Nullable<Node>;
  32422. /** @hidden */
  32423. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32424. /** @hidden */
  32425. _rebuild(): void;
  32426. /** @hidden */
  32427. _resyncLightSources(): void;
  32428. /** @hidden */
  32429. _resyncLightSource(light: Light): void;
  32430. /** @hidden */
  32431. _unBindEffect(): void;
  32432. /** @hidden */
  32433. _removeLightSource(light: Light, dispose: boolean): void;
  32434. private _markSubMeshesAsDirty;
  32435. /** @hidden */
  32436. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32437. /** @hidden */
  32438. _markSubMeshesAsAttributesDirty(): void;
  32439. /** @hidden */
  32440. _markSubMeshesAsMiscDirty(): void;
  32441. /**
  32442. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32443. */
  32444. get scaling(): Vector3;
  32445. set scaling(newScaling: Vector3);
  32446. /**
  32447. * Returns true if the mesh is blocked. Implemented by child classes
  32448. */
  32449. get isBlocked(): boolean;
  32450. /**
  32451. * Returns the mesh itself by default. Implemented by child classes
  32452. * @param camera defines the camera to use to pick the right LOD level
  32453. * @returns the currentAbstractMesh
  32454. */
  32455. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32456. /**
  32457. * Returns 0 by default. Implemented by child classes
  32458. * @returns an integer
  32459. */
  32460. getTotalVertices(): number;
  32461. /**
  32462. * Returns a positive integer : the total number of indices in this mesh geometry.
  32463. * @returns the numner of indices or zero if the mesh has no geometry.
  32464. */
  32465. getTotalIndices(): number;
  32466. /**
  32467. * Returns null by default. Implemented by child classes
  32468. * @returns null
  32469. */
  32470. getIndices(): Nullable<IndicesArray>;
  32471. /**
  32472. * Returns the array of the requested vertex data kind. Implemented by child classes
  32473. * @param kind defines the vertex data kind to use
  32474. * @returns null
  32475. */
  32476. getVerticesData(kind: string): Nullable<FloatArray>;
  32477. /**
  32478. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32479. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32480. * Note that a new underlying VertexBuffer object is created each call.
  32481. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32482. * @param kind defines vertex data kind:
  32483. * * VertexBuffer.PositionKind
  32484. * * VertexBuffer.UVKind
  32485. * * VertexBuffer.UV2Kind
  32486. * * VertexBuffer.UV3Kind
  32487. * * VertexBuffer.UV4Kind
  32488. * * VertexBuffer.UV5Kind
  32489. * * VertexBuffer.UV6Kind
  32490. * * VertexBuffer.ColorKind
  32491. * * VertexBuffer.MatricesIndicesKind
  32492. * * VertexBuffer.MatricesIndicesExtraKind
  32493. * * VertexBuffer.MatricesWeightsKind
  32494. * * VertexBuffer.MatricesWeightsExtraKind
  32495. * @param data defines the data source
  32496. * @param updatable defines if the data must be flagged as updatable (or static)
  32497. * @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
  32498. * @returns the current mesh
  32499. */
  32500. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32501. /**
  32502. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32503. * If the mesh has no geometry, it is simply returned as it is.
  32504. * @param kind defines vertex data kind:
  32505. * * VertexBuffer.PositionKind
  32506. * * VertexBuffer.UVKind
  32507. * * VertexBuffer.UV2Kind
  32508. * * VertexBuffer.UV3Kind
  32509. * * VertexBuffer.UV4Kind
  32510. * * VertexBuffer.UV5Kind
  32511. * * VertexBuffer.UV6Kind
  32512. * * VertexBuffer.ColorKind
  32513. * * VertexBuffer.MatricesIndicesKind
  32514. * * VertexBuffer.MatricesIndicesExtraKind
  32515. * * VertexBuffer.MatricesWeightsKind
  32516. * * VertexBuffer.MatricesWeightsExtraKind
  32517. * @param data defines the data source
  32518. * @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
  32519. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32520. * @returns the current mesh
  32521. */
  32522. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32523. /**
  32524. * Sets the mesh indices,
  32525. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32526. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32527. * @param totalVertices Defines the total number of vertices
  32528. * @returns the current mesh
  32529. */
  32530. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32531. /**
  32532. * Gets a boolean indicating if specific vertex data is present
  32533. * @param kind defines the vertex data kind to use
  32534. * @returns true is data kind is present
  32535. */
  32536. isVerticesDataPresent(kind: string): boolean;
  32537. /**
  32538. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32539. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32540. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32541. * @returns a BoundingInfo
  32542. */
  32543. getBoundingInfo(): BoundingInfo;
  32544. /**
  32545. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32546. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32547. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32548. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32549. * @returns the current mesh
  32550. */
  32551. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32552. /**
  32553. * Overwrite the current bounding info
  32554. * @param boundingInfo defines the new bounding info
  32555. * @returns the current mesh
  32556. */
  32557. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32558. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32559. get useBones(): boolean;
  32560. /** @hidden */
  32561. _preActivate(): void;
  32562. /** @hidden */
  32563. _preActivateForIntermediateRendering(renderId: number): void;
  32564. /** @hidden */
  32565. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32566. /** @hidden */
  32567. _postActivate(): void;
  32568. /** @hidden */
  32569. _freeze(): void;
  32570. /** @hidden */
  32571. _unFreeze(): void;
  32572. /**
  32573. * Gets the current world matrix
  32574. * @returns a Matrix
  32575. */
  32576. getWorldMatrix(): Matrix;
  32577. /** @hidden */
  32578. _getWorldMatrixDeterminant(): number;
  32579. /**
  32580. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32581. */
  32582. get isAnInstance(): boolean;
  32583. /**
  32584. * Gets a boolean indicating if this mesh has instances
  32585. */
  32586. get hasInstances(): boolean;
  32587. /**
  32588. * Gets a boolean indicating if this mesh has thin instances
  32589. */
  32590. get hasThinInstances(): boolean;
  32591. /**
  32592. * Perform relative position change from the point of view of behind the front of the mesh.
  32593. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32594. * Supports definition of mesh facing forward or backward
  32595. * @param amountRight defines the distance on the right axis
  32596. * @param amountUp defines the distance on the up axis
  32597. * @param amountForward defines the distance on the forward axis
  32598. * @returns the current mesh
  32599. */
  32600. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32601. /**
  32602. * Calculate relative position change from the point of view of behind the front of the mesh.
  32603. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32604. * Supports definition of mesh facing forward or backward
  32605. * @param amountRight defines the distance on the right axis
  32606. * @param amountUp defines the distance on the up axis
  32607. * @param amountForward defines the distance on the forward axis
  32608. * @returns the new displacement vector
  32609. */
  32610. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32611. /**
  32612. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32613. * Supports definition of mesh facing forward or backward
  32614. * @param flipBack defines the flip
  32615. * @param twirlClockwise defines the twirl
  32616. * @param tiltRight defines the tilt
  32617. * @returns the current mesh
  32618. */
  32619. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32620. /**
  32621. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32622. * Supports definition of mesh facing forward or backward.
  32623. * @param flipBack defines the flip
  32624. * @param twirlClockwise defines the twirl
  32625. * @param tiltRight defines the tilt
  32626. * @returns the new rotation vector
  32627. */
  32628. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32629. /**
  32630. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32631. * This means the mesh underlying bounding box and sphere are recomputed.
  32632. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32633. * @returns the current mesh
  32634. */
  32635. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32636. /** @hidden */
  32637. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32638. /** @hidden */
  32639. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32640. /** @hidden */
  32641. _updateBoundingInfo(): AbstractMesh;
  32642. /** @hidden */
  32643. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32644. /** @hidden */
  32645. protected _afterComputeWorldMatrix(): void;
  32646. /** @hidden */
  32647. get _effectiveMesh(): AbstractMesh;
  32648. /**
  32649. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32650. * A mesh is in the frustum if its bounding box intersects the frustum
  32651. * @param frustumPlanes defines the frustum to test
  32652. * @returns true if the mesh is in the frustum planes
  32653. */
  32654. isInFrustum(frustumPlanes: Plane[]): boolean;
  32655. /**
  32656. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32657. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32658. * @param frustumPlanes defines the frustum to test
  32659. * @returns true if the mesh is completely in the frustum planes
  32660. */
  32661. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32662. /**
  32663. * True if the mesh intersects another mesh or a SolidParticle object
  32664. * @param mesh defines a target mesh or SolidParticle to test
  32665. * @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)
  32666. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32667. * @returns true if there is an intersection
  32668. */
  32669. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32670. /**
  32671. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32672. * @param point defines the point to test
  32673. * @returns true if there is an intersection
  32674. */
  32675. intersectsPoint(point: Vector3): boolean;
  32676. /**
  32677. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32678. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32679. */
  32680. get checkCollisions(): boolean;
  32681. set checkCollisions(collisionEnabled: boolean);
  32682. /**
  32683. * Gets Collider object used to compute collisions (not physics)
  32684. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32685. */
  32686. get collider(): Nullable<Collider>;
  32687. /**
  32688. * Move the mesh using collision engine
  32689. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32690. * @param displacement defines the requested displacement vector
  32691. * @returns the current mesh
  32692. */
  32693. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32694. private _onCollisionPositionChange;
  32695. /** @hidden */
  32696. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32697. /** @hidden */
  32698. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32699. /** @hidden */
  32700. _checkCollision(collider: Collider): AbstractMesh;
  32701. /** @hidden */
  32702. _generatePointsArray(): boolean;
  32703. /**
  32704. * Checks if the passed Ray intersects with the mesh
  32705. * @param ray defines the ray to use
  32706. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32707. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32708. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32709. * @returns the picking info
  32710. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32711. */
  32712. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  32713. /**
  32714. * Clones the current mesh
  32715. * @param name defines the mesh name
  32716. * @param newParent defines the new mesh parent
  32717. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32718. * @returns the new mesh
  32719. */
  32720. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32721. /**
  32722. * Disposes all the submeshes of the current meshnp
  32723. * @returns the current mesh
  32724. */
  32725. releaseSubMeshes(): AbstractMesh;
  32726. /**
  32727. * Releases resources associated with this abstract mesh.
  32728. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32729. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32730. */
  32731. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32732. /**
  32733. * Adds the passed mesh as a child to the current mesh
  32734. * @param mesh defines the child mesh
  32735. * @returns the current mesh
  32736. */
  32737. addChild(mesh: AbstractMesh): AbstractMesh;
  32738. /**
  32739. * Removes the passed mesh from the current mesh children list
  32740. * @param mesh defines the child mesh
  32741. * @returns the current mesh
  32742. */
  32743. removeChild(mesh: AbstractMesh): AbstractMesh;
  32744. /** @hidden */
  32745. private _initFacetData;
  32746. /**
  32747. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32748. * This method can be called within the render loop.
  32749. * 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
  32750. * @returns the current mesh
  32751. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32752. */
  32753. updateFacetData(): AbstractMesh;
  32754. /**
  32755. * Returns the facetLocalNormals array.
  32756. * The normals are expressed in the mesh local spac
  32757. * @returns an array of Vector3
  32758. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32759. */
  32760. getFacetLocalNormals(): Vector3[];
  32761. /**
  32762. * Returns the facetLocalPositions array.
  32763. * The facet positions are expressed in the mesh local space
  32764. * @returns an array of Vector3
  32765. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32766. */
  32767. getFacetLocalPositions(): Vector3[];
  32768. /**
  32769. * Returns the facetLocalPartioning array
  32770. * @returns an array of array of numbers
  32771. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32772. */
  32773. getFacetLocalPartitioning(): number[][];
  32774. /**
  32775. * Returns the i-th facet position in the world system.
  32776. * This method allocates a new Vector3 per call
  32777. * @param i defines the facet index
  32778. * @returns a new Vector3
  32779. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32780. */
  32781. getFacetPosition(i: number): Vector3;
  32782. /**
  32783. * Sets the reference Vector3 with the i-th facet position in the world system
  32784. * @param i defines the facet index
  32785. * @param ref defines the target vector
  32786. * @returns the current mesh
  32787. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32788. */
  32789. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32790. /**
  32791. * Returns the i-th facet normal in the world system.
  32792. * This method allocates a new Vector3 per call
  32793. * @param i defines the facet index
  32794. * @returns a new Vector3
  32795. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32796. */
  32797. getFacetNormal(i: number): Vector3;
  32798. /**
  32799. * Sets the reference Vector3 with the i-th facet normal in the world system
  32800. * @param i defines the facet index
  32801. * @param ref defines the target vector
  32802. * @returns the current mesh
  32803. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32804. */
  32805. getFacetNormalToRef(i: number, ref: Vector3): this;
  32806. /**
  32807. * 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)
  32808. * @param x defines x coordinate
  32809. * @param y defines y coordinate
  32810. * @param z defines z coordinate
  32811. * @returns the array of facet indexes
  32812. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32813. */
  32814. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32815. /**
  32816. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32817. * @param projected sets as the (x,y,z) world projection on the facet
  32818. * @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
  32819. * @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
  32820. * @param x defines x coordinate
  32821. * @param y defines y coordinate
  32822. * @param z defines z coordinate
  32823. * @returns the face index if found (or null instead)
  32824. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32825. */
  32826. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32827. /**
  32828. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32829. * @param projected sets as the (x,y,z) local projection on the facet
  32830. * @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
  32831. * @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
  32832. * @param x defines x coordinate
  32833. * @param y defines y coordinate
  32834. * @param z defines z coordinate
  32835. * @returns the face index if found (or null instead)
  32836. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32837. */
  32838. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32839. /**
  32840. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32841. * @returns the parameters
  32842. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32843. */
  32844. getFacetDataParameters(): any;
  32845. /**
  32846. * Disables the feature FacetData and frees the related memory
  32847. * @returns the current mesh
  32848. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32849. */
  32850. disableFacetData(): AbstractMesh;
  32851. /**
  32852. * Updates the AbstractMesh indices array
  32853. * @param indices defines the data source
  32854. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32855. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  32856. * @returns the current mesh
  32857. */
  32858. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32859. /**
  32860. * Creates new normals data for the mesh
  32861. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32862. * @returns the current mesh
  32863. */
  32864. createNormals(updatable: boolean): AbstractMesh;
  32865. /**
  32866. * Align the mesh with a normal
  32867. * @param normal defines the normal to use
  32868. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32869. * @returns the current mesh
  32870. */
  32871. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32872. /** @hidden */
  32873. _checkOcclusionQuery(): boolean;
  32874. /**
  32875. * Disables the mesh edge rendering mode
  32876. * @returns the currentAbstractMesh
  32877. */
  32878. disableEdgesRendering(): AbstractMesh;
  32879. /**
  32880. * Enables the edge rendering mode on the mesh.
  32881. * This mode makes the mesh edges visible
  32882. * @param epsilon defines the maximal distance between two angles to detect a face
  32883. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32884. * @returns the currentAbstractMesh
  32885. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32886. */
  32887. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32888. /**
  32889. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  32890. * @returns an array of particle systems in the scene that use the mesh as an emitter
  32891. */
  32892. getConnectedParticleSystems(): IParticleSystem[];
  32893. }
  32894. }
  32895. declare module "babylonjs/Actions/actionEvent" {
  32896. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32897. import { Nullable } from "babylonjs/types";
  32898. import { Sprite } from "babylonjs/Sprites/sprite";
  32899. import { Scene } from "babylonjs/scene";
  32900. import { Vector2 } from "babylonjs/Maths/math.vector";
  32901. /**
  32902. * Interface used to define ActionEvent
  32903. */
  32904. export interface IActionEvent {
  32905. /** The mesh or sprite that triggered the action */
  32906. source: any;
  32907. /** The X mouse cursor position at the time of the event */
  32908. pointerX: number;
  32909. /** The Y mouse cursor position at the time of the event */
  32910. pointerY: number;
  32911. /** The mesh that is currently pointed at (can be null) */
  32912. meshUnderPointer: Nullable<AbstractMesh>;
  32913. /** the original (browser) event that triggered the ActionEvent */
  32914. sourceEvent?: any;
  32915. /** additional data for the event */
  32916. additionalData?: any;
  32917. }
  32918. /**
  32919. * ActionEvent is the event being sent when an action is triggered.
  32920. */
  32921. export class ActionEvent implements IActionEvent {
  32922. /** The mesh or sprite that triggered the action */
  32923. source: any;
  32924. /** The X mouse cursor position at the time of the event */
  32925. pointerX: number;
  32926. /** The Y mouse cursor position at the time of the event */
  32927. pointerY: number;
  32928. /** The mesh that is currently pointed at (can be null) */
  32929. meshUnderPointer: Nullable<AbstractMesh>;
  32930. /** the original (browser) event that triggered the ActionEvent */
  32931. sourceEvent?: any;
  32932. /** additional data for the event */
  32933. additionalData?: any;
  32934. /**
  32935. * Creates a new ActionEvent
  32936. * @param source The mesh or sprite that triggered the action
  32937. * @param pointerX The X mouse cursor position at the time of the event
  32938. * @param pointerY The Y mouse cursor position at the time of the event
  32939. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32940. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32941. * @param additionalData additional data for the event
  32942. */
  32943. constructor(
  32944. /** The mesh or sprite that triggered the action */
  32945. source: any,
  32946. /** The X mouse cursor position at the time of the event */
  32947. pointerX: number,
  32948. /** The Y mouse cursor position at the time of the event */
  32949. pointerY: number,
  32950. /** The mesh that is currently pointed at (can be null) */
  32951. meshUnderPointer: Nullable<AbstractMesh>,
  32952. /** the original (browser) event that triggered the ActionEvent */
  32953. sourceEvent?: any,
  32954. /** additional data for the event */
  32955. additionalData?: any);
  32956. /**
  32957. * Helper function to auto-create an ActionEvent from a source mesh.
  32958. * @param source The source mesh that triggered the event
  32959. * @param evt The original (browser) event
  32960. * @param additionalData additional data for the event
  32961. * @returns the new ActionEvent
  32962. */
  32963. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32964. /**
  32965. * Helper function to auto-create an ActionEvent from a source sprite
  32966. * @param source The source sprite that triggered the event
  32967. * @param scene Scene associated with the sprite
  32968. * @param evt The original (browser) event
  32969. * @param additionalData additional data for the event
  32970. * @returns the new ActionEvent
  32971. */
  32972. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32973. /**
  32974. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32975. * @param scene the scene where the event occurred
  32976. * @param evt The original (browser) event
  32977. * @returns the new ActionEvent
  32978. */
  32979. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32980. /**
  32981. * Helper function to auto-create an ActionEvent from a primitive
  32982. * @param prim defines the target primitive
  32983. * @param pointerPos defines the pointer position
  32984. * @param evt The original (browser) event
  32985. * @param additionalData additional data for the event
  32986. * @returns the new ActionEvent
  32987. */
  32988. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32989. }
  32990. }
  32991. declare module "babylonjs/Actions/abstractActionManager" {
  32992. import { IDisposable } from "babylonjs/scene";
  32993. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  32994. import { IAction } from "babylonjs/Actions/action";
  32995. import { Nullable } from "babylonjs/types";
  32996. /**
  32997. * Abstract class used to decouple action Manager from scene and meshes.
  32998. * Do not instantiate.
  32999. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33000. */
  33001. export abstract class AbstractActionManager implements IDisposable {
  33002. /** Gets the list of active triggers */
  33003. static Triggers: {
  33004. [key: string]: number;
  33005. };
  33006. /** Gets the cursor to use when hovering items */
  33007. hoverCursor: string;
  33008. /** Gets the list of actions */
  33009. actions: IAction[];
  33010. /**
  33011. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  33012. */
  33013. isRecursive: boolean;
  33014. /**
  33015. * Releases all associated resources
  33016. */
  33017. abstract dispose(): void;
  33018. /**
  33019. * Does this action manager has pointer triggers
  33020. */
  33021. abstract get hasPointerTriggers(): boolean;
  33022. /**
  33023. * Does this action manager has pick triggers
  33024. */
  33025. abstract get hasPickTriggers(): boolean;
  33026. /**
  33027. * Process a specific trigger
  33028. * @param trigger defines the trigger to process
  33029. * @param evt defines the event details to be processed
  33030. */
  33031. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  33032. /**
  33033. * Does this action manager handles actions of any of the given triggers
  33034. * @param triggers defines the triggers to be tested
  33035. * @return a boolean indicating whether one (or more) of the triggers is handled
  33036. */
  33037. abstract hasSpecificTriggers(triggers: number[]): boolean;
  33038. /**
  33039. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  33040. * speed.
  33041. * @param triggerA defines the trigger to be tested
  33042. * @param triggerB defines the trigger to be tested
  33043. * @return a boolean indicating whether one (or more) of the triggers is handled
  33044. */
  33045. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  33046. /**
  33047. * Does this action manager handles actions of a given trigger
  33048. * @param trigger defines the trigger to be tested
  33049. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  33050. * @return whether the trigger is handled
  33051. */
  33052. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  33053. /**
  33054. * Serialize this manager to a JSON object
  33055. * @param name defines the property name to store this manager
  33056. * @returns a JSON representation of this manager
  33057. */
  33058. abstract serialize(name: string): any;
  33059. /**
  33060. * Registers an action to this action manager
  33061. * @param action defines the action to be registered
  33062. * @return the action amended (prepared) after registration
  33063. */
  33064. abstract registerAction(action: IAction): Nullable<IAction>;
  33065. /**
  33066. * Unregisters an action to this action manager
  33067. * @param action defines the action to be unregistered
  33068. * @return a boolean indicating whether the action has been unregistered
  33069. */
  33070. abstract unregisterAction(action: IAction): Boolean;
  33071. /**
  33072. * Does exist one action manager with at least one trigger
  33073. **/
  33074. static get HasTriggers(): boolean;
  33075. /**
  33076. * Does exist one action manager with at least one pick trigger
  33077. **/
  33078. static get HasPickTriggers(): boolean;
  33079. /**
  33080. * Does exist one action manager that handles actions of a given trigger
  33081. * @param trigger defines the trigger to be tested
  33082. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  33083. **/
  33084. static HasSpecificTrigger(trigger: number): boolean;
  33085. }
  33086. }
  33087. declare module "babylonjs/node" {
  33088. import { Scene } from "babylonjs/scene";
  33089. import { Nullable } from "babylonjs/types";
  33090. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  33091. import { Engine } from "babylonjs/Engines/engine";
  33092. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  33093. import { Observable } from "babylonjs/Misc/observable";
  33094. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33095. import { IInspectable } from "babylonjs/Misc/iInspectable";
  33096. import { Animatable } from "babylonjs/Animations/animatable";
  33097. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33098. import { Animation } from "babylonjs/Animations/animation";
  33099. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33100. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33101. /**
  33102. * Defines how a node can be built from a string name.
  33103. */
  33104. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  33105. /**
  33106. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  33107. */
  33108. export class Node implements IBehaviorAware<Node> {
  33109. /** @hidden */
  33110. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  33111. private static _NodeConstructors;
  33112. /**
  33113. * Add a new node constructor
  33114. * @param type defines the type name of the node to construct
  33115. * @param constructorFunc defines the constructor function
  33116. */
  33117. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  33118. /**
  33119. * Returns a node constructor based on type name
  33120. * @param type defines the type name
  33121. * @param name defines the new node name
  33122. * @param scene defines the hosting scene
  33123. * @param options defines optional options to transmit to constructors
  33124. * @returns the new constructor or null
  33125. */
  33126. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  33127. /**
  33128. * Gets or sets the name of the node
  33129. */
  33130. name: string;
  33131. /**
  33132. * Gets or sets the id of the node
  33133. */
  33134. id: string;
  33135. /**
  33136. * Gets or sets the unique id of the node
  33137. */
  33138. uniqueId: number;
  33139. /**
  33140. * Gets or sets a string used to store user defined state for the node
  33141. */
  33142. state: string;
  33143. /**
  33144. * Gets or sets an object used to store user defined information for the node
  33145. */
  33146. metadata: any;
  33147. /**
  33148. * For internal use only. Please do not use.
  33149. */
  33150. reservedDataStore: any;
  33151. /**
  33152. * List of inspectable custom properties (used by the Inspector)
  33153. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  33154. */
  33155. inspectableCustomProperties: IInspectable[];
  33156. private _doNotSerialize;
  33157. /**
  33158. * Gets or sets a boolean used to define if the node must be serialized
  33159. */
  33160. get doNotSerialize(): boolean;
  33161. set doNotSerialize(value: boolean);
  33162. /** @hidden */
  33163. _isDisposed: boolean;
  33164. /**
  33165. * Gets a list of Animations associated with the node
  33166. */
  33167. animations: import("babylonjs/Animations/animation").Animation[];
  33168. protected _ranges: {
  33169. [name: string]: Nullable<AnimationRange>;
  33170. };
  33171. /**
  33172. * Callback raised when the node is ready to be used
  33173. */
  33174. onReady: Nullable<(node: Node) => void>;
  33175. private _isEnabled;
  33176. private _isParentEnabled;
  33177. private _isReady;
  33178. /** @hidden */
  33179. _currentRenderId: number;
  33180. private _parentUpdateId;
  33181. /** @hidden */
  33182. _childUpdateId: number;
  33183. /** @hidden */
  33184. _waitingParentId: Nullable<string>;
  33185. /** @hidden */
  33186. _scene: Scene;
  33187. /** @hidden */
  33188. _cache: any;
  33189. private _parentNode;
  33190. private _children;
  33191. /** @hidden */
  33192. _worldMatrix: Matrix;
  33193. /** @hidden */
  33194. _worldMatrixDeterminant: number;
  33195. /** @hidden */
  33196. _worldMatrixDeterminantIsDirty: boolean;
  33197. /** @hidden */
  33198. private _sceneRootNodesIndex;
  33199. /**
  33200. * Gets a boolean indicating if the node has been disposed
  33201. * @returns true if the node was disposed
  33202. */
  33203. isDisposed(): boolean;
  33204. /**
  33205. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33206. * @see https://doc.babylonjs.com/how_to/parenting
  33207. */
  33208. set parent(parent: Nullable<Node>);
  33209. get parent(): Nullable<Node>;
  33210. /** @hidden */
  33211. _addToSceneRootNodes(): void;
  33212. /** @hidden */
  33213. _removeFromSceneRootNodes(): void;
  33214. private _animationPropertiesOverride;
  33215. /**
  33216. * Gets or sets the animation properties override
  33217. */
  33218. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33219. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33220. /**
  33221. * Gets a string idenfifying the name of the class
  33222. * @returns "Node" string
  33223. */
  33224. getClassName(): string;
  33225. /** @hidden */
  33226. readonly _isNode: boolean;
  33227. /**
  33228. * An event triggered when the mesh is disposed
  33229. */
  33230. onDisposeObservable: Observable<Node>;
  33231. private _onDisposeObserver;
  33232. /**
  33233. * Sets a callback that will be raised when the node will be disposed
  33234. */
  33235. set onDispose(callback: () => void);
  33236. /**
  33237. * Creates a new Node
  33238. * @param name the name and id to be given to this node
  33239. * @param scene the scene this node will be added to
  33240. */
  33241. constructor(name: string, scene?: Nullable<Scene>);
  33242. /**
  33243. * Gets the scene of the node
  33244. * @returns a scene
  33245. */
  33246. getScene(): Scene;
  33247. /**
  33248. * Gets the engine of the node
  33249. * @returns a Engine
  33250. */
  33251. getEngine(): Engine;
  33252. private _behaviors;
  33253. /**
  33254. * Attach a behavior to the node
  33255. * @see https://doc.babylonjs.com/features/behaviour
  33256. * @param behavior defines the behavior to attach
  33257. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33258. * @returns the current Node
  33259. */
  33260. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33261. /**
  33262. * Remove an attached behavior
  33263. * @see https://doc.babylonjs.com/features/behaviour
  33264. * @param behavior defines the behavior to attach
  33265. * @returns the current Node
  33266. */
  33267. removeBehavior(behavior: Behavior<Node>): Node;
  33268. /**
  33269. * Gets the list of attached behaviors
  33270. * @see https://doc.babylonjs.com/features/behaviour
  33271. */
  33272. get behaviors(): Behavior<Node>[];
  33273. /**
  33274. * Gets an attached behavior by name
  33275. * @param name defines the name of the behavior to look for
  33276. * @see https://doc.babylonjs.com/features/behaviour
  33277. * @returns null if behavior was not found else the requested behavior
  33278. */
  33279. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33280. /**
  33281. * Returns the latest update of the World matrix
  33282. * @returns a Matrix
  33283. */
  33284. getWorldMatrix(): Matrix;
  33285. /** @hidden */
  33286. _getWorldMatrixDeterminant(): number;
  33287. /**
  33288. * Returns directly the latest state of the mesh World matrix.
  33289. * A Matrix is returned.
  33290. */
  33291. get worldMatrixFromCache(): Matrix;
  33292. /** @hidden */
  33293. _initCache(): void;
  33294. /** @hidden */
  33295. updateCache(force?: boolean): void;
  33296. /** @hidden */
  33297. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33298. /** @hidden */
  33299. _updateCache(ignoreParentClass?: boolean): void;
  33300. /** @hidden */
  33301. _isSynchronized(): boolean;
  33302. /** @hidden */
  33303. _markSyncedWithParent(): void;
  33304. /** @hidden */
  33305. isSynchronizedWithParent(): boolean;
  33306. /** @hidden */
  33307. isSynchronized(): boolean;
  33308. /**
  33309. * Is this node ready to be used/rendered
  33310. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33311. * @return true if the node is ready
  33312. */
  33313. isReady(completeCheck?: boolean): boolean;
  33314. /**
  33315. * Is this node enabled?
  33316. * 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
  33317. * @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
  33318. * @return whether this node (and its parent) is enabled
  33319. */
  33320. isEnabled(checkAncestors?: boolean): boolean;
  33321. /** @hidden */
  33322. protected _syncParentEnabledState(): void;
  33323. /**
  33324. * Set the enabled state of this node
  33325. * @param value defines the new enabled state
  33326. */
  33327. setEnabled(value: boolean): void;
  33328. /**
  33329. * Is this node a descendant of the given node?
  33330. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33331. * @param ancestor defines the parent node to inspect
  33332. * @returns a boolean indicating if this node is a descendant of the given node
  33333. */
  33334. isDescendantOf(ancestor: Node): boolean;
  33335. /** @hidden */
  33336. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33337. /**
  33338. * Will return all nodes that have this node as ascendant
  33339. * @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
  33340. * @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
  33341. * @return all children nodes of all types
  33342. */
  33343. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33344. /**
  33345. * Get all child-meshes of this node
  33346. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  33347. * @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
  33348. * @returns an array of AbstractMesh
  33349. */
  33350. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33351. /**
  33352. * Get all direct children of this node
  33353. * @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
  33354. * @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)
  33355. * @returns an array of Node
  33356. */
  33357. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33358. /** @hidden */
  33359. _setReady(state: boolean): void;
  33360. /**
  33361. * Get an animation by name
  33362. * @param name defines the name of the animation to look for
  33363. * @returns null if not found else the requested animation
  33364. */
  33365. getAnimationByName(name: string): Nullable<Animation>;
  33366. /**
  33367. * Creates an animation range for this node
  33368. * @param name defines the name of the range
  33369. * @param from defines the starting key
  33370. * @param to defines the end key
  33371. */
  33372. createAnimationRange(name: string, from: number, to: number): void;
  33373. /**
  33374. * Delete a specific animation range
  33375. * @param name defines the name of the range to delete
  33376. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33377. */
  33378. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33379. /**
  33380. * Get an animation range by name
  33381. * @param name defines the name of the animation range to look for
  33382. * @returns null if not found else the requested animation range
  33383. */
  33384. getAnimationRange(name: string): Nullable<AnimationRange>;
  33385. /**
  33386. * Gets the list of all animation ranges defined on this node
  33387. * @returns an array
  33388. */
  33389. getAnimationRanges(): Nullable<AnimationRange>[];
  33390. /**
  33391. * Will start the animation sequence
  33392. * @param name defines the range frames for animation sequence
  33393. * @param loop defines if the animation should loop (false by default)
  33394. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33395. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33396. * @returns the object created for this animation. If range does not exist, it will return null
  33397. */
  33398. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33399. /**
  33400. * Serialize animation ranges into a JSON compatible object
  33401. * @returns serialization object
  33402. */
  33403. serializeAnimationRanges(): any;
  33404. /**
  33405. * Computes the world matrix of the node
  33406. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33407. * @returns the world matrix
  33408. */
  33409. computeWorldMatrix(force?: boolean): Matrix;
  33410. /**
  33411. * Releases resources associated with this node.
  33412. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33413. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33414. */
  33415. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33416. /**
  33417. * Parse animation range data from a serialization object and store them into a given node
  33418. * @param node defines where to store the animation ranges
  33419. * @param parsedNode defines the serialization object to read data from
  33420. * @param scene defines the hosting scene
  33421. */
  33422. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33423. /**
  33424. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33425. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33426. * @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
  33427. * @returns the new bounding vectors
  33428. */
  33429. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33430. min: Vector3;
  33431. max: Vector3;
  33432. };
  33433. }
  33434. }
  33435. declare module "babylonjs/Animations/animation" {
  33436. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  33437. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  33438. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33439. import { Nullable } from "babylonjs/types";
  33440. import { Scene } from "babylonjs/scene";
  33441. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  33442. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33443. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  33444. import { Node } from "babylonjs/node";
  33445. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33446. import { Size } from "babylonjs/Maths/math.size";
  33447. import { Animatable } from "babylonjs/Animations/animatable";
  33448. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  33449. /**
  33450. * @hidden
  33451. */
  33452. export class _IAnimationState {
  33453. key: number;
  33454. repeatCount: number;
  33455. workValue?: any;
  33456. loopMode?: number;
  33457. offsetValue?: any;
  33458. highLimitValue?: any;
  33459. }
  33460. /**
  33461. * Class used to store any kind of animation
  33462. */
  33463. export class Animation {
  33464. /**Name of the animation */
  33465. name: string;
  33466. /**Property to animate */
  33467. targetProperty: string;
  33468. /**The frames per second of the animation */
  33469. framePerSecond: number;
  33470. /**The data type of the animation */
  33471. dataType: number;
  33472. /**The loop mode of the animation */
  33473. loopMode?: number | undefined;
  33474. /**Specifies if blending should be enabled */
  33475. enableBlending?: boolean | undefined;
  33476. /**
  33477. * Use matrix interpolation instead of using direct key value when animating matrices
  33478. */
  33479. static AllowMatricesInterpolation: boolean;
  33480. /**
  33481. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33482. */
  33483. static AllowMatrixDecomposeForInterpolation: boolean;
  33484. /** Define the Url to load snippets */
  33485. static SnippetUrl: string;
  33486. /** Snippet ID if the animation was created from the snippet server */
  33487. snippetId: string;
  33488. /**
  33489. * Stores the key frames of the animation
  33490. */
  33491. private _keys;
  33492. /**
  33493. * Stores the easing function of the animation
  33494. */
  33495. private _easingFunction;
  33496. /**
  33497. * @hidden Internal use only
  33498. */
  33499. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  33500. /**
  33501. * The set of event that will be linked to this animation
  33502. */
  33503. private _events;
  33504. /**
  33505. * Stores an array of target property paths
  33506. */
  33507. targetPropertyPath: string[];
  33508. /**
  33509. * Stores the blending speed of the animation
  33510. */
  33511. blendingSpeed: number;
  33512. /**
  33513. * Stores the animation ranges for the animation
  33514. */
  33515. private _ranges;
  33516. /**
  33517. * @hidden Internal use
  33518. */
  33519. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33520. /**
  33521. * Sets up an animation
  33522. * @param property The property to animate
  33523. * @param animationType The animation type to apply
  33524. * @param framePerSecond The frames per second of the animation
  33525. * @param easingFunction The easing function used in the animation
  33526. * @returns The created animation
  33527. */
  33528. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33529. /**
  33530. * Create and start an animation on a node
  33531. * @param name defines the name of the global animation that will be run on all nodes
  33532. * @param node defines the root node where the animation will take place
  33533. * @param targetProperty defines property to animate
  33534. * @param framePerSecond defines the number of frame per second yo use
  33535. * @param totalFrame defines the number of frames in total
  33536. * @param from defines the initial value
  33537. * @param to defines the final value
  33538. * @param loopMode defines which loop mode you want to use (off by default)
  33539. * @param easingFunction defines the easing function to use (linear by default)
  33540. * @param onAnimationEnd defines the callback to call when animation end
  33541. * @returns the animatable created for this animation
  33542. */
  33543. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33544. /**
  33545. * Create and start an animation on a node and its descendants
  33546. * @param name defines the name of the global animation that will be run on all nodes
  33547. * @param node defines the root node where the animation will take place
  33548. * @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
  33549. * @param targetProperty defines property to animate
  33550. * @param framePerSecond defines the number of frame per second to use
  33551. * @param totalFrame defines the number of frames in total
  33552. * @param from defines the initial value
  33553. * @param to defines the final value
  33554. * @param loopMode defines which loop mode you want to use (off by default)
  33555. * @param easingFunction defines the easing function to use (linear by default)
  33556. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33557. * @returns the list of animatables created for all nodes
  33558. * @example https://www.babylonjs-playground.com/#MH0VLI
  33559. */
  33560. 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[]>;
  33561. /**
  33562. * Creates a new animation, merges it with the existing animations and starts it
  33563. * @param name Name of the animation
  33564. * @param node Node which contains the scene that begins the animations
  33565. * @param targetProperty Specifies which property to animate
  33566. * @param framePerSecond The frames per second of the animation
  33567. * @param totalFrame The total number of frames
  33568. * @param from The frame at the beginning of the animation
  33569. * @param to The frame at the end of the animation
  33570. * @param loopMode Specifies the loop mode of the animation
  33571. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33572. * @param onAnimationEnd Callback to run once the animation is complete
  33573. * @returns Nullable animation
  33574. */
  33575. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33576. /**
  33577. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33578. * @param sourceAnimation defines the Animation containing keyframes to convert
  33579. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33580. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33581. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33582. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33583. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33584. */
  33585. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33586. /**
  33587. * Transition property of an host to the target Value
  33588. * @param property The property to transition
  33589. * @param targetValue The target Value of the property
  33590. * @param host The object where the property to animate belongs
  33591. * @param scene Scene used to run the animation
  33592. * @param frameRate Framerate (in frame/s) to use
  33593. * @param transition The transition type we want to use
  33594. * @param duration The duration of the animation, in milliseconds
  33595. * @param onAnimationEnd Callback trigger at the end of the animation
  33596. * @returns Nullable animation
  33597. */
  33598. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33599. /**
  33600. * Return the array of runtime animations currently using this animation
  33601. */
  33602. get runtimeAnimations(): RuntimeAnimation[];
  33603. /**
  33604. * Specifies if any of the runtime animations are currently running
  33605. */
  33606. get hasRunningRuntimeAnimations(): boolean;
  33607. /**
  33608. * Initializes the animation
  33609. * @param name Name of the animation
  33610. * @param targetProperty Property to animate
  33611. * @param framePerSecond The frames per second of the animation
  33612. * @param dataType The data type of the animation
  33613. * @param loopMode The loop mode of the animation
  33614. * @param enableBlending Specifies if blending should be enabled
  33615. */
  33616. constructor(
  33617. /**Name of the animation */
  33618. name: string,
  33619. /**Property to animate */
  33620. targetProperty: string,
  33621. /**The frames per second of the animation */
  33622. framePerSecond: number,
  33623. /**The data type of the animation */
  33624. dataType: number,
  33625. /**The loop mode of the animation */
  33626. loopMode?: number | undefined,
  33627. /**Specifies if blending should be enabled */
  33628. enableBlending?: boolean | undefined);
  33629. /**
  33630. * Converts the animation to a string
  33631. * @param fullDetails support for multiple levels of logging within scene loading
  33632. * @returns String form of the animation
  33633. */
  33634. toString(fullDetails?: boolean): string;
  33635. /**
  33636. * Add an event to this animation
  33637. * @param event Event to add
  33638. */
  33639. addEvent(event: AnimationEvent): void;
  33640. /**
  33641. * Remove all events found at the given frame
  33642. * @param frame The frame to remove events from
  33643. */
  33644. removeEvents(frame: number): void;
  33645. /**
  33646. * Retrieves all the events from the animation
  33647. * @returns Events from the animation
  33648. */
  33649. getEvents(): AnimationEvent[];
  33650. /**
  33651. * Creates an animation range
  33652. * @param name Name of the animation range
  33653. * @param from Starting frame of the animation range
  33654. * @param to Ending frame of the animation
  33655. */
  33656. createRange(name: string, from: number, to: number): void;
  33657. /**
  33658. * Deletes an animation range by name
  33659. * @param name Name of the animation range to delete
  33660. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33661. */
  33662. deleteRange(name: string, deleteFrames?: boolean): void;
  33663. /**
  33664. * Gets the animation range by name, or null if not defined
  33665. * @param name Name of the animation range
  33666. * @returns Nullable animation range
  33667. */
  33668. getRange(name: string): Nullable<AnimationRange>;
  33669. /**
  33670. * Gets the key frames from the animation
  33671. * @returns The key frames of the animation
  33672. */
  33673. getKeys(): Array<IAnimationKey>;
  33674. /**
  33675. * Gets the highest frame rate of the animation
  33676. * @returns Highest frame rate of the animation
  33677. */
  33678. getHighestFrame(): number;
  33679. /**
  33680. * Gets the easing function of the animation
  33681. * @returns Easing function of the animation
  33682. */
  33683. getEasingFunction(): IEasingFunction;
  33684. /**
  33685. * Sets the easing function of the animation
  33686. * @param easingFunction A custom mathematical formula for animation
  33687. */
  33688. setEasingFunction(easingFunction: EasingFunction): void;
  33689. /**
  33690. * Interpolates a scalar linearly
  33691. * @param startValue Start value of the animation curve
  33692. * @param endValue End value of the animation curve
  33693. * @param gradient Scalar amount to interpolate
  33694. * @returns Interpolated scalar value
  33695. */
  33696. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33697. /**
  33698. * Interpolates a scalar cubically
  33699. * @param startValue Start value of the animation curve
  33700. * @param outTangent End tangent of the animation
  33701. * @param endValue End value of the animation curve
  33702. * @param inTangent Start tangent of the animation curve
  33703. * @param gradient Scalar amount to interpolate
  33704. * @returns Interpolated scalar value
  33705. */
  33706. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33707. /**
  33708. * Interpolates a quaternion using a spherical linear interpolation
  33709. * @param startValue Start value of the animation curve
  33710. * @param endValue End value of the animation curve
  33711. * @param gradient Scalar amount to interpolate
  33712. * @returns Interpolated quaternion value
  33713. */
  33714. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33715. /**
  33716. * Interpolates a quaternion cubically
  33717. * @param startValue Start value of the animation curve
  33718. * @param outTangent End tangent of the animation curve
  33719. * @param endValue End value of the animation curve
  33720. * @param inTangent Start tangent of the animation curve
  33721. * @param gradient Scalar amount to interpolate
  33722. * @returns Interpolated quaternion value
  33723. */
  33724. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33725. /**
  33726. * Interpolates a Vector3 linearl
  33727. * @param startValue Start value of the animation curve
  33728. * @param endValue End value of the animation curve
  33729. * @param gradient Scalar amount to interpolate
  33730. * @returns Interpolated scalar value
  33731. */
  33732. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33733. /**
  33734. * Interpolates a Vector3 cubically
  33735. * @param startValue Start value of the animation curve
  33736. * @param outTangent End tangent of the animation
  33737. * @param endValue End value of the animation curve
  33738. * @param inTangent Start tangent of the animation curve
  33739. * @param gradient Scalar amount to interpolate
  33740. * @returns InterpolatedVector3 value
  33741. */
  33742. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33743. /**
  33744. * Interpolates a Vector2 linearly
  33745. * @param startValue Start value of the animation curve
  33746. * @param endValue End value of the animation curve
  33747. * @param gradient Scalar amount to interpolate
  33748. * @returns Interpolated Vector2 value
  33749. */
  33750. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33751. /**
  33752. * Interpolates a Vector2 cubically
  33753. * @param startValue Start value of the animation curve
  33754. * @param outTangent End tangent of the animation
  33755. * @param endValue End value of the animation curve
  33756. * @param inTangent Start tangent of the animation curve
  33757. * @param gradient Scalar amount to interpolate
  33758. * @returns Interpolated Vector2 value
  33759. */
  33760. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33761. /**
  33762. * Interpolates a size linearly
  33763. * @param startValue Start value of the animation curve
  33764. * @param endValue End value of the animation curve
  33765. * @param gradient Scalar amount to interpolate
  33766. * @returns Interpolated Size value
  33767. */
  33768. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33769. /**
  33770. * Interpolates a Color3 linearly
  33771. * @param startValue Start value of the animation curve
  33772. * @param endValue End value of the animation curve
  33773. * @param gradient Scalar amount to interpolate
  33774. * @returns Interpolated Color3 value
  33775. */
  33776. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33777. /**
  33778. * Interpolates a Color4 linearly
  33779. * @param startValue Start value of the animation curve
  33780. * @param endValue End value of the animation curve
  33781. * @param gradient Scalar amount to interpolate
  33782. * @returns Interpolated Color3 value
  33783. */
  33784. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33785. /**
  33786. * @hidden Internal use only
  33787. */
  33788. _getKeyValue(value: any): any;
  33789. /**
  33790. * @hidden Internal use only
  33791. */
  33792. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33793. /**
  33794. * Defines the function to use to interpolate matrices
  33795. * @param startValue defines the start matrix
  33796. * @param endValue defines the end matrix
  33797. * @param gradient defines the gradient between both matrices
  33798. * @param result defines an optional target matrix where to store the interpolation
  33799. * @returns the interpolated matrix
  33800. */
  33801. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33802. /**
  33803. * Makes a copy of the animation
  33804. * @returns Cloned animation
  33805. */
  33806. clone(): Animation;
  33807. /**
  33808. * Sets the key frames of the animation
  33809. * @param values The animation key frames to set
  33810. */
  33811. setKeys(values: Array<IAnimationKey>): void;
  33812. /**
  33813. * Serializes the animation to an object
  33814. * @returns Serialized object
  33815. */
  33816. serialize(): any;
  33817. /**
  33818. * Float animation type
  33819. */
  33820. static readonly ANIMATIONTYPE_FLOAT: number;
  33821. /**
  33822. * Vector3 animation type
  33823. */
  33824. static readonly ANIMATIONTYPE_VECTOR3: number;
  33825. /**
  33826. * Quaternion animation type
  33827. */
  33828. static readonly ANIMATIONTYPE_QUATERNION: number;
  33829. /**
  33830. * Matrix animation type
  33831. */
  33832. static readonly ANIMATIONTYPE_MATRIX: number;
  33833. /**
  33834. * Color3 animation type
  33835. */
  33836. static readonly ANIMATIONTYPE_COLOR3: number;
  33837. /**
  33838. * Color3 animation type
  33839. */
  33840. static readonly ANIMATIONTYPE_COLOR4: number;
  33841. /**
  33842. * Vector2 animation type
  33843. */
  33844. static readonly ANIMATIONTYPE_VECTOR2: number;
  33845. /**
  33846. * Size animation type
  33847. */
  33848. static readonly ANIMATIONTYPE_SIZE: number;
  33849. /**
  33850. * Relative Loop Mode
  33851. */
  33852. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33853. /**
  33854. * Cycle Loop Mode
  33855. */
  33856. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33857. /**
  33858. * Constant Loop Mode
  33859. */
  33860. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33861. /** @hidden */
  33862. static _UniversalLerp(left: any, right: any, amount: number): any;
  33863. /**
  33864. * Parses an animation object and creates an animation
  33865. * @param parsedAnimation Parsed animation object
  33866. * @returns Animation object
  33867. */
  33868. static Parse(parsedAnimation: any): Animation;
  33869. /**
  33870. * Appends the serialized animations from the source animations
  33871. * @param source Source containing the animations
  33872. * @param destination Target to store the animations
  33873. */
  33874. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33875. /**
  33876. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33877. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33878. * @param url defines the url to load from
  33879. * @returns a promise that will resolve to the new animation or an array of animations
  33880. */
  33881. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33882. /**
  33883. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33884. * @param snippetId defines the snippet to load
  33885. * @returns a promise that will resolve to the new animation or a new array of animations
  33886. */
  33887. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33888. }
  33889. }
  33890. declare module "babylonjs/Animations/animatable.interface" {
  33891. import { Nullable } from "babylonjs/types";
  33892. import { Animation } from "babylonjs/Animations/animation";
  33893. /**
  33894. * Interface containing an array of animations
  33895. */
  33896. export interface IAnimatable {
  33897. /**
  33898. * Array of animations
  33899. */
  33900. animations: Nullable<Array<Animation>>;
  33901. }
  33902. }
  33903. declare module "babylonjs/Misc/decorators" {
  33904. import { Nullable } from "babylonjs/types";
  33905. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33906. import { Scene } from "babylonjs/scene";
  33907. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33908. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  33909. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  33910. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33911. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33912. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33913. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33914. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33915. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33916. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33917. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33918. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33919. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33920. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33921. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33922. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33923. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33924. /**
  33925. * Decorator used to define property that can be serialized as reference to a camera
  33926. * @param sourceName defines the name of the property to decorate
  33927. */
  33928. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33929. /**
  33930. * Class used to help serialization objects
  33931. */
  33932. export class SerializationHelper {
  33933. /** @hidden */
  33934. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  33935. /** @hidden */
  33936. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  33937. /** @hidden */
  33938. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  33939. /** @hidden */
  33940. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  33941. /**
  33942. * Appends the serialized animations from the source animations
  33943. * @param source Source containing the animations
  33944. * @param destination Target to store the animations
  33945. */
  33946. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33947. /**
  33948. * Static function used to serialized a specific entity
  33949. * @param entity defines the entity to serialize
  33950. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33951. * @returns a JSON compatible object representing the serialization of the entity
  33952. */
  33953. static Serialize<T>(entity: T, serializationObject?: any): any;
  33954. /**
  33955. * Creates a new entity from a serialization data object
  33956. * @param creationFunction defines a function used to instanciated the new entity
  33957. * @param source defines the source serialization data
  33958. * @param scene defines the hosting scene
  33959. * @param rootUrl defines the root url for resources
  33960. * @returns a new entity
  33961. */
  33962. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33963. /**
  33964. * Clones an object
  33965. * @param creationFunction defines the function used to instanciate the new object
  33966. * @param source defines the source object
  33967. * @returns the cloned object
  33968. */
  33969. static Clone<T>(creationFunction: () => T, source: T): T;
  33970. /**
  33971. * Instanciates a new object based on a source one (some data will be shared between both object)
  33972. * @param creationFunction defines the function used to instanciate the new object
  33973. * @param source defines the source object
  33974. * @returns the new object
  33975. */
  33976. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33977. }
  33978. }
  33979. declare module "babylonjs/Materials/Textures/baseTexture" {
  33980. import { Observable } from "babylonjs/Misc/observable";
  33981. import { Nullable } from "babylonjs/types";
  33982. import { Scene } from "babylonjs/scene";
  33983. import { Matrix } from "babylonjs/Maths/math.vector";
  33984. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33985. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33986. import { ISize } from "babylonjs/Maths/math.size";
  33987. import "babylonjs/Misc/fileTools";
  33988. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33989. /**
  33990. * Base class of all the textures in babylon.
  33991. * It groups all the common properties the materials, post process, lights... might need
  33992. * in order to make a correct use of the texture.
  33993. */
  33994. export class BaseTexture implements IAnimatable {
  33995. /**
  33996. * Default anisotropic filtering level for the application.
  33997. * It is set to 4 as a good tradeoff between perf and quality.
  33998. */
  33999. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  34000. /**
  34001. * Gets or sets the unique id of the texture
  34002. */
  34003. uniqueId: number;
  34004. /**
  34005. * Define the name of the texture.
  34006. */
  34007. name: string;
  34008. /**
  34009. * Gets or sets an object used to store user defined information.
  34010. */
  34011. metadata: any;
  34012. /**
  34013. * For internal use only. Please do not use.
  34014. */
  34015. reservedDataStore: any;
  34016. private _hasAlpha;
  34017. /**
  34018. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  34019. */
  34020. set hasAlpha(value: boolean);
  34021. get hasAlpha(): boolean;
  34022. /**
  34023. * Defines if the alpha value should be determined via the rgb values.
  34024. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  34025. */
  34026. getAlphaFromRGB: boolean;
  34027. /**
  34028. * Intensity or strength of the texture.
  34029. * It is commonly used by materials to fine tune the intensity of the texture
  34030. */
  34031. level: number;
  34032. /**
  34033. * Define the UV chanel to use starting from 0 and defaulting to 0.
  34034. * This is part of the texture as textures usually maps to one uv set.
  34035. */
  34036. coordinatesIndex: number;
  34037. private _coordinatesMode;
  34038. /**
  34039. * How a texture is mapped.
  34040. *
  34041. * | Value | Type | Description |
  34042. * | ----- | ----------------------------------- | ----------- |
  34043. * | 0 | EXPLICIT_MODE | |
  34044. * | 1 | SPHERICAL_MODE | |
  34045. * | 2 | PLANAR_MODE | |
  34046. * | 3 | CUBIC_MODE | |
  34047. * | 4 | PROJECTION_MODE | |
  34048. * | 5 | SKYBOX_MODE | |
  34049. * | 6 | INVCUBIC_MODE | |
  34050. * | 7 | EQUIRECTANGULAR_MODE | |
  34051. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  34052. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  34053. */
  34054. set coordinatesMode(value: number);
  34055. get coordinatesMode(): number;
  34056. /**
  34057. * | Value | Type | Description |
  34058. * | ----- | ------------------ | ----------- |
  34059. * | 0 | CLAMP_ADDRESSMODE | |
  34060. * | 1 | WRAP_ADDRESSMODE | |
  34061. * | 2 | MIRROR_ADDRESSMODE | |
  34062. */
  34063. wrapU: number;
  34064. /**
  34065. * | Value | Type | Description |
  34066. * | ----- | ------------------ | ----------- |
  34067. * | 0 | CLAMP_ADDRESSMODE | |
  34068. * | 1 | WRAP_ADDRESSMODE | |
  34069. * | 2 | MIRROR_ADDRESSMODE | |
  34070. */
  34071. wrapV: number;
  34072. /**
  34073. * | Value | Type | Description |
  34074. * | ----- | ------------------ | ----------- |
  34075. * | 0 | CLAMP_ADDRESSMODE | |
  34076. * | 1 | WRAP_ADDRESSMODE | |
  34077. * | 2 | MIRROR_ADDRESSMODE | |
  34078. */
  34079. wrapR: number;
  34080. /**
  34081. * With compliant hardware and browser (supporting anisotropic filtering)
  34082. * this defines the level of anisotropic filtering in the texture.
  34083. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  34084. */
  34085. anisotropicFilteringLevel: number;
  34086. /**
  34087. * Define if the texture is a cube texture or if false a 2d texture.
  34088. */
  34089. get isCube(): boolean;
  34090. set isCube(value: boolean);
  34091. /**
  34092. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  34093. */
  34094. get is3D(): boolean;
  34095. set is3D(value: boolean);
  34096. /**
  34097. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  34098. */
  34099. get is2DArray(): boolean;
  34100. set is2DArray(value: boolean);
  34101. /**
  34102. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  34103. * HDR texture are usually stored in linear space.
  34104. * This only impacts the PBR and Background materials
  34105. */
  34106. gammaSpace: boolean;
  34107. /**
  34108. * Gets or sets whether or not the texture contains RGBD data.
  34109. */
  34110. get isRGBD(): boolean;
  34111. set isRGBD(value: boolean);
  34112. /**
  34113. * Is Z inverted in the texture (useful in a cube texture).
  34114. */
  34115. invertZ: boolean;
  34116. /**
  34117. * Are mip maps generated for this texture or not.
  34118. */
  34119. get noMipmap(): boolean;
  34120. /**
  34121. * @hidden
  34122. */
  34123. lodLevelInAlpha: boolean;
  34124. /**
  34125. * With prefiltered texture, defined the offset used during the prefiltering steps.
  34126. */
  34127. get lodGenerationOffset(): number;
  34128. set lodGenerationOffset(value: number);
  34129. /**
  34130. * With prefiltered texture, defined the scale used during the prefiltering steps.
  34131. */
  34132. get lodGenerationScale(): number;
  34133. set lodGenerationScale(value: number);
  34134. /**
  34135. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  34136. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  34137. * average roughness values.
  34138. */
  34139. get linearSpecularLOD(): boolean;
  34140. set linearSpecularLOD(value: boolean);
  34141. /**
  34142. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  34143. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  34144. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  34145. */
  34146. get irradianceTexture(): Nullable<BaseTexture>;
  34147. set irradianceTexture(value: Nullable<BaseTexture>);
  34148. /**
  34149. * Define if the texture is a render target.
  34150. */
  34151. isRenderTarget: boolean;
  34152. /**
  34153. * Define the unique id of the texture in the scene.
  34154. */
  34155. get uid(): string;
  34156. /** @hidden */
  34157. _prefiltered: boolean;
  34158. /**
  34159. * Return a string representation of the texture.
  34160. * @returns the texture as a string
  34161. */
  34162. toString(): string;
  34163. /**
  34164. * Get the class name of the texture.
  34165. * @returns "BaseTexture"
  34166. */
  34167. getClassName(): string;
  34168. /**
  34169. * Define the list of animation attached to the texture.
  34170. */
  34171. animations: import("babylonjs/Animations/animation").Animation[];
  34172. /**
  34173. * An event triggered when the texture is disposed.
  34174. */
  34175. onDisposeObservable: Observable<BaseTexture>;
  34176. private _onDisposeObserver;
  34177. /**
  34178. * Callback triggered when the texture has been disposed.
  34179. * Kept for back compatibility, you can use the onDisposeObservable instead.
  34180. */
  34181. set onDispose(callback: () => void);
  34182. /**
  34183. * Define the current state of the loading sequence when in delayed load mode.
  34184. */
  34185. delayLoadState: number;
  34186. private _scene;
  34187. private _engine;
  34188. /** @hidden */
  34189. _texture: Nullable<InternalTexture>;
  34190. private _uid;
  34191. /**
  34192. * Define if the texture is preventinga material to render or not.
  34193. * If not and the texture is not ready, the engine will use a default black texture instead.
  34194. */
  34195. get isBlocking(): boolean;
  34196. /**
  34197. * Instantiates a new BaseTexture.
  34198. * Base class of all the textures in babylon.
  34199. * It groups all the common properties the materials, post process, lights... might need
  34200. * in order to make a correct use of the texture.
  34201. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34202. */
  34203. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34204. /**
  34205. * Get the scene the texture belongs to.
  34206. * @returns the scene or null if undefined
  34207. */
  34208. getScene(): Nullable<Scene>;
  34209. /** @hidden */
  34210. protected _getEngine(): Nullable<ThinEngine>;
  34211. /**
  34212. * Get the texture transform matrix used to offset tile the texture for istance.
  34213. * @returns the transformation matrix
  34214. */
  34215. getTextureMatrix(): Matrix;
  34216. /**
  34217. * Get the texture reflection matrix used to rotate/transform the reflection.
  34218. * @returns the reflection matrix
  34219. */
  34220. getReflectionTextureMatrix(): Matrix;
  34221. /**
  34222. * Get the underlying lower level texture from Babylon.
  34223. * @returns the insternal texture
  34224. */
  34225. getInternalTexture(): Nullable<InternalTexture>;
  34226. /**
  34227. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34228. * @returns true if ready or not blocking
  34229. */
  34230. isReadyOrNotBlocking(): boolean;
  34231. /**
  34232. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34233. * @returns true if fully ready
  34234. */
  34235. isReady(): boolean;
  34236. private _cachedSize;
  34237. /**
  34238. * Get the size of the texture.
  34239. * @returns the texture size.
  34240. */
  34241. getSize(): ISize;
  34242. /**
  34243. * Get the base size of the texture.
  34244. * It can be different from the size if the texture has been resized for POT for instance
  34245. * @returns the base size
  34246. */
  34247. getBaseSize(): ISize;
  34248. /**
  34249. * Update the sampling mode of the texture.
  34250. * Default is Trilinear mode.
  34251. *
  34252. * | Value | Type | Description |
  34253. * | ----- | ------------------ | ----------- |
  34254. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34255. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34256. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34257. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34258. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34259. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34260. * | 7 | NEAREST_LINEAR | |
  34261. * | 8 | NEAREST_NEAREST | |
  34262. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34263. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34264. * | 11 | LINEAR_LINEAR | |
  34265. * | 12 | LINEAR_NEAREST | |
  34266. *
  34267. * > _mag_: magnification filter (close to the viewer)
  34268. * > _min_: minification filter (far from the viewer)
  34269. * > _mip_: filter used between mip map levels
  34270. *@param samplingMode Define the new sampling mode of the texture
  34271. */
  34272. updateSamplingMode(samplingMode: number): void;
  34273. /**
  34274. * Scales the texture if is `canRescale()`
  34275. * @param ratio the resize factor we want to use to rescale
  34276. */
  34277. scale(ratio: number): void;
  34278. /**
  34279. * Get if the texture can rescale.
  34280. */
  34281. get canRescale(): boolean;
  34282. /** @hidden */
  34283. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34284. /** @hidden */
  34285. _rebuild(): void;
  34286. /**
  34287. * Triggers the load sequence in delayed load mode.
  34288. */
  34289. delayLoad(): void;
  34290. /**
  34291. * Clones the texture.
  34292. * @returns the cloned texture
  34293. */
  34294. clone(): Nullable<BaseTexture>;
  34295. /**
  34296. * Get the texture underlying type (INT, FLOAT...)
  34297. */
  34298. get textureType(): number;
  34299. /**
  34300. * Get the texture underlying format (RGB, RGBA...)
  34301. */
  34302. get textureFormat(): number;
  34303. /**
  34304. * Indicates that textures need to be re-calculated for all materials
  34305. */
  34306. protected _markAllSubMeshesAsTexturesDirty(): void;
  34307. /**
  34308. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34309. * This will returns an RGBA array buffer containing either in values (0-255) or
  34310. * float values (0-1) depending of the underlying buffer type.
  34311. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34312. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34313. * @param buffer defines a user defined buffer to fill with data (can be null)
  34314. * @returns The Array buffer containing the pixels data.
  34315. */
  34316. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34317. /**
  34318. * Release and destroy the underlying lower level texture aka internalTexture.
  34319. */
  34320. releaseInternalTexture(): void;
  34321. /** @hidden */
  34322. get _lodTextureHigh(): Nullable<BaseTexture>;
  34323. /** @hidden */
  34324. get _lodTextureMid(): Nullable<BaseTexture>;
  34325. /** @hidden */
  34326. get _lodTextureLow(): Nullable<BaseTexture>;
  34327. /**
  34328. * Dispose the texture and release its associated resources.
  34329. */
  34330. dispose(): void;
  34331. /**
  34332. * Serialize the texture into a JSON representation that can be parsed later on.
  34333. * @returns the JSON representation of the texture
  34334. */
  34335. serialize(): any;
  34336. /**
  34337. * Helper function to be called back once a list of texture contains only ready textures.
  34338. * @param textures Define the list of textures to wait for
  34339. * @param callback Define the callback triggered once the entire list will be ready
  34340. */
  34341. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34342. private static _isScene;
  34343. }
  34344. }
  34345. declare module "babylonjs/Materials/effect" {
  34346. import { Observable } from "babylonjs/Misc/observable";
  34347. import { Nullable } from "babylonjs/types";
  34348. import { IDisposable } from "babylonjs/scene";
  34349. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34350. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34351. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  34352. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  34353. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  34354. import { Engine } from "babylonjs/Engines/engine";
  34355. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34356. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34357. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34358. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34359. /**
  34360. * Options to be used when creating an effect.
  34361. */
  34362. export interface IEffectCreationOptions {
  34363. /**
  34364. * Atrributes that will be used in the shader.
  34365. */
  34366. attributes: string[];
  34367. /**
  34368. * Uniform varible names that will be set in the shader.
  34369. */
  34370. uniformsNames: string[];
  34371. /**
  34372. * Uniform buffer variable names that will be set in the shader.
  34373. */
  34374. uniformBuffersNames: string[];
  34375. /**
  34376. * Sampler texture variable names that will be set in the shader.
  34377. */
  34378. samplers: string[];
  34379. /**
  34380. * Define statements that will be set in the shader.
  34381. */
  34382. defines: any;
  34383. /**
  34384. * Possible fallbacks for this effect to improve performance when needed.
  34385. */
  34386. fallbacks: Nullable<IEffectFallbacks>;
  34387. /**
  34388. * Callback that will be called when the shader is compiled.
  34389. */
  34390. onCompiled: Nullable<(effect: Effect) => void>;
  34391. /**
  34392. * Callback that will be called if an error occurs during shader compilation.
  34393. */
  34394. onError: Nullable<(effect: Effect, errors: string) => void>;
  34395. /**
  34396. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34397. */
  34398. indexParameters?: any;
  34399. /**
  34400. * Max number of lights that can be used in the shader.
  34401. */
  34402. maxSimultaneousLights?: number;
  34403. /**
  34404. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34405. */
  34406. transformFeedbackVaryings?: Nullable<string[]>;
  34407. /**
  34408. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  34409. */
  34410. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34411. /**
  34412. * Is this effect rendering to several color attachments ?
  34413. */
  34414. multiTarget?: boolean;
  34415. }
  34416. /**
  34417. * Effect containing vertex and fragment shader that can be executed on an object.
  34418. */
  34419. export class Effect implements IDisposable {
  34420. /**
  34421. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34422. */
  34423. static ShadersRepository: string;
  34424. /**
  34425. * Enable logging of the shader code when a compilation error occurs
  34426. */
  34427. static LogShaderCodeOnCompilationError: boolean;
  34428. /**
  34429. * Name of the effect.
  34430. */
  34431. name: any;
  34432. /**
  34433. * String container all the define statements that should be set on the shader.
  34434. */
  34435. defines: string;
  34436. /**
  34437. * Callback that will be called when the shader is compiled.
  34438. */
  34439. onCompiled: Nullable<(effect: Effect) => void>;
  34440. /**
  34441. * Callback that will be called if an error occurs during shader compilation.
  34442. */
  34443. onError: Nullable<(effect: Effect, errors: string) => void>;
  34444. /**
  34445. * Callback that will be called when effect is bound.
  34446. */
  34447. onBind: Nullable<(effect: Effect) => void>;
  34448. /**
  34449. * Unique ID of the effect.
  34450. */
  34451. uniqueId: number;
  34452. /**
  34453. * Observable that will be called when the shader is compiled.
  34454. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34455. */
  34456. onCompileObservable: Observable<Effect>;
  34457. /**
  34458. * Observable that will be called if an error occurs during shader compilation.
  34459. */
  34460. onErrorObservable: Observable<Effect>;
  34461. /** @hidden */
  34462. _onBindObservable: Nullable<Observable<Effect>>;
  34463. /**
  34464. * @hidden
  34465. * Specifies if the effect was previously ready
  34466. */
  34467. _wasPreviouslyReady: boolean;
  34468. /**
  34469. * Observable that will be called when effect is bound.
  34470. */
  34471. get onBindObservable(): Observable<Effect>;
  34472. /** @hidden */
  34473. _bonesComputationForcedToCPU: boolean;
  34474. /** @hidden */
  34475. _multiTarget: boolean;
  34476. private static _uniqueIdSeed;
  34477. private _engine;
  34478. private _uniformBuffersNames;
  34479. private _uniformBuffersNamesList;
  34480. private _uniformsNames;
  34481. private _samplerList;
  34482. private _samplers;
  34483. private _isReady;
  34484. private _compilationError;
  34485. private _allFallbacksProcessed;
  34486. private _attributesNames;
  34487. private _attributes;
  34488. private _attributeLocationByName;
  34489. private _uniforms;
  34490. /**
  34491. * Key for the effect.
  34492. * @hidden
  34493. */
  34494. _key: string;
  34495. private _indexParameters;
  34496. private _fallbacks;
  34497. private _vertexSourceCode;
  34498. private _fragmentSourceCode;
  34499. private _vertexSourceCodeOverride;
  34500. private _fragmentSourceCodeOverride;
  34501. private _transformFeedbackVaryings;
  34502. /**
  34503. * Compiled shader to webGL program.
  34504. * @hidden
  34505. */
  34506. _pipelineContext: Nullable<IPipelineContext>;
  34507. private _valueCache;
  34508. private static _baseCache;
  34509. /**
  34510. * Instantiates an effect.
  34511. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34512. * @param baseName Name of the effect.
  34513. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34514. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34515. * @param samplers List of sampler variables that will be passed to the shader.
  34516. * @param engine Engine to be used to render the effect
  34517. * @param defines Define statements to be added to the shader.
  34518. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34519. * @param onCompiled Callback that will be called when the shader is compiled.
  34520. * @param onError Callback that will be called if an error occurs during shader compilation.
  34521. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34522. */
  34523. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  34524. private _useFinalCode;
  34525. /**
  34526. * Unique key for this effect
  34527. */
  34528. get key(): string;
  34529. /**
  34530. * If the effect has been compiled and prepared.
  34531. * @returns if the effect is compiled and prepared.
  34532. */
  34533. isReady(): boolean;
  34534. private _isReadyInternal;
  34535. /**
  34536. * The engine the effect was initialized with.
  34537. * @returns the engine.
  34538. */
  34539. getEngine(): Engine;
  34540. /**
  34541. * The pipeline context for this effect
  34542. * @returns the associated pipeline context
  34543. */
  34544. getPipelineContext(): Nullable<IPipelineContext>;
  34545. /**
  34546. * The set of names of attribute variables for the shader.
  34547. * @returns An array of attribute names.
  34548. */
  34549. getAttributesNames(): string[];
  34550. /**
  34551. * Returns the attribute at the given index.
  34552. * @param index The index of the attribute.
  34553. * @returns The location of the attribute.
  34554. */
  34555. getAttributeLocation(index: number): number;
  34556. /**
  34557. * Returns the attribute based on the name of the variable.
  34558. * @param name of the attribute to look up.
  34559. * @returns the attribute location.
  34560. */
  34561. getAttributeLocationByName(name: string): number;
  34562. /**
  34563. * The number of attributes.
  34564. * @returns the numnber of attributes.
  34565. */
  34566. getAttributesCount(): number;
  34567. /**
  34568. * Gets the index of a uniform variable.
  34569. * @param uniformName of the uniform to look up.
  34570. * @returns the index.
  34571. */
  34572. getUniformIndex(uniformName: string): number;
  34573. /**
  34574. * Returns the attribute based on the name of the variable.
  34575. * @param uniformName of the uniform to look up.
  34576. * @returns the location of the uniform.
  34577. */
  34578. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34579. /**
  34580. * Returns an array of sampler variable names
  34581. * @returns The array of sampler variable names.
  34582. */
  34583. getSamplers(): string[];
  34584. /**
  34585. * Returns an array of uniform variable names
  34586. * @returns The array of uniform variable names.
  34587. */
  34588. getUniformNames(): string[];
  34589. /**
  34590. * Returns an array of uniform buffer variable names
  34591. * @returns The array of uniform buffer variable names.
  34592. */
  34593. getUniformBuffersNames(): string[];
  34594. /**
  34595. * Returns the index parameters used to create the effect
  34596. * @returns The index parameters object
  34597. */
  34598. getIndexParameters(): any;
  34599. /**
  34600. * The error from the last compilation.
  34601. * @returns the error string.
  34602. */
  34603. getCompilationError(): string;
  34604. /**
  34605. * Gets a boolean indicating that all fallbacks were used during compilation
  34606. * @returns true if all fallbacks were used
  34607. */
  34608. allFallbacksProcessed(): boolean;
  34609. /**
  34610. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34611. * @param func The callback to be used.
  34612. */
  34613. executeWhenCompiled(func: (effect: Effect) => void): void;
  34614. private _checkIsReady;
  34615. private _loadShader;
  34616. /**
  34617. * Gets the vertex shader source code of this effect
  34618. */
  34619. get vertexSourceCode(): string;
  34620. /**
  34621. * Gets the fragment shader source code of this effect
  34622. */
  34623. get fragmentSourceCode(): string;
  34624. /**
  34625. * Recompiles the webGL program
  34626. * @param vertexSourceCode The source code for the vertex shader.
  34627. * @param fragmentSourceCode The source code for the fragment shader.
  34628. * @param onCompiled Callback called when completed.
  34629. * @param onError Callback called on error.
  34630. * @hidden
  34631. */
  34632. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34633. /**
  34634. * Prepares the effect
  34635. * @hidden
  34636. */
  34637. _prepareEffect(): void;
  34638. private _getShaderCodeAndErrorLine;
  34639. private _processCompilationErrors;
  34640. /**
  34641. * Checks if the effect is supported. (Must be called after compilation)
  34642. */
  34643. get isSupported(): boolean;
  34644. /**
  34645. * Binds a texture to the engine to be used as output of the shader.
  34646. * @param channel Name of the output variable.
  34647. * @param texture Texture to bind.
  34648. * @hidden
  34649. */
  34650. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34651. /**
  34652. * Sets a texture on the engine to be used in the shader.
  34653. * @param channel Name of the sampler variable.
  34654. * @param texture Texture to set.
  34655. */
  34656. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34657. /**
  34658. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34659. * @param channel Name of the sampler variable.
  34660. * @param texture Texture to set.
  34661. */
  34662. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34663. /**
  34664. * Sets an array of textures on the engine to be used in the shader.
  34665. * @param channel Name of the variable.
  34666. * @param textures Textures to set.
  34667. */
  34668. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34669. /**
  34670. * 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)
  34671. * @param channel Name of the sampler variable.
  34672. * @param postProcess Post process to get the input texture from.
  34673. */
  34674. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34675. /**
  34676. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34677. * 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)
  34678. * @param channel Name of the sampler variable.
  34679. * @param postProcess Post process to get the output texture from.
  34680. */
  34681. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34682. /** @hidden */
  34683. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34684. /** @hidden */
  34685. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34686. /** @hidden */
  34687. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34688. /** @hidden */
  34689. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34690. /**
  34691. * Binds a buffer to a uniform.
  34692. * @param buffer Buffer to bind.
  34693. * @param name Name of the uniform variable to bind to.
  34694. */
  34695. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34696. /**
  34697. * Binds block to a uniform.
  34698. * @param blockName Name of the block to bind.
  34699. * @param index Index to bind.
  34700. */
  34701. bindUniformBlock(blockName: string, index: number): void;
  34702. /**
  34703. * Sets an interger value on a uniform variable.
  34704. * @param uniformName Name of the variable.
  34705. * @param value Value to be set.
  34706. * @returns this effect.
  34707. */
  34708. setInt(uniformName: string, value: number): Effect;
  34709. /**
  34710. * Sets an int array on a uniform variable.
  34711. * @param uniformName Name of the variable.
  34712. * @param array array to be set.
  34713. * @returns this effect.
  34714. */
  34715. setIntArray(uniformName: string, array: Int32Array): Effect;
  34716. /**
  34717. * 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)
  34718. * @param uniformName Name of the variable.
  34719. * @param array array to be set.
  34720. * @returns this effect.
  34721. */
  34722. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34723. /**
  34724. * 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)
  34725. * @param uniformName Name of the variable.
  34726. * @param array array to be set.
  34727. * @returns this effect.
  34728. */
  34729. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34730. /**
  34731. * 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)
  34732. * @param uniformName Name of the variable.
  34733. * @param array array to be set.
  34734. * @returns this effect.
  34735. */
  34736. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34737. /**
  34738. * Sets an float array on a uniform variable.
  34739. * @param uniformName Name of the variable.
  34740. * @param array array to be set.
  34741. * @returns this effect.
  34742. */
  34743. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34744. /**
  34745. * 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)
  34746. * @param uniformName Name of the variable.
  34747. * @param array array to be set.
  34748. * @returns this effect.
  34749. */
  34750. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34751. /**
  34752. * 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)
  34753. * @param uniformName Name of the variable.
  34754. * @param array array to be set.
  34755. * @returns this effect.
  34756. */
  34757. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34758. /**
  34759. * 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)
  34760. * @param uniformName Name of the variable.
  34761. * @param array array to be set.
  34762. * @returns this effect.
  34763. */
  34764. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34765. /**
  34766. * Sets an array on a uniform variable.
  34767. * @param uniformName Name of the variable.
  34768. * @param array array to be set.
  34769. * @returns this effect.
  34770. */
  34771. setArray(uniformName: string, array: number[]): Effect;
  34772. /**
  34773. * 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)
  34774. * @param uniformName Name of the variable.
  34775. * @param array array to be set.
  34776. * @returns this effect.
  34777. */
  34778. setArray2(uniformName: string, array: number[]): Effect;
  34779. /**
  34780. * 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)
  34781. * @param uniformName Name of the variable.
  34782. * @param array array to be set.
  34783. * @returns this effect.
  34784. */
  34785. setArray3(uniformName: string, array: number[]): Effect;
  34786. /**
  34787. * 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)
  34788. * @param uniformName Name of the variable.
  34789. * @param array array to be set.
  34790. * @returns this effect.
  34791. */
  34792. setArray4(uniformName: string, array: number[]): Effect;
  34793. /**
  34794. * Sets matrices on a uniform variable.
  34795. * @param uniformName Name of the variable.
  34796. * @param matrices matrices to be set.
  34797. * @returns this effect.
  34798. */
  34799. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  34800. /**
  34801. * Sets matrix on a uniform variable.
  34802. * @param uniformName Name of the variable.
  34803. * @param matrix matrix to be set.
  34804. * @returns this effect.
  34805. */
  34806. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34807. /**
  34808. * 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)
  34809. * @param uniformName Name of the variable.
  34810. * @param matrix matrix to be set.
  34811. * @returns this effect.
  34812. */
  34813. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  34814. /**
  34815. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34816. * @param uniformName Name of the variable.
  34817. * @param matrix matrix to be set.
  34818. * @returns this effect.
  34819. */
  34820. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  34821. /**
  34822. * Sets a float on a uniform variable.
  34823. * @param uniformName Name of the variable.
  34824. * @param value value to be set.
  34825. * @returns this effect.
  34826. */
  34827. setFloat(uniformName: string, value: number): Effect;
  34828. /**
  34829. * Sets a boolean on a uniform variable.
  34830. * @param uniformName Name of the variable.
  34831. * @param bool value to be set.
  34832. * @returns this effect.
  34833. */
  34834. setBool(uniformName: string, bool: boolean): Effect;
  34835. /**
  34836. * Sets a Vector2 on a uniform variable.
  34837. * @param uniformName Name of the variable.
  34838. * @param vector2 vector2 to be set.
  34839. * @returns this effect.
  34840. */
  34841. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34842. /**
  34843. * Sets a float2 on a uniform variable.
  34844. * @param uniformName Name of the variable.
  34845. * @param x First float in float2.
  34846. * @param y Second float in float2.
  34847. * @returns this effect.
  34848. */
  34849. setFloat2(uniformName: string, x: number, y: number): Effect;
  34850. /**
  34851. * Sets a Vector3 on a uniform variable.
  34852. * @param uniformName Name of the variable.
  34853. * @param vector3 Value to be set.
  34854. * @returns this effect.
  34855. */
  34856. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34857. /**
  34858. * Sets a float3 on a uniform variable.
  34859. * @param uniformName Name of the variable.
  34860. * @param x First float in float3.
  34861. * @param y Second float in float3.
  34862. * @param z Third float in float3.
  34863. * @returns this effect.
  34864. */
  34865. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34866. /**
  34867. * Sets a Vector4 on a uniform variable.
  34868. * @param uniformName Name of the variable.
  34869. * @param vector4 Value to be set.
  34870. * @returns this effect.
  34871. */
  34872. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34873. /**
  34874. * Sets a float4 on a uniform variable.
  34875. * @param uniformName Name of the variable.
  34876. * @param x First float in float4.
  34877. * @param y Second float in float4.
  34878. * @param z Third float in float4.
  34879. * @param w Fourth float in float4.
  34880. * @returns this effect.
  34881. */
  34882. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34883. /**
  34884. * Sets a Color3 on a uniform variable.
  34885. * @param uniformName Name of the variable.
  34886. * @param color3 Value to be set.
  34887. * @returns this effect.
  34888. */
  34889. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34890. /**
  34891. * Sets a Color4 on a uniform variable.
  34892. * @param uniformName Name of the variable.
  34893. * @param color3 Value to be set.
  34894. * @param alpha Alpha value to be set.
  34895. * @returns this effect.
  34896. */
  34897. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34898. /**
  34899. * Sets a Color4 on a uniform variable
  34900. * @param uniformName defines the name of the variable
  34901. * @param color4 defines the value to be set
  34902. * @returns this effect.
  34903. */
  34904. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34905. /** Release all associated resources */
  34906. dispose(): void;
  34907. /**
  34908. * This function will add a new shader to the shader store
  34909. * @param name the name of the shader
  34910. * @param pixelShader optional pixel shader content
  34911. * @param vertexShader optional vertex shader content
  34912. */
  34913. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34914. /**
  34915. * Store of each shader (The can be looked up using effect.key)
  34916. */
  34917. static ShadersStore: {
  34918. [key: string]: string;
  34919. };
  34920. /**
  34921. * Store of each included file for a shader (The can be looked up using effect.key)
  34922. */
  34923. static IncludesShadersStore: {
  34924. [key: string]: string;
  34925. };
  34926. /**
  34927. * Resets the cache of effects.
  34928. */
  34929. static ResetCache(): void;
  34930. }
  34931. }
  34932. declare module "babylonjs/Engines/engineCapabilities" {
  34933. /**
  34934. * Interface used to describe the capabilities of the engine relatively to the current browser
  34935. */
  34936. export interface EngineCapabilities {
  34937. /** Maximum textures units per fragment shader */
  34938. maxTexturesImageUnits: number;
  34939. /** Maximum texture units per vertex shader */
  34940. maxVertexTextureImageUnits: number;
  34941. /** Maximum textures units in the entire pipeline */
  34942. maxCombinedTexturesImageUnits: number;
  34943. /** Maximum texture size */
  34944. maxTextureSize: number;
  34945. /** Maximum texture samples */
  34946. maxSamples?: number;
  34947. /** Maximum cube texture size */
  34948. maxCubemapTextureSize: number;
  34949. /** Maximum render texture size */
  34950. maxRenderTextureSize: number;
  34951. /** Maximum number of vertex attributes */
  34952. maxVertexAttribs: number;
  34953. /** Maximum number of varyings */
  34954. maxVaryingVectors: number;
  34955. /** Maximum number of uniforms per vertex shader */
  34956. maxVertexUniformVectors: number;
  34957. /** Maximum number of uniforms per fragment shader */
  34958. maxFragmentUniformVectors: number;
  34959. /** Defines if standard derivates (dx/dy) are supported */
  34960. standardDerivatives: boolean;
  34961. /** Defines if s3tc texture compression is supported */
  34962. s3tc?: WEBGL_compressed_texture_s3tc;
  34963. /** Defines if pvrtc texture compression is supported */
  34964. pvrtc: any;
  34965. /** Defines if etc1 texture compression is supported */
  34966. etc1: any;
  34967. /** Defines if etc2 texture compression is supported */
  34968. etc2: any;
  34969. /** Defines if astc texture compression is supported */
  34970. astc: any;
  34971. /** Defines if float textures are supported */
  34972. textureFloat: boolean;
  34973. /** Defines if vertex array objects are supported */
  34974. vertexArrayObject: boolean;
  34975. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34976. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34977. /** Gets the maximum level of anisotropy supported */
  34978. maxAnisotropy: number;
  34979. /** Defines if instancing is supported */
  34980. instancedArrays: boolean;
  34981. /** Defines if 32 bits indices are supported */
  34982. uintIndices: boolean;
  34983. /** Defines if high precision shaders are supported */
  34984. highPrecisionShaderSupported: boolean;
  34985. /** Defines if depth reading in the fragment shader is supported */
  34986. fragmentDepthSupported: boolean;
  34987. /** Defines if float texture linear filtering is supported*/
  34988. textureFloatLinearFiltering: boolean;
  34989. /** Defines if rendering to float textures is supported */
  34990. textureFloatRender: boolean;
  34991. /** Defines if half float textures are supported*/
  34992. textureHalfFloat: boolean;
  34993. /** Defines if half float texture linear filtering is supported*/
  34994. textureHalfFloatLinearFiltering: boolean;
  34995. /** Defines if rendering to half float textures is supported */
  34996. textureHalfFloatRender: boolean;
  34997. /** Defines if textureLOD shader command is supported */
  34998. textureLOD: boolean;
  34999. /** Defines if draw buffers extension is supported */
  35000. drawBuffersExtension: boolean;
  35001. /** Defines if depth textures are supported */
  35002. depthTextureExtension: boolean;
  35003. /** Defines if float color buffer are supported */
  35004. colorBufferFloat: boolean;
  35005. /** Gets disjoint timer query extension (null if not supported) */
  35006. timerQuery?: EXT_disjoint_timer_query;
  35007. /** Defines if timestamp can be used with timer query */
  35008. canUseTimestampForTimerQuery: boolean;
  35009. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  35010. multiview?: any;
  35011. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  35012. oculusMultiview?: any;
  35013. /** Function used to let the system compiles shaders in background */
  35014. parallelShaderCompile?: {
  35015. COMPLETION_STATUS_KHR: number;
  35016. };
  35017. /** Max number of texture samples for MSAA */
  35018. maxMSAASamples: number;
  35019. /** Defines if the blend min max extension is supported */
  35020. blendMinMax: boolean;
  35021. }
  35022. }
  35023. declare module "babylonjs/States/depthCullingState" {
  35024. import { Nullable } from "babylonjs/types";
  35025. /**
  35026. * @hidden
  35027. **/
  35028. export class DepthCullingState {
  35029. private _isDepthTestDirty;
  35030. private _isDepthMaskDirty;
  35031. private _isDepthFuncDirty;
  35032. private _isCullFaceDirty;
  35033. private _isCullDirty;
  35034. private _isZOffsetDirty;
  35035. private _isFrontFaceDirty;
  35036. private _depthTest;
  35037. private _depthMask;
  35038. private _depthFunc;
  35039. private _cull;
  35040. private _cullFace;
  35041. private _zOffset;
  35042. private _frontFace;
  35043. /**
  35044. * Initializes the state.
  35045. */
  35046. constructor();
  35047. get isDirty(): boolean;
  35048. get zOffset(): number;
  35049. set zOffset(value: number);
  35050. get cullFace(): Nullable<number>;
  35051. set cullFace(value: Nullable<number>);
  35052. get cull(): Nullable<boolean>;
  35053. set cull(value: Nullable<boolean>);
  35054. get depthFunc(): Nullable<number>;
  35055. set depthFunc(value: Nullable<number>);
  35056. get depthMask(): boolean;
  35057. set depthMask(value: boolean);
  35058. get depthTest(): boolean;
  35059. set depthTest(value: boolean);
  35060. get frontFace(): Nullable<number>;
  35061. set frontFace(value: Nullable<number>);
  35062. reset(): void;
  35063. apply(gl: WebGLRenderingContext): void;
  35064. }
  35065. }
  35066. declare module "babylonjs/States/stencilState" {
  35067. /**
  35068. * @hidden
  35069. **/
  35070. export class StencilState {
  35071. /** 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 */
  35072. static readonly ALWAYS: number;
  35073. /** Passed to stencilOperation to specify that stencil value must be kept */
  35074. static readonly KEEP: number;
  35075. /** Passed to stencilOperation to specify that stencil value must be replaced */
  35076. static readonly REPLACE: number;
  35077. private _isStencilTestDirty;
  35078. private _isStencilMaskDirty;
  35079. private _isStencilFuncDirty;
  35080. private _isStencilOpDirty;
  35081. private _stencilTest;
  35082. private _stencilMask;
  35083. private _stencilFunc;
  35084. private _stencilFuncRef;
  35085. private _stencilFuncMask;
  35086. private _stencilOpStencilFail;
  35087. private _stencilOpDepthFail;
  35088. private _stencilOpStencilDepthPass;
  35089. get isDirty(): boolean;
  35090. get stencilFunc(): number;
  35091. set stencilFunc(value: number);
  35092. get stencilFuncRef(): number;
  35093. set stencilFuncRef(value: number);
  35094. get stencilFuncMask(): number;
  35095. set stencilFuncMask(value: number);
  35096. get stencilOpStencilFail(): number;
  35097. set stencilOpStencilFail(value: number);
  35098. get stencilOpDepthFail(): number;
  35099. set stencilOpDepthFail(value: number);
  35100. get stencilOpStencilDepthPass(): number;
  35101. set stencilOpStencilDepthPass(value: number);
  35102. get stencilMask(): number;
  35103. set stencilMask(value: number);
  35104. get stencilTest(): boolean;
  35105. set stencilTest(value: boolean);
  35106. constructor();
  35107. reset(): void;
  35108. apply(gl: WebGLRenderingContext): void;
  35109. }
  35110. }
  35111. declare module "babylonjs/States/alphaCullingState" {
  35112. /**
  35113. * @hidden
  35114. **/
  35115. export class AlphaState {
  35116. private _isAlphaBlendDirty;
  35117. private _isBlendFunctionParametersDirty;
  35118. private _isBlendEquationParametersDirty;
  35119. private _isBlendConstantsDirty;
  35120. private _alphaBlend;
  35121. private _blendFunctionParameters;
  35122. private _blendEquationParameters;
  35123. private _blendConstants;
  35124. /**
  35125. * Initializes the state.
  35126. */
  35127. constructor();
  35128. get isDirty(): boolean;
  35129. get alphaBlend(): boolean;
  35130. set alphaBlend(value: boolean);
  35131. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  35132. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  35133. setAlphaEquationParameters(rgb: number, alpha: number): void;
  35134. reset(): void;
  35135. apply(gl: WebGLRenderingContext): void;
  35136. }
  35137. }
  35138. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  35139. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35140. /** @hidden */
  35141. export class WebGL2ShaderProcessor implements IShaderProcessor {
  35142. attributeProcessor(attribute: string): string;
  35143. varyingProcessor(varying: string, isFragment: boolean): string;
  35144. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  35145. }
  35146. }
  35147. declare module "babylonjs/Engines/instancingAttributeInfo" {
  35148. /**
  35149. * Interface for attribute information associated with buffer instanciation
  35150. */
  35151. export interface InstancingAttributeInfo {
  35152. /**
  35153. * Name of the GLSL attribute
  35154. * if attribute index is not specified, this is used to retrieve the index from the effect
  35155. */
  35156. attributeName: string;
  35157. /**
  35158. * Index/offset of the attribute in the vertex shader
  35159. * if not specified, this will be computes from the name.
  35160. */
  35161. index?: number;
  35162. /**
  35163. * size of the attribute, 1, 2, 3 or 4
  35164. */
  35165. attributeSize: number;
  35166. /**
  35167. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  35168. */
  35169. offset: number;
  35170. /**
  35171. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  35172. * default to 1
  35173. */
  35174. divisor?: number;
  35175. /**
  35176. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  35177. * default is FLOAT
  35178. */
  35179. attributeType?: number;
  35180. /**
  35181. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  35182. */
  35183. normalized?: boolean;
  35184. }
  35185. }
  35186. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  35187. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35188. import { Nullable } from "babylonjs/types";
  35189. module "babylonjs/Engines/thinEngine" {
  35190. interface ThinEngine {
  35191. /**
  35192. * Update a video texture
  35193. * @param texture defines the texture to update
  35194. * @param video defines the video element to use
  35195. * @param invertY defines if data must be stored with Y axis inverted
  35196. */
  35197. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35198. }
  35199. }
  35200. }
  35201. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  35202. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35203. import { Nullable } from "babylonjs/types";
  35204. module "babylonjs/Engines/thinEngine" {
  35205. interface ThinEngine {
  35206. /**
  35207. * Creates a dynamic texture
  35208. * @param width defines the width of the texture
  35209. * @param height defines the height of the texture
  35210. * @param generateMipMaps defines if the engine should generate the mip levels
  35211. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  35212. * @returns the dynamic texture inside an InternalTexture
  35213. */
  35214. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  35215. /**
  35216. * Update the content of a dynamic texture
  35217. * @param texture defines the texture to update
  35218. * @param canvas defines the canvas containing the source
  35219. * @param invertY defines if data must be stored with Y axis inverted
  35220. * @param premulAlpha defines if alpha is stored as premultiplied
  35221. * @param format defines the format of the data
  35222. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  35223. */
  35224. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  35225. }
  35226. }
  35227. }
  35228. declare module "babylonjs/Materials/Textures/videoTexture" {
  35229. import { Observable } from "babylonjs/Misc/observable";
  35230. import { Nullable } from "babylonjs/types";
  35231. import { Scene } from "babylonjs/scene";
  35232. import { Texture } from "babylonjs/Materials/Textures/texture";
  35233. import "babylonjs/Engines/Extensions/engine.videoTexture";
  35234. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  35235. /**
  35236. * Settings for finer control over video usage
  35237. */
  35238. export interface VideoTextureSettings {
  35239. /**
  35240. * Applies `autoplay` to video, if specified
  35241. */
  35242. autoPlay?: boolean;
  35243. /**
  35244. * Applies `loop` to video, if specified
  35245. */
  35246. loop?: boolean;
  35247. /**
  35248. * Automatically updates internal texture from video at every frame in the render loop
  35249. */
  35250. autoUpdateTexture: boolean;
  35251. /**
  35252. * Image src displayed during the video loading or until the user interacts with the video.
  35253. */
  35254. poster?: string;
  35255. }
  35256. /**
  35257. * If you want to display a video in your scene, this is the special texture for that.
  35258. * This special texture works similar to other textures, with the exception of a few parameters.
  35259. * @see https://doc.babylonjs.com/how_to/video_texture
  35260. */
  35261. export class VideoTexture extends Texture {
  35262. /**
  35263. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35264. */
  35265. readonly autoUpdateTexture: boolean;
  35266. /**
  35267. * The video instance used by the texture internally
  35268. */
  35269. readonly video: HTMLVideoElement;
  35270. private _onUserActionRequestedObservable;
  35271. /**
  35272. * Event triggerd when a dom action is required by the user to play the video.
  35273. * This happens due to recent changes in browser policies preventing video to auto start.
  35274. */
  35275. get onUserActionRequestedObservable(): Observable<Texture>;
  35276. private _generateMipMaps;
  35277. private _stillImageCaptured;
  35278. private _displayingPosterTexture;
  35279. private _settings;
  35280. private _createInternalTextureOnEvent;
  35281. private _frameId;
  35282. private _currentSrc;
  35283. /**
  35284. * Creates a video texture.
  35285. * If you want to display a video in your scene, this is the special texture for that.
  35286. * This special texture works similar to other textures, with the exception of a few parameters.
  35287. * @see https://doc.babylonjs.com/how_to/video_texture
  35288. * @param name optional name, will detect from video source, if not defined
  35289. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35290. * @param scene is obviously the current scene.
  35291. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35292. * @param invertY is false by default but can be used to invert video on Y axis
  35293. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35294. * @param settings allows finer control over video usage
  35295. */
  35296. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35297. private _getName;
  35298. private _getVideo;
  35299. private _createInternalTexture;
  35300. private reset;
  35301. /**
  35302. * @hidden Internal method to initiate `update`.
  35303. */
  35304. _rebuild(): void;
  35305. /**
  35306. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35307. */
  35308. update(): void;
  35309. /**
  35310. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35311. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35312. */
  35313. updateTexture(isVisible: boolean): void;
  35314. protected _updateInternalTexture: () => void;
  35315. /**
  35316. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35317. * @param url New url.
  35318. */
  35319. updateURL(url: string): void;
  35320. /**
  35321. * Clones the texture.
  35322. * @returns the cloned texture
  35323. */
  35324. clone(): VideoTexture;
  35325. /**
  35326. * Dispose the texture and release its associated resources.
  35327. */
  35328. dispose(): void;
  35329. /**
  35330. * Creates a video texture straight from a stream.
  35331. * @param scene Define the scene the texture should be created in
  35332. * @param stream Define the stream the texture should be created from
  35333. * @returns The created video texture as a promise
  35334. */
  35335. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35336. /**
  35337. * Creates a video texture straight from your WebCam video feed.
  35338. * @param scene Define the scene the texture should be created in
  35339. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35340. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35341. * @returns The created video texture as a promise
  35342. */
  35343. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35344. minWidth: number;
  35345. maxWidth: number;
  35346. minHeight: number;
  35347. maxHeight: number;
  35348. deviceId: string;
  35349. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35350. /**
  35351. * Creates a video texture straight from your WebCam video feed.
  35352. * @param scene Define the scene the texture should be created in
  35353. * @param onReady Define a callback to triggered once the texture will be ready
  35354. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35355. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35356. */
  35357. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35358. minWidth: number;
  35359. maxWidth: number;
  35360. minHeight: number;
  35361. maxHeight: number;
  35362. deviceId: string;
  35363. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35364. }
  35365. }
  35366. declare module "babylonjs/Engines/thinEngine" {
  35367. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  35368. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  35369. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35370. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35371. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  35372. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  35373. import { Observable } from "babylonjs/Misc/observable";
  35374. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  35375. import { StencilState } from "babylonjs/States/stencilState";
  35376. import { AlphaState } from "babylonjs/States/alphaCullingState";
  35377. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35378. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  35379. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35380. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35381. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35382. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  35383. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  35384. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  35385. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35386. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35387. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35388. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  35389. import { WebRequest } from "babylonjs/Misc/webRequest";
  35390. import { LoadFileError } from "babylonjs/Misc/fileTools";
  35391. /**
  35392. * Defines the interface used by objects working like Scene
  35393. * @hidden
  35394. */
  35395. export interface ISceneLike {
  35396. _addPendingData(data: any): void;
  35397. _removePendingData(data: any): void;
  35398. offlineProvider: IOfflineProvider;
  35399. }
  35400. /** Interface defining initialization parameters for Engine class */
  35401. export interface EngineOptions extends WebGLContextAttributes {
  35402. /**
  35403. * Defines if the engine should no exceed a specified device ratio
  35404. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35405. */
  35406. limitDeviceRatio?: number;
  35407. /**
  35408. * Defines if webvr should be enabled automatically
  35409. * @see https://doc.babylonjs.com/how_to/webvr_camera
  35410. */
  35411. autoEnableWebVR?: boolean;
  35412. /**
  35413. * Defines if webgl2 should be turned off even if supported
  35414. * @see https://doc.babylonjs.com/features/webgl2
  35415. */
  35416. disableWebGL2Support?: boolean;
  35417. /**
  35418. * Defines if webaudio should be initialized as well
  35419. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35420. */
  35421. audioEngine?: boolean;
  35422. /**
  35423. * Defines if animations should run using a deterministic lock step
  35424. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35425. */
  35426. deterministicLockstep?: boolean;
  35427. /** Defines the maximum steps to use with deterministic lock step mode */
  35428. lockstepMaxSteps?: number;
  35429. /** Defines the seconds between each deterministic lock step */
  35430. timeStep?: number;
  35431. /**
  35432. * Defines that engine should ignore context lost events
  35433. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35434. */
  35435. doNotHandleContextLost?: boolean;
  35436. /**
  35437. * Defines that engine should ignore modifying touch action attribute and style
  35438. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35439. */
  35440. doNotHandleTouchAction?: boolean;
  35441. /**
  35442. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35443. */
  35444. useHighPrecisionFloats?: boolean;
  35445. /**
  35446. * Make the canvas XR Compatible for XR sessions
  35447. */
  35448. xrCompatible?: boolean;
  35449. }
  35450. /**
  35451. * The base engine class (root of all engines)
  35452. */
  35453. export class ThinEngine {
  35454. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35455. static ExceptionList: ({
  35456. key: string;
  35457. capture: string;
  35458. captureConstraint: number;
  35459. targets: string[];
  35460. } | {
  35461. key: string;
  35462. capture: null;
  35463. captureConstraint: null;
  35464. targets: string[];
  35465. })[];
  35466. /** @hidden */
  35467. static _TextureLoaders: IInternalTextureLoader[];
  35468. /**
  35469. * Returns the current npm package of the sdk
  35470. */
  35471. static get NpmPackage(): string;
  35472. /**
  35473. * Returns the current version of the framework
  35474. */
  35475. static get Version(): string;
  35476. /**
  35477. * Returns a string describing the current engine
  35478. */
  35479. get description(): string;
  35480. /**
  35481. * Gets or sets the epsilon value used by collision engine
  35482. */
  35483. static CollisionsEpsilon: number;
  35484. /**
  35485. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35486. */
  35487. static get ShadersRepository(): string;
  35488. static set ShadersRepository(value: string);
  35489. /** @hidden */
  35490. _shaderProcessor: IShaderProcessor;
  35491. /**
  35492. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35493. */
  35494. forcePOTTextures: boolean;
  35495. /**
  35496. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35497. */
  35498. isFullscreen: boolean;
  35499. /**
  35500. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35501. */
  35502. cullBackFaces: boolean;
  35503. /**
  35504. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35505. */
  35506. renderEvenInBackground: boolean;
  35507. /**
  35508. * Gets or sets a boolean indicating that cache can be kept between frames
  35509. */
  35510. preventCacheWipeBetweenFrames: boolean;
  35511. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35512. validateShaderPrograms: boolean;
  35513. /**
  35514. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35515. * This can provide greater z depth for distant objects.
  35516. */
  35517. useReverseDepthBuffer: boolean;
  35518. /**
  35519. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35520. */
  35521. disableUniformBuffers: boolean;
  35522. /** @hidden */
  35523. _uniformBuffers: UniformBuffer[];
  35524. /**
  35525. * Gets a boolean indicating that the engine supports uniform buffers
  35526. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35527. */
  35528. get supportsUniformBuffers(): boolean;
  35529. /** @hidden */
  35530. _gl: WebGLRenderingContext;
  35531. /** @hidden */
  35532. _webGLVersion: number;
  35533. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35534. protected _windowIsBackground: boolean;
  35535. protected _creationOptions: EngineOptions;
  35536. protected _highPrecisionShadersAllowed: boolean;
  35537. /** @hidden */
  35538. get _shouldUseHighPrecisionShader(): boolean;
  35539. /**
  35540. * Gets a boolean indicating that only power of 2 textures are supported
  35541. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35542. */
  35543. get needPOTTextures(): boolean;
  35544. /** @hidden */
  35545. _badOS: boolean;
  35546. /** @hidden */
  35547. _badDesktopOS: boolean;
  35548. private _hardwareScalingLevel;
  35549. /** @hidden */
  35550. _caps: EngineCapabilities;
  35551. private _isStencilEnable;
  35552. private _glVersion;
  35553. private _glRenderer;
  35554. private _glVendor;
  35555. /** @hidden */
  35556. _videoTextureSupported: boolean;
  35557. protected _renderingQueueLaunched: boolean;
  35558. protected _activeRenderLoops: (() => void)[];
  35559. /**
  35560. * Observable signaled when a context lost event is raised
  35561. */
  35562. onContextLostObservable: Observable<ThinEngine>;
  35563. /**
  35564. * Observable signaled when a context restored event is raised
  35565. */
  35566. onContextRestoredObservable: Observable<ThinEngine>;
  35567. private _onContextLost;
  35568. private _onContextRestored;
  35569. protected _contextWasLost: boolean;
  35570. /** @hidden */
  35571. _doNotHandleContextLost: boolean;
  35572. /**
  35573. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35574. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35575. */
  35576. get doNotHandleContextLost(): boolean;
  35577. set doNotHandleContextLost(value: boolean);
  35578. /**
  35579. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35580. */
  35581. disableVertexArrayObjects: boolean;
  35582. /** @hidden */
  35583. protected _colorWrite: boolean;
  35584. /** @hidden */
  35585. protected _colorWriteChanged: boolean;
  35586. /** @hidden */
  35587. protected _depthCullingState: DepthCullingState;
  35588. /** @hidden */
  35589. protected _stencilState: StencilState;
  35590. /** @hidden */
  35591. _alphaState: AlphaState;
  35592. /** @hidden */
  35593. _alphaMode: number;
  35594. /** @hidden */
  35595. _alphaEquation: number;
  35596. /** @hidden */
  35597. _internalTexturesCache: InternalTexture[];
  35598. /** @hidden */
  35599. protected _activeChannel: number;
  35600. private _currentTextureChannel;
  35601. /** @hidden */
  35602. protected _boundTexturesCache: {
  35603. [key: string]: Nullable<InternalTexture>;
  35604. };
  35605. /** @hidden */
  35606. protected _currentEffect: Nullable<Effect>;
  35607. /** @hidden */
  35608. protected _currentProgram: Nullable<WebGLProgram>;
  35609. private _compiledEffects;
  35610. private _vertexAttribArraysEnabled;
  35611. /** @hidden */
  35612. protected _cachedViewport: Nullable<IViewportLike>;
  35613. private _cachedVertexArrayObject;
  35614. /** @hidden */
  35615. protected _cachedVertexBuffers: any;
  35616. /** @hidden */
  35617. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35618. /** @hidden */
  35619. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35620. /** @hidden */
  35621. _currentRenderTarget: Nullable<InternalTexture>;
  35622. private _uintIndicesCurrentlySet;
  35623. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35624. /** @hidden */
  35625. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35626. /** @hidden */
  35627. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35628. private _currentBufferPointers;
  35629. private _currentInstanceLocations;
  35630. private _currentInstanceBuffers;
  35631. private _textureUnits;
  35632. /** @hidden */
  35633. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35634. /** @hidden */
  35635. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35636. /** @hidden */
  35637. _boundRenderFunction: any;
  35638. private _vaoRecordInProgress;
  35639. private _mustWipeVertexAttributes;
  35640. private _emptyTexture;
  35641. private _emptyCubeTexture;
  35642. private _emptyTexture3D;
  35643. private _emptyTexture2DArray;
  35644. /** @hidden */
  35645. _frameHandler: number;
  35646. private _nextFreeTextureSlots;
  35647. private _maxSimultaneousTextures;
  35648. private _activeRequests;
  35649. /** @hidden */
  35650. _transformTextureUrl: Nullable<(url: string) => string>;
  35651. protected get _supportsHardwareTextureRescaling(): boolean;
  35652. private _framebufferDimensionsObject;
  35653. /**
  35654. * sets the object from which width and height will be taken from when getting render width and height
  35655. * Will fallback to the gl object
  35656. * @param dimensions the framebuffer width and height that will be used.
  35657. */
  35658. set framebufferDimensionsObject(dimensions: Nullable<{
  35659. framebufferWidth: number;
  35660. framebufferHeight: number;
  35661. }>);
  35662. /**
  35663. * Gets the current viewport
  35664. */
  35665. get currentViewport(): Nullable<IViewportLike>;
  35666. /**
  35667. * Gets the default empty texture
  35668. */
  35669. get emptyTexture(): InternalTexture;
  35670. /**
  35671. * Gets the default empty 3D texture
  35672. */
  35673. get emptyTexture3D(): InternalTexture;
  35674. /**
  35675. * Gets the default empty 2D array texture
  35676. */
  35677. get emptyTexture2DArray(): InternalTexture;
  35678. /**
  35679. * Gets the default empty cube texture
  35680. */
  35681. get emptyCubeTexture(): InternalTexture;
  35682. /**
  35683. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35684. */
  35685. readonly premultipliedAlpha: boolean;
  35686. /**
  35687. * Observable event triggered before each texture is initialized
  35688. */
  35689. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  35690. /**
  35691. * Creates a new engine
  35692. * @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
  35693. * @param antialias defines enable antialiasing (default: false)
  35694. * @param options defines further options to be sent to the getContext() function
  35695. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35696. */
  35697. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35698. private _rebuildInternalTextures;
  35699. private _rebuildEffects;
  35700. /**
  35701. * Gets a boolean indicating if all created effects are ready
  35702. * @returns true if all effects are ready
  35703. */
  35704. areAllEffectsReady(): boolean;
  35705. protected _rebuildBuffers(): void;
  35706. protected _initGLContext(): void;
  35707. /**
  35708. * Gets version of the current webGL context
  35709. */
  35710. get webGLVersion(): number;
  35711. /**
  35712. * Gets a string idenfifying the name of the class
  35713. * @returns "Engine" string
  35714. */
  35715. getClassName(): string;
  35716. /**
  35717. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35718. */
  35719. get isStencilEnable(): boolean;
  35720. /** @hidden */
  35721. _prepareWorkingCanvas(): void;
  35722. /**
  35723. * Reset the texture cache to empty state
  35724. */
  35725. resetTextureCache(): void;
  35726. /**
  35727. * Gets an object containing information about the current webGL context
  35728. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35729. */
  35730. getGlInfo(): {
  35731. vendor: string;
  35732. renderer: string;
  35733. version: string;
  35734. };
  35735. /**
  35736. * Defines the hardware scaling level.
  35737. * By default the hardware scaling level is computed from the window device ratio.
  35738. * 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.
  35739. * @param level defines the level to use
  35740. */
  35741. setHardwareScalingLevel(level: number): void;
  35742. /**
  35743. * Gets the current hardware scaling level.
  35744. * By default the hardware scaling level is computed from the window device ratio.
  35745. * 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.
  35746. * @returns a number indicating the current hardware scaling level
  35747. */
  35748. getHardwareScalingLevel(): number;
  35749. /**
  35750. * Gets the list of loaded textures
  35751. * @returns an array containing all loaded textures
  35752. */
  35753. getLoadedTexturesCache(): InternalTexture[];
  35754. /**
  35755. * Gets the object containing all engine capabilities
  35756. * @returns the EngineCapabilities object
  35757. */
  35758. getCaps(): EngineCapabilities;
  35759. /**
  35760. * stop executing a render loop function and remove it from the execution array
  35761. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35762. */
  35763. stopRenderLoop(renderFunction?: () => void): void;
  35764. /** @hidden */
  35765. _renderLoop(): void;
  35766. /**
  35767. * Gets the HTML canvas attached with the current webGL context
  35768. * @returns a HTML canvas
  35769. */
  35770. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35771. /**
  35772. * Gets host window
  35773. * @returns the host window object
  35774. */
  35775. getHostWindow(): Nullable<Window>;
  35776. /**
  35777. * Gets the current render width
  35778. * @param useScreen defines if screen size must be used (or the current render target if any)
  35779. * @returns a number defining the current render width
  35780. */
  35781. getRenderWidth(useScreen?: boolean): number;
  35782. /**
  35783. * Gets the current render height
  35784. * @param useScreen defines if screen size must be used (or the current render target if any)
  35785. * @returns a number defining the current render height
  35786. */
  35787. getRenderHeight(useScreen?: boolean): number;
  35788. /**
  35789. * Can be used to override the current requestAnimationFrame requester.
  35790. * @hidden
  35791. */
  35792. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35793. /**
  35794. * Register and execute a render loop. The engine can have more than one render function
  35795. * @param renderFunction defines the function to continuously execute
  35796. */
  35797. runRenderLoop(renderFunction: () => void): void;
  35798. /**
  35799. * Clear the current render buffer or the current render target (if any is set up)
  35800. * @param color defines the color to use
  35801. * @param backBuffer defines if the back buffer must be cleared
  35802. * @param depth defines if the depth buffer must be cleared
  35803. * @param stencil defines if the stencil buffer must be cleared
  35804. */
  35805. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35806. private _viewportCached;
  35807. /** @hidden */
  35808. _viewport(x: number, y: number, width: number, height: number): void;
  35809. /**
  35810. * Set the WebGL's viewport
  35811. * @param viewport defines the viewport element to be used
  35812. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35813. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35814. */
  35815. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35816. /**
  35817. * Begin a new frame
  35818. */
  35819. beginFrame(): void;
  35820. /**
  35821. * Enf the current frame
  35822. */
  35823. endFrame(): void;
  35824. /**
  35825. * Resize the view according to the canvas' size
  35826. */
  35827. resize(): void;
  35828. /**
  35829. * Force a specific size of the canvas
  35830. * @param width defines the new canvas' width
  35831. * @param height defines the new canvas' height
  35832. * @returns true if the size was changed
  35833. */
  35834. setSize(width: number, height: number): boolean;
  35835. /**
  35836. * Binds the frame buffer to the specified texture.
  35837. * @param texture The texture to render to or null for the default canvas
  35838. * @param faceIndex The face of the texture to render to in case of cube texture
  35839. * @param requiredWidth The width of the target to render to
  35840. * @param requiredHeight The height of the target to render to
  35841. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35842. * @param lodLevel defines the lod level to bind to the frame buffer
  35843. * @param layer defines the 2d array index to bind to frame buffer to
  35844. */
  35845. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35846. /** @hidden */
  35847. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35848. /**
  35849. * Unbind the current render target texture from the webGL context
  35850. * @param texture defines the render target texture to unbind
  35851. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35852. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35853. */
  35854. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35855. /**
  35856. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35857. */
  35858. flushFramebuffer(): void;
  35859. /**
  35860. * Unbind the current render target and bind the default framebuffer
  35861. */
  35862. restoreDefaultFramebuffer(): void;
  35863. /** @hidden */
  35864. protected _resetVertexBufferBinding(): void;
  35865. /**
  35866. * Creates a vertex buffer
  35867. * @param data the data for the vertex buffer
  35868. * @returns the new WebGL static buffer
  35869. */
  35870. createVertexBuffer(data: DataArray): DataBuffer;
  35871. private _createVertexBuffer;
  35872. /**
  35873. * Creates a dynamic vertex buffer
  35874. * @param data the data for the dynamic vertex buffer
  35875. * @returns the new WebGL dynamic buffer
  35876. */
  35877. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35878. protected _resetIndexBufferBinding(): void;
  35879. /**
  35880. * Creates a new index buffer
  35881. * @param indices defines the content of the index buffer
  35882. * @param updatable defines if the index buffer must be updatable
  35883. * @returns a new webGL buffer
  35884. */
  35885. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35886. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35887. /**
  35888. * Bind a webGL buffer to the webGL context
  35889. * @param buffer defines the buffer to bind
  35890. */
  35891. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35892. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35893. private bindBuffer;
  35894. /**
  35895. * update the bound buffer with the given data
  35896. * @param data defines the data to update
  35897. */
  35898. updateArrayBuffer(data: Float32Array): void;
  35899. private _vertexAttribPointer;
  35900. /** @hidden */
  35901. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35902. private _bindVertexBuffersAttributes;
  35903. /**
  35904. * Records a vertex array object
  35905. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35906. * @param vertexBuffers defines the list of vertex buffers to store
  35907. * @param indexBuffer defines the index buffer to store
  35908. * @param effect defines the effect to store
  35909. * @returns the new vertex array object
  35910. */
  35911. recordVertexArrayObject(vertexBuffers: {
  35912. [key: string]: VertexBuffer;
  35913. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35914. /**
  35915. * Bind a specific vertex array object
  35916. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35917. * @param vertexArrayObject defines the vertex array object to bind
  35918. * @param indexBuffer defines the index buffer to bind
  35919. */
  35920. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35921. /**
  35922. * Bind webGl buffers directly to the webGL context
  35923. * @param vertexBuffer defines the vertex buffer to bind
  35924. * @param indexBuffer defines the index buffer to bind
  35925. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35926. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35927. * @param effect defines the effect associated with the vertex buffer
  35928. */
  35929. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35930. private _unbindVertexArrayObject;
  35931. /**
  35932. * Bind a list of vertex buffers to the webGL context
  35933. * @param vertexBuffers defines the list of vertex buffers to bind
  35934. * @param indexBuffer defines the index buffer to bind
  35935. * @param effect defines the effect associated with the vertex buffers
  35936. */
  35937. bindBuffers(vertexBuffers: {
  35938. [key: string]: Nullable<VertexBuffer>;
  35939. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35940. /**
  35941. * Unbind all instance attributes
  35942. */
  35943. unbindInstanceAttributes(): void;
  35944. /**
  35945. * Release and free the memory of a vertex array object
  35946. * @param vao defines the vertex array object to delete
  35947. */
  35948. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35949. /** @hidden */
  35950. _releaseBuffer(buffer: DataBuffer): boolean;
  35951. protected _deleteBuffer(buffer: DataBuffer): void;
  35952. /**
  35953. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35954. * @param instancesBuffer defines the webGL buffer to update and bind
  35955. * @param data defines the data to store in the buffer
  35956. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35957. */
  35958. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35959. /**
  35960. * Bind the content of a webGL buffer used with instantiation
  35961. * @param instancesBuffer defines the webGL buffer to bind
  35962. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35963. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35964. */
  35965. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35966. /**
  35967. * Disable the instance attribute corresponding to the name in parameter
  35968. * @param name defines the name of the attribute to disable
  35969. */
  35970. disableInstanceAttributeByName(name: string): void;
  35971. /**
  35972. * Disable the instance attribute corresponding to the location in parameter
  35973. * @param attributeLocation defines the attribute location of the attribute to disable
  35974. */
  35975. disableInstanceAttribute(attributeLocation: number): void;
  35976. /**
  35977. * Disable the attribute corresponding to the location in parameter
  35978. * @param attributeLocation defines the attribute location of the attribute to disable
  35979. */
  35980. disableAttributeByIndex(attributeLocation: number): void;
  35981. /**
  35982. * Send a draw order
  35983. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35984. * @param indexStart defines the starting index
  35985. * @param indexCount defines the number of index to draw
  35986. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35987. */
  35988. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35989. /**
  35990. * Draw a list of points
  35991. * @param verticesStart defines the index of first vertex to draw
  35992. * @param verticesCount defines the count of vertices to draw
  35993. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35994. */
  35995. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35996. /**
  35997. * Draw a list of unindexed primitives
  35998. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35999. * @param verticesStart defines the index of first vertex to draw
  36000. * @param verticesCount defines the count of vertices to draw
  36001. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36002. */
  36003. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36004. /**
  36005. * Draw a list of indexed primitives
  36006. * @param fillMode defines the primitive to use
  36007. * @param indexStart defines the starting index
  36008. * @param indexCount defines the number of index to draw
  36009. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36010. */
  36011. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  36012. /**
  36013. * Draw a list of unindexed primitives
  36014. * @param fillMode defines the primitive to use
  36015. * @param verticesStart defines the index of first vertex to draw
  36016. * @param verticesCount defines the count of vertices to draw
  36017. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36018. */
  36019. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36020. private _drawMode;
  36021. /** @hidden */
  36022. protected _reportDrawCall(): void;
  36023. /** @hidden */
  36024. _releaseEffect(effect: Effect): void;
  36025. /** @hidden */
  36026. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36027. /**
  36028. * Create a new effect (used to store vertex/fragment shaders)
  36029. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  36030. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  36031. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  36032. * @param samplers defines an array of string used to represent textures
  36033. * @param defines defines the string containing the defines to use to compile the shaders
  36034. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  36035. * @param onCompiled defines a function to call when the effect creation is successful
  36036. * @param onError defines a function to call when the effect creation has failed
  36037. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  36038. * @returns the new Effect
  36039. */
  36040. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  36041. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  36042. private _compileShader;
  36043. private _compileRawShader;
  36044. /** @hidden */
  36045. _getShaderSource(shader: WebGLShader): Nullable<string>;
  36046. /**
  36047. * Directly creates a webGL program
  36048. * @param pipelineContext defines the pipeline context to attach to
  36049. * @param vertexCode defines the vertex shader code to use
  36050. * @param fragmentCode defines the fragment shader code to use
  36051. * @param context defines the webGL context to use (if not set, the current one will be used)
  36052. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36053. * @returns the new webGL program
  36054. */
  36055. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36056. /**
  36057. * Creates a webGL program
  36058. * @param pipelineContext defines the pipeline context to attach to
  36059. * @param vertexCode defines the vertex shader code to use
  36060. * @param fragmentCode defines the fragment shader code to use
  36061. * @param defines defines the string containing the defines to use to compile the shaders
  36062. * @param context defines the webGL context to use (if not set, the current one will be used)
  36063. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36064. * @returns the new webGL program
  36065. */
  36066. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36067. /**
  36068. * Creates a new pipeline context
  36069. * @returns the new pipeline
  36070. */
  36071. createPipelineContext(): IPipelineContext;
  36072. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36073. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  36074. /** @hidden */
  36075. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  36076. /** @hidden */
  36077. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  36078. /** @hidden */
  36079. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  36080. /**
  36081. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  36082. * @param pipelineContext defines the pipeline context to use
  36083. * @param uniformsNames defines the list of uniform names
  36084. * @returns an array of webGL uniform locations
  36085. */
  36086. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  36087. /**
  36088. * Gets the lsit of active attributes for a given webGL program
  36089. * @param pipelineContext defines the pipeline context to use
  36090. * @param attributesNames defines the list of attribute names to get
  36091. * @returns an array of indices indicating the offset of each attribute
  36092. */
  36093. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  36094. /**
  36095. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  36096. * @param effect defines the effect to activate
  36097. */
  36098. enableEffect(effect: Nullable<Effect>): void;
  36099. /**
  36100. * Set the value of an uniform to a number (int)
  36101. * @param uniform defines the webGL uniform location where to store the value
  36102. * @param value defines the int number to store
  36103. */
  36104. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36105. /**
  36106. * Set the value of an uniform to an array of int32
  36107. * @param uniform defines the webGL uniform location where to store the value
  36108. * @param array defines the array of int32 to store
  36109. */
  36110. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36111. /**
  36112. * Set the value of an uniform to an array of int32 (stored as vec2)
  36113. * @param uniform defines the webGL uniform location where to store the value
  36114. * @param array defines the array of int32 to store
  36115. */
  36116. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36117. /**
  36118. * Set the value of an uniform to an array of int32 (stored as vec3)
  36119. * @param uniform defines the webGL uniform location where to store the value
  36120. * @param array defines the array of int32 to store
  36121. */
  36122. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36123. /**
  36124. * Set the value of an uniform to an array of int32 (stored as vec4)
  36125. * @param uniform defines the webGL uniform location where to store the value
  36126. * @param array defines the array of int32 to store
  36127. */
  36128. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36129. /**
  36130. * Set the value of an uniform to an array of number
  36131. * @param uniform defines the webGL uniform location where to store the value
  36132. * @param array defines the array of number to store
  36133. */
  36134. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36135. /**
  36136. * Set the value of an uniform to an array of number (stored as vec2)
  36137. * @param uniform defines the webGL uniform location where to store the value
  36138. * @param array defines the array of number to store
  36139. */
  36140. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36141. /**
  36142. * Set the value of an uniform to an array of number (stored as vec3)
  36143. * @param uniform defines the webGL uniform location where to store the value
  36144. * @param array defines the array of number to store
  36145. */
  36146. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36147. /**
  36148. * Set the value of an uniform to an array of number (stored as vec4)
  36149. * @param uniform defines the webGL uniform location where to store the value
  36150. * @param array defines the array of number to store
  36151. */
  36152. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36153. /**
  36154. * Set the value of an uniform to an array of float32 (stored as matrices)
  36155. * @param uniform defines the webGL uniform location where to store the value
  36156. * @param matrices defines the array of float32 to store
  36157. */
  36158. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  36159. /**
  36160. * Set the value of an uniform to a matrix (3x3)
  36161. * @param uniform defines the webGL uniform location where to store the value
  36162. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  36163. */
  36164. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36165. /**
  36166. * Set the value of an uniform to a matrix (2x2)
  36167. * @param uniform defines the webGL uniform location where to store the value
  36168. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  36169. */
  36170. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36171. /**
  36172. * Set the value of an uniform to a number (float)
  36173. * @param uniform defines the webGL uniform location where to store the value
  36174. * @param value defines the float number to store
  36175. */
  36176. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36177. /**
  36178. * Set the value of an uniform to a vec2
  36179. * @param uniform defines the webGL uniform location where to store the value
  36180. * @param x defines the 1st component of the value
  36181. * @param y defines the 2nd component of the value
  36182. */
  36183. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  36184. /**
  36185. * Set the value of an uniform to a vec3
  36186. * @param uniform defines the webGL uniform location where to store the value
  36187. * @param x defines the 1st component of the value
  36188. * @param y defines the 2nd component of the value
  36189. * @param z defines the 3rd component of the value
  36190. */
  36191. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  36192. /**
  36193. * Set the value of an uniform to a vec4
  36194. * @param uniform defines the webGL uniform location where to store the value
  36195. * @param x defines the 1st component of the value
  36196. * @param y defines the 2nd component of the value
  36197. * @param z defines the 3rd component of the value
  36198. * @param w defines the 4th component of the value
  36199. */
  36200. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  36201. /**
  36202. * Apply all cached states (depth, culling, stencil and alpha)
  36203. */
  36204. applyStates(): void;
  36205. /**
  36206. * Enable or disable color writing
  36207. * @param enable defines the state to set
  36208. */
  36209. setColorWrite(enable: boolean): void;
  36210. /**
  36211. * Gets a boolean indicating if color writing is enabled
  36212. * @returns the current color writing state
  36213. */
  36214. getColorWrite(): boolean;
  36215. /**
  36216. * Gets the depth culling state manager
  36217. */
  36218. get depthCullingState(): DepthCullingState;
  36219. /**
  36220. * Gets the alpha state manager
  36221. */
  36222. get alphaState(): AlphaState;
  36223. /**
  36224. * Gets the stencil state manager
  36225. */
  36226. get stencilState(): StencilState;
  36227. /**
  36228. * Clears the list of texture accessible through engine.
  36229. * This can help preventing texture load conflict due to name collision.
  36230. */
  36231. clearInternalTexturesCache(): void;
  36232. /**
  36233. * Force the entire cache to be cleared
  36234. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36235. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36236. */
  36237. wipeCaches(bruteForce?: boolean): void;
  36238. /** @hidden */
  36239. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36240. min: number;
  36241. mag: number;
  36242. };
  36243. /** @hidden */
  36244. _createTexture(): WebGLTexture;
  36245. /**
  36246. * Usually called from Texture.ts.
  36247. * Passed information to create a WebGLTexture
  36248. * @param url defines a value which contains one of the following:
  36249. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36250. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36251. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36252. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36253. * @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)
  36254. * @param scene needed for loading to the correct scene
  36255. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36256. * @param onLoad optional callback to be called upon successful completion
  36257. * @param onError optional callback to be called upon failure
  36258. * @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
  36259. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36260. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36261. * @param forcedExtension defines the extension to use to pick the right loader
  36262. * @param mimeType defines an optional mime type
  36263. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36264. */
  36265. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  36266. /**
  36267. * Loads an image as an HTMLImageElement.
  36268. * @param input url string, ArrayBuffer, or Blob to load
  36269. * @param onLoad callback called when the image successfully loads
  36270. * @param onError callback called when the image fails to load
  36271. * @param offlineProvider offline provider for caching
  36272. * @param mimeType optional mime type
  36273. * @returns the HTMLImageElement of the loaded image
  36274. * @hidden
  36275. */
  36276. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  36277. /**
  36278. * @hidden
  36279. */
  36280. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36281. private _unpackFlipYCached;
  36282. /**
  36283. * In case you are sharing the context with other applications, it might
  36284. * be interested to not cache the unpack flip y state to ensure a consistent
  36285. * value would be set.
  36286. */
  36287. enableUnpackFlipYCached: boolean;
  36288. /** @hidden */
  36289. _unpackFlipY(value: boolean): void;
  36290. /** @hidden */
  36291. _getUnpackAlignement(): number;
  36292. private _getTextureTarget;
  36293. /**
  36294. * Update the sampling mode of a given texture
  36295. * @param samplingMode defines the required sampling mode
  36296. * @param texture defines the texture to update
  36297. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36298. */
  36299. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36300. /**
  36301. * Update the sampling mode of a given texture
  36302. * @param texture defines the texture to update
  36303. * @param wrapU defines the texture wrap mode of the u coordinates
  36304. * @param wrapV defines the texture wrap mode of the v coordinates
  36305. * @param wrapR defines the texture wrap mode of the r coordinates
  36306. */
  36307. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36308. /** @hidden */
  36309. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36310. width: number;
  36311. height: number;
  36312. layers?: number;
  36313. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36314. /** @hidden */
  36315. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36316. /** @hidden */
  36317. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36318. /**
  36319. * Update a portion of an internal texture
  36320. * @param texture defines the texture to update
  36321. * @param imageData defines the data to store into the texture
  36322. * @param xOffset defines the x coordinates of the update rectangle
  36323. * @param yOffset defines the y coordinates of the update rectangle
  36324. * @param width defines the width of the update rectangle
  36325. * @param height defines the height of the update rectangle
  36326. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36327. * @param lod defines the lod level to update (0 by default)
  36328. */
  36329. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36330. /** @hidden */
  36331. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36332. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36333. private _prepareWebGLTexture;
  36334. /** @hidden */
  36335. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36336. private _getDepthStencilBuffer;
  36337. /** @hidden */
  36338. _releaseFramebufferObjects(texture: InternalTexture): void;
  36339. /** @hidden */
  36340. _releaseTexture(texture: InternalTexture): void;
  36341. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36342. protected _setProgram(program: WebGLProgram): void;
  36343. protected _boundUniforms: {
  36344. [key: number]: WebGLUniformLocation;
  36345. };
  36346. /**
  36347. * Binds an effect to the webGL context
  36348. * @param effect defines the effect to bind
  36349. */
  36350. bindSamplers(effect: Effect): void;
  36351. private _activateCurrentTexture;
  36352. /** @hidden */
  36353. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36354. /** @hidden */
  36355. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36356. /**
  36357. * Unbind all textures from the webGL context
  36358. */
  36359. unbindAllTextures(): void;
  36360. /**
  36361. * Sets a texture to the according uniform.
  36362. * @param channel The texture channel
  36363. * @param uniform The uniform to set
  36364. * @param texture The texture to apply
  36365. */
  36366. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36367. private _bindSamplerUniformToChannel;
  36368. private _getTextureWrapMode;
  36369. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36370. /**
  36371. * Sets an array of texture to the webGL context
  36372. * @param channel defines the channel where the texture array must be set
  36373. * @param uniform defines the associated uniform location
  36374. * @param textures defines the array of textures to bind
  36375. */
  36376. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36377. /** @hidden */
  36378. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36379. private _setTextureParameterFloat;
  36380. private _setTextureParameterInteger;
  36381. /**
  36382. * Unbind all vertex attributes from the webGL context
  36383. */
  36384. unbindAllAttributes(): void;
  36385. /**
  36386. * 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
  36387. */
  36388. releaseEffects(): void;
  36389. /**
  36390. * Dispose and release all associated resources
  36391. */
  36392. dispose(): void;
  36393. /**
  36394. * Attach a new callback raised when context lost event is fired
  36395. * @param callback defines the callback to call
  36396. */
  36397. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36398. /**
  36399. * Attach a new callback raised when context restored event is fired
  36400. * @param callback defines the callback to call
  36401. */
  36402. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36403. /**
  36404. * Get the current error code of the webGL context
  36405. * @returns the error code
  36406. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36407. */
  36408. getError(): number;
  36409. private _canRenderToFloatFramebuffer;
  36410. private _canRenderToHalfFloatFramebuffer;
  36411. private _canRenderToFramebuffer;
  36412. /** @hidden */
  36413. _getWebGLTextureType(type: number): number;
  36414. /** @hidden */
  36415. _getInternalFormat(format: number): number;
  36416. /** @hidden */
  36417. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36418. /** @hidden */
  36419. _getRGBAMultiSampleBufferFormat(type: number): number;
  36420. /** @hidden */
  36421. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  36422. /**
  36423. * Loads a file from a url
  36424. * @param url url to load
  36425. * @param onSuccess callback called when the file successfully loads
  36426. * @param onProgress callback called while file is loading (if the server supports this mode)
  36427. * @param offlineProvider defines the offline provider for caching
  36428. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36429. * @param onError callback called when the file fails to load
  36430. * @returns a file request object
  36431. * @hidden
  36432. */
  36433. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  36434. /**
  36435. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36436. * @param x defines the x coordinate of the rectangle where pixels must be read
  36437. * @param y defines the y coordinate of the rectangle where pixels must be read
  36438. * @param width defines the width of the rectangle where pixels must be read
  36439. * @param height defines the height of the rectangle where pixels must be read
  36440. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36441. * @returns a Uint8Array containing RGBA colors
  36442. */
  36443. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36444. private static _isSupported;
  36445. /**
  36446. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36447. * @returns true if the engine can be created
  36448. * @ignorenaming
  36449. */
  36450. static isSupported(): boolean;
  36451. /**
  36452. * Find the next highest power of two.
  36453. * @param x Number to start search from.
  36454. * @return Next highest power of two.
  36455. */
  36456. static CeilingPOT(x: number): number;
  36457. /**
  36458. * Find the next lowest power of two.
  36459. * @param x Number to start search from.
  36460. * @return Next lowest power of two.
  36461. */
  36462. static FloorPOT(x: number): number;
  36463. /**
  36464. * Find the nearest power of two.
  36465. * @param x Number to start search from.
  36466. * @return Next nearest power of two.
  36467. */
  36468. static NearestPOT(x: number): number;
  36469. /**
  36470. * Get the closest exponent of two
  36471. * @param value defines the value to approximate
  36472. * @param max defines the maximum value to return
  36473. * @param mode defines how to define the closest value
  36474. * @returns closest exponent of two of the given value
  36475. */
  36476. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36477. /**
  36478. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36479. * @param func - the function to be called
  36480. * @param requester - the object that will request the next frame. Falls back to window.
  36481. * @returns frame number
  36482. */
  36483. static QueueNewFrame(func: () => void, requester?: any): number;
  36484. /**
  36485. * Gets host document
  36486. * @returns the host document object
  36487. */
  36488. getHostDocument(): Nullable<Document>;
  36489. }
  36490. }
  36491. declare module "babylonjs/Maths/sphericalPolynomial" {
  36492. import { Vector3 } from "babylonjs/Maths/math.vector";
  36493. import { Color3 } from "babylonjs/Maths/math.color";
  36494. /**
  36495. * Class representing spherical harmonics coefficients to the 3rd degree
  36496. */
  36497. export class SphericalHarmonics {
  36498. /**
  36499. * Defines whether or not the harmonics have been prescaled for rendering.
  36500. */
  36501. preScaled: boolean;
  36502. /**
  36503. * The l0,0 coefficients of the spherical harmonics
  36504. */
  36505. l00: Vector3;
  36506. /**
  36507. * The l1,-1 coefficients of the spherical harmonics
  36508. */
  36509. l1_1: Vector3;
  36510. /**
  36511. * The l1,0 coefficients of the spherical harmonics
  36512. */
  36513. l10: Vector3;
  36514. /**
  36515. * The l1,1 coefficients of the spherical harmonics
  36516. */
  36517. l11: Vector3;
  36518. /**
  36519. * The l2,-2 coefficients of the spherical harmonics
  36520. */
  36521. l2_2: Vector3;
  36522. /**
  36523. * The l2,-1 coefficients of the spherical harmonics
  36524. */
  36525. l2_1: Vector3;
  36526. /**
  36527. * The l2,0 coefficients of the spherical harmonics
  36528. */
  36529. l20: Vector3;
  36530. /**
  36531. * The l2,1 coefficients of the spherical harmonics
  36532. */
  36533. l21: Vector3;
  36534. /**
  36535. * The l2,2 coefficients of the spherical harmonics
  36536. */
  36537. l22: Vector3;
  36538. /**
  36539. * Adds a light to the spherical harmonics
  36540. * @param direction the direction of the light
  36541. * @param color the color of the light
  36542. * @param deltaSolidAngle the delta solid angle of the light
  36543. */
  36544. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36545. /**
  36546. * Scales the spherical harmonics by the given amount
  36547. * @param scale the amount to scale
  36548. */
  36549. scaleInPlace(scale: number): void;
  36550. /**
  36551. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36552. *
  36553. * ```
  36554. * E_lm = A_l * L_lm
  36555. * ```
  36556. *
  36557. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36558. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36559. * the scaling factors are given in equation 9.
  36560. */
  36561. convertIncidentRadianceToIrradiance(): void;
  36562. /**
  36563. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36564. *
  36565. * ```
  36566. * L = (1/pi) * E * rho
  36567. * ```
  36568. *
  36569. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36570. */
  36571. convertIrradianceToLambertianRadiance(): void;
  36572. /**
  36573. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36574. * required operations at run time.
  36575. *
  36576. * This is simply done by scaling back the SH with Ylm constants parameter.
  36577. * The trigonometric part being applied by the shader at run time.
  36578. */
  36579. preScaleForRendering(): void;
  36580. /**
  36581. * Constructs a spherical harmonics from an array.
  36582. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36583. * @returns the spherical harmonics
  36584. */
  36585. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36586. /**
  36587. * Gets the spherical harmonics from polynomial
  36588. * @param polynomial the spherical polynomial
  36589. * @returns the spherical harmonics
  36590. */
  36591. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36592. }
  36593. /**
  36594. * Class representing spherical polynomial coefficients to the 3rd degree
  36595. */
  36596. export class SphericalPolynomial {
  36597. private _harmonics;
  36598. /**
  36599. * The spherical harmonics used to create the polynomials.
  36600. */
  36601. get preScaledHarmonics(): SphericalHarmonics;
  36602. /**
  36603. * The x coefficients of the spherical polynomial
  36604. */
  36605. x: Vector3;
  36606. /**
  36607. * The y coefficients of the spherical polynomial
  36608. */
  36609. y: Vector3;
  36610. /**
  36611. * The z coefficients of the spherical polynomial
  36612. */
  36613. z: Vector3;
  36614. /**
  36615. * The xx coefficients of the spherical polynomial
  36616. */
  36617. xx: Vector3;
  36618. /**
  36619. * The yy coefficients of the spherical polynomial
  36620. */
  36621. yy: Vector3;
  36622. /**
  36623. * The zz coefficients of the spherical polynomial
  36624. */
  36625. zz: Vector3;
  36626. /**
  36627. * The xy coefficients of the spherical polynomial
  36628. */
  36629. xy: Vector3;
  36630. /**
  36631. * The yz coefficients of the spherical polynomial
  36632. */
  36633. yz: Vector3;
  36634. /**
  36635. * The zx coefficients of the spherical polynomial
  36636. */
  36637. zx: Vector3;
  36638. /**
  36639. * Adds an ambient color to the spherical polynomial
  36640. * @param color the color to add
  36641. */
  36642. addAmbient(color: Color3): void;
  36643. /**
  36644. * Scales the spherical polynomial by the given amount
  36645. * @param scale the amount to scale
  36646. */
  36647. scaleInPlace(scale: number): void;
  36648. /**
  36649. * Gets the spherical polynomial from harmonics
  36650. * @param harmonics the spherical harmonics
  36651. * @returns the spherical polynomial
  36652. */
  36653. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36654. /**
  36655. * Constructs a spherical polynomial from an array.
  36656. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36657. * @returns the spherical polynomial
  36658. */
  36659. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36660. }
  36661. }
  36662. declare module "babylonjs/Materials/Textures/internalTexture" {
  36663. import { Observable } from "babylonjs/Misc/observable";
  36664. import { Nullable, int } from "babylonjs/types";
  36665. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  36666. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36667. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  36668. /**
  36669. * Defines the source of the internal texture
  36670. */
  36671. export enum InternalTextureSource {
  36672. /**
  36673. * The source of the texture data is unknown
  36674. */
  36675. Unknown = 0,
  36676. /**
  36677. * Texture data comes from an URL
  36678. */
  36679. Url = 1,
  36680. /**
  36681. * Texture data is only used for temporary storage
  36682. */
  36683. Temp = 2,
  36684. /**
  36685. * Texture data comes from raw data (ArrayBuffer)
  36686. */
  36687. Raw = 3,
  36688. /**
  36689. * Texture content is dynamic (video or dynamic texture)
  36690. */
  36691. Dynamic = 4,
  36692. /**
  36693. * Texture content is generated by rendering to it
  36694. */
  36695. RenderTarget = 5,
  36696. /**
  36697. * Texture content is part of a multi render target process
  36698. */
  36699. MultiRenderTarget = 6,
  36700. /**
  36701. * Texture data comes from a cube data file
  36702. */
  36703. Cube = 7,
  36704. /**
  36705. * Texture data comes from a raw cube data
  36706. */
  36707. CubeRaw = 8,
  36708. /**
  36709. * Texture data come from a prefiltered cube data file
  36710. */
  36711. CubePrefiltered = 9,
  36712. /**
  36713. * Texture content is raw 3D data
  36714. */
  36715. Raw3D = 10,
  36716. /**
  36717. * Texture content is raw 2D array data
  36718. */
  36719. Raw2DArray = 11,
  36720. /**
  36721. * Texture content is a depth texture
  36722. */
  36723. Depth = 12,
  36724. /**
  36725. * Texture data comes from a raw cube data encoded with RGBD
  36726. */
  36727. CubeRawRGBD = 13
  36728. }
  36729. /**
  36730. * Class used to store data associated with WebGL texture data for the engine
  36731. * This class should not be used directly
  36732. */
  36733. export class InternalTexture {
  36734. /** @hidden */
  36735. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36736. /**
  36737. * Defines if the texture is ready
  36738. */
  36739. isReady: boolean;
  36740. /**
  36741. * Defines if the texture is a cube texture
  36742. */
  36743. isCube: boolean;
  36744. /**
  36745. * Defines if the texture contains 3D data
  36746. */
  36747. is3D: boolean;
  36748. /**
  36749. * Defines if the texture contains 2D array data
  36750. */
  36751. is2DArray: boolean;
  36752. /**
  36753. * Defines if the texture contains multiview data
  36754. */
  36755. isMultiview: boolean;
  36756. /**
  36757. * Gets the URL used to load this texture
  36758. */
  36759. url: string;
  36760. /**
  36761. * Gets the sampling mode of the texture
  36762. */
  36763. samplingMode: number;
  36764. /**
  36765. * Gets a boolean indicating if the texture needs mipmaps generation
  36766. */
  36767. generateMipMaps: boolean;
  36768. /**
  36769. * Gets the number of samples used by the texture (WebGL2+ only)
  36770. */
  36771. samples: number;
  36772. /**
  36773. * Gets the type of the texture (int, float...)
  36774. */
  36775. type: number;
  36776. /**
  36777. * Gets the format of the texture (RGB, RGBA...)
  36778. */
  36779. format: number;
  36780. /**
  36781. * Observable called when the texture is loaded
  36782. */
  36783. onLoadedObservable: Observable<InternalTexture>;
  36784. /**
  36785. * Gets the width of the texture
  36786. */
  36787. width: number;
  36788. /**
  36789. * Gets the height of the texture
  36790. */
  36791. height: number;
  36792. /**
  36793. * Gets the depth of the texture
  36794. */
  36795. depth: number;
  36796. /**
  36797. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36798. */
  36799. baseWidth: number;
  36800. /**
  36801. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36802. */
  36803. baseHeight: number;
  36804. /**
  36805. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36806. */
  36807. baseDepth: number;
  36808. /**
  36809. * Gets a boolean indicating if the texture is inverted on Y axis
  36810. */
  36811. invertY: boolean;
  36812. /** @hidden */
  36813. _invertVScale: boolean;
  36814. /** @hidden */
  36815. _associatedChannel: number;
  36816. /** @hidden */
  36817. _source: InternalTextureSource;
  36818. /** @hidden */
  36819. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36820. /** @hidden */
  36821. _bufferView: Nullable<ArrayBufferView>;
  36822. /** @hidden */
  36823. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36824. /** @hidden */
  36825. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36826. /** @hidden */
  36827. _size: number;
  36828. /** @hidden */
  36829. _extension: string;
  36830. /** @hidden */
  36831. _files: Nullable<string[]>;
  36832. /** @hidden */
  36833. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36834. /** @hidden */
  36835. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36836. /** @hidden */
  36837. _framebuffer: Nullable<WebGLFramebuffer>;
  36838. /** @hidden */
  36839. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36840. /** @hidden */
  36841. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36842. /** @hidden */
  36843. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36844. /** @hidden */
  36845. _attachments: Nullable<number[]>;
  36846. /** @hidden */
  36847. _textureArray: Nullable<InternalTexture[]>;
  36848. /** @hidden */
  36849. _cachedCoordinatesMode: Nullable<number>;
  36850. /** @hidden */
  36851. _cachedWrapU: Nullable<number>;
  36852. /** @hidden */
  36853. _cachedWrapV: Nullable<number>;
  36854. /** @hidden */
  36855. _cachedWrapR: Nullable<number>;
  36856. /** @hidden */
  36857. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36858. /** @hidden */
  36859. _isDisabled: boolean;
  36860. /** @hidden */
  36861. _compression: Nullable<string>;
  36862. /** @hidden */
  36863. _generateStencilBuffer: boolean;
  36864. /** @hidden */
  36865. _generateDepthBuffer: boolean;
  36866. /** @hidden */
  36867. _comparisonFunction: number;
  36868. /** @hidden */
  36869. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36870. /** @hidden */
  36871. _lodGenerationScale: number;
  36872. /** @hidden */
  36873. _lodGenerationOffset: number;
  36874. /** @hidden */
  36875. _depthStencilTexture: Nullable<InternalTexture>;
  36876. /** @hidden */
  36877. _colorTextureArray: Nullable<WebGLTexture>;
  36878. /** @hidden */
  36879. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36880. /** @hidden */
  36881. _lodTextureHigh: Nullable<BaseTexture>;
  36882. /** @hidden */
  36883. _lodTextureMid: Nullable<BaseTexture>;
  36884. /** @hidden */
  36885. _lodTextureLow: Nullable<BaseTexture>;
  36886. /** @hidden */
  36887. _isRGBD: boolean;
  36888. /** @hidden */
  36889. _linearSpecularLOD: boolean;
  36890. /** @hidden */
  36891. _irradianceTexture: Nullable<BaseTexture>;
  36892. /** @hidden */
  36893. _webGLTexture: Nullable<WebGLTexture>;
  36894. /** @hidden */
  36895. _references: number;
  36896. private _engine;
  36897. /**
  36898. * Gets the Engine the texture belongs to.
  36899. * @returns The babylon engine
  36900. */
  36901. getEngine(): ThinEngine;
  36902. /**
  36903. * Gets the data source type of the texture
  36904. */
  36905. get source(): InternalTextureSource;
  36906. /**
  36907. * Creates a new InternalTexture
  36908. * @param engine defines the engine to use
  36909. * @param source defines the type of data that will be used
  36910. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36911. */
  36912. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36913. /**
  36914. * Increments the number of references (ie. the number of Texture that point to it)
  36915. */
  36916. incrementReferences(): void;
  36917. /**
  36918. * Change the size of the texture (not the size of the content)
  36919. * @param width defines the new width
  36920. * @param height defines the new height
  36921. * @param depth defines the new depth (1 by default)
  36922. */
  36923. updateSize(width: int, height: int, depth?: int): void;
  36924. /** @hidden */
  36925. _rebuild(): void;
  36926. /** @hidden */
  36927. _swapAndDie(target: InternalTexture): void;
  36928. /**
  36929. * Dispose the current allocated resources
  36930. */
  36931. dispose(): void;
  36932. }
  36933. }
  36934. declare module "babylonjs/Audio/analyser" {
  36935. import { Scene } from "babylonjs/scene";
  36936. /**
  36937. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36938. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36939. */
  36940. export class Analyser {
  36941. /**
  36942. * Gets or sets the smoothing
  36943. * @ignorenaming
  36944. */
  36945. SMOOTHING: number;
  36946. /**
  36947. * Gets or sets the FFT table size
  36948. * @ignorenaming
  36949. */
  36950. FFT_SIZE: number;
  36951. /**
  36952. * Gets or sets the bar graph amplitude
  36953. * @ignorenaming
  36954. */
  36955. BARGRAPHAMPLITUDE: number;
  36956. /**
  36957. * Gets or sets the position of the debug canvas
  36958. * @ignorenaming
  36959. */
  36960. DEBUGCANVASPOS: {
  36961. x: number;
  36962. y: number;
  36963. };
  36964. /**
  36965. * Gets or sets the debug canvas size
  36966. * @ignorenaming
  36967. */
  36968. DEBUGCANVASSIZE: {
  36969. width: number;
  36970. height: number;
  36971. };
  36972. private _byteFreqs;
  36973. private _byteTime;
  36974. private _floatFreqs;
  36975. private _webAudioAnalyser;
  36976. private _debugCanvas;
  36977. private _debugCanvasContext;
  36978. private _scene;
  36979. private _registerFunc;
  36980. private _audioEngine;
  36981. /**
  36982. * Creates a new analyser
  36983. * @param scene defines hosting scene
  36984. */
  36985. constructor(scene: Scene);
  36986. /**
  36987. * Get the number of data values you will have to play with for the visualization
  36988. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36989. * @returns a number
  36990. */
  36991. getFrequencyBinCount(): number;
  36992. /**
  36993. * Gets the current frequency data as a byte array
  36994. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36995. * @returns a Uint8Array
  36996. */
  36997. getByteFrequencyData(): Uint8Array;
  36998. /**
  36999. * Gets the current waveform as a byte array
  37000. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  37001. * @returns a Uint8Array
  37002. */
  37003. getByteTimeDomainData(): Uint8Array;
  37004. /**
  37005. * Gets the current frequency data as a float array
  37006. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37007. * @returns a Float32Array
  37008. */
  37009. getFloatFrequencyData(): Float32Array;
  37010. /**
  37011. * Renders the debug canvas
  37012. */
  37013. drawDebugCanvas(): void;
  37014. /**
  37015. * Stops rendering the debug canvas and removes it
  37016. */
  37017. stopDebugCanvas(): void;
  37018. /**
  37019. * Connects two audio nodes
  37020. * @param inputAudioNode defines first node to connect
  37021. * @param outputAudioNode defines second node to connect
  37022. */
  37023. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  37024. /**
  37025. * Releases all associated resources
  37026. */
  37027. dispose(): void;
  37028. }
  37029. }
  37030. declare module "babylonjs/Audio/audioEngine" {
  37031. import { IDisposable } from "babylonjs/scene";
  37032. import { Analyser } from "babylonjs/Audio/analyser";
  37033. import { Nullable } from "babylonjs/types";
  37034. import { Observable } from "babylonjs/Misc/observable";
  37035. /**
  37036. * This represents an audio engine and it is responsible
  37037. * to play, synchronize and analyse sounds throughout the application.
  37038. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37039. */
  37040. export interface IAudioEngine extends IDisposable {
  37041. /**
  37042. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37043. */
  37044. readonly canUseWebAudio: boolean;
  37045. /**
  37046. * Gets the current AudioContext if available.
  37047. */
  37048. readonly audioContext: Nullable<AudioContext>;
  37049. /**
  37050. * The master gain node defines the global audio volume of your audio engine.
  37051. */
  37052. readonly masterGain: GainNode;
  37053. /**
  37054. * Gets whether or not mp3 are supported by your browser.
  37055. */
  37056. readonly isMP3supported: boolean;
  37057. /**
  37058. * Gets whether or not ogg are supported by your browser.
  37059. */
  37060. readonly isOGGsupported: boolean;
  37061. /**
  37062. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37063. * @ignoreNaming
  37064. */
  37065. WarnedWebAudioUnsupported: boolean;
  37066. /**
  37067. * Defines if the audio engine relies on a custom unlocked button.
  37068. * In this case, the embedded button will not be displayed.
  37069. */
  37070. useCustomUnlockedButton: boolean;
  37071. /**
  37072. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  37073. */
  37074. readonly unlocked: boolean;
  37075. /**
  37076. * Event raised when audio has been unlocked on the browser.
  37077. */
  37078. onAudioUnlockedObservable: Observable<AudioEngine>;
  37079. /**
  37080. * Event raised when audio has been locked on the browser.
  37081. */
  37082. onAudioLockedObservable: Observable<AudioEngine>;
  37083. /**
  37084. * Flags the audio engine in Locked state.
  37085. * This happens due to new browser policies preventing audio to autoplay.
  37086. */
  37087. lock(): void;
  37088. /**
  37089. * Unlocks the audio engine once a user action has been done on the dom.
  37090. * This is helpful to resume play once browser policies have been satisfied.
  37091. */
  37092. unlock(): void;
  37093. /**
  37094. * Gets the global volume sets on the master gain.
  37095. * @returns the global volume if set or -1 otherwise
  37096. */
  37097. getGlobalVolume(): number;
  37098. /**
  37099. * Sets the global volume of your experience (sets on the master gain).
  37100. * @param newVolume Defines the new global volume of the application
  37101. */
  37102. setGlobalVolume(newVolume: number): void;
  37103. /**
  37104. * Connect the audio engine to an audio analyser allowing some amazing
  37105. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37106. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37107. * @param analyser The analyser to connect to the engine
  37108. */
  37109. connectToAnalyser(analyser: Analyser): void;
  37110. }
  37111. /**
  37112. * This represents the default audio engine used in babylon.
  37113. * It is responsible to play, synchronize and analyse sounds throughout the application.
  37114. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37115. */
  37116. export class AudioEngine implements IAudioEngine {
  37117. private _audioContext;
  37118. private _audioContextInitialized;
  37119. private _muteButton;
  37120. private _hostElement;
  37121. /**
  37122. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37123. */
  37124. canUseWebAudio: boolean;
  37125. /**
  37126. * The master gain node defines the global audio volume of your audio engine.
  37127. */
  37128. masterGain: GainNode;
  37129. /**
  37130. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37131. * @ignoreNaming
  37132. */
  37133. WarnedWebAudioUnsupported: boolean;
  37134. /**
  37135. * Gets whether or not mp3 are supported by your browser.
  37136. */
  37137. isMP3supported: boolean;
  37138. /**
  37139. * Gets whether or not ogg are supported by your browser.
  37140. */
  37141. isOGGsupported: boolean;
  37142. /**
  37143. * Gets whether audio has been unlocked on the device.
  37144. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  37145. * a user interaction has happened.
  37146. */
  37147. unlocked: boolean;
  37148. /**
  37149. * Defines if the audio engine relies on a custom unlocked button.
  37150. * In this case, the embedded button will not be displayed.
  37151. */
  37152. useCustomUnlockedButton: boolean;
  37153. /**
  37154. * Event raised when audio has been unlocked on the browser.
  37155. */
  37156. onAudioUnlockedObservable: Observable<AudioEngine>;
  37157. /**
  37158. * Event raised when audio has been locked on the browser.
  37159. */
  37160. onAudioLockedObservable: Observable<AudioEngine>;
  37161. /**
  37162. * Gets the current AudioContext if available.
  37163. */
  37164. get audioContext(): Nullable<AudioContext>;
  37165. private _connectedAnalyser;
  37166. /**
  37167. * Instantiates a new audio engine.
  37168. *
  37169. * There should be only one per page as some browsers restrict the number
  37170. * of audio contexts you can create.
  37171. * @param hostElement defines the host element where to display the mute icon if necessary
  37172. */
  37173. constructor(hostElement?: Nullable<HTMLElement>);
  37174. /**
  37175. * Flags the audio engine in Locked state.
  37176. * This happens due to new browser policies preventing audio to autoplay.
  37177. */
  37178. lock(): void;
  37179. /**
  37180. * Unlocks the audio engine once a user action has been done on the dom.
  37181. * This is helpful to resume play once browser policies have been satisfied.
  37182. */
  37183. unlock(): void;
  37184. private _resumeAudioContext;
  37185. private _initializeAudioContext;
  37186. private _tryToRun;
  37187. private _triggerRunningState;
  37188. private _triggerSuspendedState;
  37189. private _displayMuteButton;
  37190. private _moveButtonToTopLeft;
  37191. private _onResize;
  37192. private _hideMuteButton;
  37193. /**
  37194. * Destroy and release the resources associated with the audio ccontext.
  37195. */
  37196. dispose(): void;
  37197. /**
  37198. * Gets the global volume sets on the master gain.
  37199. * @returns the global volume if set or -1 otherwise
  37200. */
  37201. getGlobalVolume(): number;
  37202. /**
  37203. * Sets the global volume of your experience (sets on the master gain).
  37204. * @param newVolume Defines the new global volume of the application
  37205. */
  37206. setGlobalVolume(newVolume: number): void;
  37207. /**
  37208. * Connect the audio engine to an audio analyser allowing some amazing
  37209. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37210. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37211. * @param analyser The analyser to connect to the engine
  37212. */
  37213. connectToAnalyser(analyser: Analyser): void;
  37214. }
  37215. }
  37216. declare module "babylonjs/Loading/loadingScreen" {
  37217. /**
  37218. * Interface used to present a loading screen while loading a scene
  37219. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37220. */
  37221. export interface ILoadingScreen {
  37222. /**
  37223. * Function called to display the loading screen
  37224. */
  37225. displayLoadingUI: () => void;
  37226. /**
  37227. * Function called to hide the loading screen
  37228. */
  37229. hideLoadingUI: () => void;
  37230. /**
  37231. * Gets or sets the color to use for the background
  37232. */
  37233. loadingUIBackgroundColor: string;
  37234. /**
  37235. * Gets or sets the text to display while loading
  37236. */
  37237. loadingUIText: string;
  37238. }
  37239. /**
  37240. * Class used for the default loading screen
  37241. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37242. */
  37243. export class DefaultLoadingScreen implements ILoadingScreen {
  37244. private _renderingCanvas;
  37245. private _loadingText;
  37246. private _loadingDivBackgroundColor;
  37247. private _loadingDiv;
  37248. private _loadingTextDiv;
  37249. /** Gets or sets the logo url to use for the default loading screen */
  37250. static DefaultLogoUrl: string;
  37251. /** Gets or sets the spinner url to use for the default loading screen */
  37252. static DefaultSpinnerUrl: string;
  37253. /**
  37254. * Creates a new default loading screen
  37255. * @param _renderingCanvas defines the canvas used to render the scene
  37256. * @param _loadingText defines the default text to display
  37257. * @param _loadingDivBackgroundColor defines the default background color
  37258. */
  37259. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37260. /**
  37261. * Function called to display the loading screen
  37262. */
  37263. displayLoadingUI(): void;
  37264. /**
  37265. * Function called to hide the loading screen
  37266. */
  37267. hideLoadingUI(): void;
  37268. /**
  37269. * Gets or sets the text to display while loading
  37270. */
  37271. set loadingUIText(text: string);
  37272. get loadingUIText(): string;
  37273. /**
  37274. * Gets or sets the color to use for the background
  37275. */
  37276. get loadingUIBackgroundColor(): string;
  37277. set loadingUIBackgroundColor(color: string);
  37278. private _resizeLoadingUI;
  37279. }
  37280. }
  37281. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  37282. /**
  37283. * Interface for any object that can request an animation frame
  37284. */
  37285. export interface ICustomAnimationFrameRequester {
  37286. /**
  37287. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37288. */
  37289. renderFunction?: Function;
  37290. /**
  37291. * Called to request the next frame to render to
  37292. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37293. */
  37294. requestAnimationFrame: Function;
  37295. /**
  37296. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37297. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37298. */
  37299. requestID?: number;
  37300. }
  37301. }
  37302. declare module "babylonjs/Misc/performanceMonitor" {
  37303. /**
  37304. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37305. */
  37306. export class PerformanceMonitor {
  37307. private _enabled;
  37308. private _rollingFrameTime;
  37309. private _lastFrameTimeMs;
  37310. /**
  37311. * constructor
  37312. * @param frameSampleSize The number of samples required to saturate the sliding window
  37313. */
  37314. constructor(frameSampleSize?: number);
  37315. /**
  37316. * Samples current frame
  37317. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37318. */
  37319. sampleFrame(timeMs?: number): void;
  37320. /**
  37321. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37322. */
  37323. get averageFrameTime(): number;
  37324. /**
  37325. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37326. */
  37327. get averageFrameTimeVariance(): number;
  37328. /**
  37329. * Returns the frame time of the most recent frame
  37330. */
  37331. get instantaneousFrameTime(): number;
  37332. /**
  37333. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37334. */
  37335. get averageFPS(): number;
  37336. /**
  37337. * Returns the average framerate in frames per second using the most recent frame time
  37338. */
  37339. get instantaneousFPS(): number;
  37340. /**
  37341. * Returns true if enough samples have been taken to completely fill the sliding window
  37342. */
  37343. get isSaturated(): boolean;
  37344. /**
  37345. * Enables contributions to the sliding window sample set
  37346. */
  37347. enable(): void;
  37348. /**
  37349. * Disables contributions to the sliding window sample set
  37350. * Samples will not be interpolated over the disabled period
  37351. */
  37352. disable(): void;
  37353. /**
  37354. * Returns true if sampling is enabled
  37355. */
  37356. get isEnabled(): boolean;
  37357. /**
  37358. * Resets performance monitor
  37359. */
  37360. reset(): void;
  37361. }
  37362. /**
  37363. * RollingAverage
  37364. *
  37365. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37366. */
  37367. export class RollingAverage {
  37368. /**
  37369. * Current average
  37370. */
  37371. average: number;
  37372. /**
  37373. * Current variance
  37374. */
  37375. variance: number;
  37376. protected _samples: Array<number>;
  37377. protected _sampleCount: number;
  37378. protected _pos: number;
  37379. protected _m2: number;
  37380. /**
  37381. * constructor
  37382. * @param length The number of samples required to saturate the sliding window
  37383. */
  37384. constructor(length: number);
  37385. /**
  37386. * Adds a sample to the sample set
  37387. * @param v The sample value
  37388. */
  37389. add(v: number): void;
  37390. /**
  37391. * Returns previously added values or null if outside of history or outside the sliding window domain
  37392. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37393. * @return Value previously recorded with add() or null if outside of range
  37394. */
  37395. history(i: number): number;
  37396. /**
  37397. * Returns true if enough samples have been taken to completely fill the sliding window
  37398. * @return true if sample-set saturated
  37399. */
  37400. isSaturated(): boolean;
  37401. /**
  37402. * Resets the rolling average (equivalent to 0 samples taken so far)
  37403. */
  37404. reset(): void;
  37405. /**
  37406. * Wraps a value around the sample range boundaries
  37407. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37408. * @return Wrapped position in sample range
  37409. */
  37410. protected _wrapPosition(i: number): number;
  37411. }
  37412. }
  37413. declare module "babylonjs/Misc/perfCounter" {
  37414. /**
  37415. * This class is used to track a performance counter which is number based.
  37416. * The user has access to many properties which give statistics of different nature.
  37417. *
  37418. * The implementer can track two kinds of Performance Counter: time and count.
  37419. * 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.
  37420. * 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.
  37421. */
  37422. export class PerfCounter {
  37423. /**
  37424. * Gets or sets a global boolean to turn on and off all the counters
  37425. */
  37426. static Enabled: boolean;
  37427. /**
  37428. * Returns the smallest value ever
  37429. */
  37430. get min(): number;
  37431. /**
  37432. * Returns the biggest value ever
  37433. */
  37434. get max(): number;
  37435. /**
  37436. * Returns the average value since the performance counter is running
  37437. */
  37438. get average(): number;
  37439. /**
  37440. * Returns the average value of the last second the counter was monitored
  37441. */
  37442. get lastSecAverage(): number;
  37443. /**
  37444. * Returns the current value
  37445. */
  37446. get current(): number;
  37447. /**
  37448. * Gets the accumulated total
  37449. */
  37450. get total(): number;
  37451. /**
  37452. * Gets the total value count
  37453. */
  37454. get count(): number;
  37455. /**
  37456. * Creates a new counter
  37457. */
  37458. constructor();
  37459. /**
  37460. * Call this method to start monitoring a new frame.
  37461. * 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.
  37462. */
  37463. fetchNewFrame(): void;
  37464. /**
  37465. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37466. * @param newCount the count value to add to the monitored count
  37467. * @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.
  37468. */
  37469. addCount(newCount: number, fetchResult: boolean): void;
  37470. /**
  37471. * Start monitoring this performance counter
  37472. */
  37473. beginMonitoring(): void;
  37474. /**
  37475. * Compute the time lapsed since the previous beginMonitoring() call.
  37476. * @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
  37477. */
  37478. endMonitoring(newFrame?: boolean): void;
  37479. private _fetchResult;
  37480. private _startMonitoringTime;
  37481. private _min;
  37482. private _max;
  37483. private _average;
  37484. private _current;
  37485. private _totalValueCount;
  37486. private _totalAccumulated;
  37487. private _lastSecAverage;
  37488. private _lastSecAccumulated;
  37489. private _lastSecTime;
  37490. private _lastSecValueCount;
  37491. }
  37492. }
  37493. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  37494. module "babylonjs/Engines/thinEngine" {
  37495. interface ThinEngine {
  37496. /**
  37497. * Sets alpha constants used by some alpha blending modes
  37498. * @param r defines the red component
  37499. * @param g defines the green component
  37500. * @param b defines the blue component
  37501. * @param a defines the alpha component
  37502. */
  37503. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  37504. /**
  37505. * Sets the current alpha mode
  37506. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  37507. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  37508. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37509. */
  37510. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  37511. /**
  37512. * Gets the current alpha mode
  37513. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37514. * @returns the current alpha mode
  37515. */
  37516. getAlphaMode(): number;
  37517. /**
  37518. * Sets the current alpha equation
  37519. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  37520. */
  37521. setAlphaEquation(equation: number): void;
  37522. /**
  37523. * Gets the current alpha equation.
  37524. * @returns the current alpha equation
  37525. */
  37526. getAlphaEquation(): number;
  37527. }
  37528. }
  37529. }
  37530. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  37531. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37532. import { Nullable } from "babylonjs/types";
  37533. module "babylonjs/Engines/thinEngine" {
  37534. interface ThinEngine {
  37535. /** @hidden */
  37536. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37537. }
  37538. }
  37539. }
  37540. declare module "babylonjs/Engines/engine" {
  37541. import { Observable } from "babylonjs/Misc/observable";
  37542. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  37543. import { Scene } from "babylonjs/scene";
  37544. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37545. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  37546. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  37547. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  37548. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  37549. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  37550. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  37551. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  37552. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  37553. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  37554. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  37555. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  37556. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  37557. import "babylonjs/Engines/Extensions/engine.alpha";
  37558. import "babylonjs/Engines/Extensions/engine.readTexture";
  37559. import { Material } from "babylonjs/Materials/material";
  37560. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37561. /**
  37562. * Defines the interface used by display changed events
  37563. */
  37564. export interface IDisplayChangedEventArgs {
  37565. /** Gets the vrDisplay object (if any) */
  37566. vrDisplay: Nullable<any>;
  37567. /** Gets a boolean indicating if webVR is supported */
  37568. vrSupported: boolean;
  37569. }
  37570. /**
  37571. * Defines the interface used by objects containing a viewport (like a camera)
  37572. */
  37573. interface IViewportOwnerLike {
  37574. /**
  37575. * Gets or sets the viewport
  37576. */
  37577. viewport: IViewportLike;
  37578. }
  37579. /**
  37580. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37581. */
  37582. export class Engine extends ThinEngine {
  37583. /** Defines that alpha blending is disabled */
  37584. static readonly ALPHA_DISABLE: number;
  37585. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37586. static readonly ALPHA_ADD: number;
  37587. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37588. static readonly ALPHA_COMBINE: number;
  37589. /** Defines that alpha blending to DEST - SRC * DEST */
  37590. static readonly ALPHA_SUBTRACT: number;
  37591. /** Defines that alpha blending to SRC * DEST */
  37592. static readonly ALPHA_MULTIPLY: number;
  37593. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37594. static readonly ALPHA_MAXIMIZED: number;
  37595. /** Defines that alpha blending to SRC + DEST */
  37596. static readonly ALPHA_ONEONE: number;
  37597. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37598. static readonly ALPHA_PREMULTIPLIED: number;
  37599. /**
  37600. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37601. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37602. */
  37603. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37604. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37605. static readonly ALPHA_INTERPOLATE: number;
  37606. /**
  37607. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37608. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37609. */
  37610. static readonly ALPHA_SCREENMODE: number;
  37611. /** Defines that the ressource is not delayed*/
  37612. static readonly DELAYLOADSTATE_NONE: number;
  37613. /** Defines that the ressource was successfully delay loaded */
  37614. static readonly DELAYLOADSTATE_LOADED: number;
  37615. /** Defines that the ressource is currently delay loading */
  37616. static readonly DELAYLOADSTATE_LOADING: number;
  37617. /** Defines that the ressource is delayed and has not started loading */
  37618. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37619. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37620. static readonly NEVER: number;
  37621. /** 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 */
  37622. static readonly ALWAYS: number;
  37623. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37624. static readonly LESS: number;
  37625. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37626. static readonly EQUAL: number;
  37627. /** 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 */
  37628. static readonly LEQUAL: number;
  37629. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37630. static readonly GREATER: number;
  37631. /** 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 */
  37632. static readonly GEQUAL: number;
  37633. /** 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 */
  37634. static readonly NOTEQUAL: number;
  37635. /** Passed to stencilOperation to specify that stencil value must be kept */
  37636. static readonly KEEP: number;
  37637. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37638. static readonly REPLACE: number;
  37639. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37640. static readonly INCR: number;
  37641. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37642. static readonly DECR: number;
  37643. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37644. static readonly INVERT: number;
  37645. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37646. static readonly INCR_WRAP: number;
  37647. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37648. static readonly DECR_WRAP: number;
  37649. /** Texture is not repeating outside of 0..1 UVs */
  37650. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37651. /** Texture is repeating outside of 0..1 UVs */
  37652. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37653. /** Texture is repeating and mirrored */
  37654. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37655. /** ALPHA */
  37656. static readonly TEXTUREFORMAT_ALPHA: number;
  37657. /** LUMINANCE */
  37658. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37659. /** LUMINANCE_ALPHA */
  37660. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37661. /** RGB */
  37662. static readonly TEXTUREFORMAT_RGB: number;
  37663. /** RGBA */
  37664. static readonly TEXTUREFORMAT_RGBA: number;
  37665. /** RED */
  37666. static readonly TEXTUREFORMAT_RED: number;
  37667. /** RED (2nd reference) */
  37668. static readonly TEXTUREFORMAT_R: number;
  37669. /** RG */
  37670. static readonly TEXTUREFORMAT_RG: number;
  37671. /** RED_INTEGER */
  37672. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37673. /** RED_INTEGER (2nd reference) */
  37674. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37675. /** RG_INTEGER */
  37676. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37677. /** RGB_INTEGER */
  37678. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37679. /** RGBA_INTEGER */
  37680. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37681. /** UNSIGNED_BYTE */
  37682. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37683. /** UNSIGNED_BYTE (2nd reference) */
  37684. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37685. /** FLOAT */
  37686. static readonly TEXTURETYPE_FLOAT: number;
  37687. /** HALF_FLOAT */
  37688. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37689. /** BYTE */
  37690. static readonly TEXTURETYPE_BYTE: number;
  37691. /** SHORT */
  37692. static readonly TEXTURETYPE_SHORT: number;
  37693. /** UNSIGNED_SHORT */
  37694. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37695. /** INT */
  37696. static readonly TEXTURETYPE_INT: number;
  37697. /** UNSIGNED_INT */
  37698. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37699. /** UNSIGNED_SHORT_4_4_4_4 */
  37700. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37701. /** UNSIGNED_SHORT_5_5_5_1 */
  37702. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37703. /** UNSIGNED_SHORT_5_6_5 */
  37704. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37705. /** UNSIGNED_INT_2_10_10_10_REV */
  37706. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37707. /** UNSIGNED_INT_24_8 */
  37708. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37709. /** UNSIGNED_INT_10F_11F_11F_REV */
  37710. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37711. /** UNSIGNED_INT_5_9_9_9_REV */
  37712. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37713. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37714. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37715. /** nearest is mag = nearest and min = nearest and mip = linear */
  37716. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37717. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37718. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37719. /** Trilinear is mag = linear and min = linear and mip = linear */
  37720. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37721. /** nearest is mag = nearest and min = nearest and mip = linear */
  37722. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37723. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37724. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37725. /** Trilinear is mag = linear and min = linear and mip = linear */
  37726. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37727. /** mag = nearest and min = nearest and mip = nearest */
  37728. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37729. /** mag = nearest and min = linear and mip = nearest */
  37730. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37731. /** mag = nearest and min = linear and mip = linear */
  37732. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37733. /** mag = nearest and min = linear and mip = none */
  37734. static readonly TEXTURE_NEAREST_LINEAR: number;
  37735. /** mag = nearest and min = nearest and mip = none */
  37736. static readonly TEXTURE_NEAREST_NEAREST: number;
  37737. /** mag = linear and min = nearest and mip = nearest */
  37738. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37739. /** mag = linear and min = nearest and mip = linear */
  37740. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37741. /** mag = linear and min = linear and mip = none */
  37742. static readonly TEXTURE_LINEAR_LINEAR: number;
  37743. /** mag = linear and min = nearest and mip = none */
  37744. static readonly TEXTURE_LINEAR_NEAREST: number;
  37745. /** Explicit coordinates mode */
  37746. static readonly TEXTURE_EXPLICIT_MODE: number;
  37747. /** Spherical coordinates mode */
  37748. static readonly TEXTURE_SPHERICAL_MODE: number;
  37749. /** Planar coordinates mode */
  37750. static readonly TEXTURE_PLANAR_MODE: number;
  37751. /** Cubic coordinates mode */
  37752. static readonly TEXTURE_CUBIC_MODE: number;
  37753. /** Projection coordinates mode */
  37754. static readonly TEXTURE_PROJECTION_MODE: number;
  37755. /** Skybox coordinates mode */
  37756. static readonly TEXTURE_SKYBOX_MODE: number;
  37757. /** Inverse Cubic coordinates mode */
  37758. static readonly TEXTURE_INVCUBIC_MODE: number;
  37759. /** Equirectangular coordinates mode */
  37760. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37761. /** Equirectangular Fixed coordinates mode */
  37762. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37763. /** Equirectangular Fixed Mirrored coordinates mode */
  37764. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37765. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37766. static readonly SCALEMODE_FLOOR: number;
  37767. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37768. static readonly SCALEMODE_NEAREST: number;
  37769. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37770. static readonly SCALEMODE_CEILING: number;
  37771. /**
  37772. * Returns the current npm package of the sdk
  37773. */
  37774. static get NpmPackage(): string;
  37775. /**
  37776. * Returns the current version of the framework
  37777. */
  37778. static get Version(): string;
  37779. /** Gets the list of created engines */
  37780. static get Instances(): Engine[];
  37781. /**
  37782. * Gets the latest created engine
  37783. */
  37784. static get LastCreatedEngine(): Nullable<Engine>;
  37785. /**
  37786. * Gets the latest created scene
  37787. */
  37788. static get LastCreatedScene(): Nullable<Scene>;
  37789. /**
  37790. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37791. * @param flag defines which part of the materials must be marked as dirty
  37792. * @param predicate defines a predicate used to filter which materials should be affected
  37793. */
  37794. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37795. /**
  37796. * Method called to create the default loading screen.
  37797. * This can be overriden in your own app.
  37798. * @param canvas The rendering canvas element
  37799. * @returns The loading screen
  37800. */
  37801. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37802. /**
  37803. * Method called to create the default rescale post process on each engine.
  37804. */
  37805. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37806. /**
  37807. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37808. **/
  37809. enableOfflineSupport: boolean;
  37810. /**
  37811. * 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)
  37812. **/
  37813. disableManifestCheck: boolean;
  37814. /**
  37815. * Gets the list of created scenes
  37816. */
  37817. scenes: Scene[];
  37818. /**
  37819. * Event raised when a new scene is created
  37820. */
  37821. onNewSceneAddedObservable: Observable<Scene>;
  37822. /**
  37823. * Gets the list of created postprocesses
  37824. */
  37825. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  37826. /**
  37827. * Gets a boolean indicating if the pointer is currently locked
  37828. */
  37829. isPointerLock: boolean;
  37830. /**
  37831. * Observable event triggered each time the rendering canvas is resized
  37832. */
  37833. onResizeObservable: Observable<Engine>;
  37834. /**
  37835. * Observable event triggered each time the canvas loses focus
  37836. */
  37837. onCanvasBlurObservable: Observable<Engine>;
  37838. /**
  37839. * Observable event triggered each time the canvas gains focus
  37840. */
  37841. onCanvasFocusObservable: Observable<Engine>;
  37842. /**
  37843. * Observable event triggered each time the canvas receives pointerout event
  37844. */
  37845. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37846. /**
  37847. * Observable raised when the engine begins a new frame
  37848. */
  37849. onBeginFrameObservable: Observable<Engine>;
  37850. /**
  37851. * If set, will be used to request the next animation frame for the render loop
  37852. */
  37853. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37854. /**
  37855. * Observable raised when the engine ends the current frame
  37856. */
  37857. onEndFrameObservable: Observable<Engine>;
  37858. /**
  37859. * Observable raised when the engine is about to compile a shader
  37860. */
  37861. onBeforeShaderCompilationObservable: Observable<Engine>;
  37862. /**
  37863. * Observable raised when the engine has jsut compiled a shader
  37864. */
  37865. onAfterShaderCompilationObservable: Observable<Engine>;
  37866. /**
  37867. * Gets the audio engine
  37868. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37869. * @ignorenaming
  37870. */
  37871. static audioEngine: IAudioEngine;
  37872. /**
  37873. * Default AudioEngine factory responsible of creating the Audio Engine.
  37874. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37875. */
  37876. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37877. /**
  37878. * Default offline support factory responsible of creating a tool used to store data locally.
  37879. * By default, this will create a Database object if the workload has been embedded.
  37880. */
  37881. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37882. private _loadingScreen;
  37883. private _pointerLockRequested;
  37884. private _rescalePostProcess;
  37885. private _deterministicLockstep;
  37886. private _lockstepMaxSteps;
  37887. private _timeStep;
  37888. protected get _supportsHardwareTextureRescaling(): boolean;
  37889. private _fps;
  37890. private _deltaTime;
  37891. /** @hidden */
  37892. _drawCalls: PerfCounter;
  37893. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  37894. canvasTabIndex: number;
  37895. /**
  37896. * Turn this value on if you want to pause FPS computation when in background
  37897. */
  37898. disablePerformanceMonitorInBackground: boolean;
  37899. private _performanceMonitor;
  37900. /**
  37901. * Gets the performance monitor attached to this engine
  37902. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37903. */
  37904. get performanceMonitor(): PerformanceMonitor;
  37905. private _onFocus;
  37906. private _onBlur;
  37907. private _onCanvasPointerOut;
  37908. private _onCanvasBlur;
  37909. private _onCanvasFocus;
  37910. private _onFullscreenChange;
  37911. private _onPointerLockChange;
  37912. /**
  37913. * Gets the HTML element used to attach event listeners
  37914. * @returns a HTML element
  37915. */
  37916. getInputElement(): Nullable<HTMLElement>;
  37917. /**
  37918. * Creates a new engine
  37919. * @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
  37920. * @param antialias defines enable antialiasing (default: false)
  37921. * @param options defines further options to be sent to the getContext() function
  37922. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37923. */
  37924. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37925. /**
  37926. * Gets current aspect ratio
  37927. * @param viewportOwner defines the camera to use to get the aspect ratio
  37928. * @param useScreen defines if screen size must be used (or the current render target if any)
  37929. * @returns a number defining the aspect ratio
  37930. */
  37931. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37932. /**
  37933. * Gets current screen aspect ratio
  37934. * @returns a number defining the aspect ratio
  37935. */
  37936. getScreenAspectRatio(): number;
  37937. /**
  37938. * Gets the client rect of the HTML canvas attached with the current webGL context
  37939. * @returns a client rectanglee
  37940. */
  37941. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37942. /**
  37943. * Gets the client rect of the HTML element used for events
  37944. * @returns a client rectanglee
  37945. */
  37946. getInputElementClientRect(): Nullable<ClientRect>;
  37947. /**
  37948. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37949. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37950. * @returns true if engine is in deterministic lock step mode
  37951. */
  37952. isDeterministicLockStep(): boolean;
  37953. /**
  37954. * Gets the max steps when engine is running in deterministic lock step
  37955. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37956. * @returns the max steps
  37957. */
  37958. getLockstepMaxSteps(): number;
  37959. /**
  37960. * Returns the time in ms between steps when using deterministic lock step.
  37961. * @returns time step in (ms)
  37962. */
  37963. getTimeStep(): number;
  37964. /**
  37965. * Force the mipmap generation for the given render target texture
  37966. * @param texture defines the render target texture to use
  37967. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37968. */
  37969. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37970. /** States */
  37971. /**
  37972. * Set various states to the webGL context
  37973. * @param culling defines backface culling state
  37974. * @param zOffset defines the value to apply to zOffset (0 by default)
  37975. * @param force defines if states must be applied even if cache is up to date
  37976. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37977. */
  37978. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37979. /**
  37980. * Set the z offset to apply to current rendering
  37981. * @param value defines the offset to apply
  37982. */
  37983. setZOffset(value: number): void;
  37984. /**
  37985. * Gets the current value of the zOffset
  37986. * @returns the current zOffset state
  37987. */
  37988. getZOffset(): number;
  37989. /**
  37990. * Enable or disable depth buffering
  37991. * @param enable defines the state to set
  37992. */
  37993. setDepthBuffer(enable: boolean): void;
  37994. /**
  37995. * Gets a boolean indicating if depth writing is enabled
  37996. * @returns the current depth writing state
  37997. */
  37998. getDepthWrite(): boolean;
  37999. /**
  38000. * Enable or disable depth writing
  38001. * @param enable defines the state to set
  38002. */
  38003. setDepthWrite(enable: boolean): void;
  38004. /**
  38005. * Gets a boolean indicating if stencil buffer is enabled
  38006. * @returns the current stencil buffer state
  38007. */
  38008. getStencilBuffer(): boolean;
  38009. /**
  38010. * Enable or disable the stencil buffer
  38011. * @param enable defines if the stencil buffer must be enabled or disabled
  38012. */
  38013. setStencilBuffer(enable: boolean): void;
  38014. /**
  38015. * Gets the current stencil mask
  38016. * @returns a number defining the new stencil mask to use
  38017. */
  38018. getStencilMask(): number;
  38019. /**
  38020. * Sets the current stencil mask
  38021. * @param mask defines the new stencil mask to use
  38022. */
  38023. setStencilMask(mask: number): void;
  38024. /**
  38025. * Gets the current stencil function
  38026. * @returns a number defining the stencil function to use
  38027. */
  38028. getStencilFunction(): number;
  38029. /**
  38030. * Gets the current stencil reference value
  38031. * @returns a number defining the stencil reference value to use
  38032. */
  38033. getStencilFunctionReference(): number;
  38034. /**
  38035. * Gets the current stencil mask
  38036. * @returns a number defining the stencil mask to use
  38037. */
  38038. getStencilFunctionMask(): number;
  38039. /**
  38040. * Sets the current stencil function
  38041. * @param stencilFunc defines the new stencil function to use
  38042. */
  38043. setStencilFunction(stencilFunc: number): void;
  38044. /**
  38045. * Sets the current stencil reference
  38046. * @param reference defines the new stencil reference to use
  38047. */
  38048. setStencilFunctionReference(reference: number): void;
  38049. /**
  38050. * Sets the current stencil mask
  38051. * @param mask defines the new stencil mask to use
  38052. */
  38053. setStencilFunctionMask(mask: number): void;
  38054. /**
  38055. * Gets the current stencil operation when stencil fails
  38056. * @returns a number defining stencil operation to use when stencil fails
  38057. */
  38058. getStencilOperationFail(): number;
  38059. /**
  38060. * Gets the current stencil operation when depth fails
  38061. * @returns a number defining stencil operation to use when depth fails
  38062. */
  38063. getStencilOperationDepthFail(): number;
  38064. /**
  38065. * Gets the current stencil operation when stencil passes
  38066. * @returns a number defining stencil operation to use when stencil passes
  38067. */
  38068. getStencilOperationPass(): number;
  38069. /**
  38070. * Sets the stencil operation to use when stencil fails
  38071. * @param operation defines the stencil operation to use when stencil fails
  38072. */
  38073. setStencilOperationFail(operation: number): void;
  38074. /**
  38075. * Sets the stencil operation to use when depth fails
  38076. * @param operation defines the stencil operation to use when depth fails
  38077. */
  38078. setStencilOperationDepthFail(operation: number): void;
  38079. /**
  38080. * Sets the stencil operation to use when stencil passes
  38081. * @param operation defines the stencil operation to use when stencil passes
  38082. */
  38083. setStencilOperationPass(operation: number): void;
  38084. /**
  38085. * Sets a boolean indicating if the dithering state is enabled or disabled
  38086. * @param value defines the dithering state
  38087. */
  38088. setDitheringState(value: boolean): void;
  38089. /**
  38090. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  38091. * @param value defines the rasterizer state
  38092. */
  38093. setRasterizerState(value: boolean): void;
  38094. /**
  38095. * Gets the current depth function
  38096. * @returns a number defining the depth function
  38097. */
  38098. getDepthFunction(): Nullable<number>;
  38099. /**
  38100. * Sets the current depth function
  38101. * @param depthFunc defines the function to use
  38102. */
  38103. setDepthFunction(depthFunc: number): void;
  38104. /**
  38105. * Sets the current depth function to GREATER
  38106. */
  38107. setDepthFunctionToGreater(): void;
  38108. /**
  38109. * Sets the current depth function to GEQUAL
  38110. */
  38111. setDepthFunctionToGreaterOrEqual(): void;
  38112. /**
  38113. * Sets the current depth function to LESS
  38114. */
  38115. setDepthFunctionToLess(): void;
  38116. /**
  38117. * Sets the current depth function to LEQUAL
  38118. */
  38119. setDepthFunctionToLessOrEqual(): void;
  38120. private _cachedStencilBuffer;
  38121. private _cachedStencilFunction;
  38122. private _cachedStencilMask;
  38123. private _cachedStencilOperationPass;
  38124. private _cachedStencilOperationFail;
  38125. private _cachedStencilOperationDepthFail;
  38126. private _cachedStencilReference;
  38127. /**
  38128. * Caches the the state of the stencil buffer
  38129. */
  38130. cacheStencilState(): void;
  38131. /**
  38132. * Restores the state of the stencil buffer
  38133. */
  38134. restoreStencilState(): void;
  38135. /**
  38136. * Directly set the WebGL Viewport
  38137. * @param x defines the x coordinate of the viewport (in screen space)
  38138. * @param y defines the y coordinate of the viewport (in screen space)
  38139. * @param width defines the width of the viewport (in screen space)
  38140. * @param height defines the height of the viewport (in screen space)
  38141. * @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
  38142. */
  38143. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  38144. /**
  38145. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  38146. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38147. * @param y defines the y-coordinate of the corner of the clear rectangle
  38148. * @param width defines the width of the clear rectangle
  38149. * @param height defines the height of the clear rectangle
  38150. * @param clearColor defines the clear color
  38151. */
  38152. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  38153. /**
  38154. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  38155. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38156. * @param y defines the y-coordinate of the corner of the clear rectangle
  38157. * @param width defines the width of the clear rectangle
  38158. * @param height defines the height of the clear rectangle
  38159. */
  38160. enableScissor(x: number, y: number, width: number, height: number): void;
  38161. /**
  38162. * Disable previously set scissor test rectangle
  38163. */
  38164. disableScissor(): void;
  38165. protected _reportDrawCall(): void;
  38166. /**
  38167. * Initializes a webVR display and starts listening to display change events
  38168. * The onVRDisplayChangedObservable will be notified upon these changes
  38169. * @returns The onVRDisplayChangedObservable
  38170. */
  38171. initWebVR(): Observable<IDisplayChangedEventArgs>;
  38172. /** @hidden */
  38173. _prepareVRComponent(): void;
  38174. /** @hidden */
  38175. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  38176. /** @hidden */
  38177. _submitVRFrame(): void;
  38178. /**
  38179. * Call this function to leave webVR mode
  38180. * Will do nothing if webVR is not supported or if there is no webVR device
  38181. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38182. */
  38183. disableVR(): void;
  38184. /**
  38185. * Gets a boolean indicating that the system is in VR mode and is presenting
  38186. * @returns true if VR mode is engaged
  38187. */
  38188. isVRPresenting(): boolean;
  38189. /** @hidden */
  38190. _requestVRFrame(): void;
  38191. /** @hidden */
  38192. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38193. /**
  38194. * Gets the source code of the vertex shader associated with a specific webGL program
  38195. * @param program defines the program to use
  38196. * @returns a string containing the source code of the vertex shader associated with the program
  38197. */
  38198. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  38199. /**
  38200. * Gets the source code of the fragment shader associated with a specific webGL program
  38201. * @param program defines the program to use
  38202. * @returns a string containing the source code of the fragment shader associated with the program
  38203. */
  38204. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  38205. /**
  38206. * Sets a depth stencil texture from a render target to the according uniform.
  38207. * @param channel The texture channel
  38208. * @param uniform The uniform to set
  38209. * @param texture The render target texture containing the depth stencil texture to apply
  38210. */
  38211. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  38212. /**
  38213. * Sets a texture to the webGL context from a postprocess
  38214. * @param channel defines the channel to use
  38215. * @param postProcess defines the source postprocess
  38216. */
  38217. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  38218. /**
  38219. * Binds the output of the passed in post process to the texture channel specified
  38220. * @param channel The channel the texture should be bound to
  38221. * @param postProcess The post process which's output should be bound
  38222. */
  38223. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  38224. protected _rebuildBuffers(): void;
  38225. /** @hidden */
  38226. _renderFrame(): void;
  38227. _renderLoop(): void;
  38228. /** @hidden */
  38229. _renderViews(): boolean;
  38230. /**
  38231. * Toggle full screen mode
  38232. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38233. */
  38234. switchFullscreen(requestPointerLock: boolean): void;
  38235. /**
  38236. * Enters full screen mode
  38237. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38238. */
  38239. enterFullscreen(requestPointerLock: boolean): void;
  38240. /**
  38241. * Exits full screen mode
  38242. */
  38243. exitFullscreen(): void;
  38244. /**
  38245. * Enters Pointerlock mode
  38246. */
  38247. enterPointerlock(): void;
  38248. /**
  38249. * Exits Pointerlock mode
  38250. */
  38251. exitPointerlock(): void;
  38252. /**
  38253. * Begin a new frame
  38254. */
  38255. beginFrame(): void;
  38256. /**
  38257. * Enf the current frame
  38258. */
  38259. endFrame(): void;
  38260. resize(): void;
  38261. /**
  38262. * Force a specific size of the canvas
  38263. * @param width defines the new canvas' width
  38264. * @param height defines the new canvas' height
  38265. * @returns true if the size was changed
  38266. */
  38267. setSize(width: number, height: number): boolean;
  38268. /**
  38269. * Updates a dynamic vertex buffer.
  38270. * @param vertexBuffer the vertex buffer to update
  38271. * @param data the data used to update the vertex buffer
  38272. * @param byteOffset the byte offset of the data
  38273. * @param byteLength the byte length of the data
  38274. */
  38275. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  38276. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  38277. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38278. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38279. _releaseTexture(texture: InternalTexture): void;
  38280. /**
  38281. * @hidden
  38282. * Rescales a texture
  38283. * @param source input texutre
  38284. * @param destination destination texture
  38285. * @param scene scene to use to render the resize
  38286. * @param internalFormat format to use when resizing
  38287. * @param onComplete callback to be called when resize has completed
  38288. */
  38289. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  38290. /**
  38291. * Gets the current framerate
  38292. * @returns a number representing the framerate
  38293. */
  38294. getFps(): number;
  38295. /**
  38296. * Gets the time spent between current and previous frame
  38297. * @returns a number representing the delta time in ms
  38298. */
  38299. getDeltaTime(): number;
  38300. private _measureFps;
  38301. /** @hidden */
  38302. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38303. /**
  38304. * Update a dynamic index buffer
  38305. * @param indexBuffer defines the target index buffer
  38306. * @param indices defines the data to update
  38307. * @param offset defines the offset in the target index buffer where update should start
  38308. */
  38309. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  38310. /**
  38311. * Updates the sample count of a render target texture
  38312. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38313. * @param texture defines the texture to update
  38314. * @param samples defines the sample count to set
  38315. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38316. */
  38317. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38318. /**
  38319. * Updates a depth texture Comparison Mode and Function.
  38320. * If the comparison Function is equal to 0, the mode will be set to none.
  38321. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38322. * @param texture The texture to set the comparison function for
  38323. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38324. */
  38325. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38326. /**
  38327. * Creates a webGL buffer to use with instanciation
  38328. * @param capacity defines the size of the buffer
  38329. * @returns the webGL buffer
  38330. */
  38331. createInstancesBuffer(capacity: number): DataBuffer;
  38332. /**
  38333. * Delete a webGL buffer used with instanciation
  38334. * @param buffer defines the webGL buffer to delete
  38335. */
  38336. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38337. private _clientWaitAsync;
  38338. /** @hidden */
  38339. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38340. dispose(): void;
  38341. private _disableTouchAction;
  38342. /**
  38343. * Display the loading screen
  38344. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38345. */
  38346. displayLoadingUI(): void;
  38347. /**
  38348. * Hide the loading screen
  38349. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38350. */
  38351. hideLoadingUI(): void;
  38352. /**
  38353. * Gets the current loading screen object
  38354. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38355. */
  38356. get loadingScreen(): ILoadingScreen;
  38357. /**
  38358. * Sets the current loading screen object
  38359. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38360. */
  38361. set loadingScreen(loadingScreen: ILoadingScreen);
  38362. /**
  38363. * Sets the current loading screen text
  38364. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38365. */
  38366. set loadingUIText(text: string);
  38367. /**
  38368. * Sets the current loading screen background color
  38369. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38370. */
  38371. set loadingUIBackgroundColor(color: string);
  38372. /** Pointerlock and fullscreen */
  38373. /**
  38374. * Ask the browser to promote the current element to pointerlock mode
  38375. * @param element defines the DOM element to promote
  38376. */
  38377. static _RequestPointerlock(element: HTMLElement): void;
  38378. /**
  38379. * Asks the browser to exit pointerlock mode
  38380. */
  38381. static _ExitPointerlock(): void;
  38382. /**
  38383. * Ask the browser to promote the current element to fullscreen rendering mode
  38384. * @param element defines the DOM element to promote
  38385. */
  38386. static _RequestFullscreen(element: HTMLElement): void;
  38387. /**
  38388. * Asks the browser to exit fullscreen mode
  38389. */
  38390. static _ExitFullscreen(): void;
  38391. }
  38392. }
  38393. declare module "babylonjs/Engines/engineStore" {
  38394. import { Nullable } from "babylonjs/types";
  38395. import { Engine } from "babylonjs/Engines/engine";
  38396. import { Scene } from "babylonjs/scene";
  38397. /**
  38398. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38399. * during the life time of the application.
  38400. */
  38401. export class EngineStore {
  38402. /** Gets the list of created engines */
  38403. static Instances: import("babylonjs/Engines/engine").Engine[];
  38404. /** @hidden */
  38405. static _LastCreatedScene: Nullable<Scene>;
  38406. /**
  38407. * Gets the latest created engine
  38408. */
  38409. static get LastCreatedEngine(): Nullable<Engine>;
  38410. /**
  38411. * Gets the latest created scene
  38412. */
  38413. static get LastCreatedScene(): Nullable<Scene>;
  38414. /**
  38415. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38416. * @ignorenaming
  38417. */
  38418. static UseFallbackTexture: boolean;
  38419. /**
  38420. * Texture content used if a texture cannot loaded
  38421. * @ignorenaming
  38422. */
  38423. static FallbackTexture: string;
  38424. }
  38425. }
  38426. declare module "babylonjs/Misc/promise" {
  38427. /**
  38428. * Helper class that provides a small promise polyfill
  38429. */
  38430. export class PromisePolyfill {
  38431. /**
  38432. * Static function used to check if the polyfill is required
  38433. * If this is the case then the function will inject the polyfill to window.Promise
  38434. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38435. */
  38436. static Apply(force?: boolean): void;
  38437. }
  38438. }
  38439. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  38440. /**
  38441. * Interface for screenshot methods with describe argument called `size` as object with options
  38442. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38443. */
  38444. export interface IScreenshotSize {
  38445. /**
  38446. * number in pixels for canvas height
  38447. */
  38448. height?: number;
  38449. /**
  38450. * multiplier allowing render at a higher or lower resolution
  38451. * If value is defined then height and width will be ignored and taken from camera
  38452. */
  38453. precision?: number;
  38454. /**
  38455. * number in pixels for canvas width
  38456. */
  38457. width?: number;
  38458. }
  38459. }
  38460. declare module "babylonjs/Misc/tools" {
  38461. import { Nullable, float } from "babylonjs/types";
  38462. import { DomManagement } from "babylonjs/Misc/domManagement";
  38463. import { WebRequest } from "babylonjs/Misc/webRequest";
  38464. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  38465. import { ReadFileError } from "babylonjs/Misc/fileTools";
  38466. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38467. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  38468. import { Camera } from "babylonjs/Cameras/camera";
  38469. import { Engine } from "babylonjs/Engines/engine";
  38470. interface IColor4Like {
  38471. r: float;
  38472. g: float;
  38473. b: float;
  38474. a: float;
  38475. }
  38476. /**
  38477. * Class containing a set of static utilities functions
  38478. */
  38479. export class Tools {
  38480. /**
  38481. * Gets or sets the base URL to use to load assets
  38482. */
  38483. static get BaseUrl(): string;
  38484. static set BaseUrl(value: string);
  38485. /**
  38486. * Enable/Disable Custom HTTP Request Headers globally.
  38487. * default = false
  38488. * @see CustomRequestHeaders
  38489. */
  38490. static UseCustomRequestHeaders: boolean;
  38491. /**
  38492. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38493. * i.e. when loading files, where the server/service expects an Authorization header
  38494. */
  38495. static CustomRequestHeaders: {
  38496. [key: string]: string;
  38497. };
  38498. /**
  38499. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38500. */
  38501. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38502. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38503. /**
  38504. * Default behaviour for cors in the application.
  38505. * It can be a string if the expected behavior is identical in the entire app.
  38506. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38507. */
  38508. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38509. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38510. /**
  38511. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38512. * @ignorenaming
  38513. */
  38514. static get UseFallbackTexture(): boolean;
  38515. static set UseFallbackTexture(value: boolean);
  38516. /**
  38517. * Use this object to register external classes like custom textures or material
  38518. * to allow the laoders to instantiate them
  38519. */
  38520. static get RegisteredExternalClasses(): {
  38521. [key: string]: Object;
  38522. };
  38523. static set RegisteredExternalClasses(classes: {
  38524. [key: string]: Object;
  38525. });
  38526. /**
  38527. * Texture content used if a texture cannot loaded
  38528. * @ignorenaming
  38529. */
  38530. static get fallbackTexture(): string;
  38531. static set fallbackTexture(value: string);
  38532. /**
  38533. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38534. * @param u defines the coordinate on X axis
  38535. * @param v defines the coordinate on Y axis
  38536. * @param width defines the width of the source data
  38537. * @param height defines the height of the source data
  38538. * @param pixels defines the source byte array
  38539. * @param color defines the output color
  38540. */
  38541. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38542. /**
  38543. * Interpolates between a and b via alpha
  38544. * @param a The lower value (returned when alpha = 0)
  38545. * @param b The upper value (returned when alpha = 1)
  38546. * @param alpha The interpolation-factor
  38547. * @return The mixed value
  38548. */
  38549. static Mix(a: number, b: number, alpha: number): number;
  38550. /**
  38551. * Tries to instantiate a new object from a given class name
  38552. * @param className defines the class name to instantiate
  38553. * @returns the new object or null if the system was not able to do the instantiation
  38554. */
  38555. static Instantiate(className: string): any;
  38556. /**
  38557. * Provides a slice function that will work even on IE
  38558. * @param data defines the array to slice
  38559. * @param start defines the start of the data (optional)
  38560. * @param end defines the end of the data (optional)
  38561. * @returns the new sliced array
  38562. */
  38563. static Slice<T>(data: T, start?: number, end?: number): T;
  38564. /**
  38565. * Polyfill for setImmediate
  38566. * @param action defines the action to execute after the current execution block
  38567. */
  38568. static SetImmediate(action: () => void): void;
  38569. /**
  38570. * Function indicating if a number is an exponent of 2
  38571. * @param value defines the value to test
  38572. * @returns true if the value is an exponent of 2
  38573. */
  38574. static IsExponentOfTwo(value: number): boolean;
  38575. private static _tmpFloatArray;
  38576. /**
  38577. * Returns the nearest 32-bit single precision float representation of a Number
  38578. * @param value A Number. If the parameter is of a different type, it will get converted
  38579. * to a number or to NaN if it cannot be converted
  38580. * @returns number
  38581. */
  38582. static FloatRound(value: number): number;
  38583. /**
  38584. * Extracts the filename from a path
  38585. * @param path defines the path to use
  38586. * @returns the filename
  38587. */
  38588. static GetFilename(path: string): string;
  38589. /**
  38590. * Extracts the "folder" part of a path (everything before the filename).
  38591. * @param uri The URI to extract the info from
  38592. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38593. * @returns The "folder" part of the path
  38594. */
  38595. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38596. /**
  38597. * Extracts text content from a DOM element hierarchy
  38598. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38599. */
  38600. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38601. /**
  38602. * Convert an angle in radians to degrees
  38603. * @param angle defines the angle to convert
  38604. * @returns the angle in degrees
  38605. */
  38606. static ToDegrees(angle: number): number;
  38607. /**
  38608. * Convert an angle in degrees to radians
  38609. * @param angle defines the angle to convert
  38610. * @returns the angle in radians
  38611. */
  38612. static ToRadians(angle: number): number;
  38613. /**
  38614. * Returns an array if obj is not an array
  38615. * @param obj defines the object to evaluate as an array
  38616. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38617. * @returns either obj directly if obj is an array or a new array containing obj
  38618. */
  38619. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38620. /**
  38621. * Gets the pointer prefix to use
  38622. * @param engine defines the engine we are finding the prefix for
  38623. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38624. */
  38625. static GetPointerPrefix(engine: Engine): string;
  38626. /**
  38627. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38628. * @param url define the url we are trying
  38629. * @param element define the dom element where to configure the cors policy
  38630. */
  38631. static SetCorsBehavior(url: string | string[], element: {
  38632. crossOrigin: string | null;
  38633. }): void;
  38634. /**
  38635. * Removes unwanted characters from an url
  38636. * @param url defines the url to clean
  38637. * @returns the cleaned url
  38638. */
  38639. static CleanUrl(url: string): string;
  38640. /**
  38641. * Gets or sets a function used to pre-process url before using them to load assets
  38642. */
  38643. static get PreprocessUrl(): (url: string) => string;
  38644. static set PreprocessUrl(processor: (url: string) => string);
  38645. /**
  38646. * Loads an image as an HTMLImageElement.
  38647. * @param input url string, ArrayBuffer, or Blob to load
  38648. * @param onLoad callback called when the image successfully loads
  38649. * @param onError callback called when the image fails to load
  38650. * @param offlineProvider offline provider for caching
  38651. * @param mimeType optional mime type
  38652. * @returns the HTMLImageElement of the loaded image
  38653. */
  38654. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38655. /**
  38656. * Loads a file from a url
  38657. * @param url url string, ArrayBuffer, or Blob to load
  38658. * @param onSuccess callback called when the file successfully loads
  38659. * @param onProgress callback called while file is loading (if the server supports this mode)
  38660. * @param offlineProvider defines the offline provider for caching
  38661. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38662. * @param onError callback called when the file fails to load
  38663. * @returns a file request object
  38664. */
  38665. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  38666. /**
  38667. * Loads a file from a url
  38668. * @param url the file url to load
  38669. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38670. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38671. */
  38672. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38673. /**
  38674. * Load a script (identified by an url). When the url returns, the
  38675. * content of this file is added into a new script element, attached to the DOM (body element)
  38676. * @param scriptUrl defines the url of the script to laod
  38677. * @param onSuccess defines the callback called when the script is loaded
  38678. * @param onError defines the callback to call if an error occurs
  38679. * @param scriptId defines the id of the script element
  38680. */
  38681. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38682. /**
  38683. * Load an asynchronous script (identified by an url). When the url returns, the
  38684. * content of this file is added into a new script element, attached to the DOM (body element)
  38685. * @param scriptUrl defines the url of the script to laod
  38686. * @param scriptId defines the id of the script element
  38687. * @returns a promise request object
  38688. */
  38689. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38690. /**
  38691. * Loads a file from a blob
  38692. * @param fileToLoad defines the blob to use
  38693. * @param callback defines the callback to call when data is loaded
  38694. * @param progressCallback defines the callback to call during loading process
  38695. * @returns a file request object
  38696. */
  38697. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38698. /**
  38699. * Reads a file from a File object
  38700. * @param file defines the file to load
  38701. * @param onSuccess defines the callback to call when data is loaded
  38702. * @param onProgress defines the callback to call during loading process
  38703. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38704. * @param onError defines the callback to call when an error occurs
  38705. * @returns a file request object
  38706. */
  38707. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38708. /**
  38709. * Creates a data url from a given string content
  38710. * @param content defines the content to convert
  38711. * @returns the new data url link
  38712. */
  38713. static FileAsURL(content: string): string;
  38714. /**
  38715. * Format the given number to a specific decimal format
  38716. * @param value defines the number to format
  38717. * @param decimals defines the number of decimals to use
  38718. * @returns the formatted string
  38719. */
  38720. static Format(value: number, decimals?: number): string;
  38721. /**
  38722. * Tries to copy an object by duplicating every property
  38723. * @param source defines the source object
  38724. * @param destination defines the target object
  38725. * @param doNotCopyList defines a list of properties to avoid
  38726. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38727. */
  38728. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38729. /**
  38730. * Gets a boolean indicating if the given object has no own property
  38731. * @param obj defines the object to test
  38732. * @returns true if object has no own property
  38733. */
  38734. static IsEmpty(obj: any): boolean;
  38735. /**
  38736. * Function used to register events at window level
  38737. * @param windowElement defines the Window object to use
  38738. * @param events defines the events to register
  38739. */
  38740. static RegisterTopRootEvents(windowElement: Window, events: {
  38741. name: string;
  38742. handler: Nullable<(e: FocusEvent) => any>;
  38743. }[]): void;
  38744. /**
  38745. * Function used to unregister events from window level
  38746. * @param windowElement defines the Window object to use
  38747. * @param events defines the events to unregister
  38748. */
  38749. static UnregisterTopRootEvents(windowElement: Window, events: {
  38750. name: string;
  38751. handler: Nullable<(e: FocusEvent) => any>;
  38752. }[]): void;
  38753. /**
  38754. * @ignore
  38755. */
  38756. static _ScreenshotCanvas: HTMLCanvasElement;
  38757. /**
  38758. * Dumps the current bound framebuffer
  38759. * @param width defines the rendering width
  38760. * @param height defines the rendering height
  38761. * @param engine defines the hosting engine
  38762. * @param successCallback defines the callback triggered once the data are available
  38763. * @param mimeType defines the mime type of the result
  38764. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38765. */
  38766. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38767. /**
  38768. * Converts the canvas data to blob.
  38769. * This acts as a polyfill for browsers not supporting the to blob function.
  38770. * @param canvas Defines the canvas to extract the data from
  38771. * @param successCallback Defines the callback triggered once the data are available
  38772. * @param mimeType Defines the mime type of the result
  38773. */
  38774. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38775. /**
  38776. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38777. * @param successCallback defines the callback triggered once the data are available
  38778. * @param mimeType defines the mime type of the result
  38779. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38780. */
  38781. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38782. /**
  38783. * Downloads a blob in the browser
  38784. * @param blob defines the blob to download
  38785. * @param fileName defines the name of the downloaded file
  38786. */
  38787. static Download(blob: Blob, fileName: string): void;
  38788. /**
  38789. * Captures a screenshot of the current rendering
  38790. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38791. * @param engine defines the rendering engine
  38792. * @param camera defines the source camera
  38793. * @param size This parameter can be set to a single number or to an object with the
  38794. * following (optional) properties: precision, width, height. If a single number is passed,
  38795. * it will be used for both width and height. If an object is passed, the screenshot size
  38796. * will be derived from the parameters. The precision property is a multiplier allowing
  38797. * rendering at a higher or lower resolution
  38798. * @param successCallback defines the callback receives a single parameter which contains the
  38799. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38800. * src parameter of an <img> to display it
  38801. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38802. * Check your browser for supported MIME types
  38803. */
  38804. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38805. /**
  38806. * Captures a screenshot of the current rendering
  38807. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38808. * @param engine defines the rendering engine
  38809. * @param camera defines the source camera
  38810. * @param size This parameter can be set to a single number or to an object with the
  38811. * following (optional) properties: precision, width, height. If a single number is passed,
  38812. * it will be used for both width and height. If an object is passed, the screenshot size
  38813. * will be derived from the parameters. The precision property is a multiplier allowing
  38814. * rendering at a higher or lower resolution
  38815. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38816. * Check your browser for supported MIME types
  38817. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38818. * to the src parameter of an <img> to display it
  38819. */
  38820. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38821. /**
  38822. * Generates an image screenshot from the specified camera.
  38823. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38824. * @param engine The engine to use for rendering
  38825. * @param camera The camera to use for rendering
  38826. * @param size This parameter can be set to a single number or to an object with the
  38827. * following (optional) properties: precision, width, height. If a single number is passed,
  38828. * it will be used for both width and height. If an object is passed, the screenshot size
  38829. * will be derived from the parameters. The precision property is a multiplier allowing
  38830. * rendering at a higher or lower resolution
  38831. * @param successCallback The callback receives a single parameter which contains the
  38832. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38833. * src parameter of an <img> to display it
  38834. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38835. * Check your browser for supported MIME types
  38836. * @param samples Texture samples (default: 1)
  38837. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38838. * @param fileName A name for for the downloaded file.
  38839. */
  38840. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38841. /**
  38842. * Generates an image screenshot from the specified camera.
  38843. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38844. * @param engine The engine to use for rendering
  38845. * @param camera The camera to use for rendering
  38846. * @param size This parameter can be set to a single number or to an object with the
  38847. * following (optional) properties: precision, width, height. If a single number is passed,
  38848. * it will be used for both width and height. If an object is passed, the screenshot size
  38849. * will be derived from the parameters. The precision property is a multiplier allowing
  38850. * rendering at a higher or lower resolution
  38851. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38852. * Check your browser for supported MIME types
  38853. * @param samples Texture samples (default: 1)
  38854. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38855. * @param fileName A name for for the downloaded file.
  38856. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38857. * to the src parameter of an <img> to display it
  38858. */
  38859. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38860. /**
  38861. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38862. * Be aware Math.random() could cause collisions, but:
  38863. * "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"
  38864. * @returns a pseudo random id
  38865. */
  38866. static RandomId(): string;
  38867. /**
  38868. * Test if the given uri is a base64 string
  38869. * @param uri The uri to test
  38870. * @return True if the uri is a base64 string or false otherwise
  38871. */
  38872. static IsBase64(uri: string): boolean;
  38873. /**
  38874. * Decode the given base64 uri.
  38875. * @param uri The uri to decode
  38876. * @return The decoded base64 data.
  38877. */
  38878. static DecodeBase64(uri: string): ArrayBuffer;
  38879. /**
  38880. * Gets the absolute url.
  38881. * @param url the input url
  38882. * @return the absolute url
  38883. */
  38884. static GetAbsoluteUrl(url: string): string;
  38885. /**
  38886. * No log
  38887. */
  38888. static readonly NoneLogLevel: number;
  38889. /**
  38890. * Only message logs
  38891. */
  38892. static readonly MessageLogLevel: number;
  38893. /**
  38894. * Only warning logs
  38895. */
  38896. static readonly WarningLogLevel: number;
  38897. /**
  38898. * Only error logs
  38899. */
  38900. static readonly ErrorLogLevel: number;
  38901. /**
  38902. * All logs
  38903. */
  38904. static readonly AllLogLevel: number;
  38905. /**
  38906. * Gets a value indicating the number of loading errors
  38907. * @ignorenaming
  38908. */
  38909. static get errorsCount(): number;
  38910. /**
  38911. * Callback called when a new log is added
  38912. */
  38913. static OnNewCacheEntry: (entry: string) => void;
  38914. /**
  38915. * Log a message to the console
  38916. * @param message defines the message to log
  38917. */
  38918. static Log(message: string): void;
  38919. /**
  38920. * Write a warning message to the console
  38921. * @param message defines the message to log
  38922. */
  38923. static Warn(message: string): void;
  38924. /**
  38925. * Write an error message to the console
  38926. * @param message defines the message to log
  38927. */
  38928. static Error(message: string): void;
  38929. /**
  38930. * Gets current log cache (list of logs)
  38931. */
  38932. static get LogCache(): string;
  38933. /**
  38934. * Clears the log cache
  38935. */
  38936. static ClearLogCache(): void;
  38937. /**
  38938. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38939. */
  38940. static set LogLevels(level: number);
  38941. /**
  38942. * Checks if the window object exists
  38943. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38944. */
  38945. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38946. /**
  38947. * No performance log
  38948. */
  38949. static readonly PerformanceNoneLogLevel: number;
  38950. /**
  38951. * Use user marks to log performance
  38952. */
  38953. static readonly PerformanceUserMarkLogLevel: number;
  38954. /**
  38955. * Log performance to the console
  38956. */
  38957. static readonly PerformanceConsoleLogLevel: number;
  38958. private static _performance;
  38959. /**
  38960. * Sets the current performance log level
  38961. */
  38962. static set PerformanceLogLevel(level: number);
  38963. private static _StartPerformanceCounterDisabled;
  38964. private static _EndPerformanceCounterDisabled;
  38965. private static _StartUserMark;
  38966. private static _EndUserMark;
  38967. private static _StartPerformanceConsole;
  38968. private static _EndPerformanceConsole;
  38969. /**
  38970. * Starts a performance counter
  38971. */
  38972. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38973. /**
  38974. * Ends a specific performance coutner
  38975. */
  38976. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38977. /**
  38978. * Gets either window.performance.now() if supported or Date.now() else
  38979. */
  38980. static get Now(): number;
  38981. /**
  38982. * This method will return the name of the class used to create the instance of the given object.
  38983. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38984. * @param object the object to get the class name from
  38985. * @param isType defines if the object is actually a type
  38986. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38987. */
  38988. static GetClassName(object: any, isType?: boolean): string;
  38989. /**
  38990. * Gets the first element of an array satisfying a given predicate
  38991. * @param array defines the array to browse
  38992. * @param predicate defines the predicate to use
  38993. * @returns null if not found or the element
  38994. */
  38995. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38996. /**
  38997. * This method will return the name of the full name of the class, including its owning module (if any).
  38998. * 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).
  38999. * @param object the object to get the class name from
  39000. * @param isType defines if the object is actually a type
  39001. * @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.
  39002. * @ignorenaming
  39003. */
  39004. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  39005. /**
  39006. * Returns a promise that resolves after the given amount of time.
  39007. * @param delay Number of milliseconds to delay
  39008. * @returns Promise that resolves after the given amount of time
  39009. */
  39010. static DelayAsync(delay: number): Promise<void>;
  39011. /**
  39012. * Utility function to detect if the current user agent is Safari
  39013. * @returns whether or not the current user agent is safari
  39014. */
  39015. static IsSafari(): boolean;
  39016. }
  39017. /**
  39018. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  39019. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  39020. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  39021. * @param name The name of the class, case should be preserved
  39022. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  39023. */
  39024. export function className(name: string, module?: string): (target: Object) => void;
  39025. /**
  39026. * An implementation of a loop for asynchronous functions.
  39027. */
  39028. export class AsyncLoop {
  39029. /**
  39030. * Defines the number of iterations for the loop
  39031. */
  39032. iterations: number;
  39033. /**
  39034. * Defines the current index of the loop.
  39035. */
  39036. index: number;
  39037. private _done;
  39038. private _fn;
  39039. private _successCallback;
  39040. /**
  39041. * Constructor.
  39042. * @param iterations the number of iterations.
  39043. * @param func the function to run each iteration
  39044. * @param successCallback the callback that will be called upon succesful execution
  39045. * @param offset starting offset.
  39046. */
  39047. constructor(
  39048. /**
  39049. * Defines the number of iterations for the loop
  39050. */
  39051. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  39052. /**
  39053. * Execute the next iteration. Must be called after the last iteration was finished.
  39054. */
  39055. executeNext(): void;
  39056. /**
  39057. * Break the loop and run the success callback.
  39058. */
  39059. breakLoop(): void;
  39060. /**
  39061. * Create and run an async loop.
  39062. * @param iterations the number of iterations.
  39063. * @param fn the function to run each iteration
  39064. * @param successCallback the callback that will be called upon succesful execution
  39065. * @param offset starting offset.
  39066. * @returns the created async loop object
  39067. */
  39068. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  39069. /**
  39070. * A for-loop that will run a given number of iterations synchronous and the rest async.
  39071. * @param iterations total number of iterations
  39072. * @param syncedIterations number of synchronous iterations in each async iteration.
  39073. * @param fn the function to call each iteration.
  39074. * @param callback a success call back that will be called when iterating stops.
  39075. * @param breakFunction a break condition (optional)
  39076. * @param timeout timeout settings for the setTimeout function. default - 0.
  39077. * @returns the created async loop object
  39078. */
  39079. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  39080. }
  39081. }
  39082. declare module "babylonjs/Misc/stringDictionary" {
  39083. import { Nullable } from "babylonjs/types";
  39084. /**
  39085. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39086. * The underlying implementation relies on an associative array to ensure the best performances.
  39087. * The value can be anything including 'null' but except 'undefined'
  39088. */
  39089. export class StringDictionary<T> {
  39090. /**
  39091. * This will clear this dictionary and copy the content from the 'source' one.
  39092. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39093. * @param source the dictionary to take the content from and copy to this dictionary
  39094. */
  39095. copyFrom(source: StringDictionary<T>): void;
  39096. /**
  39097. * Get a value based from its key
  39098. * @param key the given key to get the matching value from
  39099. * @return the value if found, otherwise undefined is returned
  39100. */
  39101. get(key: string): T | undefined;
  39102. /**
  39103. * Get a value from its key or add it if it doesn't exist.
  39104. * This method will ensure you that a given key/data will be present in the dictionary.
  39105. * @param key the given key to get the matching value from
  39106. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39107. * The factory will only be invoked if there's no data for the given key.
  39108. * @return the value corresponding to the key.
  39109. */
  39110. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39111. /**
  39112. * Get a value from its key if present in the dictionary otherwise add it
  39113. * @param key the key to get the value from
  39114. * @param val if there's no such key/value pair in the dictionary add it with this value
  39115. * @return the value corresponding to the key
  39116. */
  39117. getOrAdd(key: string, val: T): T;
  39118. /**
  39119. * Check if there's a given key in the dictionary
  39120. * @param key the key to check for
  39121. * @return true if the key is present, false otherwise
  39122. */
  39123. contains(key: string): boolean;
  39124. /**
  39125. * Add a new key and its corresponding value
  39126. * @param key the key to add
  39127. * @param value the value corresponding to the key
  39128. * @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
  39129. */
  39130. add(key: string, value: T): boolean;
  39131. /**
  39132. * Update a specific value associated to a key
  39133. * @param key defines the key to use
  39134. * @param value defines the value to store
  39135. * @returns true if the value was updated (or false if the key was not found)
  39136. */
  39137. set(key: string, value: T): boolean;
  39138. /**
  39139. * Get the element of the given key and remove it from the dictionary
  39140. * @param key defines the key to search
  39141. * @returns the value associated with the key or null if not found
  39142. */
  39143. getAndRemove(key: string): Nullable<T>;
  39144. /**
  39145. * Remove a key/value from the dictionary.
  39146. * @param key the key to remove
  39147. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39148. */
  39149. remove(key: string): boolean;
  39150. /**
  39151. * Clear the whole content of the dictionary
  39152. */
  39153. clear(): void;
  39154. /**
  39155. * Gets the current count
  39156. */
  39157. get count(): number;
  39158. /**
  39159. * Execute a callback on each key/val of the dictionary.
  39160. * Note that you can remove any element in this dictionary in the callback implementation
  39161. * @param callback the callback to execute on a given key/value pair
  39162. */
  39163. forEach(callback: (key: string, val: T) => void): void;
  39164. /**
  39165. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39166. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39167. * Note that you can remove any element in this dictionary in the callback implementation
  39168. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39169. * @returns the first item
  39170. */
  39171. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39172. private _count;
  39173. private _data;
  39174. }
  39175. }
  39176. declare module "babylonjs/Collisions/collisionCoordinator" {
  39177. import { Nullable } from "babylonjs/types";
  39178. import { Scene } from "babylonjs/scene";
  39179. import { Vector3 } from "babylonjs/Maths/math.vector";
  39180. import { Collider } from "babylonjs/Collisions/collider";
  39181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39182. /** @hidden */
  39183. export interface ICollisionCoordinator {
  39184. createCollider(): Collider;
  39185. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39186. init(scene: Scene): void;
  39187. }
  39188. /** @hidden */
  39189. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  39190. private _scene;
  39191. private _scaledPosition;
  39192. private _scaledVelocity;
  39193. private _finalPosition;
  39194. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39195. createCollider(): Collider;
  39196. init(scene: Scene): void;
  39197. private _collideWithWorld;
  39198. }
  39199. }
  39200. declare module "babylonjs/Inputs/scene.inputManager" {
  39201. import { Nullable } from "babylonjs/types";
  39202. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39203. import { Vector2 } from "babylonjs/Maths/math.vector";
  39204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39205. import { Scene } from "babylonjs/scene";
  39206. /**
  39207. * Class used to manage all inputs for the scene.
  39208. */
  39209. export class InputManager {
  39210. /** The distance in pixel that you have to move to prevent some events */
  39211. static DragMovementThreshold: number;
  39212. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  39213. static LongPressDelay: number;
  39214. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  39215. static DoubleClickDelay: number;
  39216. /** If you need to check double click without raising a single click at first click, enable this flag */
  39217. static ExclusiveDoubleClickMode: boolean;
  39218. private _wheelEventName;
  39219. private _onPointerMove;
  39220. private _onPointerDown;
  39221. private _onPointerUp;
  39222. private _initClickEvent;
  39223. private _initActionManager;
  39224. private _delayedSimpleClick;
  39225. private _delayedSimpleClickTimeout;
  39226. private _previousDelayedSimpleClickTimeout;
  39227. private _meshPickProceed;
  39228. private _previousButtonPressed;
  39229. private _currentPickResult;
  39230. private _previousPickResult;
  39231. private _totalPointersPressed;
  39232. private _doubleClickOccured;
  39233. private _pointerOverMesh;
  39234. private _pickedDownMesh;
  39235. private _pickedUpMesh;
  39236. private _pointerX;
  39237. private _pointerY;
  39238. private _unTranslatedPointerX;
  39239. private _unTranslatedPointerY;
  39240. private _startingPointerPosition;
  39241. private _previousStartingPointerPosition;
  39242. private _startingPointerTime;
  39243. private _previousStartingPointerTime;
  39244. private _pointerCaptures;
  39245. private _onKeyDown;
  39246. private _onKeyUp;
  39247. private _onCanvasFocusObserver;
  39248. private _onCanvasBlurObserver;
  39249. private _scene;
  39250. /**
  39251. * Creates a new InputManager
  39252. * @param scene defines the hosting scene
  39253. */
  39254. constructor(scene: Scene);
  39255. /**
  39256. * Gets the mesh that is currently under the pointer
  39257. */
  39258. get meshUnderPointer(): Nullable<AbstractMesh>;
  39259. /**
  39260. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  39261. */
  39262. get unTranslatedPointer(): Vector2;
  39263. /**
  39264. * Gets or sets the current on-screen X position of the pointer
  39265. */
  39266. get pointerX(): number;
  39267. set pointerX(value: number);
  39268. /**
  39269. * Gets or sets the current on-screen Y position of the pointer
  39270. */
  39271. get pointerY(): number;
  39272. set pointerY(value: number);
  39273. private _updatePointerPosition;
  39274. private _processPointerMove;
  39275. private _setRayOnPointerInfo;
  39276. private _checkPrePointerObservable;
  39277. /**
  39278. * Use this method to simulate a pointer move on a mesh
  39279. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39280. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39281. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39282. */
  39283. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39284. /**
  39285. * Use this method to simulate a pointer down on a mesh
  39286. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39287. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39288. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39289. */
  39290. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39291. private _processPointerDown;
  39292. /** @hidden */
  39293. _isPointerSwiping(): boolean;
  39294. /**
  39295. * Use this method to simulate a pointer up on a mesh
  39296. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39297. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39298. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39299. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39300. */
  39301. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  39302. private _processPointerUp;
  39303. /**
  39304. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39305. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39306. * @returns true if the pointer was captured
  39307. */
  39308. isPointerCaptured(pointerId?: number): boolean;
  39309. /**
  39310. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39311. * @param attachUp defines if you want to attach events to pointerup
  39312. * @param attachDown defines if you want to attach events to pointerdown
  39313. * @param attachMove defines if you want to attach events to pointermove
  39314. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  39315. */
  39316. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  39317. /**
  39318. * Detaches all event handlers
  39319. */
  39320. detachControl(): void;
  39321. /**
  39322. * Force the value of meshUnderPointer
  39323. * @param mesh defines the mesh to use
  39324. */
  39325. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39326. /**
  39327. * Gets the mesh under the pointer
  39328. * @returns a Mesh or null if no mesh is under the pointer
  39329. */
  39330. getPointerOverMesh(): Nullable<AbstractMesh>;
  39331. }
  39332. }
  39333. declare module "babylonjs/Animations/animationGroup" {
  39334. import { Animatable } from "babylonjs/Animations/animatable";
  39335. import { Animation } from "babylonjs/Animations/animation";
  39336. import { Scene, IDisposable } from "babylonjs/scene";
  39337. import { Observable } from "babylonjs/Misc/observable";
  39338. import { Nullable } from "babylonjs/types";
  39339. import "babylonjs/Animations/animatable";
  39340. /**
  39341. * This class defines the direct association between an animation and a target
  39342. */
  39343. export class TargetedAnimation {
  39344. /**
  39345. * Animation to perform
  39346. */
  39347. animation: Animation;
  39348. /**
  39349. * Target to animate
  39350. */
  39351. target: any;
  39352. /**
  39353. * Returns the string "TargetedAnimation"
  39354. * @returns "TargetedAnimation"
  39355. */
  39356. getClassName(): string;
  39357. /**
  39358. * Serialize the object
  39359. * @returns the JSON object representing the current entity
  39360. */
  39361. serialize(): any;
  39362. }
  39363. /**
  39364. * Use this class to create coordinated animations on multiple targets
  39365. */
  39366. export class AnimationGroup implements IDisposable {
  39367. /** The name of the animation group */
  39368. name: string;
  39369. private _scene;
  39370. private _targetedAnimations;
  39371. private _animatables;
  39372. private _from;
  39373. private _to;
  39374. private _isStarted;
  39375. private _isPaused;
  39376. private _speedRatio;
  39377. private _loopAnimation;
  39378. private _isAdditive;
  39379. /**
  39380. * Gets or sets the unique id of the node
  39381. */
  39382. uniqueId: number;
  39383. /**
  39384. * This observable will notify when one animation have ended
  39385. */
  39386. onAnimationEndObservable: Observable<TargetedAnimation>;
  39387. /**
  39388. * Observer raised when one animation loops
  39389. */
  39390. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39391. /**
  39392. * Observer raised when all animations have looped
  39393. */
  39394. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39395. /**
  39396. * This observable will notify when all animations have ended.
  39397. */
  39398. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39399. /**
  39400. * This observable will notify when all animations have paused.
  39401. */
  39402. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39403. /**
  39404. * This observable will notify when all animations are playing.
  39405. */
  39406. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39407. /**
  39408. * Gets the first frame
  39409. */
  39410. get from(): number;
  39411. /**
  39412. * Gets the last frame
  39413. */
  39414. get to(): number;
  39415. /**
  39416. * Define if the animations are started
  39417. */
  39418. get isStarted(): boolean;
  39419. /**
  39420. * Gets a value indicating that the current group is playing
  39421. */
  39422. get isPlaying(): boolean;
  39423. /**
  39424. * Gets or sets the speed ratio to use for all animations
  39425. */
  39426. get speedRatio(): number;
  39427. /**
  39428. * Gets or sets the speed ratio to use for all animations
  39429. */
  39430. set speedRatio(value: number);
  39431. /**
  39432. * Gets or sets if all animations should loop or not
  39433. */
  39434. get loopAnimation(): boolean;
  39435. set loopAnimation(value: boolean);
  39436. /**
  39437. * Gets or sets if all animations should be evaluated additively
  39438. */
  39439. get isAdditive(): boolean;
  39440. set isAdditive(value: boolean);
  39441. /**
  39442. * Gets the targeted animations for this animation group
  39443. */
  39444. get targetedAnimations(): Array<TargetedAnimation>;
  39445. /**
  39446. * returning the list of animatables controlled by this animation group.
  39447. */
  39448. get animatables(): Array<Animatable>;
  39449. /**
  39450. * Gets the list of target animations
  39451. */
  39452. get children(): TargetedAnimation[];
  39453. /**
  39454. * Instantiates a new Animation Group.
  39455. * This helps managing several animations at once.
  39456. * @see https://doc.babylonjs.com/how_to/group
  39457. * @param name Defines the name of the group
  39458. * @param scene Defines the scene the group belongs to
  39459. */
  39460. constructor(
  39461. /** The name of the animation group */
  39462. name: string, scene?: Nullable<Scene>);
  39463. /**
  39464. * Add an animation (with its target) in the group
  39465. * @param animation defines the animation we want to add
  39466. * @param target defines the target of the animation
  39467. * @returns the TargetedAnimation object
  39468. */
  39469. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39470. /**
  39471. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39472. * It can add constant keys at begin or end
  39473. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39474. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39475. * @returns the animation group
  39476. */
  39477. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39478. private _animationLoopCount;
  39479. private _animationLoopFlags;
  39480. private _processLoop;
  39481. /**
  39482. * Start all animations on given targets
  39483. * @param loop defines if animations must loop
  39484. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39485. * @param from defines the from key (optional)
  39486. * @param to defines the to key (optional)
  39487. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39488. * @returns the current animation group
  39489. */
  39490. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39491. /**
  39492. * Pause all animations
  39493. * @returns the animation group
  39494. */
  39495. pause(): AnimationGroup;
  39496. /**
  39497. * Play all animations to initial state
  39498. * This function will start() the animations if they were not started or will restart() them if they were paused
  39499. * @param loop defines if animations must loop
  39500. * @returns the animation group
  39501. */
  39502. play(loop?: boolean): AnimationGroup;
  39503. /**
  39504. * Reset all animations to initial state
  39505. * @returns the animation group
  39506. */
  39507. reset(): AnimationGroup;
  39508. /**
  39509. * Restart animations from key 0
  39510. * @returns the animation group
  39511. */
  39512. restart(): AnimationGroup;
  39513. /**
  39514. * Stop all animations
  39515. * @returns the animation group
  39516. */
  39517. stop(): AnimationGroup;
  39518. /**
  39519. * Set animation weight for all animatables
  39520. * @param weight defines the weight to use
  39521. * @return the animationGroup
  39522. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39523. */
  39524. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39525. /**
  39526. * Synchronize and normalize all animatables with a source animatable
  39527. * @param root defines the root animatable to synchronize with
  39528. * @return the animationGroup
  39529. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39530. */
  39531. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39532. /**
  39533. * Goes to a specific frame in this animation group
  39534. * @param frame the frame number to go to
  39535. * @return the animationGroup
  39536. */
  39537. goToFrame(frame: number): AnimationGroup;
  39538. /**
  39539. * Dispose all associated resources
  39540. */
  39541. dispose(): void;
  39542. private _checkAnimationGroupEnded;
  39543. /**
  39544. * Clone the current animation group and returns a copy
  39545. * @param newName defines the name of the new group
  39546. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39547. * @returns the new aniamtion group
  39548. */
  39549. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39550. /**
  39551. * Serializes the animationGroup to an object
  39552. * @returns Serialized object
  39553. */
  39554. serialize(): any;
  39555. /**
  39556. * Returns a new AnimationGroup object parsed from the source provided.
  39557. * @param parsedAnimationGroup defines the source
  39558. * @param scene defines the scene that will receive the animationGroup
  39559. * @returns a new AnimationGroup
  39560. */
  39561. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39562. /**
  39563. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39564. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39565. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39566. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39567. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39568. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39569. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39570. */
  39571. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39572. /**
  39573. * Returns the string "AnimationGroup"
  39574. * @returns "AnimationGroup"
  39575. */
  39576. getClassName(): string;
  39577. /**
  39578. * Creates a detailled string about the object
  39579. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39580. * @returns a string representing the object
  39581. */
  39582. toString(fullDetails?: boolean): string;
  39583. }
  39584. }
  39585. declare module "babylonjs/scene" {
  39586. import { Nullable } from "babylonjs/types";
  39587. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  39588. import { Observable } from "babylonjs/Misc/observable";
  39589. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  39590. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  39591. import { Geometry } from "babylonjs/Meshes/geometry";
  39592. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39593. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39594. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39595. import { Mesh } from "babylonjs/Meshes/mesh";
  39596. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  39597. import { Bone } from "babylonjs/Bones/bone";
  39598. import { Skeleton } from "babylonjs/Bones/skeleton";
  39599. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  39600. import { Camera } from "babylonjs/Cameras/camera";
  39601. import { AbstractScene } from "babylonjs/abstractScene";
  39602. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39603. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39604. import { Material } from "babylonjs/Materials/material";
  39605. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39606. import { Effect } from "babylonjs/Materials/effect";
  39607. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  39608. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  39609. import { Light } from "babylonjs/Lights/light";
  39610. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39611. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  39612. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  39613. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  39614. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39615. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  39616. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39617. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  39618. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  39619. import { Engine } from "babylonjs/Engines/engine";
  39620. import { Node } from "babylonjs/node";
  39621. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  39622. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  39623. import { WebRequest } from "babylonjs/Misc/webRequest";
  39624. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  39625. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  39626. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39627. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  39628. import { Plane } from "babylonjs/Maths/math.plane";
  39629. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  39630. import { Ray } from "babylonjs/Culling/ray";
  39631. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  39632. import { Animation } from "babylonjs/Animations/animation";
  39633. import { Animatable } from "babylonjs/Animations/animatable";
  39634. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  39635. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  39636. import { Collider } from "babylonjs/Collisions/collider";
  39637. /**
  39638. * Define an interface for all classes that will hold resources
  39639. */
  39640. export interface IDisposable {
  39641. /**
  39642. * Releases all held resources
  39643. */
  39644. dispose(): void;
  39645. }
  39646. /** Interface defining initialization parameters for Scene class */
  39647. export interface SceneOptions {
  39648. /**
  39649. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39650. * It will improve performance when the number of geometries becomes important.
  39651. */
  39652. useGeometryUniqueIdsMap?: boolean;
  39653. /**
  39654. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39655. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39656. */
  39657. useMaterialMeshMap?: boolean;
  39658. /**
  39659. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39660. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39661. */
  39662. useClonedMeshMap?: boolean;
  39663. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39664. virtual?: boolean;
  39665. }
  39666. /**
  39667. * Represents a scene to be rendered by the engine.
  39668. * @see https://doc.babylonjs.com/features/scene
  39669. */
  39670. export class Scene extends AbstractScene implements IAnimatable {
  39671. /** The fog is deactivated */
  39672. static readonly FOGMODE_NONE: number;
  39673. /** The fog density is following an exponential function */
  39674. static readonly FOGMODE_EXP: number;
  39675. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39676. static readonly FOGMODE_EXP2: number;
  39677. /** The fog density is following a linear function. */
  39678. static readonly FOGMODE_LINEAR: number;
  39679. /**
  39680. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39681. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39682. */
  39683. static MinDeltaTime: number;
  39684. /**
  39685. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39686. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39687. */
  39688. static MaxDeltaTime: number;
  39689. /**
  39690. * Factory used to create the default material.
  39691. * @param name The name of the material to create
  39692. * @param scene The scene to create the material for
  39693. * @returns The default material
  39694. */
  39695. static DefaultMaterialFactory(scene: Scene): Material;
  39696. /**
  39697. * Factory used to create the a collision coordinator.
  39698. * @returns The collision coordinator
  39699. */
  39700. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39701. /** @hidden */
  39702. _inputManager: InputManager;
  39703. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39704. cameraToUseForPointers: Nullable<Camera>;
  39705. /** @hidden */
  39706. readonly _isScene: boolean;
  39707. /** @hidden */
  39708. _blockEntityCollection: boolean;
  39709. /**
  39710. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39711. */
  39712. autoClear: boolean;
  39713. /**
  39714. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39715. */
  39716. autoClearDepthAndStencil: boolean;
  39717. /**
  39718. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39719. */
  39720. clearColor: Color4;
  39721. /**
  39722. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39723. */
  39724. ambientColor: Color3;
  39725. /**
  39726. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39727. * It should only be one of the following (if not the default embedded one):
  39728. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39729. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39730. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39731. * The material properties need to be setup according to the type of texture in use.
  39732. */
  39733. environmentBRDFTexture: BaseTexture;
  39734. /** @hidden */
  39735. protected _environmentTexture: Nullable<BaseTexture>;
  39736. /**
  39737. * Texture used in all pbr material as the reflection texture.
  39738. * As in the majority of the scene they are the same (exception for multi room and so on),
  39739. * this is easier to reference from here than from all the materials.
  39740. */
  39741. get environmentTexture(): Nullable<BaseTexture>;
  39742. /**
  39743. * Texture used in all pbr material as the reflection texture.
  39744. * As in the majority of the scene they are the same (exception for multi room and so on),
  39745. * this is easier to set here than in all the materials.
  39746. */
  39747. set environmentTexture(value: Nullable<BaseTexture>);
  39748. /** @hidden */
  39749. protected _environmentIntensity: number;
  39750. /**
  39751. * Intensity of the environment in all pbr material.
  39752. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39753. * As in the majority of the scene they are the same (exception for multi room and so on),
  39754. * this is easier to reference from here than from all the materials.
  39755. */
  39756. get environmentIntensity(): number;
  39757. /**
  39758. * Intensity of the environment in all pbr material.
  39759. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39760. * As in the majority of the scene they are the same (exception for multi room and so on),
  39761. * this is easier to set here than in all the materials.
  39762. */
  39763. set environmentIntensity(value: number);
  39764. /** @hidden */
  39765. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39766. /**
  39767. * Default image processing configuration used either in the rendering
  39768. * Forward main pass or through the imageProcessingPostProcess if present.
  39769. * As in the majority of the scene they are the same (exception for multi camera),
  39770. * this is easier to reference from here than from all the materials and post process.
  39771. *
  39772. * No setter as we it is a shared configuration, you can set the values instead.
  39773. */
  39774. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39775. private _forceWireframe;
  39776. /**
  39777. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39778. */
  39779. set forceWireframe(value: boolean);
  39780. get forceWireframe(): boolean;
  39781. private _skipFrustumClipping;
  39782. /**
  39783. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39784. */
  39785. set skipFrustumClipping(value: boolean);
  39786. get skipFrustumClipping(): boolean;
  39787. private _forcePointsCloud;
  39788. /**
  39789. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39790. */
  39791. set forcePointsCloud(value: boolean);
  39792. get forcePointsCloud(): boolean;
  39793. /**
  39794. * Gets or sets the active clipplane 1
  39795. */
  39796. clipPlane: Nullable<Plane>;
  39797. /**
  39798. * Gets or sets the active clipplane 2
  39799. */
  39800. clipPlane2: Nullable<Plane>;
  39801. /**
  39802. * Gets or sets the active clipplane 3
  39803. */
  39804. clipPlane3: Nullable<Plane>;
  39805. /**
  39806. * Gets or sets the active clipplane 4
  39807. */
  39808. clipPlane4: Nullable<Plane>;
  39809. /**
  39810. * Gets or sets the active clipplane 5
  39811. */
  39812. clipPlane5: Nullable<Plane>;
  39813. /**
  39814. * Gets or sets the active clipplane 6
  39815. */
  39816. clipPlane6: Nullable<Plane>;
  39817. /**
  39818. * Gets or sets a boolean indicating if animations are enabled
  39819. */
  39820. animationsEnabled: boolean;
  39821. private _animationPropertiesOverride;
  39822. /**
  39823. * Gets or sets the animation properties override
  39824. */
  39825. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39826. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39827. /**
  39828. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39829. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39830. */
  39831. useConstantAnimationDeltaTime: boolean;
  39832. /**
  39833. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39834. * Please note that it requires to run a ray cast through the scene on every frame
  39835. */
  39836. constantlyUpdateMeshUnderPointer: boolean;
  39837. /**
  39838. * Defines the HTML cursor to use when hovering over interactive elements
  39839. */
  39840. hoverCursor: string;
  39841. /**
  39842. * Defines the HTML default cursor to use (empty by default)
  39843. */
  39844. defaultCursor: string;
  39845. /**
  39846. * Defines whether cursors are handled by the scene.
  39847. */
  39848. doNotHandleCursors: boolean;
  39849. /**
  39850. * This is used to call preventDefault() on pointer down
  39851. * in order to block unwanted artifacts like system double clicks
  39852. */
  39853. preventDefaultOnPointerDown: boolean;
  39854. /**
  39855. * This is used to call preventDefault() on pointer up
  39856. * in order to block unwanted artifacts like system double clicks
  39857. */
  39858. preventDefaultOnPointerUp: boolean;
  39859. /**
  39860. * Gets or sets user defined metadata
  39861. */
  39862. metadata: any;
  39863. /**
  39864. * For internal use only. Please do not use.
  39865. */
  39866. reservedDataStore: any;
  39867. /**
  39868. * Gets the name of the plugin used to load this scene (null by default)
  39869. */
  39870. loadingPluginName: string;
  39871. /**
  39872. * Use this array to add regular expressions used to disable offline support for specific urls
  39873. */
  39874. disableOfflineSupportExceptionRules: RegExp[];
  39875. /**
  39876. * An event triggered when the scene is disposed.
  39877. */
  39878. onDisposeObservable: Observable<Scene>;
  39879. private _onDisposeObserver;
  39880. /** Sets a function to be executed when this scene is disposed. */
  39881. set onDispose(callback: () => void);
  39882. /**
  39883. * An event triggered before rendering the scene (right after animations and physics)
  39884. */
  39885. onBeforeRenderObservable: Observable<Scene>;
  39886. private _onBeforeRenderObserver;
  39887. /** Sets a function to be executed before rendering this scene */
  39888. set beforeRender(callback: Nullable<() => void>);
  39889. /**
  39890. * An event triggered after rendering the scene
  39891. */
  39892. onAfterRenderObservable: Observable<Scene>;
  39893. /**
  39894. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39895. */
  39896. onAfterRenderCameraObservable: Observable<Camera>;
  39897. private _onAfterRenderObserver;
  39898. /** Sets a function to be executed after rendering this scene */
  39899. set afterRender(callback: Nullable<() => void>);
  39900. /**
  39901. * An event triggered before animating the scene
  39902. */
  39903. onBeforeAnimationsObservable: Observable<Scene>;
  39904. /**
  39905. * An event triggered after animations processing
  39906. */
  39907. onAfterAnimationsObservable: Observable<Scene>;
  39908. /**
  39909. * An event triggered before draw calls are ready to be sent
  39910. */
  39911. onBeforeDrawPhaseObservable: Observable<Scene>;
  39912. /**
  39913. * An event triggered after draw calls have been sent
  39914. */
  39915. onAfterDrawPhaseObservable: Observable<Scene>;
  39916. /**
  39917. * An event triggered when the scene is ready
  39918. */
  39919. onReadyObservable: Observable<Scene>;
  39920. /**
  39921. * An event triggered before rendering a camera
  39922. */
  39923. onBeforeCameraRenderObservable: Observable<Camera>;
  39924. private _onBeforeCameraRenderObserver;
  39925. /** Sets a function to be executed before rendering a camera*/
  39926. set beforeCameraRender(callback: () => void);
  39927. /**
  39928. * An event triggered after rendering a camera
  39929. */
  39930. onAfterCameraRenderObservable: Observable<Camera>;
  39931. private _onAfterCameraRenderObserver;
  39932. /** Sets a function to be executed after rendering a camera*/
  39933. set afterCameraRender(callback: () => void);
  39934. /**
  39935. * An event triggered when active meshes evaluation is about to start
  39936. */
  39937. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39938. /**
  39939. * An event triggered when active meshes evaluation is done
  39940. */
  39941. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39942. /**
  39943. * An event triggered when particles rendering is about to start
  39944. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39945. */
  39946. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39947. /**
  39948. * An event triggered when particles rendering is done
  39949. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39950. */
  39951. onAfterParticlesRenderingObservable: Observable<Scene>;
  39952. /**
  39953. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39954. */
  39955. onDataLoadedObservable: Observable<Scene>;
  39956. /**
  39957. * An event triggered when a camera is created
  39958. */
  39959. onNewCameraAddedObservable: Observable<Camera>;
  39960. /**
  39961. * An event triggered when a camera is removed
  39962. */
  39963. onCameraRemovedObservable: Observable<Camera>;
  39964. /**
  39965. * An event triggered when a light is created
  39966. */
  39967. onNewLightAddedObservable: Observable<Light>;
  39968. /**
  39969. * An event triggered when a light is removed
  39970. */
  39971. onLightRemovedObservable: Observable<Light>;
  39972. /**
  39973. * An event triggered when a geometry is created
  39974. */
  39975. onNewGeometryAddedObservable: Observable<Geometry>;
  39976. /**
  39977. * An event triggered when a geometry is removed
  39978. */
  39979. onGeometryRemovedObservable: Observable<Geometry>;
  39980. /**
  39981. * An event triggered when a transform node is created
  39982. */
  39983. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39984. /**
  39985. * An event triggered when a transform node is removed
  39986. */
  39987. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39988. /**
  39989. * An event triggered when a mesh is created
  39990. */
  39991. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39992. /**
  39993. * An event triggered when a mesh is removed
  39994. */
  39995. onMeshRemovedObservable: Observable<AbstractMesh>;
  39996. /**
  39997. * An event triggered when a skeleton is created
  39998. */
  39999. onNewSkeletonAddedObservable: Observable<Skeleton>;
  40000. /**
  40001. * An event triggered when a skeleton is removed
  40002. */
  40003. onSkeletonRemovedObservable: Observable<Skeleton>;
  40004. /**
  40005. * An event triggered when a material is created
  40006. */
  40007. onNewMaterialAddedObservable: Observable<Material>;
  40008. /**
  40009. * An event triggered when a material is removed
  40010. */
  40011. onMaterialRemovedObservable: Observable<Material>;
  40012. /**
  40013. * An event triggered when a texture is created
  40014. */
  40015. onNewTextureAddedObservable: Observable<BaseTexture>;
  40016. /**
  40017. * An event triggered when a texture is removed
  40018. */
  40019. onTextureRemovedObservable: Observable<BaseTexture>;
  40020. /**
  40021. * An event triggered when render targets are about to be rendered
  40022. * Can happen multiple times per frame.
  40023. */
  40024. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  40025. /**
  40026. * An event triggered when render targets were rendered.
  40027. * Can happen multiple times per frame.
  40028. */
  40029. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  40030. /**
  40031. * An event triggered before calculating deterministic simulation step
  40032. */
  40033. onBeforeStepObservable: Observable<Scene>;
  40034. /**
  40035. * An event triggered after calculating deterministic simulation step
  40036. */
  40037. onAfterStepObservable: Observable<Scene>;
  40038. /**
  40039. * An event triggered when the activeCamera property is updated
  40040. */
  40041. onActiveCameraChanged: Observable<Scene>;
  40042. /**
  40043. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  40044. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40045. * 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)
  40046. */
  40047. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40048. /**
  40049. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  40050. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40051. * 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)
  40052. */
  40053. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40054. /**
  40055. * This Observable will when a mesh has been imported into the scene.
  40056. */
  40057. onMeshImportedObservable: Observable<AbstractMesh>;
  40058. /**
  40059. * This Observable will when an animation file has been imported into the scene.
  40060. */
  40061. onAnimationFileImportedObservable: Observable<Scene>;
  40062. /**
  40063. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  40064. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  40065. */
  40066. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  40067. /** @hidden */
  40068. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  40069. /**
  40070. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  40071. */
  40072. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  40073. /**
  40074. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  40075. */
  40076. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  40077. /**
  40078. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  40079. */
  40080. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  40081. /** Callback called when a pointer move is detected */
  40082. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  40083. /** Callback called when a pointer down is detected */
  40084. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  40085. /** Callback called when a pointer up is detected */
  40086. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  40087. /** Callback called when a pointer pick is detected */
  40088. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  40089. /**
  40090. * 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).
  40091. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  40092. */
  40093. onPrePointerObservable: Observable<PointerInfoPre>;
  40094. /**
  40095. * Observable event triggered each time an input event is received from the rendering canvas
  40096. */
  40097. onPointerObservable: Observable<PointerInfo>;
  40098. /**
  40099. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  40100. */
  40101. get unTranslatedPointer(): Vector2;
  40102. /**
  40103. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  40104. */
  40105. static get DragMovementThreshold(): number;
  40106. static set DragMovementThreshold(value: number);
  40107. /**
  40108. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  40109. */
  40110. static get LongPressDelay(): number;
  40111. static set LongPressDelay(value: number);
  40112. /**
  40113. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  40114. */
  40115. static get DoubleClickDelay(): number;
  40116. static set DoubleClickDelay(value: number);
  40117. /** If you need to check double click without raising a single click at first click, enable this flag */
  40118. static get ExclusiveDoubleClickMode(): boolean;
  40119. static set ExclusiveDoubleClickMode(value: boolean);
  40120. /** @hidden */
  40121. _mirroredCameraPosition: Nullable<Vector3>;
  40122. /**
  40123. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  40124. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  40125. */
  40126. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  40127. /**
  40128. * Observable event triggered each time an keyboard event is received from the hosting window
  40129. */
  40130. onKeyboardObservable: Observable<KeyboardInfo>;
  40131. private _useRightHandedSystem;
  40132. /**
  40133. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  40134. */
  40135. set useRightHandedSystem(value: boolean);
  40136. get useRightHandedSystem(): boolean;
  40137. private _timeAccumulator;
  40138. private _currentStepId;
  40139. private _currentInternalStep;
  40140. /**
  40141. * Sets the step Id used by deterministic lock step
  40142. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40143. * @param newStepId defines the step Id
  40144. */
  40145. setStepId(newStepId: number): void;
  40146. /**
  40147. * Gets the step Id used by deterministic lock step
  40148. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40149. * @returns the step Id
  40150. */
  40151. getStepId(): number;
  40152. /**
  40153. * Gets the internal step used by deterministic lock step
  40154. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40155. * @returns the internal step
  40156. */
  40157. getInternalStep(): number;
  40158. private _fogEnabled;
  40159. /**
  40160. * Gets or sets a boolean indicating if fog is enabled on this scene
  40161. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40162. * (Default is true)
  40163. */
  40164. set fogEnabled(value: boolean);
  40165. get fogEnabled(): boolean;
  40166. private _fogMode;
  40167. /**
  40168. * Gets or sets the fog mode to use
  40169. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40170. * | mode | value |
  40171. * | --- | --- |
  40172. * | FOGMODE_NONE | 0 |
  40173. * | FOGMODE_EXP | 1 |
  40174. * | FOGMODE_EXP2 | 2 |
  40175. * | FOGMODE_LINEAR | 3 |
  40176. */
  40177. set fogMode(value: number);
  40178. get fogMode(): number;
  40179. /**
  40180. * Gets or sets the fog color to use
  40181. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40182. * (Default is Color3(0.2, 0.2, 0.3))
  40183. */
  40184. fogColor: Color3;
  40185. /**
  40186. * Gets or sets the fog density to use
  40187. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40188. * (Default is 0.1)
  40189. */
  40190. fogDensity: number;
  40191. /**
  40192. * Gets or sets the fog start distance to use
  40193. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40194. * (Default is 0)
  40195. */
  40196. fogStart: number;
  40197. /**
  40198. * Gets or sets the fog end distance to use
  40199. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40200. * (Default is 1000)
  40201. */
  40202. fogEnd: number;
  40203. /**
  40204. * Flag indicating that the frame buffer binding is handled by another component
  40205. */
  40206. prePass: boolean;
  40207. private _shadowsEnabled;
  40208. /**
  40209. * Gets or sets a boolean indicating if shadows are enabled on this scene
  40210. */
  40211. set shadowsEnabled(value: boolean);
  40212. get shadowsEnabled(): boolean;
  40213. private _lightsEnabled;
  40214. /**
  40215. * Gets or sets a boolean indicating if lights are enabled on this scene
  40216. */
  40217. set lightsEnabled(value: boolean);
  40218. get lightsEnabled(): boolean;
  40219. /** All of the active cameras added to this scene. */
  40220. activeCameras: Camera[];
  40221. /** @hidden */
  40222. _activeCamera: Nullable<Camera>;
  40223. /** Gets or sets the current active camera */
  40224. get activeCamera(): Nullable<Camera>;
  40225. set activeCamera(value: Nullable<Camera>);
  40226. private _defaultMaterial;
  40227. /** The default material used on meshes when no material is affected */
  40228. get defaultMaterial(): Material;
  40229. /** The default material used on meshes when no material is affected */
  40230. set defaultMaterial(value: Material);
  40231. private _texturesEnabled;
  40232. /**
  40233. * Gets or sets a boolean indicating if textures are enabled on this scene
  40234. */
  40235. set texturesEnabled(value: boolean);
  40236. get texturesEnabled(): boolean;
  40237. /**
  40238. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  40239. */
  40240. physicsEnabled: boolean;
  40241. /**
  40242. * Gets or sets a boolean indicating if particles are enabled on this scene
  40243. */
  40244. particlesEnabled: boolean;
  40245. /**
  40246. * Gets or sets a boolean indicating if sprites are enabled on this scene
  40247. */
  40248. spritesEnabled: boolean;
  40249. private _skeletonsEnabled;
  40250. /**
  40251. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  40252. */
  40253. set skeletonsEnabled(value: boolean);
  40254. get skeletonsEnabled(): boolean;
  40255. /**
  40256. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  40257. */
  40258. lensFlaresEnabled: boolean;
  40259. /**
  40260. * Gets or sets a boolean indicating if collisions are enabled on this scene
  40261. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40262. */
  40263. collisionsEnabled: boolean;
  40264. private _collisionCoordinator;
  40265. /** @hidden */
  40266. get collisionCoordinator(): ICollisionCoordinator;
  40267. /**
  40268. * Defines the gravity applied to this scene (used only for collisions)
  40269. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40270. */
  40271. gravity: Vector3;
  40272. /**
  40273. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  40274. */
  40275. postProcessesEnabled: boolean;
  40276. /**
  40277. * The list of postprocesses added to the scene
  40278. */
  40279. postProcesses: PostProcess[];
  40280. /**
  40281. * Gets the current postprocess manager
  40282. */
  40283. postProcessManager: PostProcessManager;
  40284. /**
  40285. * Gets or sets a boolean indicating if render targets are enabled on this scene
  40286. */
  40287. renderTargetsEnabled: boolean;
  40288. /**
  40289. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  40290. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  40291. */
  40292. dumpNextRenderTargets: boolean;
  40293. /**
  40294. * The list of user defined render targets added to the scene
  40295. */
  40296. customRenderTargets: RenderTargetTexture[];
  40297. /**
  40298. * Defines if texture loading must be delayed
  40299. * If true, textures will only be loaded when they need to be rendered
  40300. */
  40301. useDelayedTextureLoading: boolean;
  40302. /**
  40303. * Gets the list of meshes imported to the scene through SceneLoader
  40304. */
  40305. importedMeshesFiles: String[];
  40306. /**
  40307. * Gets or sets a boolean indicating if probes are enabled on this scene
  40308. */
  40309. probesEnabled: boolean;
  40310. /**
  40311. * Gets or sets the current offline provider to use to store scene data
  40312. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  40313. */
  40314. offlineProvider: IOfflineProvider;
  40315. /**
  40316. * Gets or sets the action manager associated with the scene
  40317. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  40318. */
  40319. actionManager: AbstractActionManager;
  40320. private _meshesForIntersections;
  40321. /**
  40322. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  40323. */
  40324. proceduralTexturesEnabled: boolean;
  40325. private _engine;
  40326. private _totalVertices;
  40327. /** @hidden */
  40328. _activeIndices: PerfCounter;
  40329. /** @hidden */
  40330. _activeParticles: PerfCounter;
  40331. /** @hidden */
  40332. _activeBones: PerfCounter;
  40333. private _animationRatio;
  40334. /** @hidden */
  40335. _animationTimeLast: number;
  40336. /** @hidden */
  40337. _animationTime: number;
  40338. /**
  40339. * Gets or sets a general scale for animation speed
  40340. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  40341. */
  40342. animationTimeScale: number;
  40343. /** @hidden */
  40344. _cachedMaterial: Nullable<Material>;
  40345. /** @hidden */
  40346. _cachedEffect: Nullable<Effect>;
  40347. /** @hidden */
  40348. _cachedVisibility: Nullable<number>;
  40349. private _renderId;
  40350. private _frameId;
  40351. private _executeWhenReadyTimeoutId;
  40352. private _intermediateRendering;
  40353. private _viewUpdateFlag;
  40354. private _projectionUpdateFlag;
  40355. /** @hidden */
  40356. _toBeDisposed: Nullable<IDisposable>[];
  40357. private _activeRequests;
  40358. /** @hidden */
  40359. _pendingData: any[];
  40360. private _isDisposed;
  40361. /**
  40362. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  40363. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  40364. */
  40365. dispatchAllSubMeshesOfActiveMeshes: boolean;
  40366. private _activeMeshes;
  40367. private _processedMaterials;
  40368. private _renderTargets;
  40369. /** @hidden */
  40370. _activeParticleSystems: SmartArray<IParticleSystem>;
  40371. private _activeSkeletons;
  40372. private _softwareSkinnedMeshes;
  40373. private _renderingManager;
  40374. /** @hidden */
  40375. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  40376. private _transformMatrix;
  40377. private _sceneUbo;
  40378. /** @hidden */
  40379. _viewMatrix: Matrix;
  40380. private _projectionMatrix;
  40381. /** @hidden */
  40382. _forcedViewPosition: Nullable<Vector3>;
  40383. /** @hidden */
  40384. _frustumPlanes: Plane[];
  40385. /**
  40386. * Gets the list of frustum planes (built from the active camera)
  40387. */
  40388. get frustumPlanes(): Plane[];
  40389. /**
  40390. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40391. * This is useful if there are more lights that the maximum simulteanous authorized
  40392. */
  40393. requireLightSorting: boolean;
  40394. /** @hidden */
  40395. readonly useMaterialMeshMap: boolean;
  40396. /** @hidden */
  40397. readonly useClonedMeshMap: boolean;
  40398. private _externalData;
  40399. private _uid;
  40400. /**
  40401. * @hidden
  40402. * Backing store of defined scene components.
  40403. */
  40404. _components: ISceneComponent[];
  40405. /**
  40406. * @hidden
  40407. * Backing store of defined scene components.
  40408. */
  40409. _serializableComponents: ISceneSerializableComponent[];
  40410. /**
  40411. * List of components to register on the next registration step.
  40412. */
  40413. private _transientComponents;
  40414. /**
  40415. * Registers the transient components if needed.
  40416. */
  40417. private _registerTransientComponents;
  40418. /**
  40419. * @hidden
  40420. * Add a component to the scene.
  40421. * Note that the ccomponent could be registered on th next frame if this is called after
  40422. * the register component stage.
  40423. * @param component Defines the component to add to the scene
  40424. */
  40425. _addComponent(component: ISceneComponent): void;
  40426. /**
  40427. * @hidden
  40428. * Gets a component from the scene.
  40429. * @param name defines the name of the component to retrieve
  40430. * @returns the component or null if not present
  40431. */
  40432. _getComponent(name: string): Nullable<ISceneComponent>;
  40433. /**
  40434. * @hidden
  40435. * Defines the actions happening before camera updates.
  40436. */
  40437. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40438. /**
  40439. * @hidden
  40440. * Defines the actions happening before clear the canvas.
  40441. */
  40442. _beforeClearStage: Stage<SimpleStageAction>;
  40443. /**
  40444. * @hidden
  40445. * Defines the actions when collecting render targets for the frame.
  40446. */
  40447. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40448. /**
  40449. * @hidden
  40450. * Defines the actions happening for one camera in the frame.
  40451. */
  40452. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40453. /**
  40454. * @hidden
  40455. * Defines the actions happening during the per mesh ready checks.
  40456. */
  40457. _isReadyForMeshStage: Stage<MeshStageAction>;
  40458. /**
  40459. * @hidden
  40460. * Defines the actions happening before evaluate active mesh checks.
  40461. */
  40462. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40463. /**
  40464. * @hidden
  40465. * Defines the actions happening during the evaluate sub mesh checks.
  40466. */
  40467. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40468. /**
  40469. * @hidden
  40470. * Defines the actions happening during the active mesh stage.
  40471. */
  40472. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40473. /**
  40474. * @hidden
  40475. * Defines the actions happening during the per camera render target step.
  40476. */
  40477. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40478. /**
  40479. * @hidden
  40480. * Defines the actions happening just before the active camera is drawing.
  40481. */
  40482. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40483. /**
  40484. * @hidden
  40485. * Defines the actions happening just before a render target is drawing.
  40486. */
  40487. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40488. /**
  40489. * @hidden
  40490. * Defines the actions happening just before a rendering group is drawing.
  40491. */
  40492. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40493. /**
  40494. * @hidden
  40495. * Defines the actions happening just before a mesh is drawing.
  40496. */
  40497. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40498. /**
  40499. * @hidden
  40500. * Defines the actions happening just after a mesh has been drawn.
  40501. */
  40502. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40503. /**
  40504. * @hidden
  40505. * Defines the actions happening just after a rendering group has been drawn.
  40506. */
  40507. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40508. /**
  40509. * @hidden
  40510. * Defines the actions happening just after the active camera has been drawn.
  40511. */
  40512. _afterCameraDrawStage: Stage<CameraStageAction>;
  40513. /**
  40514. * @hidden
  40515. * Defines the actions happening just after a render target has been drawn.
  40516. */
  40517. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40518. /**
  40519. * @hidden
  40520. * Defines the actions happening just after rendering all cameras and computing intersections.
  40521. */
  40522. _afterRenderStage: Stage<SimpleStageAction>;
  40523. /**
  40524. * @hidden
  40525. * Defines the actions happening when a pointer move event happens.
  40526. */
  40527. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40528. /**
  40529. * @hidden
  40530. * Defines the actions happening when a pointer down event happens.
  40531. */
  40532. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40533. /**
  40534. * @hidden
  40535. * Defines the actions happening when a pointer up event happens.
  40536. */
  40537. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40538. /**
  40539. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40540. */
  40541. private geometriesByUniqueId;
  40542. /**
  40543. * Creates a new Scene
  40544. * @param engine defines the engine to use to render this scene
  40545. * @param options defines the scene options
  40546. */
  40547. constructor(engine: Engine, options?: SceneOptions);
  40548. /**
  40549. * Gets a string idenfifying the name of the class
  40550. * @returns "Scene" string
  40551. */
  40552. getClassName(): string;
  40553. private _defaultMeshCandidates;
  40554. /**
  40555. * @hidden
  40556. */
  40557. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40558. private _defaultSubMeshCandidates;
  40559. /**
  40560. * @hidden
  40561. */
  40562. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40563. /**
  40564. * Sets the default candidate providers for the scene.
  40565. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40566. * and getCollidingSubMeshCandidates to their default function
  40567. */
  40568. setDefaultCandidateProviders(): void;
  40569. /**
  40570. * Gets the mesh that is currently under the pointer
  40571. */
  40572. get meshUnderPointer(): Nullable<AbstractMesh>;
  40573. /**
  40574. * Gets or sets the current on-screen X position of the pointer
  40575. */
  40576. get pointerX(): number;
  40577. set pointerX(value: number);
  40578. /**
  40579. * Gets or sets the current on-screen Y position of the pointer
  40580. */
  40581. get pointerY(): number;
  40582. set pointerY(value: number);
  40583. /**
  40584. * Gets the cached material (ie. the latest rendered one)
  40585. * @returns the cached material
  40586. */
  40587. getCachedMaterial(): Nullable<Material>;
  40588. /**
  40589. * Gets the cached effect (ie. the latest rendered one)
  40590. * @returns the cached effect
  40591. */
  40592. getCachedEffect(): Nullable<Effect>;
  40593. /**
  40594. * Gets the cached visibility state (ie. the latest rendered one)
  40595. * @returns the cached visibility state
  40596. */
  40597. getCachedVisibility(): Nullable<number>;
  40598. /**
  40599. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40600. * @param material defines the current material
  40601. * @param effect defines the current effect
  40602. * @param visibility defines the current visibility state
  40603. * @returns true if one parameter is not cached
  40604. */
  40605. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40606. /**
  40607. * Gets the engine associated with the scene
  40608. * @returns an Engine
  40609. */
  40610. getEngine(): Engine;
  40611. /**
  40612. * Gets the total number of vertices rendered per frame
  40613. * @returns the total number of vertices rendered per frame
  40614. */
  40615. getTotalVertices(): number;
  40616. /**
  40617. * Gets the performance counter for total vertices
  40618. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40619. */
  40620. get totalVerticesPerfCounter(): PerfCounter;
  40621. /**
  40622. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40623. * @returns the total number of active indices rendered per frame
  40624. */
  40625. getActiveIndices(): number;
  40626. /**
  40627. * Gets the performance counter for active indices
  40628. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40629. */
  40630. get totalActiveIndicesPerfCounter(): PerfCounter;
  40631. /**
  40632. * Gets the total number of active particles rendered per frame
  40633. * @returns the total number of active particles rendered per frame
  40634. */
  40635. getActiveParticles(): number;
  40636. /**
  40637. * Gets the performance counter for active particles
  40638. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40639. */
  40640. get activeParticlesPerfCounter(): PerfCounter;
  40641. /**
  40642. * Gets the total number of active bones rendered per frame
  40643. * @returns the total number of active bones rendered per frame
  40644. */
  40645. getActiveBones(): number;
  40646. /**
  40647. * Gets the performance counter for active bones
  40648. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40649. */
  40650. get activeBonesPerfCounter(): PerfCounter;
  40651. /**
  40652. * Gets the array of active meshes
  40653. * @returns an array of AbstractMesh
  40654. */
  40655. getActiveMeshes(): SmartArray<AbstractMesh>;
  40656. /**
  40657. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40658. * @returns a number
  40659. */
  40660. getAnimationRatio(): number;
  40661. /**
  40662. * Gets an unique Id for the current render phase
  40663. * @returns a number
  40664. */
  40665. getRenderId(): number;
  40666. /**
  40667. * Gets an unique Id for the current frame
  40668. * @returns a number
  40669. */
  40670. getFrameId(): number;
  40671. /** Call this function if you want to manually increment the render Id*/
  40672. incrementRenderId(): void;
  40673. private _createUbo;
  40674. /**
  40675. * Use this method to simulate a pointer move on a mesh
  40676. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40677. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40678. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40679. * @returns the current scene
  40680. */
  40681. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40682. /**
  40683. * Use this method to simulate a pointer down on a mesh
  40684. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40685. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40686. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40687. * @returns the current scene
  40688. */
  40689. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40690. /**
  40691. * Use this method to simulate a pointer up on a mesh
  40692. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40693. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40694. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40695. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40696. * @returns the current scene
  40697. */
  40698. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40699. /**
  40700. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40701. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40702. * @returns true if the pointer was captured
  40703. */
  40704. isPointerCaptured(pointerId?: number): boolean;
  40705. /**
  40706. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40707. * @param attachUp defines if you want to attach events to pointerup
  40708. * @param attachDown defines if you want to attach events to pointerdown
  40709. * @param attachMove defines if you want to attach events to pointermove
  40710. */
  40711. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40712. /** Detaches all event handlers*/
  40713. detachControl(): void;
  40714. /**
  40715. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40716. * Delay loaded resources are not taking in account
  40717. * @return true if all required resources are ready
  40718. */
  40719. isReady(): boolean;
  40720. /** Resets all cached information relative to material (including effect and visibility) */
  40721. resetCachedMaterial(): void;
  40722. /**
  40723. * Registers a function to be called before every frame render
  40724. * @param func defines the function to register
  40725. */
  40726. registerBeforeRender(func: () => void): void;
  40727. /**
  40728. * Unregisters a function called before every frame render
  40729. * @param func defines the function to unregister
  40730. */
  40731. unregisterBeforeRender(func: () => void): void;
  40732. /**
  40733. * Registers a function to be called after every frame render
  40734. * @param func defines the function to register
  40735. */
  40736. registerAfterRender(func: () => void): void;
  40737. /**
  40738. * Unregisters a function called after every frame render
  40739. * @param func defines the function to unregister
  40740. */
  40741. unregisterAfterRender(func: () => void): void;
  40742. private _executeOnceBeforeRender;
  40743. /**
  40744. * The provided function will run before render once and will be disposed afterwards.
  40745. * A timeout delay can be provided so that the function will be executed in N ms.
  40746. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40747. * @param func The function to be executed.
  40748. * @param timeout optional delay in ms
  40749. */
  40750. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40751. /** @hidden */
  40752. _addPendingData(data: any): void;
  40753. /** @hidden */
  40754. _removePendingData(data: any): void;
  40755. /**
  40756. * Returns the number of items waiting to be loaded
  40757. * @returns the number of items waiting to be loaded
  40758. */
  40759. getWaitingItemsCount(): number;
  40760. /**
  40761. * Returns a boolean indicating if the scene is still loading data
  40762. */
  40763. get isLoading(): boolean;
  40764. /**
  40765. * Registers a function to be executed when the scene is ready
  40766. * @param {Function} func - the function to be executed
  40767. */
  40768. executeWhenReady(func: () => void): void;
  40769. /**
  40770. * Returns a promise that resolves when the scene is ready
  40771. * @returns A promise that resolves when the scene is ready
  40772. */
  40773. whenReadyAsync(): Promise<void>;
  40774. /** @hidden */
  40775. _checkIsReady(): void;
  40776. /**
  40777. * Gets all animatable attached to the scene
  40778. */
  40779. get animatables(): Animatable[];
  40780. /**
  40781. * Resets the last animation time frame.
  40782. * Useful to override when animations start running when loading a scene for the first time.
  40783. */
  40784. resetLastAnimationTimeFrame(): void;
  40785. /**
  40786. * Gets the current view matrix
  40787. * @returns a Matrix
  40788. */
  40789. getViewMatrix(): Matrix;
  40790. /**
  40791. * Gets the current projection matrix
  40792. * @returns a Matrix
  40793. */
  40794. getProjectionMatrix(): Matrix;
  40795. /**
  40796. * Gets the current transform matrix
  40797. * @returns a Matrix made of View * Projection
  40798. */
  40799. getTransformMatrix(): Matrix;
  40800. /**
  40801. * Sets the current transform matrix
  40802. * @param viewL defines the View matrix to use
  40803. * @param projectionL defines the Projection matrix to use
  40804. * @param viewR defines the right View matrix to use (if provided)
  40805. * @param projectionR defines the right Projection matrix to use (if provided)
  40806. */
  40807. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40808. /**
  40809. * Gets the uniform buffer used to store scene data
  40810. * @returns a UniformBuffer
  40811. */
  40812. getSceneUniformBuffer(): UniformBuffer;
  40813. /**
  40814. * Gets an unique (relatively to the current scene) Id
  40815. * @returns an unique number for the scene
  40816. */
  40817. getUniqueId(): number;
  40818. /**
  40819. * Add a mesh to the list of scene's meshes
  40820. * @param newMesh defines the mesh to add
  40821. * @param recursive if all child meshes should also be added to the scene
  40822. */
  40823. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40824. /**
  40825. * Remove a mesh for the list of scene's meshes
  40826. * @param toRemove defines the mesh to remove
  40827. * @param recursive if all child meshes should also be removed from the scene
  40828. * @returns the index where the mesh was in the mesh list
  40829. */
  40830. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40831. /**
  40832. * Add a transform node to the list of scene's transform nodes
  40833. * @param newTransformNode defines the transform node to add
  40834. */
  40835. addTransformNode(newTransformNode: TransformNode): void;
  40836. /**
  40837. * Remove a transform node for the list of scene's transform nodes
  40838. * @param toRemove defines the transform node to remove
  40839. * @returns the index where the transform node was in the transform node list
  40840. */
  40841. removeTransformNode(toRemove: TransformNode): number;
  40842. /**
  40843. * Remove a skeleton for the list of scene's skeletons
  40844. * @param toRemove defines the skeleton to remove
  40845. * @returns the index where the skeleton was in the skeleton list
  40846. */
  40847. removeSkeleton(toRemove: Skeleton): number;
  40848. /**
  40849. * Remove a morph target for the list of scene's morph targets
  40850. * @param toRemove defines the morph target to remove
  40851. * @returns the index where the morph target was in the morph target list
  40852. */
  40853. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40854. /**
  40855. * Remove a light for the list of scene's lights
  40856. * @param toRemove defines the light to remove
  40857. * @returns the index where the light was in the light list
  40858. */
  40859. removeLight(toRemove: Light): number;
  40860. /**
  40861. * Remove a camera for the list of scene's cameras
  40862. * @param toRemove defines the camera to remove
  40863. * @returns the index where the camera was in the camera list
  40864. */
  40865. removeCamera(toRemove: Camera): number;
  40866. /**
  40867. * Remove a particle system for the list of scene's particle systems
  40868. * @param toRemove defines the particle system to remove
  40869. * @returns the index where the particle system was in the particle system list
  40870. */
  40871. removeParticleSystem(toRemove: IParticleSystem): number;
  40872. /**
  40873. * Remove a animation for the list of scene's animations
  40874. * @param toRemove defines the animation to remove
  40875. * @returns the index where the animation was in the animation list
  40876. */
  40877. removeAnimation(toRemove: Animation): number;
  40878. /**
  40879. * Will stop the animation of the given target
  40880. * @param target - the target
  40881. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40882. * @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)
  40883. */
  40884. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40885. /**
  40886. * Removes the given animation group from this scene.
  40887. * @param toRemove The animation group to remove
  40888. * @returns The index of the removed animation group
  40889. */
  40890. removeAnimationGroup(toRemove: AnimationGroup): number;
  40891. /**
  40892. * Removes the given multi-material from this scene.
  40893. * @param toRemove The multi-material to remove
  40894. * @returns The index of the removed multi-material
  40895. */
  40896. removeMultiMaterial(toRemove: MultiMaterial): number;
  40897. /**
  40898. * Removes the given material from this scene.
  40899. * @param toRemove The material to remove
  40900. * @returns The index of the removed material
  40901. */
  40902. removeMaterial(toRemove: Material): number;
  40903. /**
  40904. * Removes the given action manager from this scene.
  40905. * @param toRemove The action manager to remove
  40906. * @returns The index of the removed action manager
  40907. */
  40908. removeActionManager(toRemove: AbstractActionManager): number;
  40909. /**
  40910. * Removes the given texture from this scene.
  40911. * @param toRemove The texture to remove
  40912. * @returns The index of the removed texture
  40913. */
  40914. removeTexture(toRemove: BaseTexture): number;
  40915. /**
  40916. * Adds the given light to this scene
  40917. * @param newLight The light to add
  40918. */
  40919. addLight(newLight: Light): void;
  40920. /**
  40921. * Sorts the list list based on light priorities
  40922. */
  40923. sortLightsByPriority(): void;
  40924. /**
  40925. * Adds the given camera to this scene
  40926. * @param newCamera The camera to add
  40927. */
  40928. addCamera(newCamera: Camera): void;
  40929. /**
  40930. * Adds the given skeleton to this scene
  40931. * @param newSkeleton The skeleton to add
  40932. */
  40933. addSkeleton(newSkeleton: Skeleton): void;
  40934. /**
  40935. * Adds the given particle system to this scene
  40936. * @param newParticleSystem The particle system to add
  40937. */
  40938. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40939. /**
  40940. * Adds the given animation to this scene
  40941. * @param newAnimation The animation to add
  40942. */
  40943. addAnimation(newAnimation: Animation): void;
  40944. /**
  40945. * Adds the given animation group to this scene.
  40946. * @param newAnimationGroup The animation group to add
  40947. */
  40948. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40949. /**
  40950. * Adds the given multi-material to this scene
  40951. * @param newMultiMaterial The multi-material to add
  40952. */
  40953. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40954. /**
  40955. * Adds the given material to this scene
  40956. * @param newMaterial The material to add
  40957. */
  40958. addMaterial(newMaterial: Material): void;
  40959. /**
  40960. * Adds the given morph target to this scene
  40961. * @param newMorphTargetManager The morph target to add
  40962. */
  40963. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40964. /**
  40965. * Adds the given geometry to this scene
  40966. * @param newGeometry The geometry to add
  40967. */
  40968. addGeometry(newGeometry: Geometry): void;
  40969. /**
  40970. * Adds the given action manager to this scene
  40971. * @param newActionManager The action manager to add
  40972. */
  40973. addActionManager(newActionManager: AbstractActionManager): void;
  40974. /**
  40975. * Adds the given texture to this scene.
  40976. * @param newTexture The texture to add
  40977. */
  40978. addTexture(newTexture: BaseTexture): void;
  40979. /**
  40980. * Switch active camera
  40981. * @param newCamera defines the new active camera
  40982. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40983. */
  40984. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40985. /**
  40986. * sets the active camera of the scene using its ID
  40987. * @param id defines the camera's ID
  40988. * @return the new active camera or null if none found.
  40989. */
  40990. setActiveCameraByID(id: string): Nullable<Camera>;
  40991. /**
  40992. * sets the active camera of the scene using its name
  40993. * @param name defines the camera's name
  40994. * @returns the new active camera or null if none found.
  40995. */
  40996. setActiveCameraByName(name: string): Nullable<Camera>;
  40997. /**
  40998. * get an animation group using its name
  40999. * @param name defines the material's name
  41000. * @return the animation group or null if none found.
  41001. */
  41002. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  41003. /**
  41004. * Get a material using its unique id
  41005. * @param uniqueId defines the material's unique id
  41006. * @return the material or null if none found.
  41007. */
  41008. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  41009. /**
  41010. * get a material using its id
  41011. * @param id defines the material's ID
  41012. * @return the material or null if none found.
  41013. */
  41014. getMaterialByID(id: string): Nullable<Material>;
  41015. /**
  41016. * Gets a the last added material using a given id
  41017. * @param id defines the material's ID
  41018. * @return the last material with the given id or null if none found.
  41019. */
  41020. getLastMaterialByID(id: string): Nullable<Material>;
  41021. /**
  41022. * Gets a material using its name
  41023. * @param name defines the material's name
  41024. * @return the material or null if none found.
  41025. */
  41026. getMaterialByName(name: string): Nullable<Material>;
  41027. /**
  41028. * Get a texture using its unique id
  41029. * @param uniqueId defines the texture's unique id
  41030. * @return the texture or null if none found.
  41031. */
  41032. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  41033. /**
  41034. * Gets a camera using its id
  41035. * @param id defines the id to look for
  41036. * @returns the camera or null if not found
  41037. */
  41038. getCameraByID(id: string): Nullable<Camera>;
  41039. /**
  41040. * Gets a camera using its unique id
  41041. * @param uniqueId defines the unique id to look for
  41042. * @returns the camera or null if not found
  41043. */
  41044. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  41045. /**
  41046. * Gets a camera using its name
  41047. * @param name defines the camera's name
  41048. * @return the camera or null if none found.
  41049. */
  41050. getCameraByName(name: string): Nullable<Camera>;
  41051. /**
  41052. * Gets a bone using its id
  41053. * @param id defines the bone's id
  41054. * @return the bone or null if not found
  41055. */
  41056. getBoneByID(id: string): Nullable<Bone>;
  41057. /**
  41058. * Gets a bone using its id
  41059. * @param name defines the bone's name
  41060. * @return the bone or null if not found
  41061. */
  41062. getBoneByName(name: string): Nullable<Bone>;
  41063. /**
  41064. * Gets a light node using its name
  41065. * @param name defines the the light's name
  41066. * @return the light or null if none found.
  41067. */
  41068. getLightByName(name: string): Nullable<Light>;
  41069. /**
  41070. * Gets a light node using its id
  41071. * @param id defines the light's id
  41072. * @return the light or null if none found.
  41073. */
  41074. getLightByID(id: string): Nullable<Light>;
  41075. /**
  41076. * Gets a light node using its scene-generated unique ID
  41077. * @param uniqueId defines the light's unique id
  41078. * @return the light or null if none found.
  41079. */
  41080. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  41081. /**
  41082. * Gets a particle system by id
  41083. * @param id defines the particle system id
  41084. * @return the corresponding system or null if none found
  41085. */
  41086. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  41087. /**
  41088. * Gets a geometry using its ID
  41089. * @param id defines the geometry's id
  41090. * @return the geometry or null if none found.
  41091. */
  41092. getGeometryByID(id: string): Nullable<Geometry>;
  41093. private _getGeometryByUniqueID;
  41094. /**
  41095. * Add a new geometry to this scene
  41096. * @param geometry defines the geometry to be added to the scene.
  41097. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  41098. * @return a boolean defining if the geometry was added or not
  41099. */
  41100. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  41101. /**
  41102. * Removes an existing geometry
  41103. * @param geometry defines the geometry to be removed from the scene
  41104. * @return a boolean defining if the geometry was removed or not
  41105. */
  41106. removeGeometry(geometry: Geometry): boolean;
  41107. /**
  41108. * Gets the list of geometries attached to the scene
  41109. * @returns an array of Geometry
  41110. */
  41111. getGeometries(): Geometry[];
  41112. /**
  41113. * Gets the first added mesh found of a given ID
  41114. * @param id defines the id to search for
  41115. * @return the mesh found or null if not found at all
  41116. */
  41117. getMeshByID(id: string): Nullable<AbstractMesh>;
  41118. /**
  41119. * Gets a list of meshes using their id
  41120. * @param id defines the id to search for
  41121. * @returns a list of meshes
  41122. */
  41123. getMeshesByID(id: string): Array<AbstractMesh>;
  41124. /**
  41125. * Gets the first added transform node found of a given ID
  41126. * @param id defines the id to search for
  41127. * @return the found transform node or null if not found at all.
  41128. */
  41129. getTransformNodeByID(id: string): Nullable<TransformNode>;
  41130. /**
  41131. * Gets a transform node with its auto-generated unique id
  41132. * @param uniqueId efines the unique id to search for
  41133. * @return the found transform node or null if not found at all.
  41134. */
  41135. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  41136. /**
  41137. * Gets a list of transform nodes using their id
  41138. * @param id defines the id to search for
  41139. * @returns a list of transform nodes
  41140. */
  41141. getTransformNodesByID(id: string): Array<TransformNode>;
  41142. /**
  41143. * Gets a mesh with its auto-generated unique id
  41144. * @param uniqueId defines the unique id to search for
  41145. * @return the found mesh or null if not found at all.
  41146. */
  41147. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  41148. /**
  41149. * Gets a the last added mesh using a given id
  41150. * @param id defines the id to search for
  41151. * @return the found mesh or null if not found at all.
  41152. */
  41153. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  41154. /**
  41155. * Gets a the last added node (Mesh, Camera, Light) using a given id
  41156. * @param id defines the id to search for
  41157. * @return the found node or null if not found at all
  41158. */
  41159. getLastEntryByID(id: string): Nullable<Node>;
  41160. /**
  41161. * Gets a node (Mesh, Camera, Light) using a given id
  41162. * @param id defines the id to search for
  41163. * @return the found node or null if not found at all
  41164. */
  41165. getNodeByID(id: string): Nullable<Node>;
  41166. /**
  41167. * Gets a node (Mesh, Camera, Light) using a given name
  41168. * @param name defines the name to search for
  41169. * @return the found node or null if not found at all.
  41170. */
  41171. getNodeByName(name: string): Nullable<Node>;
  41172. /**
  41173. * Gets a mesh using a given name
  41174. * @param name defines the name to search for
  41175. * @return the found mesh or null if not found at all.
  41176. */
  41177. getMeshByName(name: string): Nullable<AbstractMesh>;
  41178. /**
  41179. * Gets a transform node using a given name
  41180. * @param name defines the name to search for
  41181. * @return the found transform node or null if not found at all.
  41182. */
  41183. getTransformNodeByName(name: string): Nullable<TransformNode>;
  41184. /**
  41185. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  41186. * @param id defines the id to search for
  41187. * @return the found skeleton or null if not found at all.
  41188. */
  41189. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  41190. /**
  41191. * Gets a skeleton using a given auto generated unique id
  41192. * @param uniqueId defines the unique id to search for
  41193. * @return the found skeleton or null if not found at all.
  41194. */
  41195. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  41196. /**
  41197. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  41198. * @param id defines the id to search for
  41199. * @return the found skeleton or null if not found at all.
  41200. */
  41201. getSkeletonById(id: string): Nullable<Skeleton>;
  41202. /**
  41203. * Gets a skeleton using a given name
  41204. * @param name defines the name to search for
  41205. * @return the found skeleton or null if not found at all.
  41206. */
  41207. getSkeletonByName(name: string): Nullable<Skeleton>;
  41208. /**
  41209. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  41210. * @param id defines the id to search for
  41211. * @return the found morph target manager or null if not found at all.
  41212. */
  41213. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  41214. /**
  41215. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  41216. * @param id defines the id to search for
  41217. * @return the found morph target or null if not found at all.
  41218. */
  41219. getMorphTargetById(id: string): Nullable<MorphTarget>;
  41220. /**
  41221. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  41222. * @param name defines the name to search for
  41223. * @return the found morph target or null if not found at all.
  41224. */
  41225. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  41226. /**
  41227. * Gets a boolean indicating if the given mesh is active
  41228. * @param mesh defines the mesh to look for
  41229. * @returns true if the mesh is in the active list
  41230. */
  41231. isActiveMesh(mesh: AbstractMesh): boolean;
  41232. /**
  41233. * Return a unique id as a string which can serve as an identifier for the scene
  41234. */
  41235. get uid(): string;
  41236. /**
  41237. * Add an externaly attached data from its key.
  41238. * This method call will fail and return false, if such key already exists.
  41239. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  41240. * @param key the unique key that identifies the data
  41241. * @param data the data object to associate to the key for this Engine instance
  41242. * @return true if no such key were already present and the data was added successfully, false otherwise
  41243. */
  41244. addExternalData<T>(key: string, data: T): boolean;
  41245. /**
  41246. * Get an externaly attached data from its key
  41247. * @param key the unique key that identifies the data
  41248. * @return the associated data, if present (can be null), or undefined if not present
  41249. */
  41250. getExternalData<T>(key: string): Nullable<T>;
  41251. /**
  41252. * Get an externaly attached data from its key, create it using a factory if it's not already present
  41253. * @param key the unique key that identifies the data
  41254. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  41255. * @return the associated data, can be null if the factory returned null.
  41256. */
  41257. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  41258. /**
  41259. * Remove an externaly attached data from the Engine instance
  41260. * @param key the unique key that identifies the data
  41261. * @return true if the data was successfully removed, false if it doesn't exist
  41262. */
  41263. removeExternalData(key: string): boolean;
  41264. private _evaluateSubMesh;
  41265. /**
  41266. * Clear the processed materials smart array preventing retention point in material dispose.
  41267. */
  41268. freeProcessedMaterials(): void;
  41269. private _preventFreeActiveMeshesAndRenderingGroups;
  41270. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  41271. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  41272. * when disposing several meshes in a row or a hierarchy of meshes.
  41273. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  41274. */
  41275. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  41276. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  41277. /**
  41278. * Clear the active meshes smart array preventing retention point in mesh dispose.
  41279. */
  41280. freeActiveMeshes(): void;
  41281. /**
  41282. * Clear the info related to rendering groups preventing retention points during dispose.
  41283. */
  41284. freeRenderingGroups(): void;
  41285. /** @hidden */
  41286. _isInIntermediateRendering(): boolean;
  41287. /**
  41288. * Lambda returning the list of potentially active meshes.
  41289. */
  41290. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  41291. /**
  41292. * Lambda returning the list of potentially active sub meshes.
  41293. */
  41294. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  41295. /**
  41296. * Lambda returning the list of potentially intersecting sub meshes.
  41297. */
  41298. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  41299. /**
  41300. * Lambda returning the list of potentially colliding sub meshes.
  41301. */
  41302. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  41303. private _activeMeshesFrozen;
  41304. private _skipEvaluateActiveMeshesCompletely;
  41305. /**
  41306. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  41307. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  41308. * @returns the current scene
  41309. */
  41310. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  41311. /**
  41312. * Use this function to restart evaluating active meshes on every frame
  41313. * @returns the current scene
  41314. */
  41315. unfreezeActiveMeshes(): Scene;
  41316. private _evaluateActiveMeshes;
  41317. private _activeMesh;
  41318. /**
  41319. * Update the transform matrix to update from the current active camera
  41320. * @param force defines a boolean used to force the update even if cache is up to date
  41321. */
  41322. updateTransformMatrix(force?: boolean): void;
  41323. private _bindFrameBuffer;
  41324. /** @hidden */
  41325. _allowPostProcessClearColor: boolean;
  41326. /** @hidden */
  41327. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  41328. private _processSubCameras;
  41329. private _checkIntersections;
  41330. /** @hidden */
  41331. _advancePhysicsEngineStep(step: number): void;
  41332. /**
  41333. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  41334. */
  41335. getDeterministicFrameTime: () => number;
  41336. /** @hidden */
  41337. _animate(): void;
  41338. /** Execute all animations (for a frame) */
  41339. animate(): void;
  41340. /**
  41341. * Render the scene
  41342. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  41343. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  41344. */
  41345. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  41346. /**
  41347. * Freeze all materials
  41348. * A frozen material will not be updatable but should be faster to render
  41349. */
  41350. freezeMaterials(): void;
  41351. /**
  41352. * Unfreeze all materials
  41353. * A frozen material will not be updatable but should be faster to render
  41354. */
  41355. unfreezeMaterials(): void;
  41356. /**
  41357. * Releases all held ressources
  41358. */
  41359. dispose(): void;
  41360. /**
  41361. * Gets if the scene is already disposed
  41362. */
  41363. get isDisposed(): boolean;
  41364. /**
  41365. * Call this function to reduce memory footprint of the scene.
  41366. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  41367. */
  41368. clearCachedVertexData(): void;
  41369. /**
  41370. * This function will remove the local cached buffer data from texture.
  41371. * It will save memory but will prevent the texture from being rebuilt
  41372. */
  41373. cleanCachedTextureBuffer(): void;
  41374. /**
  41375. * Get the world extend vectors with an optional filter
  41376. *
  41377. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41378. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41379. */
  41380. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41381. min: Vector3;
  41382. max: Vector3;
  41383. };
  41384. /**
  41385. * Creates a ray that can be used to pick in the scene
  41386. * @param x defines the x coordinate of the origin (on-screen)
  41387. * @param y defines the y coordinate of the origin (on-screen)
  41388. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41389. * @param camera defines the camera to use for the picking
  41390. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41391. * @returns a Ray
  41392. */
  41393. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41394. /**
  41395. * Creates a ray that can be used to pick in the scene
  41396. * @param x defines the x coordinate of the origin (on-screen)
  41397. * @param y defines the y coordinate of the origin (on-screen)
  41398. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41399. * @param result defines the ray where to store the picking ray
  41400. * @param camera defines the camera to use for the picking
  41401. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41402. * @returns the current scene
  41403. */
  41404. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41405. /**
  41406. * Creates a ray that can be used to pick in the scene
  41407. * @param x defines the x coordinate of the origin (on-screen)
  41408. * @param y defines the y coordinate of the origin (on-screen)
  41409. * @param camera defines the camera to use for the picking
  41410. * @returns a Ray
  41411. */
  41412. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41413. /**
  41414. * Creates a ray that can be used to pick in the scene
  41415. * @param x defines the x coordinate of the origin (on-screen)
  41416. * @param y defines the y coordinate of the origin (on-screen)
  41417. * @param result defines the ray where to store the picking ray
  41418. * @param camera defines the camera to use for the picking
  41419. * @returns the current scene
  41420. */
  41421. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41422. /** Launch a ray to try to pick a mesh in the scene
  41423. * @param x position on screen
  41424. * @param y position on screen
  41425. * @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
  41426. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41427. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41428. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41429. * @returns a PickingInfo
  41430. */
  41431. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41432. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41433. * @param x position on screen
  41434. * @param y position on screen
  41435. * @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
  41436. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41437. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41438. * @returns a PickingInfo (Please note that some info will not be set like distance, bv, bu and everything that cannot be capture by only using bounding infos)
  41439. */
  41440. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41441. /** Use the given ray to pick a mesh in the scene
  41442. * @param ray The ray to use to pick meshes
  41443. * @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
  41444. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41445. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41446. * @returns a PickingInfo
  41447. */
  41448. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41449. /**
  41450. * Launch a ray to try to pick a mesh in the scene
  41451. * @param x X position on screen
  41452. * @param y Y position on screen
  41453. * @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
  41454. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41455. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41456. * @returns an array of PickingInfo
  41457. */
  41458. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41459. /**
  41460. * Launch a ray to try to pick a mesh in the scene
  41461. * @param ray Ray to use
  41462. * @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
  41463. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41464. * @returns an array of PickingInfo
  41465. */
  41466. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41467. /**
  41468. * Force the value of meshUnderPointer
  41469. * @param mesh defines the mesh to use
  41470. */
  41471. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  41472. /**
  41473. * Gets the mesh under the pointer
  41474. * @returns a Mesh or null if no mesh is under the pointer
  41475. */
  41476. getPointerOverMesh(): Nullable<AbstractMesh>;
  41477. /** @hidden */
  41478. _rebuildGeometries(): void;
  41479. /** @hidden */
  41480. _rebuildTextures(): void;
  41481. private _getByTags;
  41482. /**
  41483. * Get a list of meshes by tags
  41484. * @param tagsQuery defines the tags query to use
  41485. * @param forEach defines a predicate used to filter results
  41486. * @returns an array of Mesh
  41487. */
  41488. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41489. /**
  41490. * Get a list of cameras by tags
  41491. * @param tagsQuery defines the tags query to use
  41492. * @param forEach defines a predicate used to filter results
  41493. * @returns an array of Camera
  41494. */
  41495. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41496. /**
  41497. * Get a list of lights by tags
  41498. * @param tagsQuery defines the tags query to use
  41499. * @param forEach defines a predicate used to filter results
  41500. * @returns an array of Light
  41501. */
  41502. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41503. /**
  41504. * Get a list of materials by tags
  41505. * @param tagsQuery defines the tags query to use
  41506. * @param forEach defines a predicate used to filter results
  41507. * @returns an array of Material
  41508. */
  41509. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41510. /**
  41511. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41512. * This allowed control for front to back rendering or reversly depending of the special needs.
  41513. *
  41514. * @param renderingGroupId The rendering group id corresponding to its index
  41515. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41516. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41517. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41518. */
  41519. 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;
  41520. /**
  41521. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41522. *
  41523. * @param renderingGroupId The rendering group id corresponding to its index
  41524. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41525. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41526. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41527. */
  41528. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41529. /**
  41530. * Gets the current auto clear configuration for one rendering group of the rendering
  41531. * manager.
  41532. * @param index the rendering group index to get the information for
  41533. * @returns The auto clear setup for the requested rendering group
  41534. */
  41535. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41536. private _blockMaterialDirtyMechanism;
  41537. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41538. get blockMaterialDirtyMechanism(): boolean;
  41539. set blockMaterialDirtyMechanism(value: boolean);
  41540. /**
  41541. * Will flag all materials as dirty to trigger new shader compilation
  41542. * @param flag defines the flag used to specify which material part must be marked as dirty
  41543. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41544. */
  41545. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41546. /** @hidden */
  41547. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  41548. /** @hidden */
  41549. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41550. /** @hidden */
  41551. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  41552. /** @hidden */
  41553. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41554. /** @hidden */
  41555. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41556. /** @hidden */
  41557. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41558. }
  41559. }
  41560. declare module "babylonjs/assetContainer" {
  41561. import { AbstractScene } from "babylonjs/abstractScene";
  41562. import { Scene } from "babylonjs/scene";
  41563. import { Mesh } from "babylonjs/Meshes/mesh";
  41564. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41565. import { Skeleton } from "babylonjs/Bones/skeleton";
  41566. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41567. import { Animatable } from "babylonjs/Animations/animatable";
  41568. import { Nullable } from "babylonjs/types";
  41569. import { Node } from "babylonjs/node";
  41570. /**
  41571. * Set of assets to keep when moving a scene into an asset container.
  41572. */
  41573. export class KeepAssets extends AbstractScene {
  41574. }
  41575. /**
  41576. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41577. */
  41578. export class InstantiatedEntries {
  41579. /**
  41580. * List of new root nodes (eg. nodes with no parent)
  41581. */
  41582. rootNodes: TransformNode[];
  41583. /**
  41584. * List of new skeletons
  41585. */
  41586. skeletons: Skeleton[];
  41587. /**
  41588. * List of new animation groups
  41589. */
  41590. animationGroups: AnimationGroup[];
  41591. }
  41592. /**
  41593. * Container with a set of assets that can be added or removed from a scene.
  41594. */
  41595. export class AssetContainer extends AbstractScene {
  41596. private _wasAddedToScene;
  41597. /**
  41598. * The scene the AssetContainer belongs to.
  41599. */
  41600. scene: Scene;
  41601. /**
  41602. * Instantiates an AssetContainer.
  41603. * @param scene The scene the AssetContainer belongs to.
  41604. */
  41605. constructor(scene: Scene);
  41606. /**
  41607. * Instantiate or clone all meshes and add the new ones to the scene.
  41608. * Skeletons and animation groups will all be cloned
  41609. * @param nameFunction defines an optional function used to get new names for clones
  41610. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41611. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41612. */
  41613. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41614. /**
  41615. * Adds all the assets from the container to the scene.
  41616. */
  41617. addAllToScene(): void;
  41618. /**
  41619. * Removes all the assets in the container from the scene
  41620. */
  41621. removeAllFromScene(): void;
  41622. /**
  41623. * Disposes all the assets in the container
  41624. */
  41625. dispose(): void;
  41626. private _moveAssets;
  41627. /**
  41628. * Removes all the assets contained in the scene and adds them to the container.
  41629. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41630. */
  41631. moveAllFromScene(keepAssets?: KeepAssets): void;
  41632. /**
  41633. * 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.
  41634. * @returns the root mesh
  41635. */
  41636. createRootMesh(): Mesh;
  41637. /**
  41638. * Merge animations (direct and animation groups) from this asset container into a scene
  41639. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41640. * @param animatables set of animatables to retarget to a node from the scene
  41641. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41642. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41643. */
  41644. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41645. }
  41646. }
  41647. declare module "babylonjs/abstractScene" {
  41648. import { Scene } from "babylonjs/scene";
  41649. import { Nullable } from "babylonjs/types";
  41650. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41651. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41652. import { Geometry } from "babylonjs/Meshes/geometry";
  41653. import { Skeleton } from "babylonjs/Bones/skeleton";
  41654. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  41655. import { AssetContainer } from "babylonjs/assetContainer";
  41656. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  41657. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41658. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41659. import { Material } from "babylonjs/Materials/material";
  41660. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  41661. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  41662. import { Camera } from "babylonjs/Cameras/camera";
  41663. import { Light } from "babylonjs/Lights/light";
  41664. import { Node } from "babylonjs/node";
  41665. import { Animation } from "babylonjs/Animations/animation";
  41666. /**
  41667. * Defines how the parser contract is defined.
  41668. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41669. */
  41670. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41671. /**
  41672. * Defines how the individual parser contract is defined.
  41673. * These parser can parse an individual asset
  41674. */
  41675. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41676. /**
  41677. * Base class of the scene acting as a container for the different elements composing a scene.
  41678. * This class is dynamically extended by the different components of the scene increasing
  41679. * flexibility and reducing coupling
  41680. */
  41681. export abstract class AbstractScene {
  41682. /**
  41683. * Stores the list of available parsers in the application.
  41684. */
  41685. private static _BabylonFileParsers;
  41686. /**
  41687. * Stores the list of available individual parsers in the application.
  41688. */
  41689. private static _IndividualBabylonFileParsers;
  41690. /**
  41691. * Adds a parser in the list of available ones
  41692. * @param name Defines the name of the parser
  41693. * @param parser Defines the parser to add
  41694. */
  41695. static AddParser(name: string, parser: BabylonFileParser): void;
  41696. /**
  41697. * Gets a general parser from the list of avaialble ones
  41698. * @param name Defines the name of the parser
  41699. * @returns the requested parser or null
  41700. */
  41701. static GetParser(name: string): Nullable<BabylonFileParser>;
  41702. /**
  41703. * Adds n individual parser in the list of available ones
  41704. * @param name Defines the name of the parser
  41705. * @param parser Defines the parser to add
  41706. */
  41707. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41708. /**
  41709. * Gets an individual parser from the list of avaialble ones
  41710. * @param name Defines the name of the parser
  41711. * @returns the requested parser or null
  41712. */
  41713. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41714. /**
  41715. * Parser json data and populate both a scene and its associated container object
  41716. * @param jsonData Defines the data to parse
  41717. * @param scene Defines the scene to parse the data for
  41718. * @param container Defines the container attached to the parsing sequence
  41719. * @param rootUrl Defines the root url of the data
  41720. */
  41721. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41722. /**
  41723. * Gets the list of root nodes (ie. nodes with no parent)
  41724. */
  41725. rootNodes: Node[];
  41726. /** All of the cameras added to this scene
  41727. * @see https://doc.babylonjs.com/babylon101/cameras
  41728. */
  41729. cameras: Camera[];
  41730. /**
  41731. * All of the lights added to this scene
  41732. * @see https://doc.babylonjs.com/babylon101/lights
  41733. */
  41734. lights: Light[];
  41735. /**
  41736. * All of the (abstract) meshes added to this scene
  41737. */
  41738. meshes: AbstractMesh[];
  41739. /**
  41740. * The list of skeletons added to the scene
  41741. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41742. */
  41743. skeletons: Skeleton[];
  41744. /**
  41745. * All of the particle systems added to this scene
  41746. * @see https://doc.babylonjs.com/babylon101/particles
  41747. */
  41748. particleSystems: IParticleSystem[];
  41749. /**
  41750. * Gets a list of Animations associated with the scene
  41751. */
  41752. animations: Animation[];
  41753. /**
  41754. * All of the animation groups added to this scene
  41755. * @see https://doc.babylonjs.com/how_to/group
  41756. */
  41757. animationGroups: AnimationGroup[];
  41758. /**
  41759. * All of the multi-materials added to this scene
  41760. * @see https://doc.babylonjs.com/how_to/multi_materials
  41761. */
  41762. multiMaterials: MultiMaterial[];
  41763. /**
  41764. * All of the materials added to this scene
  41765. * In the context of a Scene, it is not supposed to be modified manually.
  41766. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41767. * Note also that the order of the Material within the array is not significant and might change.
  41768. * @see https://doc.babylonjs.com/babylon101/materials
  41769. */
  41770. materials: Material[];
  41771. /**
  41772. * The list of morph target managers added to the scene
  41773. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41774. */
  41775. morphTargetManagers: MorphTargetManager[];
  41776. /**
  41777. * The list of geometries used in the scene.
  41778. */
  41779. geometries: Geometry[];
  41780. /**
  41781. * All of the tranform nodes added to this scene
  41782. * In the context of a Scene, it is not supposed to be modified manually.
  41783. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41784. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41785. * @see https://doc.babylonjs.com/how_to/transformnode
  41786. */
  41787. transformNodes: TransformNode[];
  41788. /**
  41789. * ActionManagers available on the scene.
  41790. */
  41791. actionManagers: AbstractActionManager[];
  41792. /**
  41793. * Textures to keep.
  41794. */
  41795. textures: BaseTexture[];
  41796. /**
  41797. * Environment texture for the scene
  41798. */
  41799. environmentTexture: Nullable<BaseTexture>;
  41800. /**
  41801. * @returns all meshes, lights, cameras, transformNodes and bones
  41802. */
  41803. getNodes(): Array<Node>;
  41804. }
  41805. }
  41806. declare module "babylonjs/Audio/sound" {
  41807. import { Observable } from "babylonjs/Misc/observable";
  41808. import { Vector3 } from "babylonjs/Maths/math.vector";
  41809. import { Nullable } from "babylonjs/types";
  41810. import { Scene } from "babylonjs/scene";
  41811. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41812. /**
  41813. * Interface used to define options for Sound class
  41814. */
  41815. export interface ISoundOptions {
  41816. /**
  41817. * Does the sound autoplay once loaded.
  41818. */
  41819. autoplay?: boolean;
  41820. /**
  41821. * Does the sound loop after it finishes playing once.
  41822. */
  41823. loop?: boolean;
  41824. /**
  41825. * Sound's volume
  41826. */
  41827. volume?: number;
  41828. /**
  41829. * Is it a spatial sound?
  41830. */
  41831. spatialSound?: boolean;
  41832. /**
  41833. * Maximum distance to hear that sound
  41834. */
  41835. maxDistance?: number;
  41836. /**
  41837. * Uses user defined attenuation function
  41838. */
  41839. useCustomAttenuation?: boolean;
  41840. /**
  41841. * Define the roll off factor of spatial sounds.
  41842. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41843. */
  41844. rolloffFactor?: number;
  41845. /**
  41846. * Define the reference distance the sound should be heard perfectly.
  41847. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41848. */
  41849. refDistance?: number;
  41850. /**
  41851. * Define the distance attenuation model the sound will follow.
  41852. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41853. */
  41854. distanceModel?: string;
  41855. /**
  41856. * Defines the playback speed (1 by default)
  41857. */
  41858. playbackRate?: number;
  41859. /**
  41860. * Defines if the sound is from a streaming source
  41861. */
  41862. streaming?: boolean;
  41863. /**
  41864. * Defines an optional length (in seconds) inside the sound file
  41865. */
  41866. length?: number;
  41867. /**
  41868. * Defines an optional offset (in seconds) inside the sound file
  41869. */
  41870. offset?: number;
  41871. /**
  41872. * If true, URLs will not be required to state the audio file codec to use.
  41873. */
  41874. skipCodecCheck?: boolean;
  41875. }
  41876. /**
  41877. * Defines a sound that can be played in the application.
  41878. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41879. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41880. */
  41881. export class Sound {
  41882. /**
  41883. * The name of the sound in the scene.
  41884. */
  41885. name: string;
  41886. /**
  41887. * Does the sound autoplay once loaded.
  41888. */
  41889. autoplay: boolean;
  41890. /**
  41891. * Does the sound loop after it finishes playing once.
  41892. */
  41893. loop: boolean;
  41894. /**
  41895. * Does the sound use a custom attenuation curve to simulate the falloff
  41896. * happening when the source gets further away from the camera.
  41897. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41898. */
  41899. useCustomAttenuation: boolean;
  41900. /**
  41901. * The sound track id this sound belongs to.
  41902. */
  41903. soundTrackId: number;
  41904. /**
  41905. * Is this sound currently played.
  41906. */
  41907. isPlaying: boolean;
  41908. /**
  41909. * Is this sound currently paused.
  41910. */
  41911. isPaused: boolean;
  41912. /**
  41913. * Does this sound enables spatial sound.
  41914. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41915. */
  41916. spatialSound: boolean;
  41917. /**
  41918. * Define the reference distance the sound should be heard perfectly.
  41919. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41920. */
  41921. refDistance: number;
  41922. /**
  41923. * Define the roll off factor of spatial sounds.
  41924. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41925. */
  41926. rolloffFactor: number;
  41927. /**
  41928. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41929. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41930. */
  41931. maxDistance: number;
  41932. /**
  41933. * Define the distance attenuation model the sound will follow.
  41934. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41935. */
  41936. distanceModel: string;
  41937. /**
  41938. * @hidden
  41939. * Back Compat
  41940. **/
  41941. onended: () => any;
  41942. /**
  41943. * Gets or sets an object used to store user defined information for the sound.
  41944. */
  41945. metadata: any;
  41946. /**
  41947. * Observable event when the current playing sound finishes.
  41948. */
  41949. onEndedObservable: Observable<Sound>;
  41950. private _panningModel;
  41951. private _playbackRate;
  41952. private _streaming;
  41953. private _startTime;
  41954. private _startOffset;
  41955. private _position;
  41956. /** @hidden */
  41957. _positionInEmitterSpace: boolean;
  41958. private _localDirection;
  41959. private _volume;
  41960. private _isReadyToPlay;
  41961. private _isDirectional;
  41962. private _readyToPlayCallback;
  41963. private _audioBuffer;
  41964. private _soundSource;
  41965. private _streamingSource;
  41966. private _soundPanner;
  41967. private _soundGain;
  41968. private _inputAudioNode;
  41969. private _outputAudioNode;
  41970. private _coneInnerAngle;
  41971. private _coneOuterAngle;
  41972. private _coneOuterGain;
  41973. private _scene;
  41974. private _connectedTransformNode;
  41975. private _customAttenuationFunction;
  41976. private _registerFunc;
  41977. private _isOutputConnected;
  41978. private _htmlAudioElement;
  41979. private _urlType;
  41980. private _length?;
  41981. private _offset?;
  41982. /** @hidden */
  41983. static _SceneComponentInitialization: (scene: Scene) => void;
  41984. /**
  41985. * Create a sound and attach it to a scene
  41986. * @param name Name of your sound
  41987. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41988. * @param scene defines the scene the sound belongs to
  41989. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41990. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41991. */
  41992. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41993. /**
  41994. * Release the sound and its associated resources
  41995. */
  41996. dispose(): void;
  41997. /**
  41998. * Gets if the sounds is ready to be played or not.
  41999. * @returns true if ready, otherwise false
  42000. */
  42001. isReady(): boolean;
  42002. private _soundLoaded;
  42003. /**
  42004. * Sets the data of the sound from an audiobuffer
  42005. * @param audioBuffer The audioBuffer containing the data
  42006. */
  42007. setAudioBuffer(audioBuffer: AudioBuffer): void;
  42008. /**
  42009. * Updates the current sounds options such as maxdistance, loop...
  42010. * @param options A JSON object containing values named as the object properties
  42011. */
  42012. updateOptions(options: ISoundOptions): void;
  42013. private _createSpatialParameters;
  42014. private _updateSpatialParameters;
  42015. /**
  42016. * Switch the panning model to HRTF:
  42017. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42018. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42019. */
  42020. switchPanningModelToHRTF(): void;
  42021. /**
  42022. * Switch the panning model to Equal Power:
  42023. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42024. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42025. */
  42026. switchPanningModelToEqualPower(): void;
  42027. private _switchPanningModel;
  42028. /**
  42029. * Connect this sound to a sound track audio node like gain...
  42030. * @param soundTrackAudioNode the sound track audio node to connect to
  42031. */
  42032. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  42033. /**
  42034. * Transform this sound into a directional source
  42035. * @param coneInnerAngle Size of the inner cone in degree
  42036. * @param coneOuterAngle Size of the outer cone in degree
  42037. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  42038. */
  42039. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  42040. /**
  42041. * Gets or sets the inner angle for the directional cone.
  42042. */
  42043. get directionalConeInnerAngle(): number;
  42044. /**
  42045. * Gets or sets the inner angle for the directional cone.
  42046. */
  42047. set directionalConeInnerAngle(value: number);
  42048. /**
  42049. * Gets or sets the outer angle for the directional cone.
  42050. */
  42051. get directionalConeOuterAngle(): number;
  42052. /**
  42053. * Gets or sets the outer angle for the directional cone.
  42054. */
  42055. set directionalConeOuterAngle(value: number);
  42056. /**
  42057. * Sets the position of the emitter if spatial sound is enabled
  42058. * @param newPosition Defines the new posisiton
  42059. */
  42060. setPosition(newPosition: Vector3): void;
  42061. /**
  42062. * Sets the local direction of the emitter if spatial sound is enabled
  42063. * @param newLocalDirection Defines the new local direction
  42064. */
  42065. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  42066. private _updateDirection;
  42067. /** @hidden */
  42068. updateDistanceFromListener(): void;
  42069. /**
  42070. * Sets a new custom attenuation function for the sound.
  42071. * @param callback Defines the function used for the attenuation
  42072. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  42073. */
  42074. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  42075. /**
  42076. * Play the sound
  42077. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  42078. * @param offset (optional) Start the sound at a specific time in seconds
  42079. * @param length (optional) Sound duration (in seconds)
  42080. */
  42081. play(time?: number, offset?: number, length?: number): void;
  42082. private _onended;
  42083. /**
  42084. * Stop the sound
  42085. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  42086. */
  42087. stop(time?: number): void;
  42088. /**
  42089. * Put the sound in pause
  42090. */
  42091. pause(): void;
  42092. /**
  42093. * Sets a dedicated volume for this sounds
  42094. * @param newVolume Define the new volume of the sound
  42095. * @param time Define time for gradual change to new volume
  42096. */
  42097. setVolume(newVolume: number, time?: number): void;
  42098. /**
  42099. * Set the sound play back rate
  42100. * @param newPlaybackRate Define the playback rate the sound should be played at
  42101. */
  42102. setPlaybackRate(newPlaybackRate: number): void;
  42103. /**
  42104. * Gets the volume of the sound.
  42105. * @returns the volume of the sound
  42106. */
  42107. getVolume(): number;
  42108. /**
  42109. * Attach the sound to a dedicated mesh
  42110. * @param transformNode The transform node to connect the sound with
  42111. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  42112. */
  42113. attachToMesh(transformNode: TransformNode): void;
  42114. /**
  42115. * Detach the sound from the previously attached mesh
  42116. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  42117. */
  42118. detachFromMesh(): void;
  42119. private _onRegisterAfterWorldMatrixUpdate;
  42120. /**
  42121. * Clone the current sound in the scene.
  42122. * @returns the new sound clone
  42123. */
  42124. clone(): Nullable<Sound>;
  42125. /**
  42126. * Gets the current underlying audio buffer containing the data
  42127. * @returns the audio buffer
  42128. */
  42129. getAudioBuffer(): Nullable<AudioBuffer>;
  42130. /**
  42131. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  42132. * @returns the source node
  42133. */
  42134. getSoundSource(): Nullable<AudioBufferSourceNode>;
  42135. /**
  42136. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  42137. * @returns the gain node
  42138. */
  42139. getSoundGain(): Nullable<GainNode>;
  42140. /**
  42141. * Serializes the Sound in a JSON representation
  42142. * @returns the JSON representation of the sound
  42143. */
  42144. serialize(): any;
  42145. /**
  42146. * Parse a JSON representation of a sound to innstantiate in a given scene
  42147. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  42148. * @param scene Define the scene the new parsed sound should be created in
  42149. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  42150. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  42151. * @returns the newly parsed sound
  42152. */
  42153. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  42154. }
  42155. }
  42156. declare module "babylonjs/Actions/directAudioActions" {
  42157. import { Action } from "babylonjs/Actions/action";
  42158. import { Condition } from "babylonjs/Actions/condition";
  42159. import { Sound } from "babylonjs/Audio/sound";
  42160. /**
  42161. * This defines an action helpful to play a defined sound on a triggered action.
  42162. */
  42163. export class PlaySoundAction extends Action {
  42164. private _sound;
  42165. /**
  42166. * Instantiate the action
  42167. * @param triggerOptions defines the trigger options
  42168. * @param sound defines the sound to play
  42169. * @param condition defines the trigger related conditions
  42170. */
  42171. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  42172. /** @hidden */
  42173. _prepare(): void;
  42174. /**
  42175. * Execute the action and play the sound.
  42176. */
  42177. execute(): void;
  42178. /**
  42179. * Serializes the actions and its related information.
  42180. * @param parent defines the object to serialize in
  42181. * @returns the serialized object
  42182. */
  42183. serialize(parent: any): any;
  42184. }
  42185. /**
  42186. * This defines an action helpful to stop a defined sound on a triggered action.
  42187. */
  42188. export class StopSoundAction extends Action {
  42189. private _sound;
  42190. /**
  42191. * Instantiate the action
  42192. * @param triggerOptions defines the trigger options
  42193. * @param sound defines the sound to stop
  42194. * @param condition defines the trigger related conditions
  42195. */
  42196. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  42197. /** @hidden */
  42198. _prepare(): void;
  42199. /**
  42200. * Execute the action and stop the sound.
  42201. */
  42202. execute(): void;
  42203. /**
  42204. * Serializes the actions and its related information.
  42205. * @param parent defines the object to serialize in
  42206. * @returns the serialized object
  42207. */
  42208. serialize(parent: any): any;
  42209. }
  42210. }
  42211. declare module "babylonjs/Actions/interpolateValueAction" {
  42212. import { Action } from "babylonjs/Actions/action";
  42213. import { Condition } from "babylonjs/Actions/condition";
  42214. import { Observable } from "babylonjs/Misc/observable";
  42215. /**
  42216. * This defines an action responsible to change the value of a property
  42217. * by interpolating between its current value and the newly set one once triggered.
  42218. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  42219. */
  42220. export class InterpolateValueAction extends Action {
  42221. /**
  42222. * Defines the path of the property where the value should be interpolated
  42223. */
  42224. propertyPath: string;
  42225. /**
  42226. * Defines the target value at the end of the interpolation.
  42227. */
  42228. value: any;
  42229. /**
  42230. * Defines the time it will take for the property to interpolate to the value.
  42231. */
  42232. duration: number;
  42233. /**
  42234. * Defines if the other scene animations should be stopped when the action has been triggered
  42235. */
  42236. stopOtherAnimations?: boolean;
  42237. /**
  42238. * Defines a callback raised once the interpolation animation has been done.
  42239. */
  42240. onInterpolationDone?: () => void;
  42241. /**
  42242. * Observable triggered once the interpolation animation has been done.
  42243. */
  42244. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  42245. private _target;
  42246. private _effectiveTarget;
  42247. private _property;
  42248. /**
  42249. * Instantiate the action
  42250. * @param triggerOptions defines the trigger options
  42251. * @param target defines the object containing the value to interpolate
  42252. * @param propertyPath defines the path to the property in the target object
  42253. * @param value defines the target value at the end of the interpolation
  42254. * @param duration deines the time it will take for the property to interpolate to the value.
  42255. * @param condition defines the trigger related conditions
  42256. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  42257. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  42258. */
  42259. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  42260. /** @hidden */
  42261. _prepare(): void;
  42262. /**
  42263. * Execute the action starts the value interpolation.
  42264. */
  42265. execute(): void;
  42266. /**
  42267. * Serializes the actions and its related information.
  42268. * @param parent defines the object to serialize in
  42269. * @returns the serialized object
  42270. */
  42271. serialize(parent: any): any;
  42272. }
  42273. }
  42274. declare module "babylonjs/Actions/index" {
  42275. export * from "babylonjs/Actions/abstractActionManager";
  42276. export * from "babylonjs/Actions/action";
  42277. export * from "babylonjs/Actions/actionEvent";
  42278. export * from "babylonjs/Actions/actionManager";
  42279. export * from "babylonjs/Actions/condition";
  42280. export * from "babylonjs/Actions/directActions";
  42281. export * from "babylonjs/Actions/directAudioActions";
  42282. export * from "babylonjs/Actions/interpolateValueAction";
  42283. }
  42284. declare module "babylonjs/Animations/index" {
  42285. export * from "babylonjs/Animations/animatable";
  42286. export * from "babylonjs/Animations/animation";
  42287. export * from "babylonjs/Animations/animationGroup";
  42288. export * from "babylonjs/Animations/animationPropertiesOverride";
  42289. export * from "babylonjs/Animations/easing";
  42290. export * from "babylonjs/Animations/runtimeAnimation";
  42291. export * from "babylonjs/Animations/animationEvent";
  42292. export * from "babylonjs/Animations/animationGroup";
  42293. export * from "babylonjs/Animations/animationKey";
  42294. export * from "babylonjs/Animations/animationRange";
  42295. export * from "babylonjs/Animations/animatable.interface";
  42296. }
  42297. declare module "babylonjs/Audio/soundTrack" {
  42298. import { Sound } from "babylonjs/Audio/sound";
  42299. import { Analyser } from "babylonjs/Audio/analyser";
  42300. import { Scene } from "babylonjs/scene";
  42301. /**
  42302. * Options allowed during the creation of a sound track.
  42303. */
  42304. export interface ISoundTrackOptions {
  42305. /**
  42306. * The volume the sound track should take during creation
  42307. */
  42308. volume?: number;
  42309. /**
  42310. * Define if the sound track is the main sound track of the scene
  42311. */
  42312. mainTrack?: boolean;
  42313. }
  42314. /**
  42315. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  42316. * It will be also used in a future release to apply effects on a specific track.
  42317. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42318. */
  42319. export class SoundTrack {
  42320. /**
  42321. * The unique identifier of the sound track in the scene.
  42322. */
  42323. id: number;
  42324. /**
  42325. * The list of sounds included in the sound track.
  42326. */
  42327. soundCollection: Array<Sound>;
  42328. private _outputAudioNode;
  42329. private _scene;
  42330. private _connectedAnalyser;
  42331. private _options;
  42332. private _isInitialized;
  42333. /**
  42334. * Creates a new sound track.
  42335. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42336. * @param scene Define the scene the sound track belongs to
  42337. * @param options
  42338. */
  42339. constructor(scene: Scene, options?: ISoundTrackOptions);
  42340. private _initializeSoundTrackAudioGraph;
  42341. /**
  42342. * Release the sound track and its associated resources
  42343. */
  42344. dispose(): void;
  42345. /**
  42346. * Adds a sound to this sound track
  42347. * @param sound define the cound to add
  42348. * @ignoreNaming
  42349. */
  42350. AddSound(sound: Sound): void;
  42351. /**
  42352. * Removes a sound to this sound track
  42353. * @param sound define the cound to remove
  42354. * @ignoreNaming
  42355. */
  42356. RemoveSound(sound: Sound): void;
  42357. /**
  42358. * Set a global volume for the full sound track.
  42359. * @param newVolume Define the new volume of the sound track
  42360. */
  42361. setVolume(newVolume: number): void;
  42362. /**
  42363. * Switch the panning model to HRTF:
  42364. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42365. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42366. */
  42367. switchPanningModelToHRTF(): void;
  42368. /**
  42369. * Switch the panning model to Equal Power:
  42370. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42371. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42372. */
  42373. switchPanningModelToEqualPower(): void;
  42374. /**
  42375. * Connect the sound track to an audio analyser allowing some amazing
  42376. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42377. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42378. * @param analyser The analyser to connect to the engine
  42379. */
  42380. connectToAnalyser(analyser: Analyser): void;
  42381. }
  42382. }
  42383. declare module "babylonjs/Audio/audioSceneComponent" {
  42384. import { Sound } from "babylonjs/Audio/sound";
  42385. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  42386. import { Nullable } from "babylonjs/types";
  42387. import { Vector3 } from "babylonjs/Maths/math.vector";
  42388. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  42389. import { Scene } from "babylonjs/scene";
  42390. import { AbstractScene } from "babylonjs/abstractScene";
  42391. import "babylonjs/Audio/audioEngine";
  42392. module "babylonjs/abstractScene" {
  42393. interface AbstractScene {
  42394. /**
  42395. * The list of sounds used in the scene.
  42396. */
  42397. sounds: Nullable<Array<Sound>>;
  42398. }
  42399. }
  42400. module "babylonjs/scene" {
  42401. interface Scene {
  42402. /**
  42403. * @hidden
  42404. * Backing field
  42405. */
  42406. _mainSoundTrack: SoundTrack;
  42407. /**
  42408. * The main sound track played by the scene.
  42409. * It cotains your primary collection of sounds.
  42410. */
  42411. mainSoundTrack: SoundTrack;
  42412. /**
  42413. * The list of sound tracks added to the scene
  42414. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42415. */
  42416. soundTracks: Nullable<Array<SoundTrack>>;
  42417. /**
  42418. * Gets a sound using a given name
  42419. * @param name defines the name to search for
  42420. * @return the found sound or null if not found at all.
  42421. */
  42422. getSoundByName(name: string): Nullable<Sound>;
  42423. /**
  42424. * Gets or sets if audio support is enabled
  42425. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42426. */
  42427. audioEnabled: boolean;
  42428. /**
  42429. * Gets or sets if audio will be output to headphones
  42430. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42431. */
  42432. headphone: boolean;
  42433. /**
  42434. * Gets or sets custom audio listener position provider
  42435. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42436. */
  42437. audioListenerPositionProvider: Nullable<() => Vector3>;
  42438. /**
  42439. * Gets or sets a refresh rate when using 3D audio positioning
  42440. */
  42441. audioPositioningRefreshRate: number;
  42442. }
  42443. }
  42444. /**
  42445. * Defines the sound scene component responsible to manage any sounds
  42446. * in a given scene.
  42447. */
  42448. export class AudioSceneComponent implements ISceneSerializableComponent {
  42449. /**
  42450. * The component name helpfull to identify the component in the list of scene components.
  42451. */
  42452. readonly name: string;
  42453. /**
  42454. * The scene the component belongs to.
  42455. */
  42456. scene: Scene;
  42457. private _audioEnabled;
  42458. /**
  42459. * Gets whether audio is enabled or not.
  42460. * Please use related enable/disable method to switch state.
  42461. */
  42462. get audioEnabled(): boolean;
  42463. private _headphone;
  42464. /**
  42465. * Gets whether audio is outputing to headphone or not.
  42466. * Please use the according Switch methods to change output.
  42467. */
  42468. get headphone(): boolean;
  42469. /**
  42470. * Gets or sets a refresh rate when using 3D audio positioning
  42471. */
  42472. audioPositioningRefreshRate: number;
  42473. private _audioListenerPositionProvider;
  42474. /**
  42475. * Gets the current audio listener position provider
  42476. */
  42477. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42478. /**
  42479. * Sets a custom listener position for all sounds in the scene
  42480. * By default, this is the position of the first active camera
  42481. */
  42482. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42483. /**
  42484. * Creates a new instance of the component for the given scene
  42485. * @param scene Defines the scene to register the component in
  42486. */
  42487. constructor(scene: Scene);
  42488. /**
  42489. * Registers the component in a given scene
  42490. */
  42491. register(): void;
  42492. /**
  42493. * Rebuilds the elements related to this component in case of
  42494. * context lost for instance.
  42495. */
  42496. rebuild(): void;
  42497. /**
  42498. * Serializes the component data to the specified json object
  42499. * @param serializationObject The object to serialize to
  42500. */
  42501. serialize(serializationObject: any): void;
  42502. /**
  42503. * Adds all the elements from the container to the scene
  42504. * @param container the container holding the elements
  42505. */
  42506. addFromContainer(container: AbstractScene): void;
  42507. /**
  42508. * Removes all the elements in the container from the scene
  42509. * @param container contains the elements to remove
  42510. * @param dispose if the removed element should be disposed (default: false)
  42511. */
  42512. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42513. /**
  42514. * Disposes the component and the associated ressources.
  42515. */
  42516. dispose(): void;
  42517. /**
  42518. * Disables audio in the associated scene.
  42519. */
  42520. disableAudio(): void;
  42521. /**
  42522. * Enables audio in the associated scene.
  42523. */
  42524. enableAudio(): void;
  42525. /**
  42526. * Switch audio to headphone output.
  42527. */
  42528. switchAudioModeForHeadphones(): void;
  42529. /**
  42530. * Switch audio to normal speakers.
  42531. */
  42532. switchAudioModeForNormalSpeakers(): void;
  42533. private _cachedCameraDirection;
  42534. private _cachedCameraPosition;
  42535. private _lastCheck;
  42536. private _afterRender;
  42537. }
  42538. }
  42539. declare module "babylonjs/Audio/weightedsound" {
  42540. import { Sound } from "babylonjs/Audio/sound";
  42541. /**
  42542. * Wraps one or more Sound objects and selects one with random weight for playback.
  42543. */
  42544. export class WeightedSound {
  42545. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42546. loop: boolean;
  42547. private _coneInnerAngle;
  42548. private _coneOuterAngle;
  42549. private _volume;
  42550. /** A Sound is currently playing. */
  42551. isPlaying: boolean;
  42552. /** A Sound is currently paused. */
  42553. isPaused: boolean;
  42554. private _sounds;
  42555. private _weights;
  42556. private _currentIndex?;
  42557. /**
  42558. * Creates a new WeightedSound from the list of sounds given.
  42559. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42560. * @param sounds Array of Sounds that will be selected from.
  42561. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42562. */
  42563. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42564. /**
  42565. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42566. */
  42567. get directionalConeInnerAngle(): number;
  42568. /**
  42569. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42570. */
  42571. set directionalConeInnerAngle(value: number);
  42572. /**
  42573. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42574. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42575. */
  42576. get directionalConeOuterAngle(): number;
  42577. /**
  42578. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42579. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42580. */
  42581. set directionalConeOuterAngle(value: number);
  42582. /**
  42583. * Playback volume.
  42584. */
  42585. get volume(): number;
  42586. /**
  42587. * Playback volume.
  42588. */
  42589. set volume(value: number);
  42590. private _onended;
  42591. /**
  42592. * Suspend playback
  42593. */
  42594. pause(): void;
  42595. /**
  42596. * Stop playback
  42597. */
  42598. stop(): void;
  42599. /**
  42600. * Start playback.
  42601. * @param startOffset Position the clip head at a specific time in seconds.
  42602. */
  42603. play(startOffset?: number): void;
  42604. }
  42605. }
  42606. declare module "babylonjs/Audio/index" {
  42607. export * from "babylonjs/Audio/analyser";
  42608. export * from "babylonjs/Audio/audioEngine";
  42609. export * from "babylonjs/Audio/audioSceneComponent";
  42610. export * from "babylonjs/Audio/sound";
  42611. export * from "babylonjs/Audio/soundTrack";
  42612. export * from "babylonjs/Audio/weightedsound";
  42613. }
  42614. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  42615. import { Behavior } from "babylonjs/Behaviors/behavior";
  42616. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42617. import { BackEase } from "babylonjs/Animations/easing";
  42618. /**
  42619. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42620. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42621. */
  42622. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42623. /**
  42624. * Gets the name of the behavior.
  42625. */
  42626. get name(): string;
  42627. /**
  42628. * The easing function used by animations
  42629. */
  42630. static EasingFunction: BackEase;
  42631. /**
  42632. * The easing mode used by animations
  42633. */
  42634. static EasingMode: number;
  42635. /**
  42636. * The duration of the animation, in milliseconds
  42637. */
  42638. transitionDuration: number;
  42639. /**
  42640. * Length of the distance animated by the transition when lower radius is reached
  42641. */
  42642. lowerRadiusTransitionRange: number;
  42643. /**
  42644. * Length of the distance animated by the transition when upper radius is reached
  42645. */
  42646. upperRadiusTransitionRange: number;
  42647. private _autoTransitionRange;
  42648. /**
  42649. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42650. */
  42651. get autoTransitionRange(): boolean;
  42652. /**
  42653. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42654. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42655. */
  42656. set autoTransitionRange(value: boolean);
  42657. private _attachedCamera;
  42658. private _onAfterCheckInputsObserver;
  42659. private _onMeshTargetChangedObserver;
  42660. /**
  42661. * Initializes the behavior.
  42662. */
  42663. init(): void;
  42664. /**
  42665. * Attaches the behavior to its arc rotate camera.
  42666. * @param camera Defines the camera to attach the behavior to
  42667. */
  42668. attach(camera: ArcRotateCamera): void;
  42669. /**
  42670. * Detaches the behavior from its current arc rotate camera.
  42671. */
  42672. detach(): void;
  42673. private _radiusIsAnimating;
  42674. private _radiusBounceTransition;
  42675. private _animatables;
  42676. private _cachedWheelPrecision;
  42677. /**
  42678. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42679. * @param radiusLimit The limit to check against.
  42680. * @return Bool to indicate if at limit.
  42681. */
  42682. private _isRadiusAtLimit;
  42683. /**
  42684. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42685. * @param radiusDelta The delta by which to animate to. Can be negative.
  42686. */
  42687. private _applyBoundRadiusAnimation;
  42688. /**
  42689. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42690. */
  42691. protected _clearAnimationLocks(): void;
  42692. /**
  42693. * Stops and removes all animations that have been applied to the camera
  42694. */
  42695. stopAllAnimations(): void;
  42696. }
  42697. }
  42698. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  42699. import { Behavior } from "babylonjs/Behaviors/behavior";
  42700. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42701. import { ExponentialEase } from "babylonjs/Animations/easing";
  42702. import { Nullable } from "babylonjs/types";
  42703. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42704. import { Vector3 } from "babylonjs/Maths/math.vector";
  42705. /**
  42706. * 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.
  42707. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42708. */
  42709. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42710. /**
  42711. * Gets the name of the behavior.
  42712. */
  42713. get name(): string;
  42714. private _mode;
  42715. private _radiusScale;
  42716. private _positionScale;
  42717. private _defaultElevation;
  42718. private _elevationReturnTime;
  42719. private _elevationReturnWaitTime;
  42720. private _zoomStopsAnimation;
  42721. private _framingTime;
  42722. /**
  42723. * The easing function used by animations
  42724. */
  42725. static EasingFunction: ExponentialEase;
  42726. /**
  42727. * The easing mode used by animations
  42728. */
  42729. static EasingMode: number;
  42730. /**
  42731. * Sets the current mode used by the behavior
  42732. */
  42733. set mode(mode: number);
  42734. /**
  42735. * Gets current mode used by the behavior.
  42736. */
  42737. get mode(): number;
  42738. /**
  42739. * Sets the scale applied to the radius (1 by default)
  42740. */
  42741. set radiusScale(radius: number);
  42742. /**
  42743. * Gets the scale applied to the radius
  42744. */
  42745. get radiusScale(): number;
  42746. /**
  42747. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42748. */
  42749. set positionScale(scale: number);
  42750. /**
  42751. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42752. */
  42753. get positionScale(): number;
  42754. /**
  42755. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42756. * behaviour is triggered, in radians.
  42757. */
  42758. set defaultElevation(elevation: number);
  42759. /**
  42760. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42761. * behaviour is triggered, in radians.
  42762. */
  42763. get defaultElevation(): number;
  42764. /**
  42765. * Sets the time (in milliseconds) taken to return to the default beta position.
  42766. * Negative value indicates camera should not return to default.
  42767. */
  42768. set elevationReturnTime(speed: number);
  42769. /**
  42770. * Gets the time (in milliseconds) taken to return to the default beta position.
  42771. * Negative value indicates camera should not return to default.
  42772. */
  42773. get elevationReturnTime(): number;
  42774. /**
  42775. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42776. */
  42777. set elevationReturnWaitTime(time: number);
  42778. /**
  42779. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42780. */
  42781. get elevationReturnWaitTime(): number;
  42782. /**
  42783. * Sets the flag that indicates if user zooming should stop animation.
  42784. */
  42785. set zoomStopsAnimation(flag: boolean);
  42786. /**
  42787. * Gets the flag that indicates if user zooming should stop animation.
  42788. */
  42789. get zoomStopsAnimation(): boolean;
  42790. /**
  42791. * Sets the transition time when framing the mesh, in milliseconds
  42792. */
  42793. set framingTime(time: number);
  42794. /**
  42795. * Gets the transition time when framing the mesh, in milliseconds
  42796. */
  42797. get framingTime(): number;
  42798. /**
  42799. * Define if the behavior should automatically change the configured
  42800. * camera limits and sensibilities.
  42801. */
  42802. autoCorrectCameraLimitsAndSensibility: boolean;
  42803. private _onPrePointerObservableObserver;
  42804. private _onAfterCheckInputsObserver;
  42805. private _onMeshTargetChangedObserver;
  42806. private _attachedCamera;
  42807. private _isPointerDown;
  42808. private _lastInteractionTime;
  42809. /**
  42810. * Initializes the behavior.
  42811. */
  42812. init(): void;
  42813. /**
  42814. * Attaches the behavior to its arc rotate camera.
  42815. * @param camera Defines the camera to attach the behavior to
  42816. */
  42817. attach(camera: ArcRotateCamera): void;
  42818. /**
  42819. * Detaches the behavior from its current arc rotate camera.
  42820. */
  42821. detach(): void;
  42822. private _animatables;
  42823. private _betaIsAnimating;
  42824. private _betaTransition;
  42825. private _radiusTransition;
  42826. private _vectorTransition;
  42827. /**
  42828. * Targets the given mesh and updates zoom level accordingly.
  42829. * @param mesh The mesh to target.
  42830. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42831. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42832. */
  42833. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42834. /**
  42835. * Targets the given mesh with its children and updates zoom level accordingly.
  42836. * @param mesh The mesh to target.
  42837. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42838. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42839. */
  42840. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42841. /**
  42842. * Targets the given meshes with their children and updates zoom level accordingly.
  42843. * @param meshes The mesh to target.
  42844. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42845. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42846. */
  42847. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42848. /**
  42849. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42850. * @param minimumWorld Determines the smaller position of the bounding box extend
  42851. * @param maximumWorld Determines the bigger position of the bounding box extend
  42852. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42853. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42854. */
  42855. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42856. /**
  42857. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42858. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42859. * frustum width.
  42860. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42861. * to fully enclose the mesh in the viewing frustum.
  42862. */
  42863. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42864. /**
  42865. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42866. * is automatically returned to its default position (expected to be above ground plane).
  42867. */
  42868. private _maintainCameraAboveGround;
  42869. /**
  42870. * Returns the frustum slope based on the canvas ratio and camera FOV
  42871. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42872. */
  42873. private _getFrustumSlope;
  42874. /**
  42875. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42876. */
  42877. private _clearAnimationLocks;
  42878. /**
  42879. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42880. */
  42881. private _applyUserInteraction;
  42882. /**
  42883. * Stops and removes all animations that have been applied to the camera
  42884. */
  42885. stopAllAnimations(): void;
  42886. /**
  42887. * Gets a value indicating if the user is moving the camera
  42888. */
  42889. get isUserIsMoving(): boolean;
  42890. /**
  42891. * The camera can move all the way towards the mesh.
  42892. */
  42893. static IgnoreBoundsSizeMode: number;
  42894. /**
  42895. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42896. */
  42897. static FitFrustumSidesMode: number;
  42898. }
  42899. }
  42900. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  42901. import { Nullable } from "babylonjs/types";
  42902. import { Camera } from "babylonjs/Cameras/camera";
  42903. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42904. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42905. /**
  42906. * Base class for Camera Pointer Inputs.
  42907. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42908. * for example usage.
  42909. */
  42910. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42911. /**
  42912. * Defines the camera the input is attached to.
  42913. */
  42914. abstract camera: Camera;
  42915. /**
  42916. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42917. */
  42918. protected _altKey: boolean;
  42919. protected _ctrlKey: boolean;
  42920. protected _metaKey: boolean;
  42921. protected _shiftKey: boolean;
  42922. /**
  42923. * Which mouse buttons were pressed at time of last mouse event.
  42924. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42925. */
  42926. protected _buttonsPressed: number;
  42927. /**
  42928. * Defines the buttons associated with the input to handle camera move.
  42929. */
  42930. buttons: number[];
  42931. /**
  42932. * Attach the input controls to a specific dom element to get the input from.
  42933. * @param element Defines the element the controls should be listened from
  42934. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42935. */
  42936. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42937. /**
  42938. * Detach the current controls from the specified dom element.
  42939. * @param element Defines the element to stop listening the inputs from
  42940. */
  42941. detachControl(element: Nullable<HTMLElement>): void;
  42942. /**
  42943. * Gets the class name of the current input.
  42944. * @returns the class name
  42945. */
  42946. getClassName(): string;
  42947. /**
  42948. * Get the friendly name associated with the input class.
  42949. * @returns the input friendly name
  42950. */
  42951. getSimpleName(): string;
  42952. /**
  42953. * Called on pointer POINTERDOUBLETAP event.
  42954. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42955. */
  42956. protected onDoubleTap(type: string): void;
  42957. /**
  42958. * Called on pointer POINTERMOVE event if only a single touch is active.
  42959. * Override this method to provide functionality.
  42960. */
  42961. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42962. /**
  42963. * Called on pointer POINTERMOVE event if multiple touches are active.
  42964. * Override this method to provide functionality.
  42965. */
  42966. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42967. /**
  42968. * Called on JS contextmenu event.
  42969. * Override this method to provide functionality.
  42970. */
  42971. protected onContextMenu(evt: PointerEvent): void;
  42972. /**
  42973. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42974. * press.
  42975. * Override this method to provide functionality.
  42976. */
  42977. protected onButtonDown(evt: PointerEvent): void;
  42978. /**
  42979. * Called each time a new POINTERUP event occurs. Ie, for each button
  42980. * release.
  42981. * Override this method to provide functionality.
  42982. */
  42983. protected onButtonUp(evt: PointerEvent): void;
  42984. /**
  42985. * Called when window becomes inactive.
  42986. * Override this method to provide functionality.
  42987. */
  42988. protected onLostFocus(): void;
  42989. private _pointerInput;
  42990. private _observer;
  42991. private _onLostFocus;
  42992. private pointA;
  42993. private pointB;
  42994. }
  42995. }
  42996. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  42997. import { Nullable } from "babylonjs/types";
  42998. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42999. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  43000. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  43001. /**
  43002. * Manage the pointers inputs to control an arc rotate camera.
  43003. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43004. */
  43005. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  43006. /**
  43007. * Defines the camera the input is attached to.
  43008. */
  43009. camera: ArcRotateCamera;
  43010. /**
  43011. * Gets the class name of the current input.
  43012. * @returns the class name
  43013. */
  43014. getClassName(): string;
  43015. /**
  43016. * Defines the buttons associated with the input to handle camera move.
  43017. */
  43018. buttons: number[];
  43019. /**
  43020. * Defines the pointer angular sensibility along the X axis or how fast is
  43021. * the camera rotating.
  43022. */
  43023. angularSensibilityX: number;
  43024. /**
  43025. * Defines the pointer angular sensibility along the Y axis or how fast is
  43026. * the camera rotating.
  43027. */
  43028. angularSensibilityY: number;
  43029. /**
  43030. * Defines the pointer pinch precision or how fast is the camera zooming.
  43031. */
  43032. pinchPrecision: number;
  43033. /**
  43034. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43035. * from 0.
  43036. * It defines the percentage of current camera.radius to use as delta when
  43037. * pinch zoom is used.
  43038. */
  43039. pinchDeltaPercentage: number;
  43040. /**
  43041. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43042. * that any object in the plane at the camera's target point will scale
  43043. * perfectly with finger motion.
  43044. * Overrides pinchDeltaPercentage and pinchPrecision.
  43045. */
  43046. useNaturalPinchZoom: boolean;
  43047. /**
  43048. * Defines the pointer panning sensibility or how fast is the camera moving.
  43049. */
  43050. panningSensibility: number;
  43051. /**
  43052. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  43053. */
  43054. multiTouchPanning: boolean;
  43055. /**
  43056. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  43057. * zoom (pinch) through multitouch.
  43058. */
  43059. multiTouchPanAndZoom: boolean;
  43060. /**
  43061. * Revers pinch action direction.
  43062. */
  43063. pinchInwards: boolean;
  43064. private _isPanClick;
  43065. private _twoFingerActivityCount;
  43066. private _isPinching;
  43067. /**
  43068. * Called on pointer POINTERMOVE event if only a single touch is active.
  43069. */
  43070. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43071. /**
  43072. * Called on pointer POINTERDOUBLETAP event.
  43073. */
  43074. protected onDoubleTap(type: string): void;
  43075. /**
  43076. * Called on pointer POINTERMOVE event if multiple touches are active.
  43077. */
  43078. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43079. /**
  43080. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  43081. * press.
  43082. */
  43083. protected onButtonDown(evt: PointerEvent): void;
  43084. /**
  43085. * Called each time a new POINTERUP event occurs. Ie, for each button
  43086. * release.
  43087. */
  43088. protected onButtonUp(evt: PointerEvent): void;
  43089. /**
  43090. * Called when window becomes inactive.
  43091. */
  43092. protected onLostFocus(): void;
  43093. }
  43094. }
  43095. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  43096. import { Nullable } from "babylonjs/types";
  43097. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43098. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43099. /**
  43100. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  43101. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43102. */
  43103. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  43104. /**
  43105. * Defines the camera the input is attached to.
  43106. */
  43107. camera: ArcRotateCamera;
  43108. /**
  43109. * Defines the list of key codes associated with the up action (increase alpha)
  43110. */
  43111. keysUp: number[];
  43112. /**
  43113. * Defines the list of key codes associated with the down action (decrease alpha)
  43114. */
  43115. keysDown: number[];
  43116. /**
  43117. * Defines the list of key codes associated with the left action (increase beta)
  43118. */
  43119. keysLeft: number[];
  43120. /**
  43121. * Defines the list of key codes associated with the right action (decrease beta)
  43122. */
  43123. keysRight: number[];
  43124. /**
  43125. * Defines the list of key codes associated with the reset action.
  43126. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  43127. */
  43128. keysReset: number[];
  43129. /**
  43130. * Defines the panning sensibility of the inputs.
  43131. * (How fast is the camera panning)
  43132. */
  43133. panningSensibility: number;
  43134. /**
  43135. * Defines the zooming sensibility of the inputs.
  43136. * (How fast is the camera zooming)
  43137. */
  43138. zoomingSensibility: number;
  43139. /**
  43140. * Defines whether maintaining the alt key down switch the movement mode from
  43141. * orientation to zoom.
  43142. */
  43143. useAltToZoom: boolean;
  43144. /**
  43145. * Rotation speed of the camera
  43146. */
  43147. angularSpeed: number;
  43148. private _keys;
  43149. private _ctrlPressed;
  43150. private _altPressed;
  43151. private _onCanvasBlurObserver;
  43152. private _onKeyboardObserver;
  43153. private _engine;
  43154. private _scene;
  43155. /**
  43156. * Attach the input controls to a specific dom element to get the input from.
  43157. * @param element Defines the element the controls should be listened from
  43158. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43159. */
  43160. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43161. /**
  43162. * Detach the current controls from the specified dom element.
  43163. * @param element Defines the element to stop listening the inputs from
  43164. */
  43165. detachControl(element: Nullable<HTMLElement>): void;
  43166. /**
  43167. * Update the current camera state depending on the inputs that have been used this frame.
  43168. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43169. */
  43170. checkInputs(): void;
  43171. /**
  43172. * Gets the class name of the current intput.
  43173. * @returns the class name
  43174. */
  43175. getClassName(): string;
  43176. /**
  43177. * Get the friendly name associated with the input class.
  43178. * @returns the input friendly name
  43179. */
  43180. getSimpleName(): string;
  43181. }
  43182. }
  43183. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  43184. import { Nullable } from "babylonjs/types";
  43185. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43186. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43187. /**
  43188. * Manage the mouse wheel inputs to control an arc rotate camera.
  43189. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43190. */
  43191. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  43192. /**
  43193. * Defines the camera the input is attached to.
  43194. */
  43195. camera: ArcRotateCamera;
  43196. /**
  43197. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43198. */
  43199. wheelPrecision: number;
  43200. /**
  43201. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43202. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43203. */
  43204. wheelDeltaPercentage: number;
  43205. private _wheel;
  43206. private _observer;
  43207. private computeDeltaFromMouseWheelLegacyEvent;
  43208. /**
  43209. * Attach the input controls to a specific dom element to get the input from.
  43210. * @param element Defines the element the controls should be listened from
  43211. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43212. */
  43213. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43214. /**
  43215. * Detach the current controls from the specified dom element.
  43216. * @param element Defines the element to stop listening the inputs from
  43217. */
  43218. detachControl(element: Nullable<HTMLElement>): void;
  43219. /**
  43220. * Gets the class name of the current intput.
  43221. * @returns the class name
  43222. */
  43223. getClassName(): string;
  43224. /**
  43225. * Get the friendly name associated with the input class.
  43226. * @returns the input friendly name
  43227. */
  43228. getSimpleName(): string;
  43229. }
  43230. }
  43231. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43232. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43233. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  43234. /**
  43235. * Default Inputs manager for the ArcRotateCamera.
  43236. * It groups all the default supported inputs for ease of use.
  43237. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43238. */
  43239. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  43240. /**
  43241. * Instantiates a new ArcRotateCameraInputsManager.
  43242. * @param camera Defines the camera the inputs belong to
  43243. */
  43244. constructor(camera: ArcRotateCamera);
  43245. /**
  43246. * Add mouse wheel input support to the input manager.
  43247. * @returns the current input manager
  43248. */
  43249. addMouseWheel(): ArcRotateCameraInputsManager;
  43250. /**
  43251. * Add pointers input support to the input manager.
  43252. * @returns the current input manager
  43253. */
  43254. addPointers(): ArcRotateCameraInputsManager;
  43255. /**
  43256. * Add keyboard input support to the input manager.
  43257. * @returns the current input manager
  43258. */
  43259. addKeyboard(): ArcRotateCameraInputsManager;
  43260. }
  43261. }
  43262. declare module "babylonjs/Cameras/arcRotateCamera" {
  43263. import { Observable } from "babylonjs/Misc/observable";
  43264. import { Nullable } from "babylonjs/types";
  43265. import { Scene } from "babylonjs/scene";
  43266. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  43267. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43268. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43269. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43270. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  43271. import { Camera } from "babylonjs/Cameras/camera";
  43272. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  43273. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43274. import { Collider } from "babylonjs/Collisions/collider";
  43275. /**
  43276. * This represents an orbital type of camera.
  43277. *
  43278. * 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.
  43279. * 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.
  43280. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  43281. */
  43282. export class ArcRotateCamera extends TargetCamera {
  43283. /**
  43284. * Defines the rotation angle of the camera along the longitudinal axis.
  43285. */
  43286. alpha: number;
  43287. /**
  43288. * Defines the rotation angle of the camera along the latitudinal axis.
  43289. */
  43290. beta: number;
  43291. /**
  43292. * Defines the radius of the camera from it s target point.
  43293. */
  43294. radius: number;
  43295. protected _target: Vector3;
  43296. protected _targetHost: Nullable<AbstractMesh>;
  43297. /**
  43298. * Defines the target point of the camera.
  43299. * The camera looks towards it form the radius distance.
  43300. */
  43301. get target(): Vector3;
  43302. set target(value: Vector3);
  43303. /**
  43304. * Define the current local position of the camera in the scene
  43305. */
  43306. get position(): Vector3;
  43307. set position(newPosition: Vector3);
  43308. protected _upVector: Vector3;
  43309. protected _upToYMatrix: Matrix;
  43310. protected _YToUpMatrix: Matrix;
  43311. /**
  43312. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  43313. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  43314. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  43315. */
  43316. set upVector(vec: Vector3);
  43317. get upVector(): Vector3;
  43318. /**
  43319. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  43320. */
  43321. setMatUp(): void;
  43322. /**
  43323. * Current inertia value on the longitudinal axis.
  43324. * The bigger this number the longer it will take for the camera to stop.
  43325. */
  43326. inertialAlphaOffset: number;
  43327. /**
  43328. * Current inertia value on the latitudinal axis.
  43329. * The bigger this number the longer it will take for the camera to stop.
  43330. */
  43331. inertialBetaOffset: number;
  43332. /**
  43333. * Current inertia value on the radius axis.
  43334. * The bigger this number the longer it will take for the camera to stop.
  43335. */
  43336. inertialRadiusOffset: number;
  43337. /**
  43338. * Minimum allowed angle on the longitudinal axis.
  43339. * This can help limiting how the Camera is able to move in the scene.
  43340. */
  43341. lowerAlphaLimit: Nullable<number>;
  43342. /**
  43343. * Maximum allowed angle on the longitudinal axis.
  43344. * This can help limiting how the Camera is able to move in the scene.
  43345. */
  43346. upperAlphaLimit: Nullable<number>;
  43347. /**
  43348. * Minimum allowed angle on the latitudinal axis.
  43349. * This can help limiting how the Camera is able to move in the scene.
  43350. */
  43351. lowerBetaLimit: number;
  43352. /**
  43353. * Maximum allowed angle on the latitudinal axis.
  43354. * This can help limiting how the Camera is able to move in the scene.
  43355. */
  43356. upperBetaLimit: number;
  43357. /**
  43358. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  43359. * This can help limiting how the Camera is able to move in the scene.
  43360. */
  43361. lowerRadiusLimit: Nullable<number>;
  43362. /**
  43363. * Maximum allowed distance of the camera to the target (The camera can not get further).
  43364. * This can help limiting how the Camera is able to move in the scene.
  43365. */
  43366. upperRadiusLimit: Nullable<number>;
  43367. /**
  43368. * Defines the current inertia value used during panning of the camera along the X axis.
  43369. */
  43370. inertialPanningX: number;
  43371. /**
  43372. * Defines the current inertia value used during panning of the camera along the Y axis.
  43373. */
  43374. inertialPanningY: number;
  43375. /**
  43376. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  43377. * Basically if your fingers moves away from more than this distance you will be considered
  43378. * in pinch mode.
  43379. */
  43380. pinchToPanMaxDistance: number;
  43381. /**
  43382. * Defines the maximum distance the camera can pan.
  43383. * This could help keeping the cammera always in your scene.
  43384. */
  43385. panningDistanceLimit: Nullable<number>;
  43386. /**
  43387. * Defines the target of the camera before paning.
  43388. */
  43389. panningOriginTarget: Vector3;
  43390. /**
  43391. * Defines the value of the inertia used during panning.
  43392. * 0 would mean stop inertia and one would mean no decelleration at all.
  43393. */
  43394. panningInertia: number;
  43395. /**
  43396. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  43397. */
  43398. get angularSensibilityX(): number;
  43399. set angularSensibilityX(value: number);
  43400. /**
  43401. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  43402. */
  43403. get angularSensibilityY(): number;
  43404. set angularSensibilityY(value: number);
  43405. /**
  43406. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  43407. */
  43408. get pinchPrecision(): number;
  43409. set pinchPrecision(value: number);
  43410. /**
  43411. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  43412. * It will be used instead of pinchDeltaPrecision if different from 0.
  43413. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43414. */
  43415. get pinchDeltaPercentage(): number;
  43416. set pinchDeltaPercentage(value: number);
  43417. /**
  43418. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  43419. * and pinch delta percentage.
  43420. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43421. * that any object in the plane at the camera's target point will scale
  43422. * perfectly with finger motion.
  43423. */
  43424. get useNaturalPinchZoom(): boolean;
  43425. set useNaturalPinchZoom(value: boolean);
  43426. /**
  43427. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  43428. */
  43429. get panningSensibility(): number;
  43430. set panningSensibility(value: number);
  43431. /**
  43432. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  43433. */
  43434. get keysUp(): number[];
  43435. set keysUp(value: number[]);
  43436. /**
  43437. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  43438. */
  43439. get keysDown(): number[];
  43440. set keysDown(value: number[]);
  43441. /**
  43442. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  43443. */
  43444. get keysLeft(): number[];
  43445. set keysLeft(value: number[]);
  43446. /**
  43447. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  43448. */
  43449. get keysRight(): number[];
  43450. set keysRight(value: number[]);
  43451. /**
  43452. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43453. */
  43454. get wheelPrecision(): number;
  43455. set wheelPrecision(value: number);
  43456. /**
  43457. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  43458. * It will be used instead of pinchDeltaPrecision if different from 0.
  43459. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43460. */
  43461. get wheelDeltaPercentage(): number;
  43462. set wheelDeltaPercentage(value: number);
  43463. /**
  43464. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  43465. */
  43466. zoomOnFactor: number;
  43467. /**
  43468. * Defines a screen offset for the camera position.
  43469. */
  43470. targetScreenOffset: Vector2;
  43471. /**
  43472. * Allows the camera to be completely reversed.
  43473. * If false the camera can not arrive upside down.
  43474. */
  43475. allowUpsideDown: boolean;
  43476. /**
  43477. * Define if double tap/click is used to restore the previously saved state of the camera.
  43478. */
  43479. useInputToRestoreState: boolean;
  43480. /** @hidden */
  43481. _viewMatrix: Matrix;
  43482. /** @hidden */
  43483. _useCtrlForPanning: boolean;
  43484. /** @hidden */
  43485. _panningMouseButton: number;
  43486. /**
  43487. * Defines the input associated to the camera.
  43488. */
  43489. inputs: ArcRotateCameraInputsManager;
  43490. /** @hidden */
  43491. _reset: () => void;
  43492. /**
  43493. * Defines the allowed panning axis.
  43494. */
  43495. panningAxis: Vector3;
  43496. protected _localDirection: Vector3;
  43497. protected _transformedDirection: Vector3;
  43498. private _bouncingBehavior;
  43499. /**
  43500. * Gets the bouncing behavior of the camera if it has been enabled.
  43501. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43502. */
  43503. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43504. /**
  43505. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43506. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43507. */
  43508. get useBouncingBehavior(): boolean;
  43509. set useBouncingBehavior(value: boolean);
  43510. private _framingBehavior;
  43511. /**
  43512. * Gets the framing behavior of the camera if it has been enabled.
  43513. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43514. */
  43515. get framingBehavior(): Nullable<FramingBehavior>;
  43516. /**
  43517. * Defines if the framing behavior of the camera is enabled on the camera.
  43518. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43519. */
  43520. get useFramingBehavior(): boolean;
  43521. set useFramingBehavior(value: boolean);
  43522. private _autoRotationBehavior;
  43523. /**
  43524. * Gets the auto rotation behavior of the camera if it has been enabled.
  43525. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43526. */
  43527. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43528. /**
  43529. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43530. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43531. */
  43532. get useAutoRotationBehavior(): boolean;
  43533. set useAutoRotationBehavior(value: boolean);
  43534. /**
  43535. * Observable triggered when the mesh target has been changed on the camera.
  43536. */
  43537. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43538. /**
  43539. * Event raised when the camera is colliding with a mesh.
  43540. */
  43541. onCollide: (collidedMesh: AbstractMesh) => void;
  43542. /**
  43543. * Defines whether the camera should check collision with the objects oh the scene.
  43544. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43545. */
  43546. checkCollisions: boolean;
  43547. /**
  43548. * Defines the collision radius of the camera.
  43549. * This simulates a sphere around the camera.
  43550. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43551. */
  43552. collisionRadius: Vector3;
  43553. protected _collider: Collider;
  43554. protected _previousPosition: Vector3;
  43555. protected _collisionVelocity: Vector3;
  43556. protected _newPosition: Vector3;
  43557. protected _previousAlpha: number;
  43558. protected _previousBeta: number;
  43559. protected _previousRadius: number;
  43560. protected _collisionTriggered: boolean;
  43561. protected _targetBoundingCenter: Nullable<Vector3>;
  43562. private _computationVector;
  43563. /**
  43564. * Instantiates a new ArcRotateCamera in a given scene
  43565. * @param name Defines the name of the camera
  43566. * @param alpha Defines the camera rotation along the logitudinal axis
  43567. * @param beta Defines the camera rotation along the latitudinal axis
  43568. * @param radius Defines the camera distance from its target
  43569. * @param target Defines the camera target
  43570. * @param scene Defines the scene the camera belongs to
  43571. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43572. */
  43573. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43574. /** @hidden */
  43575. _initCache(): void;
  43576. /** @hidden */
  43577. _updateCache(ignoreParentClass?: boolean): void;
  43578. protected _getTargetPosition(): Vector3;
  43579. private _storedAlpha;
  43580. private _storedBeta;
  43581. private _storedRadius;
  43582. private _storedTarget;
  43583. private _storedTargetScreenOffset;
  43584. /**
  43585. * Stores the current state of the camera (alpha, beta, radius and target)
  43586. * @returns the camera itself
  43587. */
  43588. storeState(): Camera;
  43589. /**
  43590. * @hidden
  43591. * Restored camera state. You must call storeState() first
  43592. */
  43593. _restoreStateValues(): boolean;
  43594. /** @hidden */
  43595. _isSynchronizedViewMatrix(): boolean;
  43596. /**
  43597. * Attached controls to the current camera.
  43598. * @param element Defines the element the controls should be listened from
  43599. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43600. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43601. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43602. */
  43603. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43604. /**
  43605. * Detach the current controls from the camera.
  43606. * The camera will stop reacting to inputs.
  43607. * @param element Defines the element to stop listening the inputs from
  43608. */
  43609. detachControl(element: HTMLElement): void;
  43610. /** @hidden */
  43611. _checkInputs(): void;
  43612. protected _checkLimits(): void;
  43613. /**
  43614. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43615. */
  43616. rebuildAnglesAndRadius(): void;
  43617. /**
  43618. * Use a position to define the current camera related information like alpha, beta and radius
  43619. * @param position Defines the position to set the camera at
  43620. */
  43621. setPosition(position: Vector3): void;
  43622. /**
  43623. * Defines the target the camera should look at.
  43624. * This will automatically adapt alpha beta and radius to fit within the new target.
  43625. * @param target Defines the new target as a Vector or a mesh
  43626. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43627. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43628. */
  43629. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43630. /** @hidden */
  43631. _getViewMatrix(): Matrix;
  43632. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43633. /**
  43634. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43635. * @param meshes Defines the mesh to zoom on
  43636. * @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)
  43637. */
  43638. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43639. /**
  43640. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43641. * The target will be changed but the radius
  43642. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43643. * @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)
  43644. */
  43645. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43646. min: Vector3;
  43647. max: Vector3;
  43648. distance: number;
  43649. }, doNotUpdateMaxZ?: boolean): void;
  43650. /**
  43651. * @override
  43652. * Override Camera.createRigCamera
  43653. */
  43654. createRigCamera(name: string, cameraIndex: number): Camera;
  43655. /**
  43656. * @hidden
  43657. * @override
  43658. * Override Camera._updateRigCameras
  43659. */
  43660. _updateRigCameras(): void;
  43661. /**
  43662. * Destroy the camera and release the current resources hold by it.
  43663. */
  43664. dispose(): void;
  43665. /**
  43666. * Gets the current object class name.
  43667. * @return the class name
  43668. */
  43669. getClassName(): string;
  43670. }
  43671. }
  43672. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  43673. import { Behavior } from "babylonjs/Behaviors/behavior";
  43674. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43675. /**
  43676. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43677. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43678. */
  43679. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43680. /**
  43681. * Gets the name of the behavior.
  43682. */
  43683. get name(): string;
  43684. private _zoomStopsAnimation;
  43685. private _idleRotationSpeed;
  43686. private _idleRotationWaitTime;
  43687. private _idleRotationSpinupTime;
  43688. /**
  43689. * Sets the flag that indicates if user zooming should stop animation.
  43690. */
  43691. set zoomStopsAnimation(flag: boolean);
  43692. /**
  43693. * Gets the flag that indicates if user zooming should stop animation.
  43694. */
  43695. get zoomStopsAnimation(): boolean;
  43696. /**
  43697. * Sets the default speed at which the camera rotates around the model.
  43698. */
  43699. set idleRotationSpeed(speed: number);
  43700. /**
  43701. * Gets the default speed at which the camera rotates around the model.
  43702. */
  43703. get idleRotationSpeed(): number;
  43704. /**
  43705. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43706. */
  43707. set idleRotationWaitTime(time: number);
  43708. /**
  43709. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43710. */
  43711. get idleRotationWaitTime(): number;
  43712. /**
  43713. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43714. */
  43715. set idleRotationSpinupTime(time: number);
  43716. /**
  43717. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43718. */
  43719. get idleRotationSpinupTime(): number;
  43720. /**
  43721. * Gets a value indicating if the camera is currently rotating because of this behavior
  43722. */
  43723. get rotationInProgress(): boolean;
  43724. private _onPrePointerObservableObserver;
  43725. private _onAfterCheckInputsObserver;
  43726. private _attachedCamera;
  43727. private _isPointerDown;
  43728. private _lastFrameTime;
  43729. private _lastInteractionTime;
  43730. private _cameraRotationSpeed;
  43731. /**
  43732. * Initializes the behavior.
  43733. */
  43734. init(): void;
  43735. /**
  43736. * Attaches the behavior to its arc rotate camera.
  43737. * @param camera Defines the camera to attach the behavior to
  43738. */
  43739. attach(camera: ArcRotateCamera): void;
  43740. /**
  43741. * Detaches the behavior from its current arc rotate camera.
  43742. */
  43743. detach(): void;
  43744. /**
  43745. * Returns true if user is scrolling.
  43746. * @return true if user is scrolling.
  43747. */
  43748. private _userIsZooming;
  43749. private _lastFrameRadius;
  43750. private _shouldAnimationStopForInteraction;
  43751. /**
  43752. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43753. */
  43754. private _applyUserInteraction;
  43755. private _userIsMoving;
  43756. }
  43757. }
  43758. declare module "babylonjs/Behaviors/Cameras/index" {
  43759. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43760. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43761. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  43762. }
  43763. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  43764. import { Mesh } from "babylonjs/Meshes/mesh";
  43765. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43766. import { Behavior } from "babylonjs/Behaviors/behavior";
  43767. /**
  43768. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43769. */
  43770. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43771. private ui;
  43772. /**
  43773. * The name of the behavior
  43774. */
  43775. name: string;
  43776. /**
  43777. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43778. */
  43779. distanceAwayFromFace: number;
  43780. /**
  43781. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43782. */
  43783. distanceAwayFromBottomOfFace: number;
  43784. private _faceVectors;
  43785. private _target;
  43786. private _scene;
  43787. private _onRenderObserver;
  43788. private _tmpMatrix;
  43789. private _tmpVector;
  43790. /**
  43791. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43792. * @param ui The transform node that should be attched to the mesh
  43793. */
  43794. constructor(ui: TransformNode);
  43795. /**
  43796. * Initializes the behavior
  43797. */
  43798. init(): void;
  43799. private _closestFace;
  43800. private _zeroVector;
  43801. private _lookAtTmpMatrix;
  43802. private _lookAtToRef;
  43803. /**
  43804. * Attaches the AttachToBoxBehavior to the passed in mesh
  43805. * @param target The mesh that the specified node will be attached to
  43806. */
  43807. attach(target: Mesh): void;
  43808. /**
  43809. * Detaches the behavior from the mesh
  43810. */
  43811. detach(): void;
  43812. }
  43813. }
  43814. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  43815. import { Behavior } from "babylonjs/Behaviors/behavior";
  43816. import { Mesh } from "babylonjs/Meshes/mesh";
  43817. /**
  43818. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43819. */
  43820. export class FadeInOutBehavior implements Behavior<Mesh> {
  43821. /**
  43822. * Time in milliseconds to delay before fading in (Default: 0)
  43823. */
  43824. delay: number;
  43825. /**
  43826. * Time in milliseconds for the mesh to fade in (Default: 300)
  43827. */
  43828. fadeInTime: number;
  43829. private _millisecondsPerFrame;
  43830. private _hovered;
  43831. private _hoverValue;
  43832. private _ownerNode;
  43833. /**
  43834. * Instatiates the FadeInOutBehavior
  43835. */
  43836. constructor();
  43837. /**
  43838. * The name of the behavior
  43839. */
  43840. get name(): string;
  43841. /**
  43842. * Initializes the behavior
  43843. */
  43844. init(): void;
  43845. /**
  43846. * Attaches the fade behavior on the passed in mesh
  43847. * @param ownerNode The mesh that will be faded in/out once attached
  43848. */
  43849. attach(ownerNode: Mesh): void;
  43850. /**
  43851. * Detaches the behavior from the mesh
  43852. */
  43853. detach(): void;
  43854. /**
  43855. * Triggers the mesh to begin fading in or out
  43856. * @param value if the object should fade in or out (true to fade in)
  43857. */
  43858. fadeIn(value: boolean): void;
  43859. private _update;
  43860. private _setAllVisibility;
  43861. }
  43862. }
  43863. declare module "babylonjs/Misc/pivotTools" {
  43864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43865. /**
  43866. * Class containing a set of static utilities functions for managing Pivots
  43867. * @hidden
  43868. */
  43869. export class PivotTools {
  43870. private static _PivotCached;
  43871. private static _OldPivotPoint;
  43872. private static _PivotTranslation;
  43873. private static _PivotTmpVector;
  43874. /** @hidden */
  43875. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43876. /** @hidden */
  43877. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43878. }
  43879. }
  43880. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  43881. import { Scene } from "babylonjs/scene";
  43882. import { Vector4 } from "babylonjs/Maths/math.vector";
  43883. import { Mesh } from "babylonjs/Meshes/mesh";
  43884. import { Nullable } from "babylonjs/types";
  43885. import { Plane } from "babylonjs/Maths/math.plane";
  43886. /**
  43887. * Class containing static functions to help procedurally build meshes
  43888. */
  43889. export class PlaneBuilder {
  43890. /**
  43891. * Creates a plane mesh
  43892. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43893. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43894. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43895. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43896. * * 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
  43897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43898. * @param name defines the name of the mesh
  43899. * @param options defines the options used to create the mesh
  43900. * @param scene defines the hosting scene
  43901. * @returns the plane mesh
  43902. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43903. */
  43904. static CreatePlane(name: string, options: {
  43905. size?: number;
  43906. width?: number;
  43907. height?: number;
  43908. sideOrientation?: number;
  43909. frontUVs?: Vector4;
  43910. backUVs?: Vector4;
  43911. updatable?: boolean;
  43912. sourcePlane?: Plane;
  43913. }, scene?: Nullable<Scene>): Mesh;
  43914. }
  43915. }
  43916. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  43917. import { Behavior } from "babylonjs/Behaviors/behavior";
  43918. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43919. import { Observable } from "babylonjs/Misc/observable";
  43920. import { Vector3 } from "babylonjs/Maths/math.vector";
  43921. import { Ray } from "babylonjs/Culling/ray";
  43922. import "babylonjs/Meshes/Builders/planeBuilder";
  43923. /**
  43924. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43925. */
  43926. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43927. private static _AnyMouseID;
  43928. /**
  43929. * Abstract mesh the behavior is set on
  43930. */
  43931. attachedNode: AbstractMesh;
  43932. private _dragPlane;
  43933. private _scene;
  43934. private _pointerObserver;
  43935. private _beforeRenderObserver;
  43936. private static _planeScene;
  43937. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43938. /**
  43939. * 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)
  43940. */
  43941. maxDragAngle: number;
  43942. /**
  43943. * @hidden
  43944. */
  43945. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43946. /**
  43947. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43948. */
  43949. currentDraggingPointerID: number;
  43950. /**
  43951. * The last position where the pointer hit the drag plane in world space
  43952. */
  43953. lastDragPosition: Vector3;
  43954. /**
  43955. * If the behavior is currently in a dragging state
  43956. */
  43957. dragging: boolean;
  43958. /**
  43959. * 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)
  43960. */
  43961. dragDeltaRatio: number;
  43962. /**
  43963. * If the drag plane orientation should be updated during the dragging (Default: true)
  43964. */
  43965. updateDragPlane: boolean;
  43966. private _debugMode;
  43967. private _moving;
  43968. /**
  43969. * Fires each time the attached mesh is dragged with the pointer
  43970. * * delta between last drag position and current drag position in world space
  43971. * * dragDistance along the drag axis
  43972. * * dragPlaneNormal normal of the current drag plane used during the drag
  43973. * * dragPlanePoint in world space where the drag intersects the drag plane
  43974. */
  43975. onDragObservable: Observable<{
  43976. delta: Vector3;
  43977. dragPlanePoint: Vector3;
  43978. dragPlaneNormal: Vector3;
  43979. dragDistance: number;
  43980. pointerId: number;
  43981. }>;
  43982. /**
  43983. * Fires each time a drag begins (eg. mouse down on mesh)
  43984. */
  43985. onDragStartObservable: Observable<{
  43986. dragPlanePoint: Vector3;
  43987. pointerId: number;
  43988. }>;
  43989. /**
  43990. * Fires each time a drag ends (eg. mouse release after drag)
  43991. */
  43992. onDragEndObservable: Observable<{
  43993. dragPlanePoint: Vector3;
  43994. pointerId: number;
  43995. }>;
  43996. /**
  43997. * If the attached mesh should be moved when dragged
  43998. */
  43999. moveAttached: boolean;
  44000. /**
  44001. * If the drag behavior will react to drag events (Default: true)
  44002. */
  44003. enabled: boolean;
  44004. /**
  44005. * If pointer events should start and release the drag (Default: true)
  44006. */
  44007. startAndReleaseDragOnPointerEvents: boolean;
  44008. /**
  44009. * If camera controls should be detached during the drag
  44010. */
  44011. detachCameraControls: boolean;
  44012. /**
  44013. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  44014. */
  44015. useObjectOrientationForDragging: boolean;
  44016. private _options;
  44017. /**
  44018. * Gets the options used by the behavior
  44019. */
  44020. get options(): {
  44021. dragAxis?: Vector3;
  44022. dragPlaneNormal?: Vector3;
  44023. };
  44024. /**
  44025. * Sets the options used by the behavior
  44026. */
  44027. set options(options: {
  44028. dragAxis?: Vector3;
  44029. dragPlaneNormal?: Vector3;
  44030. });
  44031. /**
  44032. * Creates a pointer drag behavior that can be attached to a mesh
  44033. * @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)
  44034. */
  44035. constructor(options?: {
  44036. dragAxis?: Vector3;
  44037. dragPlaneNormal?: Vector3;
  44038. });
  44039. /**
  44040. * Predicate to determine if it is valid to move the object to a new position when it is moved
  44041. */
  44042. validateDrag: (targetPosition: Vector3) => boolean;
  44043. /**
  44044. * The name of the behavior
  44045. */
  44046. get name(): string;
  44047. /**
  44048. * Initializes the behavior
  44049. */
  44050. init(): void;
  44051. private _tmpVector;
  44052. private _alternatePickedPoint;
  44053. private _worldDragAxis;
  44054. private _targetPosition;
  44055. private _attachedElement;
  44056. /**
  44057. * Attaches the drag behavior the passed in mesh
  44058. * @param ownerNode The mesh that will be dragged around once attached
  44059. * @param predicate Predicate to use for pick filtering
  44060. */
  44061. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  44062. /**
  44063. * Force relase the drag action by code.
  44064. */
  44065. releaseDrag(): void;
  44066. private _startDragRay;
  44067. private _lastPointerRay;
  44068. /**
  44069. * Simulates the start of a pointer drag event on the behavior
  44070. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  44071. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  44072. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  44073. */
  44074. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  44075. private _startDrag;
  44076. private _dragDelta;
  44077. private _moveDrag;
  44078. private _pickWithRayOnDragPlane;
  44079. private _pointA;
  44080. private _pointB;
  44081. private _pointC;
  44082. private _lineA;
  44083. private _lineB;
  44084. private _localAxis;
  44085. private _lookAt;
  44086. private _updateDragPlanePosition;
  44087. /**
  44088. * Detaches the behavior from the mesh
  44089. */
  44090. detach(): void;
  44091. }
  44092. }
  44093. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  44094. import { Mesh } from "babylonjs/Meshes/mesh";
  44095. import { Behavior } from "babylonjs/Behaviors/behavior";
  44096. /**
  44097. * A behavior that when attached to a mesh will allow the mesh to be scaled
  44098. */
  44099. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  44100. private _dragBehaviorA;
  44101. private _dragBehaviorB;
  44102. private _startDistance;
  44103. private _initialScale;
  44104. private _targetScale;
  44105. private _ownerNode;
  44106. private _sceneRenderObserver;
  44107. /**
  44108. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  44109. */
  44110. constructor();
  44111. /**
  44112. * The name of the behavior
  44113. */
  44114. get name(): string;
  44115. /**
  44116. * Initializes the behavior
  44117. */
  44118. init(): void;
  44119. private _getCurrentDistance;
  44120. /**
  44121. * Attaches the scale behavior the passed in mesh
  44122. * @param ownerNode The mesh that will be scaled around once attached
  44123. */
  44124. attach(ownerNode: Mesh): void;
  44125. /**
  44126. * Detaches the behavior from the mesh
  44127. */
  44128. detach(): void;
  44129. }
  44130. }
  44131. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  44132. import { Behavior } from "babylonjs/Behaviors/behavior";
  44133. import { Mesh } from "babylonjs/Meshes/mesh";
  44134. import { Observable } from "babylonjs/Misc/observable";
  44135. /**
  44136. * 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
  44137. */
  44138. export class SixDofDragBehavior implements Behavior<Mesh> {
  44139. private static _virtualScene;
  44140. private _ownerNode;
  44141. private _sceneRenderObserver;
  44142. private _scene;
  44143. private _targetPosition;
  44144. private _virtualOriginMesh;
  44145. private _virtualDragMesh;
  44146. private _pointerObserver;
  44147. private _moving;
  44148. private _startingOrientation;
  44149. private _attachedElement;
  44150. /**
  44151. * 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)
  44152. */
  44153. private zDragFactor;
  44154. /**
  44155. * If the object should rotate to face the drag origin
  44156. */
  44157. rotateDraggedObject: boolean;
  44158. /**
  44159. * If the behavior is currently in a dragging state
  44160. */
  44161. dragging: boolean;
  44162. /**
  44163. * 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)
  44164. */
  44165. dragDeltaRatio: number;
  44166. /**
  44167. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  44168. */
  44169. currentDraggingPointerID: number;
  44170. /**
  44171. * If camera controls should be detached during the drag
  44172. */
  44173. detachCameraControls: boolean;
  44174. /**
  44175. * Fires each time a drag starts
  44176. */
  44177. onDragStartObservable: Observable<{}>;
  44178. /**
  44179. * Fires each time a drag ends (eg. mouse release after drag)
  44180. */
  44181. onDragEndObservable: Observable<{}>;
  44182. /**
  44183. * 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
  44184. */
  44185. constructor();
  44186. /**
  44187. * The name of the behavior
  44188. */
  44189. get name(): string;
  44190. /**
  44191. * Initializes the behavior
  44192. */
  44193. init(): void;
  44194. /**
  44195. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  44196. */
  44197. private get _pointerCamera();
  44198. /**
  44199. * Attaches the scale behavior the passed in mesh
  44200. * @param ownerNode The mesh that will be scaled around once attached
  44201. */
  44202. attach(ownerNode: Mesh): void;
  44203. /**
  44204. * Detaches the behavior from the mesh
  44205. */
  44206. detach(): void;
  44207. }
  44208. }
  44209. declare module "babylonjs/Behaviors/Meshes/index" {
  44210. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  44211. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  44212. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  44213. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44214. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44215. }
  44216. declare module "babylonjs/Behaviors/index" {
  44217. export * from "babylonjs/Behaviors/behavior";
  44218. export * from "babylonjs/Behaviors/Cameras/index";
  44219. export * from "babylonjs/Behaviors/Meshes/index";
  44220. }
  44221. declare module "babylonjs/Bones/boneIKController" {
  44222. import { Bone } from "babylonjs/Bones/bone";
  44223. import { Vector3 } from "babylonjs/Maths/math.vector";
  44224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44225. import { Nullable } from "babylonjs/types";
  44226. /**
  44227. * Class used to apply inverse kinematics to bones
  44228. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  44229. */
  44230. export class BoneIKController {
  44231. private static _tmpVecs;
  44232. private static _tmpQuat;
  44233. private static _tmpMats;
  44234. /**
  44235. * Gets or sets the target mesh
  44236. */
  44237. targetMesh: AbstractMesh;
  44238. /** Gets or sets the mesh used as pole */
  44239. poleTargetMesh: AbstractMesh;
  44240. /**
  44241. * Gets or sets the bone used as pole
  44242. */
  44243. poleTargetBone: Nullable<Bone>;
  44244. /**
  44245. * Gets or sets the target position
  44246. */
  44247. targetPosition: Vector3;
  44248. /**
  44249. * Gets or sets the pole target position
  44250. */
  44251. poleTargetPosition: Vector3;
  44252. /**
  44253. * Gets or sets the pole target local offset
  44254. */
  44255. poleTargetLocalOffset: Vector3;
  44256. /**
  44257. * Gets or sets the pole angle
  44258. */
  44259. poleAngle: number;
  44260. /**
  44261. * Gets or sets the mesh associated with the controller
  44262. */
  44263. mesh: AbstractMesh;
  44264. /**
  44265. * 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)
  44266. */
  44267. slerpAmount: number;
  44268. private _bone1Quat;
  44269. private _bone1Mat;
  44270. private _bone2Ang;
  44271. private _bone1;
  44272. private _bone2;
  44273. private _bone1Length;
  44274. private _bone2Length;
  44275. private _maxAngle;
  44276. private _maxReach;
  44277. private _rightHandedSystem;
  44278. private _bendAxis;
  44279. private _slerping;
  44280. private _adjustRoll;
  44281. /**
  44282. * Gets or sets maximum allowed angle
  44283. */
  44284. get maxAngle(): number;
  44285. set maxAngle(value: number);
  44286. /**
  44287. * Creates a new BoneIKController
  44288. * @param mesh defines the mesh to control
  44289. * @param bone defines the bone to control
  44290. * @param options defines options to set up the controller
  44291. */
  44292. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  44293. targetMesh?: AbstractMesh;
  44294. poleTargetMesh?: AbstractMesh;
  44295. poleTargetBone?: Bone;
  44296. poleTargetLocalOffset?: Vector3;
  44297. poleAngle?: number;
  44298. bendAxis?: Vector3;
  44299. maxAngle?: number;
  44300. slerpAmount?: number;
  44301. });
  44302. private _setMaxAngle;
  44303. /**
  44304. * Force the controller to update the bones
  44305. */
  44306. update(): void;
  44307. }
  44308. }
  44309. declare module "babylonjs/Bones/boneLookController" {
  44310. import { Vector3 } from "babylonjs/Maths/math.vector";
  44311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44312. import { Bone } from "babylonjs/Bones/bone";
  44313. import { Space } from "babylonjs/Maths/math.axis";
  44314. /**
  44315. * Class used to make a bone look toward a point in space
  44316. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  44317. */
  44318. export class BoneLookController {
  44319. private static _tmpVecs;
  44320. private static _tmpQuat;
  44321. private static _tmpMats;
  44322. /**
  44323. * The target Vector3 that the bone will look at
  44324. */
  44325. target: Vector3;
  44326. /**
  44327. * The mesh that the bone is attached to
  44328. */
  44329. mesh: AbstractMesh;
  44330. /**
  44331. * The bone that will be looking to the target
  44332. */
  44333. bone: Bone;
  44334. /**
  44335. * The up axis of the coordinate system that is used when the bone is rotated
  44336. */
  44337. upAxis: Vector3;
  44338. /**
  44339. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  44340. */
  44341. upAxisSpace: Space;
  44342. /**
  44343. * Used to make an adjustment to the yaw of the bone
  44344. */
  44345. adjustYaw: number;
  44346. /**
  44347. * Used to make an adjustment to the pitch of the bone
  44348. */
  44349. adjustPitch: number;
  44350. /**
  44351. * Used to make an adjustment to the roll of the bone
  44352. */
  44353. adjustRoll: number;
  44354. /**
  44355. * 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)
  44356. */
  44357. slerpAmount: number;
  44358. private _minYaw;
  44359. private _maxYaw;
  44360. private _minPitch;
  44361. private _maxPitch;
  44362. private _minYawSin;
  44363. private _minYawCos;
  44364. private _maxYawSin;
  44365. private _maxYawCos;
  44366. private _midYawConstraint;
  44367. private _minPitchTan;
  44368. private _maxPitchTan;
  44369. private _boneQuat;
  44370. private _slerping;
  44371. private _transformYawPitch;
  44372. private _transformYawPitchInv;
  44373. private _firstFrameSkipped;
  44374. private _yawRange;
  44375. private _fowardAxis;
  44376. /**
  44377. * Gets or sets the minimum yaw angle that the bone can look to
  44378. */
  44379. get minYaw(): number;
  44380. set minYaw(value: number);
  44381. /**
  44382. * Gets or sets the maximum yaw angle that the bone can look to
  44383. */
  44384. get maxYaw(): number;
  44385. set maxYaw(value: number);
  44386. /**
  44387. * Gets or sets the minimum pitch angle that the bone can look to
  44388. */
  44389. get minPitch(): number;
  44390. set minPitch(value: number);
  44391. /**
  44392. * Gets or sets the maximum pitch angle that the bone can look to
  44393. */
  44394. get maxPitch(): number;
  44395. set maxPitch(value: number);
  44396. /**
  44397. * Create a BoneLookController
  44398. * @param mesh the mesh that the bone belongs to
  44399. * @param bone the bone that will be looking to the target
  44400. * @param target the target Vector3 to look at
  44401. * @param options optional settings:
  44402. * * maxYaw: the maximum angle the bone will yaw to
  44403. * * minYaw: the minimum angle the bone will yaw to
  44404. * * maxPitch: the maximum angle the bone will pitch to
  44405. * * minPitch: the minimum angle the bone will yaw to
  44406. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  44407. * * upAxis: the up axis of the coordinate system
  44408. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  44409. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  44410. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  44411. * * adjustYaw: used to make an adjustment to the yaw of the bone
  44412. * * adjustPitch: used to make an adjustment to the pitch of the bone
  44413. * * adjustRoll: used to make an adjustment to the roll of the bone
  44414. **/
  44415. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  44416. maxYaw?: number;
  44417. minYaw?: number;
  44418. maxPitch?: number;
  44419. minPitch?: number;
  44420. slerpAmount?: number;
  44421. upAxis?: Vector3;
  44422. upAxisSpace?: Space;
  44423. yawAxis?: Vector3;
  44424. pitchAxis?: Vector3;
  44425. adjustYaw?: number;
  44426. adjustPitch?: number;
  44427. adjustRoll?: number;
  44428. });
  44429. /**
  44430. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  44431. */
  44432. update(): void;
  44433. private _getAngleDiff;
  44434. private _getAngleBetween;
  44435. private _isAngleBetween;
  44436. }
  44437. }
  44438. declare module "babylonjs/Bones/index" {
  44439. export * from "babylonjs/Bones/bone";
  44440. export * from "babylonjs/Bones/boneIKController";
  44441. export * from "babylonjs/Bones/boneLookController";
  44442. export * from "babylonjs/Bones/skeleton";
  44443. }
  44444. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  44445. import { Nullable } from "babylonjs/types";
  44446. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44447. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44448. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  44449. /**
  44450. * Manage the gamepad inputs to control an arc rotate camera.
  44451. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44452. */
  44453. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  44454. /**
  44455. * Defines the camera the input is attached to.
  44456. */
  44457. camera: ArcRotateCamera;
  44458. /**
  44459. * Defines the gamepad the input is gathering event from.
  44460. */
  44461. gamepad: Nullable<Gamepad>;
  44462. /**
  44463. * Defines the gamepad rotation sensiblity.
  44464. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44465. */
  44466. gamepadRotationSensibility: number;
  44467. /**
  44468. * Defines the gamepad move sensiblity.
  44469. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44470. */
  44471. gamepadMoveSensibility: number;
  44472. private _yAxisScale;
  44473. /**
  44474. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44475. */
  44476. get invertYAxis(): boolean;
  44477. set invertYAxis(value: boolean);
  44478. private _onGamepadConnectedObserver;
  44479. private _onGamepadDisconnectedObserver;
  44480. /**
  44481. * Attach the input controls to a specific dom element to get the input from.
  44482. * @param element Defines the element the controls should be listened from
  44483. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44484. */
  44485. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44486. /**
  44487. * Detach the current controls from the specified dom element.
  44488. * @param element Defines the element to stop listening the inputs from
  44489. */
  44490. detachControl(element: Nullable<HTMLElement>): void;
  44491. /**
  44492. * Update the current camera state depending on the inputs that have been used this frame.
  44493. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44494. */
  44495. checkInputs(): void;
  44496. /**
  44497. * Gets the class name of the current intput.
  44498. * @returns the class name
  44499. */
  44500. getClassName(): string;
  44501. /**
  44502. * Get the friendly name associated with the input class.
  44503. * @returns the input friendly name
  44504. */
  44505. getSimpleName(): string;
  44506. }
  44507. }
  44508. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  44509. import { Nullable } from "babylonjs/types";
  44510. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44511. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44512. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44513. interface ArcRotateCameraInputsManager {
  44514. /**
  44515. * Add orientation input support to the input manager.
  44516. * @returns the current input manager
  44517. */
  44518. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  44519. }
  44520. }
  44521. /**
  44522. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  44523. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44524. */
  44525. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  44526. /**
  44527. * Defines the camera the input is attached to.
  44528. */
  44529. camera: ArcRotateCamera;
  44530. /**
  44531. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  44532. */
  44533. alphaCorrection: number;
  44534. /**
  44535. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  44536. */
  44537. gammaCorrection: number;
  44538. private _alpha;
  44539. private _gamma;
  44540. private _dirty;
  44541. private _deviceOrientationHandler;
  44542. /**
  44543. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  44544. */
  44545. constructor();
  44546. /**
  44547. * Attach the input controls to a specific dom element to get the input from.
  44548. * @param element Defines the element the controls should be listened from
  44549. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44550. */
  44551. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44552. /** @hidden */
  44553. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44554. /**
  44555. * Update the current camera state depending on the inputs that have been used this frame.
  44556. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44557. */
  44558. checkInputs(): void;
  44559. /**
  44560. * Detach the current controls from the specified dom element.
  44561. * @param element Defines the element to stop listening the inputs from
  44562. */
  44563. detachControl(element: Nullable<HTMLElement>): void;
  44564. /**
  44565. * Gets the class name of the current intput.
  44566. * @returns the class name
  44567. */
  44568. getClassName(): string;
  44569. /**
  44570. * Get the friendly name associated with the input class.
  44571. * @returns the input friendly name
  44572. */
  44573. getSimpleName(): string;
  44574. }
  44575. }
  44576. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  44577. import { Nullable } from "babylonjs/types";
  44578. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44579. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44580. /**
  44581. * Listen to mouse events to control the camera.
  44582. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44583. */
  44584. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44585. /**
  44586. * Defines the camera the input is attached to.
  44587. */
  44588. camera: FlyCamera;
  44589. /**
  44590. * Defines if touch is enabled. (Default is true.)
  44591. */
  44592. touchEnabled: boolean;
  44593. /**
  44594. * Defines the buttons associated with the input to handle camera rotation.
  44595. */
  44596. buttons: number[];
  44597. /**
  44598. * Assign buttons for Yaw control.
  44599. */
  44600. buttonsYaw: number[];
  44601. /**
  44602. * Assign buttons for Pitch control.
  44603. */
  44604. buttonsPitch: number[];
  44605. /**
  44606. * Assign buttons for Roll control.
  44607. */
  44608. buttonsRoll: number[];
  44609. /**
  44610. * Detect if any button is being pressed while mouse is moved.
  44611. * -1 = Mouse locked.
  44612. * 0 = Left button.
  44613. * 1 = Middle Button.
  44614. * 2 = Right Button.
  44615. */
  44616. activeButton: number;
  44617. /**
  44618. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44619. * Higher values reduce its sensitivity.
  44620. */
  44621. angularSensibility: number;
  44622. private _mousemoveCallback;
  44623. private _observer;
  44624. private _rollObserver;
  44625. private previousPosition;
  44626. private noPreventDefault;
  44627. private element;
  44628. /**
  44629. * Listen to mouse events to control the camera.
  44630. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44631. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44632. */
  44633. constructor(touchEnabled?: boolean);
  44634. /**
  44635. * Attach the mouse control to the HTML DOM element.
  44636. * @param element Defines the element that listens to the input events.
  44637. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44638. */
  44639. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44640. /**
  44641. * Detach the current controls from the specified dom element.
  44642. * @param element Defines the element to stop listening the inputs from
  44643. */
  44644. detachControl(element: Nullable<HTMLElement>): void;
  44645. /**
  44646. * Gets the class name of the current input.
  44647. * @returns the class name.
  44648. */
  44649. getClassName(): string;
  44650. /**
  44651. * Get the friendly name associated with the input class.
  44652. * @returns the input's friendly name.
  44653. */
  44654. getSimpleName(): string;
  44655. private _pointerInput;
  44656. private _onMouseMove;
  44657. /**
  44658. * Rotate camera by mouse offset.
  44659. */
  44660. private rotateCamera;
  44661. }
  44662. }
  44663. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  44664. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44665. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44666. /**
  44667. * Default Inputs manager for the FlyCamera.
  44668. * It groups all the default supported inputs for ease of use.
  44669. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44670. */
  44671. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44672. /**
  44673. * Instantiates a new FlyCameraInputsManager.
  44674. * @param camera Defines the camera the inputs belong to.
  44675. */
  44676. constructor(camera: FlyCamera);
  44677. /**
  44678. * Add keyboard input support to the input manager.
  44679. * @returns the new FlyCameraKeyboardMoveInput().
  44680. */
  44681. addKeyboard(): FlyCameraInputsManager;
  44682. /**
  44683. * Add mouse input support to the input manager.
  44684. * @param touchEnabled Enable touch screen support.
  44685. * @returns the new FlyCameraMouseInput().
  44686. */
  44687. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44688. }
  44689. }
  44690. declare module "babylonjs/Cameras/flyCamera" {
  44691. import { Scene } from "babylonjs/scene";
  44692. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  44693. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44694. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44695. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  44696. /**
  44697. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44698. * such as in a 3D Space Shooter or a Flight Simulator.
  44699. */
  44700. export class FlyCamera extends TargetCamera {
  44701. /**
  44702. * Define the collision ellipsoid of the camera.
  44703. * This is helpful for simulating a camera body, like a player's body.
  44704. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44705. */
  44706. ellipsoid: Vector3;
  44707. /**
  44708. * Define an offset for the position of the ellipsoid around the camera.
  44709. * This can be helpful if the camera is attached away from the player's body center,
  44710. * such as at its head.
  44711. */
  44712. ellipsoidOffset: Vector3;
  44713. /**
  44714. * Enable or disable collisions of the camera with the rest of the scene objects.
  44715. */
  44716. checkCollisions: boolean;
  44717. /**
  44718. * Enable or disable gravity on the camera.
  44719. */
  44720. applyGravity: boolean;
  44721. /**
  44722. * Define the current direction the camera is moving to.
  44723. */
  44724. cameraDirection: Vector3;
  44725. /**
  44726. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44727. * This overrides and empties cameraRotation.
  44728. */
  44729. rotationQuaternion: Quaternion;
  44730. /**
  44731. * Track Roll to maintain the wanted Rolling when looking around.
  44732. */
  44733. _trackRoll: number;
  44734. /**
  44735. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44736. */
  44737. rollCorrect: number;
  44738. /**
  44739. * Mimic a banked turn, Rolling the camera when Yawing.
  44740. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44741. */
  44742. bankedTurn: boolean;
  44743. /**
  44744. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44745. */
  44746. bankedTurnLimit: number;
  44747. /**
  44748. * Value of 0 disables the banked Roll.
  44749. * Value of 1 is equal to the Yaw angle in radians.
  44750. */
  44751. bankedTurnMultiplier: number;
  44752. /**
  44753. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44754. */
  44755. inputs: FlyCameraInputsManager;
  44756. /**
  44757. * Gets the input sensibility for mouse input.
  44758. * Higher values reduce sensitivity.
  44759. */
  44760. get angularSensibility(): number;
  44761. /**
  44762. * Sets the input sensibility for a mouse input.
  44763. * Higher values reduce sensitivity.
  44764. */
  44765. set angularSensibility(value: number);
  44766. /**
  44767. * Get the keys for camera movement forward.
  44768. */
  44769. get keysForward(): number[];
  44770. /**
  44771. * Set the keys for camera movement forward.
  44772. */
  44773. set keysForward(value: number[]);
  44774. /**
  44775. * Get the keys for camera movement backward.
  44776. */
  44777. get keysBackward(): number[];
  44778. set keysBackward(value: number[]);
  44779. /**
  44780. * Get the keys for camera movement up.
  44781. */
  44782. get keysUp(): number[];
  44783. /**
  44784. * Set the keys for camera movement up.
  44785. */
  44786. set keysUp(value: number[]);
  44787. /**
  44788. * Get the keys for camera movement down.
  44789. */
  44790. get keysDown(): number[];
  44791. /**
  44792. * Set the keys for camera movement down.
  44793. */
  44794. set keysDown(value: number[]);
  44795. /**
  44796. * Get the keys for camera movement left.
  44797. */
  44798. get keysLeft(): number[];
  44799. /**
  44800. * Set the keys for camera movement left.
  44801. */
  44802. set keysLeft(value: number[]);
  44803. /**
  44804. * Set the keys for camera movement right.
  44805. */
  44806. get keysRight(): number[];
  44807. /**
  44808. * Set the keys for camera movement right.
  44809. */
  44810. set keysRight(value: number[]);
  44811. /**
  44812. * Event raised when the camera collides with a mesh in the scene.
  44813. */
  44814. onCollide: (collidedMesh: AbstractMesh) => void;
  44815. private _collider;
  44816. private _needMoveForGravity;
  44817. private _oldPosition;
  44818. private _diffPosition;
  44819. private _newPosition;
  44820. /** @hidden */
  44821. _localDirection: Vector3;
  44822. /** @hidden */
  44823. _transformedDirection: Vector3;
  44824. /**
  44825. * Instantiates a FlyCamera.
  44826. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44827. * such as in a 3D Space Shooter or a Flight Simulator.
  44828. * @param name Define the name of the camera in the scene.
  44829. * @param position Define the starting position of the camera in the scene.
  44830. * @param scene Define the scene the camera belongs to.
  44831. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44832. */
  44833. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44834. /**
  44835. * Attach a control to the HTML DOM element.
  44836. * @param element Defines the element that listens to the input events.
  44837. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44838. */
  44839. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44840. /**
  44841. * Detach a control from the HTML DOM element.
  44842. * The camera will stop reacting to that input.
  44843. * @param element Defines the element that listens to the input events.
  44844. */
  44845. detachControl(element: HTMLElement): void;
  44846. private _collisionMask;
  44847. /**
  44848. * Get the mask that the camera ignores in collision events.
  44849. */
  44850. get collisionMask(): number;
  44851. /**
  44852. * Set the mask that the camera ignores in collision events.
  44853. */
  44854. set collisionMask(mask: number);
  44855. /** @hidden */
  44856. _collideWithWorld(displacement: Vector3): void;
  44857. /** @hidden */
  44858. private _onCollisionPositionChange;
  44859. /** @hidden */
  44860. _checkInputs(): void;
  44861. /** @hidden */
  44862. _decideIfNeedsToMove(): boolean;
  44863. /** @hidden */
  44864. _updatePosition(): void;
  44865. /**
  44866. * Restore the Roll to its target value at the rate specified.
  44867. * @param rate - Higher means slower restoring.
  44868. * @hidden
  44869. */
  44870. restoreRoll(rate: number): void;
  44871. /**
  44872. * Destroy the camera and release the current resources held by it.
  44873. */
  44874. dispose(): void;
  44875. /**
  44876. * Get the current object class name.
  44877. * @returns the class name.
  44878. */
  44879. getClassName(): string;
  44880. }
  44881. }
  44882. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  44883. import { Nullable } from "babylonjs/types";
  44884. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44885. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44886. /**
  44887. * Listen to keyboard events to control the camera.
  44888. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44889. */
  44890. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44891. /**
  44892. * Defines the camera the input is attached to.
  44893. */
  44894. camera: FlyCamera;
  44895. /**
  44896. * The list of keyboard keys used to control the forward move of the camera.
  44897. */
  44898. keysForward: number[];
  44899. /**
  44900. * The list of keyboard keys used to control the backward move of the camera.
  44901. */
  44902. keysBackward: number[];
  44903. /**
  44904. * The list of keyboard keys used to control the forward move of the camera.
  44905. */
  44906. keysUp: number[];
  44907. /**
  44908. * The list of keyboard keys used to control the backward move of the camera.
  44909. */
  44910. keysDown: number[];
  44911. /**
  44912. * The list of keyboard keys used to control the right strafe move of the camera.
  44913. */
  44914. keysRight: number[];
  44915. /**
  44916. * The list of keyboard keys used to control the left strafe move of the camera.
  44917. */
  44918. keysLeft: number[];
  44919. private _keys;
  44920. private _onCanvasBlurObserver;
  44921. private _onKeyboardObserver;
  44922. private _engine;
  44923. private _scene;
  44924. /**
  44925. * Attach the input controls to a specific dom element to get the input from.
  44926. * @param element Defines the element the controls should be listened from
  44927. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44928. */
  44929. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44930. /**
  44931. * Detach the current controls from the specified dom element.
  44932. * @param element Defines the element to stop listening the inputs from
  44933. */
  44934. detachControl(element: Nullable<HTMLElement>): void;
  44935. /**
  44936. * Gets the class name of the current intput.
  44937. * @returns the class name
  44938. */
  44939. getClassName(): string;
  44940. /** @hidden */
  44941. _onLostFocus(e: FocusEvent): void;
  44942. /**
  44943. * Get the friendly name associated with the input class.
  44944. * @returns the input friendly name
  44945. */
  44946. getSimpleName(): string;
  44947. /**
  44948. * Update the current camera state depending on the inputs that have been used this frame.
  44949. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44950. */
  44951. checkInputs(): void;
  44952. }
  44953. }
  44954. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  44955. import { Nullable } from "babylonjs/types";
  44956. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44957. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44958. /**
  44959. * Manage the mouse wheel inputs to control a follow camera.
  44960. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44961. */
  44962. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44963. /**
  44964. * Defines the camera the input is attached to.
  44965. */
  44966. camera: FollowCamera;
  44967. /**
  44968. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44969. */
  44970. axisControlRadius: boolean;
  44971. /**
  44972. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44973. */
  44974. axisControlHeight: boolean;
  44975. /**
  44976. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44977. */
  44978. axisControlRotation: boolean;
  44979. /**
  44980. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44981. * relation to mouseWheel events.
  44982. */
  44983. wheelPrecision: number;
  44984. /**
  44985. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44986. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44987. */
  44988. wheelDeltaPercentage: number;
  44989. private _wheel;
  44990. private _observer;
  44991. /**
  44992. * Attach the input controls to a specific dom element to get the input from.
  44993. * @param element Defines the element the controls should be listened from
  44994. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44995. */
  44996. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44997. /**
  44998. * Detach the current controls from the specified dom element.
  44999. * @param element Defines the element to stop listening the inputs from
  45000. */
  45001. detachControl(element: Nullable<HTMLElement>): void;
  45002. /**
  45003. * Gets the class name of the current intput.
  45004. * @returns the class name
  45005. */
  45006. getClassName(): string;
  45007. /**
  45008. * Get the friendly name associated with the input class.
  45009. * @returns the input friendly name
  45010. */
  45011. getSimpleName(): string;
  45012. }
  45013. }
  45014. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  45015. import { Nullable } from "babylonjs/types";
  45016. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45017. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  45018. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  45019. /**
  45020. * Manage the pointers inputs to control an follow camera.
  45021. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45022. */
  45023. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  45024. /**
  45025. * Defines the camera the input is attached to.
  45026. */
  45027. camera: FollowCamera;
  45028. /**
  45029. * Gets the class name of the current input.
  45030. * @returns the class name
  45031. */
  45032. getClassName(): string;
  45033. /**
  45034. * Defines the pointer angular sensibility along the X axis or how fast is
  45035. * the camera rotating.
  45036. * A negative number will reverse the axis direction.
  45037. */
  45038. angularSensibilityX: number;
  45039. /**
  45040. * Defines the pointer angular sensibility along the Y axis or how fast is
  45041. * the camera rotating.
  45042. * A negative number will reverse the axis direction.
  45043. */
  45044. angularSensibilityY: number;
  45045. /**
  45046. * Defines the pointer pinch precision or how fast is the camera zooming.
  45047. * A negative number will reverse the axis direction.
  45048. */
  45049. pinchPrecision: number;
  45050. /**
  45051. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  45052. * from 0.
  45053. * It defines the percentage of current camera.radius to use as delta when
  45054. * pinch zoom is used.
  45055. */
  45056. pinchDeltaPercentage: number;
  45057. /**
  45058. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  45059. */
  45060. axisXControlRadius: boolean;
  45061. /**
  45062. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  45063. */
  45064. axisXControlHeight: boolean;
  45065. /**
  45066. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  45067. */
  45068. axisXControlRotation: boolean;
  45069. /**
  45070. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  45071. */
  45072. axisYControlRadius: boolean;
  45073. /**
  45074. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  45075. */
  45076. axisYControlHeight: boolean;
  45077. /**
  45078. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  45079. */
  45080. axisYControlRotation: boolean;
  45081. /**
  45082. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  45083. */
  45084. axisPinchControlRadius: boolean;
  45085. /**
  45086. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  45087. */
  45088. axisPinchControlHeight: boolean;
  45089. /**
  45090. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  45091. */
  45092. axisPinchControlRotation: boolean;
  45093. /**
  45094. * Log error messages if basic misconfiguration has occurred.
  45095. */
  45096. warningEnable: boolean;
  45097. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45098. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45099. private _warningCounter;
  45100. private _warning;
  45101. }
  45102. }
  45103. declare module "babylonjs/Cameras/followCameraInputsManager" {
  45104. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45105. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45106. /**
  45107. * Default Inputs manager for the FollowCamera.
  45108. * It groups all the default supported inputs for ease of use.
  45109. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45110. */
  45111. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  45112. /**
  45113. * Instantiates a new FollowCameraInputsManager.
  45114. * @param camera Defines the camera the inputs belong to
  45115. */
  45116. constructor(camera: FollowCamera);
  45117. /**
  45118. * Add keyboard input support to the input manager.
  45119. * @returns the current input manager
  45120. */
  45121. addKeyboard(): FollowCameraInputsManager;
  45122. /**
  45123. * Add mouse wheel input support to the input manager.
  45124. * @returns the current input manager
  45125. */
  45126. addMouseWheel(): FollowCameraInputsManager;
  45127. /**
  45128. * Add pointers input support to the input manager.
  45129. * @returns the current input manager
  45130. */
  45131. addPointers(): FollowCameraInputsManager;
  45132. /**
  45133. * Add orientation input support to the input manager.
  45134. * @returns the current input manager
  45135. */
  45136. addVRDeviceOrientation(): FollowCameraInputsManager;
  45137. }
  45138. }
  45139. declare module "babylonjs/Cameras/followCamera" {
  45140. import { Nullable } from "babylonjs/types";
  45141. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45142. import { Scene } from "babylonjs/scene";
  45143. import { Vector3 } from "babylonjs/Maths/math.vector";
  45144. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45145. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  45146. /**
  45147. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  45148. * an arc rotate version arcFollowCamera are available.
  45149. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  45150. */
  45151. export class FollowCamera extends TargetCamera {
  45152. /**
  45153. * Distance the follow camera should follow an object at
  45154. */
  45155. radius: number;
  45156. /**
  45157. * Minimum allowed distance of the camera to the axis of rotation
  45158. * (The camera can not get closer).
  45159. * This can help limiting how the Camera is able to move in the scene.
  45160. */
  45161. lowerRadiusLimit: Nullable<number>;
  45162. /**
  45163. * Maximum allowed distance of the camera to the axis of rotation
  45164. * (The camera can not get further).
  45165. * This can help limiting how the Camera is able to move in the scene.
  45166. */
  45167. upperRadiusLimit: Nullable<number>;
  45168. /**
  45169. * Define a rotation offset between the camera and the object it follows
  45170. */
  45171. rotationOffset: number;
  45172. /**
  45173. * Minimum allowed angle to camera position relative to target object.
  45174. * This can help limiting how the Camera is able to move in the scene.
  45175. */
  45176. lowerRotationOffsetLimit: Nullable<number>;
  45177. /**
  45178. * Maximum allowed angle to camera position relative to target object.
  45179. * This can help limiting how the Camera is able to move in the scene.
  45180. */
  45181. upperRotationOffsetLimit: Nullable<number>;
  45182. /**
  45183. * Define a height offset between the camera and the object it follows.
  45184. * It can help following an object from the top (like a car chaing a plane)
  45185. */
  45186. heightOffset: number;
  45187. /**
  45188. * Minimum allowed height of camera position relative to target object.
  45189. * This can help limiting how the Camera is able to move in the scene.
  45190. */
  45191. lowerHeightOffsetLimit: Nullable<number>;
  45192. /**
  45193. * Maximum allowed height of camera position relative to target object.
  45194. * This can help limiting how the Camera is able to move in the scene.
  45195. */
  45196. upperHeightOffsetLimit: Nullable<number>;
  45197. /**
  45198. * Define how fast the camera can accelerate to follow it s target.
  45199. */
  45200. cameraAcceleration: number;
  45201. /**
  45202. * Define the speed limit of the camera following an object.
  45203. */
  45204. maxCameraSpeed: number;
  45205. /**
  45206. * Define the target of the camera.
  45207. */
  45208. lockedTarget: Nullable<AbstractMesh>;
  45209. /**
  45210. * Defines the input associated with the camera.
  45211. */
  45212. inputs: FollowCameraInputsManager;
  45213. /**
  45214. * Instantiates the follow camera.
  45215. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  45216. * @param name Define the name of the camera in the scene
  45217. * @param position Define the position of the camera
  45218. * @param scene Define the scene the camera belong to
  45219. * @param lockedTarget Define the target of the camera
  45220. */
  45221. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  45222. private _follow;
  45223. /**
  45224. * Attached controls to the current camera.
  45225. * @param element Defines the element the controls should be listened from
  45226. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45227. */
  45228. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45229. /**
  45230. * Detach the current controls from the camera.
  45231. * The camera will stop reacting to inputs.
  45232. * @param element Defines the element to stop listening the inputs from
  45233. */
  45234. detachControl(element: HTMLElement): void;
  45235. /** @hidden */
  45236. _checkInputs(): void;
  45237. private _checkLimits;
  45238. /**
  45239. * Gets the camera class name.
  45240. * @returns the class name
  45241. */
  45242. getClassName(): string;
  45243. }
  45244. /**
  45245. * Arc Rotate version of the follow camera.
  45246. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  45247. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  45248. */
  45249. export class ArcFollowCamera extends TargetCamera {
  45250. /** The longitudinal angle of the camera */
  45251. alpha: number;
  45252. /** The latitudinal angle of the camera */
  45253. beta: number;
  45254. /** The radius of the camera from its target */
  45255. radius: number;
  45256. /** Define the camera target (the mesh it should follow) */
  45257. target: Nullable<AbstractMesh>;
  45258. private _cartesianCoordinates;
  45259. /**
  45260. * Instantiates a new ArcFollowCamera
  45261. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  45262. * @param name Define the name of the camera
  45263. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  45264. * @param beta Define the rotation angle of the camera around the elevation axis
  45265. * @param radius Define the radius of the camera from its target point
  45266. * @param target Define the target of the camera
  45267. * @param scene Define the scene the camera belongs to
  45268. */
  45269. constructor(name: string,
  45270. /** The longitudinal angle of the camera */
  45271. alpha: number,
  45272. /** The latitudinal angle of the camera */
  45273. beta: number,
  45274. /** The radius of the camera from its target */
  45275. radius: number,
  45276. /** Define the camera target (the mesh it should follow) */
  45277. target: Nullable<AbstractMesh>, scene: Scene);
  45278. private _follow;
  45279. /** @hidden */
  45280. _checkInputs(): void;
  45281. /**
  45282. * Returns the class name of the object.
  45283. * It is mostly used internally for serialization purposes.
  45284. */
  45285. getClassName(): string;
  45286. }
  45287. }
  45288. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  45289. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45290. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45291. import { Nullable } from "babylonjs/types";
  45292. /**
  45293. * Manage the keyboard inputs to control the movement of a follow camera.
  45294. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45295. */
  45296. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  45297. /**
  45298. * Defines the camera the input is attached to.
  45299. */
  45300. camera: FollowCamera;
  45301. /**
  45302. * Defines the list of key codes associated with the up action (increase heightOffset)
  45303. */
  45304. keysHeightOffsetIncr: number[];
  45305. /**
  45306. * Defines the list of key codes associated with the down action (decrease heightOffset)
  45307. */
  45308. keysHeightOffsetDecr: number[];
  45309. /**
  45310. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  45311. */
  45312. keysHeightOffsetModifierAlt: boolean;
  45313. /**
  45314. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  45315. */
  45316. keysHeightOffsetModifierCtrl: boolean;
  45317. /**
  45318. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  45319. */
  45320. keysHeightOffsetModifierShift: boolean;
  45321. /**
  45322. * Defines the list of key codes associated with the left action (increase rotationOffset)
  45323. */
  45324. keysRotationOffsetIncr: number[];
  45325. /**
  45326. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  45327. */
  45328. keysRotationOffsetDecr: number[];
  45329. /**
  45330. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  45331. */
  45332. keysRotationOffsetModifierAlt: boolean;
  45333. /**
  45334. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  45335. */
  45336. keysRotationOffsetModifierCtrl: boolean;
  45337. /**
  45338. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  45339. */
  45340. keysRotationOffsetModifierShift: boolean;
  45341. /**
  45342. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  45343. */
  45344. keysRadiusIncr: number[];
  45345. /**
  45346. * Defines the list of key codes associated with the zoom-out action (increase radius)
  45347. */
  45348. keysRadiusDecr: number[];
  45349. /**
  45350. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  45351. */
  45352. keysRadiusModifierAlt: boolean;
  45353. /**
  45354. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  45355. */
  45356. keysRadiusModifierCtrl: boolean;
  45357. /**
  45358. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  45359. */
  45360. keysRadiusModifierShift: boolean;
  45361. /**
  45362. * Defines the rate of change of heightOffset.
  45363. */
  45364. heightSensibility: number;
  45365. /**
  45366. * Defines the rate of change of rotationOffset.
  45367. */
  45368. rotationSensibility: number;
  45369. /**
  45370. * Defines the rate of change of radius.
  45371. */
  45372. radiusSensibility: number;
  45373. private _keys;
  45374. private _ctrlPressed;
  45375. private _altPressed;
  45376. private _shiftPressed;
  45377. private _onCanvasBlurObserver;
  45378. private _onKeyboardObserver;
  45379. private _engine;
  45380. private _scene;
  45381. /**
  45382. * Attach the input controls to a specific dom element to get the input from.
  45383. * @param element Defines the element the controls should be listened from
  45384. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45385. */
  45386. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45387. /**
  45388. * Detach the current controls from the specified dom element.
  45389. * @param element Defines the element to stop listening the inputs from
  45390. */
  45391. detachControl(element: Nullable<HTMLElement>): void;
  45392. /**
  45393. * Update the current camera state depending on the inputs that have been used this frame.
  45394. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45395. */
  45396. checkInputs(): void;
  45397. /**
  45398. * Gets the class name of the current input.
  45399. * @returns the class name
  45400. */
  45401. getClassName(): string;
  45402. /**
  45403. * Get the friendly name associated with the input class.
  45404. * @returns the input friendly name
  45405. */
  45406. getSimpleName(): string;
  45407. /**
  45408. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45409. * allow modification of the heightOffset value.
  45410. */
  45411. private _modifierHeightOffset;
  45412. /**
  45413. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45414. * allow modification of the rotationOffset value.
  45415. */
  45416. private _modifierRotationOffset;
  45417. /**
  45418. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45419. * allow modification of the radius value.
  45420. */
  45421. private _modifierRadius;
  45422. }
  45423. }
  45424. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  45425. import { Nullable } from "babylonjs/types";
  45426. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45427. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45428. import { Observable } from "babylonjs/Misc/observable";
  45429. module "babylonjs/Cameras/freeCameraInputsManager" {
  45430. interface FreeCameraInputsManager {
  45431. /**
  45432. * @hidden
  45433. */
  45434. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  45435. /**
  45436. * Add orientation input support to the input manager.
  45437. * @returns the current input manager
  45438. */
  45439. addDeviceOrientation(): FreeCameraInputsManager;
  45440. }
  45441. }
  45442. /**
  45443. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  45444. * Screen rotation is taken into account.
  45445. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45446. */
  45447. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  45448. private _camera;
  45449. private _screenOrientationAngle;
  45450. private _constantTranform;
  45451. private _screenQuaternion;
  45452. private _alpha;
  45453. private _beta;
  45454. private _gamma;
  45455. /**
  45456. * Can be used to detect if a device orientation sensor is available on a device
  45457. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  45458. * @returns a promise that will resolve on orientation change
  45459. */
  45460. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  45461. /**
  45462. * @hidden
  45463. */
  45464. _onDeviceOrientationChangedObservable: Observable<void>;
  45465. /**
  45466. * Instantiates a new input
  45467. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45468. */
  45469. constructor();
  45470. /**
  45471. * Define the camera controlled by the input.
  45472. */
  45473. get camera(): FreeCamera;
  45474. set camera(camera: FreeCamera);
  45475. /**
  45476. * Attach the input controls to a specific dom element to get the input from.
  45477. * @param element Defines the element the controls should be listened from
  45478. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45479. */
  45480. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45481. private _orientationChanged;
  45482. private _deviceOrientation;
  45483. /**
  45484. * Detach the current controls from the specified dom element.
  45485. * @param element Defines the element to stop listening the inputs from
  45486. */
  45487. detachControl(element: Nullable<HTMLElement>): void;
  45488. /**
  45489. * Update the current camera state depending on the inputs that have been used this frame.
  45490. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45491. */
  45492. checkInputs(): void;
  45493. /**
  45494. * Gets the class name of the current intput.
  45495. * @returns the class name
  45496. */
  45497. getClassName(): string;
  45498. /**
  45499. * Get the friendly name associated with the input class.
  45500. * @returns the input friendly name
  45501. */
  45502. getSimpleName(): string;
  45503. }
  45504. }
  45505. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  45506. import { Nullable } from "babylonjs/types";
  45507. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45508. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45509. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45510. /**
  45511. * Manage the gamepad inputs to control a free camera.
  45512. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45513. */
  45514. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  45515. /**
  45516. * Define the camera the input is attached to.
  45517. */
  45518. camera: FreeCamera;
  45519. /**
  45520. * Define the Gamepad controlling the input
  45521. */
  45522. gamepad: Nullable<Gamepad>;
  45523. /**
  45524. * Defines the gamepad rotation sensiblity.
  45525. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45526. */
  45527. gamepadAngularSensibility: number;
  45528. /**
  45529. * Defines the gamepad move sensiblity.
  45530. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45531. */
  45532. gamepadMoveSensibility: number;
  45533. private _yAxisScale;
  45534. /**
  45535. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45536. */
  45537. get invertYAxis(): boolean;
  45538. set invertYAxis(value: boolean);
  45539. private _onGamepadConnectedObserver;
  45540. private _onGamepadDisconnectedObserver;
  45541. private _cameraTransform;
  45542. private _deltaTransform;
  45543. private _vector3;
  45544. private _vector2;
  45545. /**
  45546. * Attach the input controls to a specific dom element to get the input from.
  45547. * @param element Defines the element the controls should be listened from
  45548. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45549. */
  45550. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45551. /**
  45552. * Detach the current controls from the specified dom element.
  45553. * @param element Defines the element to stop listening the inputs from
  45554. */
  45555. detachControl(element: Nullable<HTMLElement>): void;
  45556. /**
  45557. * Update the current camera state depending on the inputs that have been used this frame.
  45558. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45559. */
  45560. checkInputs(): void;
  45561. /**
  45562. * Gets the class name of the current intput.
  45563. * @returns the class name
  45564. */
  45565. getClassName(): string;
  45566. /**
  45567. * Get the friendly name associated with the input class.
  45568. * @returns the input friendly name
  45569. */
  45570. getSimpleName(): string;
  45571. }
  45572. }
  45573. declare module "babylonjs/Misc/virtualJoystick" {
  45574. import { Nullable } from "babylonjs/types";
  45575. import { Vector3 } from "babylonjs/Maths/math.vector";
  45576. /**
  45577. * Defines the potential axis of a Joystick
  45578. */
  45579. export enum JoystickAxis {
  45580. /** X axis */
  45581. X = 0,
  45582. /** Y axis */
  45583. Y = 1,
  45584. /** Z axis */
  45585. Z = 2
  45586. }
  45587. /**
  45588. * Represents the different customization options available
  45589. * for VirtualJoystick
  45590. */
  45591. interface VirtualJoystickCustomizations {
  45592. /**
  45593. * Size of the joystick's puck
  45594. */
  45595. puckSize: number;
  45596. /**
  45597. * Size of the joystick's container
  45598. */
  45599. containerSize: number;
  45600. /**
  45601. * Color of the joystick && puck
  45602. */
  45603. color: string;
  45604. /**
  45605. * Image URL for the joystick's puck
  45606. */
  45607. puckImage?: string;
  45608. /**
  45609. * Image URL for the joystick's container
  45610. */
  45611. containerImage?: string;
  45612. /**
  45613. * Defines the unmoving position of the joystick container
  45614. */
  45615. position?: {
  45616. x: number;
  45617. y: number;
  45618. };
  45619. /**
  45620. * Defines whether or not the joystick container is always visible
  45621. */
  45622. alwaysVisible: boolean;
  45623. /**
  45624. * Defines whether or not to limit the movement of the puck to the joystick's container
  45625. */
  45626. limitToContainer: boolean;
  45627. }
  45628. /**
  45629. * Class used to define virtual joystick (used in touch mode)
  45630. */
  45631. export class VirtualJoystick {
  45632. /**
  45633. * Gets or sets a boolean indicating that left and right values must be inverted
  45634. */
  45635. reverseLeftRight: boolean;
  45636. /**
  45637. * Gets or sets a boolean indicating that up and down values must be inverted
  45638. */
  45639. reverseUpDown: boolean;
  45640. /**
  45641. * Gets the offset value for the position (ie. the change of the position value)
  45642. */
  45643. deltaPosition: Vector3;
  45644. /**
  45645. * Gets a boolean indicating if the virtual joystick was pressed
  45646. */
  45647. pressed: boolean;
  45648. /**
  45649. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45650. */
  45651. static Canvas: Nullable<HTMLCanvasElement>;
  45652. /**
  45653. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  45654. */
  45655. limitToContainer: boolean;
  45656. private static _globalJoystickIndex;
  45657. private static _alwaysVisibleSticks;
  45658. private static vjCanvasContext;
  45659. private static vjCanvasWidth;
  45660. private static vjCanvasHeight;
  45661. private static halfWidth;
  45662. private static _GetDefaultOptions;
  45663. private _action;
  45664. private _axisTargetedByLeftAndRight;
  45665. private _axisTargetedByUpAndDown;
  45666. private _joystickSensibility;
  45667. private _inversedSensibility;
  45668. private _joystickPointerID;
  45669. private _joystickColor;
  45670. private _joystickPointerPos;
  45671. private _joystickPreviousPointerPos;
  45672. private _joystickPointerStartPos;
  45673. private _deltaJoystickVector;
  45674. private _leftJoystick;
  45675. private _touches;
  45676. private _joystickPosition;
  45677. private _alwaysVisible;
  45678. private _puckImage;
  45679. private _containerImage;
  45680. private _joystickPuckSize;
  45681. private _joystickContainerSize;
  45682. private _clearPuckSize;
  45683. private _clearContainerSize;
  45684. private _clearPuckSizeOffset;
  45685. private _clearContainerSizeOffset;
  45686. private _onPointerDownHandlerRef;
  45687. private _onPointerMoveHandlerRef;
  45688. private _onPointerUpHandlerRef;
  45689. private _onResize;
  45690. /**
  45691. * Creates a new virtual joystick
  45692. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45693. * @param customizations Defines the options we want to customize the VirtualJoystick
  45694. */
  45695. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  45696. /**
  45697. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45698. * @param newJoystickSensibility defines the new sensibility
  45699. */
  45700. setJoystickSensibility(newJoystickSensibility: number): void;
  45701. private _onPointerDown;
  45702. private _onPointerMove;
  45703. private _onPointerUp;
  45704. /**
  45705. * Change the color of the virtual joystick
  45706. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45707. */
  45708. setJoystickColor(newColor: string): void;
  45709. /**
  45710. * Size of the joystick's container
  45711. */
  45712. set containerSize(newSize: number);
  45713. get containerSize(): number;
  45714. /**
  45715. * Size of the joystick's puck
  45716. */
  45717. set puckSize(newSize: number);
  45718. get puckSize(): number;
  45719. /**
  45720. * Clears the set position of the joystick
  45721. */
  45722. clearPosition(): void;
  45723. /**
  45724. * Defines whether or not the joystick container is always visible
  45725. */
  45726. set alwaysVisible(value: boolean);
  45727. get alwaysVisible(): boolean;
  45728. /**
  45729. * Sets the constant position of the Joystick container
  45730. * @param x X axis coordinate
  45731. * @param y Y axis coordinate
  45732. */
  45733. setPosition(x: number, y: number): void;
  45734. /**
  45735. * Defines a callback to call when the joystick is touched
  45736. * @param action defines the callback
  45737. */
  45738. setActionOnTouch(action: () => any): void;
  45739. /**
  45740. * Defines which axis you'd like to control for left & right
  45741. * @param axis defines the axis to use
  45742. */
  45743. setAxisForLeftRight(axis: JoystickAxis): void;
  45744. /**
  45745. * Defines which axis you'd like to control for up & down
  45746. * @param axis defines the axis to use
  45747. */
  45748. setAxisForUpDown(axis: JoystickAxis): void;
  45749. /**
  45750. * Clears the canvas from the previous puck / container draw
  45751. */
  45752. private _clearPreviousDraw;
  45753. /**
  45754. * Loads `urlPath` to be used for the container's image
  45755. * @param urlPath defines the urlPath of an image to use
  45756. */
  45757. setContainerImage(urlPath: string): void;
  45758. /**
  45759. * Loads `urlPath` to be used for the puck's image
  45760. * @param urlPath defines the urlPath of an image to use
  45761. */
  45762. setPuckImage(urlPath: string): void;
  45763. /**
  45764. * Draws the Virtual Joystick's container
  45765. */
  45766. private _drawContainer;
  45767. /**
  45768. * Draws the Virtual Joystick's puck
  45769. */
  45770. private _drawPuck;
  45771. private _drawVirtualJoystick;
  45772. /**
  45773. * Release internal HTML canvas
  45774. */
  45775. releaseCanvas(): void;
  45776. }
  45777. }
  45778. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  45779. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  45780. import { Nullable } from "babylonjs/types";
  45781. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45782. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45783. module "babylonjs/Cameras/freeCameraInputsManager" {
  45784. interface FreeCameraInputsManager {
  45785. /**
  45786. * Add virtual joystick input support to the input manager.
  45787. * @returns the current input manager
  45788. */
  45789. addVirtualJoystick(): FreeCameraInputsManager;
  45790. }
  45791. }
  45792. /**
  45793. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45794. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45795. */
  45796. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45797. /**
  45798. * Defines the camera the input is attached to.
  45799. */
  45800. camera: FreeCamera;
  45801. private _leftjoystick;
  45802. private _rightjoystick;
  45803. /**
  45804. * Gets the left stick of the virtual joystick.
  45805. * @returns The virtual Joystick
  45806. */
  45807. getLeftJoystick(): VirtualJoystick;
  45808. /**
  45809. * Gets the right stick of the virtual joystick.
  45810. * @returns The virtual Joystick
  45811. */
  45812. getRightJoystick(): VirtualJoystick;
  45813. /**
  45814. * Update the current camera state depending on the inputs that have been used this frame.
  45815. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45816. */
  45817. checkInputs(): void;
  45818. /**
  45819. * Attach the input controls to a specific dom element to get the input from.
  45820. * @param element Defines the element the controls should be listened from
  45821. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45822. */
  45823. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45824. /**
  45825. * Detach the current controls from the specified dom element.
  45826. * @param element Defines the element to stop listening the inputs from
  45827. */
  45828. detachControl(element: Nullable<HTMLElement>): void;
  45829. /**
  45830. * Gets the class name of the current intput.
  45831. * @returns the class name
  45832. */
  45833. getClassName(): string;
  45834. /**
  45835. * Get the friendly name associated with the input class.
  45836. * @returns the input friendly name
  45837. */
  45838. getSimpleName(): string;
  45839. }
  45840. }
  45841. declare module "babylonjs/Cameras/Inputs/index" {
  45842. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  45843. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  45844. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  45845. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  45846. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  45847. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  45848. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  45849. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  45850. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  45851. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  45852. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45853. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  45854. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  45855. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  45856. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  45857. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  45858. }
  45859. declare module "babylonjs/Cameras/touchCamera" {
  45860. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45861. import { Scene } from "babylonjs/scene";
  45862. import { Vector3 } from "babylonjs/Maths/math.vector";
  45863. /**
  45864. * This represents a FPS type of camera controlled by touch.
  45865. * This is like a universal camera minus the Gamepad controls.
  45866. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45867. */
  45868. export class TouchCamera extends FreeCamera {
  45869. /**
  45870. * Defines the touch sensibility for rotation.
  45871. * The higher the faster.
  45872. */
  45873. get touchAngularSensibility(): number;
  45874. set touchAngularSensibility(value: number);
  45875. /**
  45876. * Defines the touch sensibility for move.
  45877. * The higher the faster.
  45878. */
  45879. get touchMoveSensibility(): number;
  45880. set touchMoveSensibility(value: number);
  45881. /**
  45882. * Instantiates a new touch camera.
  45883. * This represents a FPS type of camera controlled by touch.
  45884. * This is like a universal camera minus the Gamepad controls.
  45885. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45886. * @param name Define the name of the camera in the scene
  45887. * @param position Define the start position of the camera in the scene
  45888. * @param scene Define the scene the camera belongs to
  45889. */
  45890. constructor(name: string, position: Vector3, scene: Scene);
  45891. /**
  45892. * Gets the current object class name.
  45893. * @return the class name
  45894. */
  45895. getClassName(): string;
  45896. /** @hidden */
  45897. _setupInputs(): void;
  45898. }
  45899. }
  45900. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  45901. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45902. import { Scene } from "babylonjs/scene";
  45903. import { Vector3 } from "babylonjs/Maths/math.vector";
  45904. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45905. import { Axis } from "babylonjs/Maths/math.axis";
  45906. /**
  45907. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45908. * being tilted forward or back and left or right.
  45909. */
  45910. export class DeviceOrientationCamera extends FreeCamera {
  45911. private _initialQuaternion;
  45912. private _quaternionCache;
  45913. private _tmpDragQuaternion;
  45914. private _disablePointerInputWhenUsingDeviceOrientation;
  45915. /**
  45916. * Creates a new device orientation camera
  45917. * @param name The name of the camera
  45918. * @param position The start position camera
  45919. * @param scene The scene the camera belongs to
  45920. */
  45921. constructor(name: string, position: Vector3, scene: Scene);
  45922. /**
  45923. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45924. */
  45925. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45926. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45927. private _dragFactor;
  45928. /**
  45929. * Enabled turning on the y axis when the orientation sensor is active
  45930. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45931. */
  45932. enableHorizontalDragging(dragFactor?: number): void;
  45933. /**
  45934. * Gets the current instance class name ("DeviceOrientationCamera").
  45935. * This helps avoiding instanceof at run time.
  45936. * @returns the class name
  45937. */
  45938. getClassName(): string;
  45939. /**
  45940. * @hidden
  45941. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45942. */
  45943. _checkInputs(): void;
  45944. /**
  45945. * Reset the camera to its default orientation on the specified axis only.
  45946. * @param axis The axis to reset
  45947. */
  45948. resetToCurrentRotation(axis?: Axis): void;
  45949. }
  45950. }
  45951. declare module "babylonjs/Gamepads/xboxGamepad" {
  45952. import { Observable } from "babylonjs/Misc/observable";
  45953. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45954. /**
  45955. * Defines supported buttons for XBox360 compatible gamepads
  45956. */
  45957. export enum Xbox360Button {
  45958. /** A */
  45959. A = 0,
  45960. /** B */
  45961. B = 1,
  45962. /** X */
  45963. X = 2,
  45964. /** Y */
  45965. Y = 3,
  45966. /** Left button */
  45967. LB = 4,
  45968. /** Right button */
  45969. RB = 5,
  45970. /** Back */
  45971. Back = 8,
  45972. /** Start */
  45973. Start = 9,
  45974. /** Left stick */
  45975. LeftStick = 10,
  45976. /** Right stick */
  45977. RightStick = 11
  45978. }
  45979. /** Defines values for XBox360 DPad */
  45980. export enum Xbox360Dpad {
  45981. /** Up */
  45982. Up = 12,
  45983. /** Down */
  45984. Down = 13,
  45985. /** Left */
  45986. Left = 14,
  45987. /** Right */
  45988. Right = 15
  45989. }
  45990. /**
  45991. * Defines a XBox360 gamepad
  45992. */
  45993. export class Xbox360Pad extends Gamepad {
  45994. private _leftTrigger;
  45995. private _rightTrigger;
  45996. private _onlefttriggerchanged;
  45997. private _onrighttriggerchanged;
  45998. private _onbuttondown;
  45999. private _onbuttonup;
  46000. private _ondpaddown;
  46001. private _ondpadup;
  46002. /** Observable raised when a button is pressed */
  46003. onButtonDownObservable: Observable<Xbox360Button>;
  46004. /** Observable raised when a button is released */
  46005. onButtonUpObservable: Observable<Xbox360Button>;
  46006. /** Observable raised when a pad is pressed */
  46007. onPadDownObservable: Observable<Xbox360Dpad>;
  46008. /** Observable raised when a pad is released */
  46009. onPadUpObservable: Observable<Xbox360Dpad>;
  46010. private _buttonA;
  46011. private _buttonB;
  46012. private _buttonX;
  46013. private _buttonY;
  46014. private _buttonBack;
  46015. private _buttonStart;
  46016. private _buttonLB;
  46017. private _buttonRB;
  46018. private _buttonLeftStick;
  46019. private _buttonRightStick;
  46020. private _dPadUp;
  46021. private _dPadDown;
  46022. private _dPadLeft;
  46023. private _dPadRight;
  46024. private _isXboxOnePad;
  46025. /**
  46026. * Creates a new XBox360 gamepad object
  46027. * @param id defines the id of this gamepad
  46028. * @param index defines its index
  46029. * @param gamepad defines the internal HTML gamepad object
  46030. * @param xboxOne defines if it is a XBox One gamepad
  46031. */
  46032. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  46033. /**
  46034. * Defines the callback to call when left trigger is pressed
  46035. * @param callback defines the callback to use
  46036. */
  46037. onlefttriggerchanged(callback: (value: number) => void): void;
  46038. /**
  46039. * Defines the callback to call when right trigger is pressed
  46040. * @param callback defines the callback to use
  46041. */
  46042. onrighttriggerchanged(callback: (value: number) => void): void;
  46043. /**
  46044. * Gets the left trigger value
  46045. */
  46046. get leftTrigger(): number;
  46047. /**
  46048. * Sets the left trigger value
  46049. */
  46050. set leftTrigger(newValue: number);
  46051. /**
  46052. * Gets the right trigger value
  46053. */
  46054. get rightTrigger(): number;
  46055. /**
  46056. * Sets the right trigger value
  46057. */
  46058. set rightTrigger(newValue: number);
  46059. /**
  46060. * Defines the callback to call when a button is pressed
  46061. * @param callback defines the callback to use
  46062. */
  46063. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  46064. /**
  46065. * Defines the callback to call when a button is released
  46066. * @param callback defines the callback to use
  46067. */
  46068. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  46069. /**
  46070. * Defines the callback to call when a pad is pressed
  46071. * @param callback defines the callback to use
  46072. */
  46073. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  46074. /**
  46075. * Defines the callback to call when a pad is released
  46076. * @param callback defines the callback to use
  46077. */
  46078. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  46079. private _setButtonValue;
  46080. private _setDPadValue;
  46081. /**
  46082. * Gets the value of the `A` button
  46083. */
  46084. get buttonA(): number;
  46085. /**
  46086. * Sets the value of the `A` button
  46087. */
  46088. set buttonA(value: number);
  46089. /**
  46090. * Gets the value of the `B` button
  46091. */
  46092. get buttonB(): number;
  46093. /**
  46094. * Sets the value of the `B` button
  46095. */
  46096. set buttonB(value: number);
  46097. /**
  46098. * Gets the value of the `X` button
  46099. */
  46100. get buttonX(): number;
  46101. /**
  46102. * Sets the value of the `X` button
  46103. */
  46104. set buttonX(value: number);
  46105. /**
  46106. * Gets the value of the `Y` button
  46107. */
  46108. get buttonY(): number;
  46109. /**
  46110. * Sets the value of the `Y` button
  46111. */
  46112. set buttonY(value: number);
  46113. /**
  46114. * Gets the value of the `Start` button
  46115. */
  46116. get buttonStart(): number;
  46117. /**
  46118. * Sets the value of the `Start` button
  46119. */
  46120. set buttonStart(value: number);
  46121. /**
  46122. * Gets the value of the `Back` button
  46123. */
  46124. get buttonBack(): number;
  46125. /**
  46126. * Sets the value of the `Back` button
  46127. */
  46128. set buttonBack(value: number);
  46129. /**
  46130. * Gets the value of the `Left` button
  46131. */
  46132. get buttonLB(): number;
  46133. /**
  46134. * Sets the value of the `Left` button
  46135. */
  46136. set buttonLB(value: number);
  46137. /**
  46138. * Gets the value of the `Right` button
  46139. */
  46140. get buttonRB(): number;
  46141. /**
  46142. * Sets the value of the `Right` button
  46143. */
  46144. set buttonRB(value: number);
  46145. /**
  46146. * Gets the value of the Left joystick
  46147. */
  46148. get buttonLeftStick(): number;
  46149. /**
  46150. * Sets the value of the Left joystick
  46151. */
  46152. set buttonLeftStick(value: number);
  46153. /**
  46154. * Gets the value of the Right joystick
  46155. */
  46156. get buttonRightStick(): number;
  46157. /**
  46158. * Sets the value of the Right joystick
  46159. */
  46160. set buttonRightStick(value: number);
  46161. /**
  46162. * Gets the value of D-pad up
  46163. */
  46164. get dPadUp(): number;
  46165. /**
  46166. * Sets the value of D-pad up
  46167. */
  46168. set dPadUp(value: number);
  46169. /**
  46170. * Gets the value of D-pad down
  46171. */
  46172. get dPadDown(): number;
  46173. /**
  46174. * Sets the value of D-pad down
  46175. */
  46176. set dPadDown(value: number);
  46177. /**
  46178. * Gets the value of D-pad left
  46179. */
  46180. get dPadLeft(): number;
  46181. /**
  46182. * Sets the value of D-pad left
  46183. */
  46184. set dPadLeft(value: number);
  46185. /**
  46186. * Gets the value of D-pad right
  46187. */
  46188. get dPadRight(): number;
  46189. /**
  46190. * Sets the value of D-pad right
  46191. */
  46192. set dPadRight(value: number);
  46193. /**
  46194. * Force the gamepad to synchronize with device values
  46195. */
  46196. update(): void;
  46197. /**
  46198. * Disposes the gamepad
  46199. */
  46200. dispose(): void;
  46201. }
  46202. }
  46203. declare module "babylonjs/Gamepads/dualShockGamepad" {
  46204. import { Observable } from "babylonjs/Misc/observable";
  46205. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46206. /**
  46207. * Defines supported buttons for DualShock compatible gamepads
  46208. */
  46209. export enum DualShockButton {
  46210. /** Cross */
  46211. Cross = 0,
  46212. /** Circle */
  46213. Circle = 1,
  46214. /** Square */
  46215. Square = 2,
  46216. /** Triangle */
  46217. Triangle = 3,
  46218. /** L1 */
  46219. L1 = 4,
  46220. /** R1 */
  46221. R1 = 5,
  46222. /** Share */
  46223. Share = 8,
  46224. /** Options */
  46225. Options = 9,
  46226. /** Left stick */
  46227. LeftStick = 10,
  46228. /** Right stick */
  46229. RightStick = 11
  46230. }
  46231. /** Defines values for DualShock DPad */
  46232. export enum DualShockDpad {
  46233. /** Up */
  46234. Up = 12,
  46235. /** Down */
  46236. Down = 13,
  46237. /** Left */
  46238. Left = 14,
  46239. /** Right */
  46240. Right = 15
  46241. }
  46242. /**
  46243. * Defines a DualShock gamepad
  46244. */
  46245. export class DualShockPad extends Gamepad {
  46246. private _leftTrigger;
  46247. private _rightTrigger;
  46248. private _onlefttriggerchanged;
  46249. private _onrighttriggerchanged;
  46250. private _onbuttondown;
  46251. private _onbuttonup;
  46252. private _ondpaddown;
  46253. private _ondpadup;
  46254. /** Observable raised when a button is pressed */
  46255. onButtonDownObservable: Observable<DualShockButton>;
  46256. /** Observable raised when a button is released */
  46257. onButtonUpObservable: Observable<DualShockButton>;
  46258. /** Observable raised when a pad is pressed */
  46259. onPadDownObservable: Observable<DualShockDpad>;
  46260. /** Observable raised when a pad is released */
  46261. onPadUpObservable: Observable<DualShockDpad>;
  46262. private _buttonCross;
  46263. private _buttonCircle;
  46264. private _buttonSquare;
  46265. private _buttonTriangle;
  46266. private _buttonShare;
  46267. private _buttonOptions;
  46268. private _buttonL1;
  46269. private _buttonR1;
  46270. private _buttonLeftStick;
  46271. private _buttonRightStick;
  46272. private _dPadUp;
  46273. private _dPadDown;
  46274. private _dPadLeft;
  46275. private _dPadRight;
  46276. /**
  46277. * Creates a new DualShock gamepad object
  46278. * @param id defines the id of this gamepad
  46279. * @param index defines its index
  46280. * @param gamepad defines the internal HTML gamepad object
  46281. */
  46282. constructor(id: string, index: number, gamepad: any);
  46283. /**
  46284. * Defines the callback to call when left trigger is pressed
  46285. * @param callback defines the callback to use
  46286. */
  46287. onlefttriggerchanged(callback: (value: number) => void): void;
  46288. /**
  46289. * Defines the callback to call when right trigger is pressed
  46290. * @param callback defines the callback to use
  46291. */
  46292. onrighttriggerchanged(callback: (value: number) => void): void;
  46293. /**
  46294. * Gets the left trigger value
  46295. */
  46296. get leftTrigger(): number;
  46297. /**
  46298. * Sets the left trigger value
  46299. */
  46300. set leftTrigger(newValue: number);
  46301. /**
  46302. * Gets the right trigger value
  46303. */
  46304. get rightTrigger(): number;
  46305. /**
  46306. * Sets the right trigger value
  46307. */
  46308. set rightTrigger(newValue: number);
  46309. /**
  46310. * Defines the callback to call when a button is pressed
  46311. * @param callback defines the callback to use
  46312. */
  46313. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  46314. /**
  46315. * Defines the callback to call when a button is released
  46316. * @param callback defines the callback to use
  46317. */
  46318. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  46319. /**
  46320. * Defines the callback to call when a pad is pressed
  46321. * @param callback defines the callback to use
  46322. */
  46323. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  46324. /**
  46325. * Defines the callback to call when a pad is released
  46326. * @param callback defines the callback to use
  46327. */
  46328. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  46329. private _setButtonValue;
  46330. private _setDPadValue;
  46331. /**
  46332. * Gets the value of the `Cross` button
  46333. */
  46334. get buttonCross(): number;
  46335. /**
  46336. * Sets the value of the `Cross` button
  46337. */
  46338. set buttonCross(value: number);
  46339. /**
  46340. * Gets the value of the `Circle` button
  46341. */
  46342. get buttonCircle(): number;
  46343. /**
  46344. * Sets the value of the `Circle` button
  46345. */
  46346. set buttonCircle(value: number);
  46347. /**
  46348. * Gets the value of the `Square` button
  46349. */
  46350. get buttonSquare(): number;
  46351. /**
  46352. * Sets the value of the `Square` button
  46353. */
  46354. set buttonSquare(value: number);
  46355. /**
  46356. * Gets the value of the `Triangle` button
  46357. */
  46358. get buttonTriangle(): number;
  46359. /**
  46360. * Sets the value of the `Triangle` button
  46361. */
  46362. set buttonTriangle(value: number);
  46363. /**
  46364. * Gets the value of the `Options` button
  46365. */
  46366. get buttonOptions(): number;
  46367. /**
  46368. * Sets the value of the `Options` button
  46369. */
  46370. set buttonOptions(value: number);
  46371. /**
  46372. * Gets the value of the `Share` button
  46373. */
  46374. get buttonShare(): number;
  46375. /**
  46376. * Sets the value of the `Share` button
  46377. */
  46378. set buttonShare(value: number);
  46379. /**
  46380. * Gets the value of the `L1` button
  46381. */
  46382. get buttonL1(): number;
  46383. /**
  46384. * Sets the value of the `L1` button
  46385. */
  46386. set buttonL1(value: number);
  46387. /**
  46388. * Gets the value of the `R1` button
  46389. */
  46390. get buttonR1(): number;
  46391. /**
  46392. * Sets the value of the `R1` button
  46393. */
  46394. set buttonR1(value: number);
  46395. /**
  46396. * Gets the value of the Left joystick
  46397. */
  46398. get buttonLeftStick(): number;
  46399. /**
  46400. * Sets the value of the Left joystick
  46401. */
  46402. set buttonLeftStick(value: number);
  46403. /**
  46404. * Gets the value of the Right joystick
  46405. */
  46406. get buttonRightStick(): number;
  46407. /**
  46408. * Sets the value of the Right joystick
  46409. */
  46410. set buttonRightStick(value: number);
  46411. /**
  46412. * Gets the value of D-pad up
  46413. */
  46414. get dPadUp(): number;
  46415. /**
  46416. * Sets the value of D-pad up
  46417. */
  46418. set dPadUp(value: number);
  46419. /**
  46420. * Gets the value of D-pad down
  46421. */
  46422. get dPadDown(): number;
  46423. /**
  46424. * Sets the value of D-pad down
  46425. */
  46426. set dPadDown(value: number);
  46427. /**
  46428. * Gets the value of D-pad left
  46429. */
  46430. get dPadLeft(): number;
  46431. /**
  46432. * Sets the value of D-pad left
  46433. */
  46434. set dPadLeft(value: number);
  46435. /**
  46436. * Gets the value of D-pad right
  46437. */
  46438. get dPadRight(): number;
  46439. /**
  46440. * Sets the value of D-pad right
  46441. */
  46442. set dPadRight(value: number);
  46443. /**
  46444. * Force the gamepad to synchronize with device values
  46445. */
  46446. update(): void;
  46447. /**
  46448. * Disposes the gamepad
  46449. */
  46450. dispose(): void;
  46451. }
  46452. }
  46453. declare module "babylonjs/Gamepads/gamepadManager" {
  46454. import { Observable } from "babylonjs/Misc/observable";
  46455. import { Nullable } from "babylonjs/types";
  46456. import { Scene } from "babylonjs/scene";
  46457. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46458. /**
  46459. * Manager for handling gamepads
  46460. */
  46461. export class GamepadManager {
  46462. private _scene?;
  46463. private _babylonGamepads;
  46464. private _oneGamepadConnected;
  46465. /** @hidden */
  46466. _isMonitoring: boolean;
  46467. private _gamepadEventSupported;
  46468. private _gamepadSupport?;
  46469. /**
  46470. * observable to be triggered when the gamepad controller has been connected
  46471. */
  46472. onGamepadConnectedObservable: Observable<Gamepad>;
  46473. /**
  46474. * observable to be triggered when the gamepad controller has been disconnected
  46475. */
  46476. onGamepadDisconnectedObservable: Observable<Gamepad>;
  46477. private _onGamepadConnectedEvent;
  46478. private _onGamepadDisconnectedEvent;
  46479. /**
  46480. * Initializes the gamepad manager
  46481. * @param _scene BabylonJS scene
  46482. */
  46483. constructor(_scene?: Scene | undefined);
  46484. /**
  46485. * The gamepads in the game pad manager
  46486. */
  46487. get gamepads(): Gamepad[];
  46488. /**
  46489. * Get the gamepad controllers based on type
  46490. * @param type The type of gamepad controller
  46491. * @returns Nullable gamepad
  46492. */
  46493. getGamepadByType(type?: number): Nullable<Gamepad>;
  46494. /**
  46495. * Disposes the gamepad manager
  46496. */
  46497. dispose(): void;
  46498. private _addNewGamepad;
  46499. private _startMonitoringGamepads;
  46500. private _stopMonitoringGamepads;
  46501. /** @hidden */
  46502. _checkGamepadsStatus(): void;
  46503. private _updateGamepadObjects;
  46504. }
  46505. }
  46506. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  46507. import { Nullable } from "babylonjs/types";
  46508. import { Scene } from "babylonjs/scene";
  46509. import { ISceneComponent } from "babylonjs/sceneComponent";
  46510. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  46511. module "babylonjs/scene" {
  46512. interface Scene {
  46513. /** @hidden */
  46514. _gamepadManager: Nullable<GamepadManager>;
  46515. /**
  46516. * Gets the gamepad manager associated with the scene
  46517. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  46518. */
  46519. gamepadManager: GamepadManager;
  46520. }
  46521. }
  46522. module "babylonjs/Cameras/freeCameraInputsManager" {
  46523. /**
  46524. * Interface representing a free camera inputs manager
  46525. */
  46526. interface FreeCameraInputsManager {
  46527. /**
  46528. * Adds gamepad input support to the FreeCameraInputsManager.
  46529. * @returns the FreeCameraInputsManager
  46530. */
  46531. addGamepad(): FreeCameraInputsManager;
  46532. }
  46533. }
  46534. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  46535. /**
  46536. * Interface representing an arc rotate camera inputs manager
  46537. */
  46538. interface ArcRotateCameraInputsManager {
  46539. /**
  46540. * Adds gamepad input support to the ArcRotateCamera InputManager.
  46541. * @returns the camera inputs manager
  46542. */
  46543. addGamepad(): ArcRotateCameraInputsManager;
  46544. }
  46545. }
  46546. /**
  46547. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  46548. */
  46549. export class GamepadSystemSceneComponent implements ISceneComponent {
  46550. /**
  46551. * The component name helpfull to identify the component in the list of scene components.
  46552. */
  46553. readonly name: string;
  46554. /**
  46555. * The scene the component belongs to.
  46556. */
  46557. scene: Scene;
  46558. /**
  46559. * Creates a new instance of the component for the given scene
  46560. * @param scene Defines the scene to register the component in
  46561. */
  46562. constructor(scene: Scene);
  46563. /**
  46564. * Registers the component in a given scene
  46565. */
  46566. register(): void;
  46567. /**
  46568. * Rebuilds the elements related to this component in case of
  46569. * context lost for instance.
  46570. */
  46571. rebuild(): void;
  46572. /**
  46573. * Disposes the component and the associated ressources
  46574. */
  46575. dispose(): void;
  46576. private _beforeCameraUpdate;
  46577. }
  46578. }
  46579. declare module "babylonjs/Cameras/universalCamera" {
  46580. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  46581. import { Scene } from "babylonjs/scene";
  46582. import { Vector3 } from "babylonjs/Maths/math.vector";
  46583. import "babylonjs/Gamepads/gamepadSceneComponent";
  46584. /**
  46585. * 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,
  46586. * which still works and will still be found in many Playgrounds.
  46587. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46588. */
  46589. export class UniversalCamera extends TouchCamera {
  46590. /**
  46591. * Defines the gamepad rotation sensiblity.
  46592. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46593. */
  46594. get gamepadAngularSensibility(): number;
  46595. set gamepadAngularSensibility(value: number);
  46596. /**
  46597. * Defines the gamepad move sensiblity.
  46598. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46599. */
  46600. get gamepadMoveSensibility(): number;
  46601. set gamepadMoveSensibility(value: number);
  46602. /**
  46603. * 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,
  46604. * which still works and will still be found in many Playgrounds.
  46605. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46606. * @param name Define the name of the camera in the scene
  46607. * @param position Define the start position of the camera in the scene
  46608. * @param scene Define the scene the camera belongs to
  46609. */
  46610. constructor(name: string, position: Vector3, scene: Scene);
  46611. /**
  46612. * Gets the current object class name.
  46613. * @return the class name
  46614. */
  46615. getClassName(): string;
  46616. }
  46617. }
  46618. declare module "babylonjs/Cameras/gamepadCamera" {
  46619. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46620. import { Scene } from "babylonjs/scene";
  46621. import { Vector3 } from "babylonjs/Maths/math.vector";
  46622. /**
  46623. * This represents a FPS type of camera. This is only here for back compat purpose.
  46624. * Please use the UniversalCamera instead as both are identical.
  46625. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46626. */
  46627. export class GamepadCamera extends UniversalCamera {
  46628. /**
  46629. * Instantiates a new Gamepad Camera
  46630. * This represents a FPS type of camera. This is only here for back compat purpose.
  46631. * Please use the UniversalCamera instead as both are identical.
  46632. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46633. * @param name Define the name of the camera in the scene
  46634. * @param position Define the start position of the camera in the scene
  46635. * @param scene Define the scene the camera belongs to
  46636. */
  46637. constructor(name: string, position: Vector3, scene: Scene);
  46638. /**
  46639. * Gets the current object class name.
  46640. * @return the class name
  46641. */
  46642. getClassName(): string;
  46643. }
  46644. }
  46645. declare module "babylonjs/Shaders/pass.fragment" {
  46646. /** @hidden */
  46647. export var passPixelShader: {
  46648. name: string;
  46649. shader: string;
  46650. };
  46651. }
  46652. declare module "babylonjs/Shaders/passCube.fragment" {
  46653. /** @hidden */
  46654. export var passCubePixelShader: {
  46655. name: string;
  46656. shader: string;
  46657. };
  46658. }
  46659. declare module "babylonjs/PostProcesses/passPostProcess" {
  46660. import { Nullable } from "babylonjs/types";
  46661. import { Camera } from "babylonjs/Cameras/camera";
  46662. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46663. import { Engine } from "babylonjs/Engines/engine";
  46664. import "babylonjs/Shaders/pass.fragment";
  46665. import "babylonjs/Shaders/passCube.fragment";
  46666. /**
  46667. * PassPostProcess which produces an output the same as it's input
  46668. */
  46669. export class PassPostProcess extends PostProcess {
  46670. /**
  46671. * Creates the PassPostProcess
  46672. * @param name The name of the effect.
  46673. * @param options The required width/height ratio to downsize to before computing the render pass.
  46674. * @param camera The camera to apply the render pass to.
  46675. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46676. * @param engine The engine which the post process will be applied. (default: current engine)
  46677. * @param reusable If the post process can be reused on the same frame. (default: false)
  46678. * @param textureType The type of texture to be used when performing the post processing.
  46679. * @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)
  46680. */
  46681. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46682. }
  46683. /**
  46684. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46685. */
  46686. export class PassCubePostProcess extends PostProcess {
  46687. private _face;
  46688. /**
  46689. * Gets or sets the cube face to display.
  46690. * * 0 is +X
  46691. * * 1 is -X
  46692. * * 2 is +Y
  46693. * * 3 is -Y
  46694. * * 4 is +Z
  46695. * * 5 is -Z
  46696. */
  46697. get face(): number;
  46698. set face(value: number);
  46699. /**
  46700. * Creates the PassCubePostProcess
  46701. * @param name The name of the effect.
  46702. * @param options The required width/height ratio to downsize to before computing the render pass.
  46703. * @param camera The camera to apply the render pass to.
  46704. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46705. * @param engine The engine which the post process will be applied. (default: current engine)
  46706. * @param reusable If the post process can be reused on the same frame. (default: false)
  46707. * @param textureType The type of texture to be used when performing the post processing.
  46708. * @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)
  46709. */
  46710. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46711. }
  46712. }
  46713. declare module "babylonjs/Shaders/anaglyph.fragment" {
  46714. /** @hidden */
  46715. export var anaglyphPixelShader: {
  46716. name: string;
  46717. shader: string;
  46718. };
  46719. }
  46720. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  46721. import { Engine } from "babylonjs/Engines/engine";
  46722. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46723. import { Camera } from "babylonjs/Cameras/camera";
  46724. import "babylonjs/Shaders/anaglyph.fragment";
  46725. /**
  46726. * Postprocess used to generate anaglyphic rendering
  46727. */
  46728. export class AnaglyphPostProcess extends PostProcess {
  46729. private _passedProcess;
  46730. /**
  46731. * Creates a new AnaglyphPostProcess
  46732. * @param name defines postprocess name
  46733. * @param options defines creation options or target ratio scale
  46734. * @param rigCameras defines cameras using this postprocess
  46735. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46736. * @param engine defines hosting engine
  46737. * @param reusable defines if the postprocess will be reused multiple times per frame
  46738. */
  46739. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46740. }
  46741. }
  46742. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  46743. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  46744. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46745. import { Scene } from "babylonjs/scene";
  46746. import { Vector3 } from "babylonjs/Maths/math.vector";
  46747. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46748. /**
  46749. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46750. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46751. */
  46752. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46753. /**
  46754. * Creates a new AnaglyphArcRotateCamera
  46755. * @param name defines camera name
  46756. * @param alpha defines alpha angle (in radians)
  46757. * @param beta defines beta angle (in radians)
  46758. * @param radius defines radius
  46759. * @param target defines camera target
  46760. * @param interaxialDistance defines distance between each color axis
  46761. * @param scene defines the hosting scene
  46762. */
  46763. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46764. /**
  46765. * Gets camera class name
  46766. * @returns AnaglyphArcRotateCamera
  46767. */
  46768. getClassName(): string;
  46769. }
  46770. }
  46771. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  46772. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46773. import { Scene } from "babylonjs/scene";
  46774. import { Vector3 } from "babylonjs/Maths/math.vector";
  46775. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46776. /**
  46777. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46778. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46779. */
  46780. export class AnaglyphFreeCamera extends FreeCamera {
  46781. /**
  46782. * Creates a new AnaglyphFreeCamera
  46783. * @param name defines camera name
  46784. * @param position defines initial position
  46785. * @param interaxialDistance defines distance between each color axis
  46786. * @param scene defines the hosting scene
  46787. */
  46788. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46789. /**
  46790. * Gets camera class name
  46791. * @returns AnaglyphFreeCamera
  46792. */
  46793. getClassName(): string;
  46794. }
  46795. }
  46796. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  46797. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46798. import { Scene } from "babylonjs/scene";
  46799. import { Vector3 } from "babylonjs/Maths/math.vector";
  46800. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46801. /**
  46802. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46803. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46804. */
  46805. export class AnaglyphGamepadCamera extends GamepadCamera {
  46806. /**
  46807. * Creates a new AnaglyphGamepadCamera
  46808. * @param name defines camera name
  46809. * @param position defines initial position
  46810. * @param interaxialDistance defines distance between each color axis
  46811. * @param scene defines the hosting scene
  46812. */
  46813. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46814. /**
  46815. * Gets camera class name
  46816. * @returns AnaglyphGamepadCamera
  46817. */
  46818. getClassName(): string;
  46819. }
  46820. }
  46821. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  46822. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46823. import { Scene } from "babylonjs/scene";
  46824. import { Vector3 } from "babylonjs/Maths/math.vector";
  46825. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46826. /**
  46827. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46828. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46829. */
  46830. export class AnaglyphUniversalCamera extends UniversalCamera {
  46831. /**
  46832. * Creates a new AnaglyphUniversalCamera
  46833. * @param name defines camera name
  46834. * @param position defines initial position
  46835. * @param interaxialDistance defines distance between each color axis
  46836. * @param scene defines the hosting scene
  46837. */
  46838. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46839. /**
  46840. * Gets camera class name
  46841. * @returns AnaglyphUniversalCamera
  46842. */
  46843. getClassName(): string;
  46844. }
  46845. }
  46846. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  46847. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  46848. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46849. import { Scene } from "babylonjs/scene";
  46850. import { Vector3 } from "babylonjs/Maths/math.vector";
  46851. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46852. /**
  46853. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46854. * @see https://doc.babylonjs.com/features/cameras
  46855. */
  46856. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46857. /**
  46858. * Creates a new StereoscopicArcRotateCamera
  46859. * @param name defines camera name
  46860. * @param alpha defines alpha angle (in radians)
  46861. * @param beta defines beta angle (in radians)
  46862. * @param radius defines radius
  46863. * @param target defines camera target
  46864. * @param interaxialDistance defines distance between each color axis
  46865. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46866. * @param scene defines the hosting scene
  46867. */
  46868. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46869. /**
  46870. * Gets camera class name
  46871. * @returns StereoscopicArcRotateCamera
  46872. */
  46873. getClassName(): string;
  46874. }
  46875. }
  46876. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  46877. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46878. import { Scene } from "babylonjs/scene";
  46879. import { Vector3 } from "babylonjs/Maths/math.vector";
  46880. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46881. /**
  46882. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46883. * @see https://doc.babylonjs.com/features/cameras
  46884. */
  46885. export class StereoscopicFreeCamera extends FreeCamera {
  46886. /**
  46887. * Creates a new StereoscopicFreeCamera
  46888. * @param name defines camera name
  46889. * @param position defines initial position
  46890. * @param interaxialDistance defines distance between each color axis
  46891. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46892. * @param scene defines the hosting scene
  46893. */
  46894. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46895. /**
  46896. * Gets camera class name
  46897. * @returns StereoscopicFreeCamera
  46898. */
  46899. getClassName(): string;
  46900. }
  46901. }
  46902. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  46903. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46904. import { Scene } from "babylonjs/scene";
  46905. import { Vector3 } from "babylonjs/Maths/math.vector";
  46906. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46907. /**
  46908. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46909. * @see https://doc.babylonjs.com/features/cameras
  46910. */
  46911. export class StereoscopicGamepadCamera extends GamepadCamera {
  46912. /**
  46913. * Creates a new StereoscopicGamepadCamera
  46914. * @param name defines camera name
  46915. * @param position defines initial position
  46916. * @param interaxialDistance defines distance between each color axis
  46917. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46918. * @param scene defines the hosting scene
  46919. */
  46920. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46921. /**
  46922. * Gets camera class name
  46923. * @returns StereoscopicGamepadCamera
  46924. */
  46925. getClassName(): string;
  46926. }
  46927. }
  46928. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  46929. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46930. import { Scene } from "babylonjs/scene";
  46931. import { Vector3 } from "babylonjs/Maths/math.vector";
  46932. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46933. /**
  46934. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46935. * @see https://doc.babylonjs.com/features/cameras
  46936. */
  46937. export class StereoscopicUniversalCamera extends UniversalCamera {
  46938. /**
  46939. * Creates a new StereoscopicUniversalCamera
  46940. * @param name defines camera name
  46941. * @param position defines initial position
  46942. * @param interaxialDistance defines distance between each color axis
  46943. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46944. * @param scene defines the hosting scene
  46945. */
  46946. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46947. /**
  46948. * Gets camera class name
  46949. * @returns StereoscopicUniversalCamera
  46950. */
  46951. getClassName(): string;
  46952. }
  46953. }
  46954. declare module "babylonjs/Cameras/Stereoscopic/index" {
  46955. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  46956. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  46957. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  46958. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  46959. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  46960. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  46961. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  46962. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  46963. }
  46964. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  46965. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46966. import { Scene } from "babylonjs/scene";
  46967. import { Vector3 } from "babylonjs/Maths/math.vector";
  46968. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  46969. /**
  46970. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46971. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46972. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46973. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46974. */
  46975. export class VirtualJoysticksCamera extends FreeCamera {
  46976. /**
  46977. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46978. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46979. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46980. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46981. * @param name Define the name of the camera in the scene
  46982. * @param position Define the start position of the camera in the scene
  46983. * @param scene Define the scene the camera belongs to
  46984. */
  46985. constructor(name: string, position: Vector3, scene: Scene);
  46986. /**
  46987. * Gets the current object class name.
  46988. * @return the class name
  46989. */
  46990. getClassName(): string;
  46991. }
  46992. }
  46993. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  46994. import { Matrix } from "babylonjs/Maths/math.vector";
  46995. /**
  46996. * This represents all the required metrics to create a VR camera.
  46997. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46998. */
  46999. export class VRCameraMetrics {
  47000. /**
  47001. * Define the horizontal resolution off the screen.
  47002. */
  47003. hResolution: number;
  47004. /**
  47005. * Define the vertical resolution off the screen.
  47006. */
  47007. vResolution: number;
  47008. /**
  47009. * Define the horizontal screen size.
  47010. */
  47011. hScreenSize: number;
  47012. /**
  47013. * Define the vertical screen size.
  47014. */
  47015. vScreenSize: number;
  47016. /**
  47017. * Define the vertical screen center position.
  47018. */
  47019. vScreenCenter: number;
  47020. /**
  47021. * Define the distance of the eyes to the screen.
  47022. */
  47023. eyeToScreenDistance: number;
  47024. /**
  47025. * Define the distance between both lenses
  47026. */
  47027. lensSeparationDistance: number;
  47028. /**
  47029. * Define the distance between both viewer's eyes.
  47030. */
  47031. interpupillaryDistance: number;
  47032. /**
  47033. * Define the distortion factor of the VR postprocess.
  47034. * Please, touch with care.
  47035. */
  47036. distortionK: number[];
  47037. /**
  47038. * Define the chromatic aberration correction factors for the VR post process.
  47039. */
  47040. chromaAbCorrection: number[];
  47041. /**
  47042. * Define the scale factor of the post process.
  47043. * The smaller the better but the slower.
  47044. */
  47045. postProcessScaleFactor: number;
  47046. /**
  47047. * Define an offset for the lens center.
  47048. */
  47049. lensCenterOffset: number;
  47050. /**
  47051. * Define if the current vr camera should compensate the distortion of the lense or not.
  47052. */
  47053. compensateDistortion: boolean;
  47054. /**
  47055. * Defines if multiview should be enabled when rendering (Default: false)
  47056. */
  47057. multiviewEnabled: boolean;
  47058. /**
  47059. * Gets the rendering aspect ratio based on the provided resolutions.
  47060. */
  47061. get aspectRatio(): number;
  47062. /**
  47063. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  47064. */
  47065. get aspectRatioFov(): number;
  47066. /**
  47067. * @hidden
  47068. */
  47069. get leftHMatrix(): Matrix;
  47070. /**
  47071. * @hidden
  47072. */
  47073. get rightHMatrix(): Matrix;
  47074. /**
  47075. * @hidden
  47076. */
  47077. get leftPreViewMatrix(): Matrix;
  47078. /**
  47079. * @hidden
  47080. */
  47081. get rightPreViewMatrix(): Matrix;
  47082. /**
  47083. * Get the default VRMetrics based on the most generic setup.
  47084. * @returns the default vr metrics
  47085. */
  47086. static GetDefault(): VRCameraMetrics;
  47087. }
  47088. }
  47089. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  47090. /** @hidden */
  47091. export var vrDistortionCorrectionPixelShader: {
  47092. name: string;
  47093. shader: string;
  47094. };
  47095. }
  47096. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  47097. import { Camera } from "babylonjs/Cameras/camera";
  47098. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47099. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  47100. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  47101. /**
  47102. * VRDistortionCorrectionPostProcess used for mobile VR
  47103. */
  47104. export class VRDistortionCorrectionPostProcess extends PostProcess {
  47105. private _isRightEye;
  47106. private _distortionFactors;
  47107. private _postProcessScaleFactor;
  47108. private _lensCenterOffset;
  47109. private _scaleIn;
  47110. private _scaleFactor;
  47111. private _lensCenter;
  47112. /**
  47113. * Initializes the VRDistortionCorrectionPostProcess
  47114. * @param name The name of the effect.
  47115. * @param camera The camera to apply the render pass to.
  47116. * @param isRightEye If this is for the right eye distortion
  47117. * @param vrMetrics All the required metrics for the VR camera
  47118. */
  47119. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  47120. }
  47121. }
  47122. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  47123. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  47124. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47125. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47126. import { Scene } from "babylonjs/scene";
  47127. import { Vector3 } from "babylonjs/Maths/math.vector";
  47128. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  47129. import "babylonjs/Cameras/RigModes/vrRigMode";
  47130. /**
  47131. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  47132. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47133. */
  47134. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  47135. /**
  47136. * Creates a new VRDeviceOrientationArcRotateCamera
  47137. * @param name defines camera name
  47138. * @param alpha defines the camera rotation along the logitudinal axis
  47139. * @param beta defines the camera rotation along the latitudinal axis
  47140. * @param radius defines the camera distance from its target
  47141. * @param target defines the camera target
  47142. * @param scene defines the scene the camera belongs to
  47143. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47144. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47145. */
  47146. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47147. /**
  47148. * Gets camera class name
  47149. * @returns VRDeviceOrientationArcRotateCamera
  47150. */
  47151. getClassName(): string;
  47152. }
  47153. }
  47154. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  47155. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  47156. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47157. import { Scene } from "babylonjs/scene";
  47158. import { Vector3 } from "babylonjs/Maths/math.vector";
  47159. import "babylonjs/Cameras/RigModes/vrRigMode";
  47160. /**
  47161. * Camera used to simulate VR rendering (based on FreeCamera)
  47162. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47163. */
  47164. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  47165. /**
  47166. * Creates a new VRDeviceOrientationFreeCamera
  47167. * @param name defines camera name
  47168. * @param position defines the start position of the camera
  47169. * @param scene defines the scene the camera belongs to
  47170. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47171. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47172. */
  47173. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47174. /**
  47175. * Gets camera class name
  47176. * @returns VRDeviceOrientationFreeCamera
  47177. */
  47178. getClassName(): string;
  47179. }
  47180. }
  47181. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  47182. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47183. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47184. import { Scene } from "babylonjs/scene";
  47185. import { Vector3 } from "babylonjs/Maths/math.vector";
  47186. import "babylonjs/Gamepads/gamepadSceneComponent";
  47187. /**
  47188. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  47189. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47190. */
  47191. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  47192. /**
  47193. * Creates a new VRDeviceOrientationGamepadCamera
  47194. * @param name defines camera name
  47195. * @param position defines the start position of the camera
  47196. * @param scene defines the scene the camera belongs to
  47197. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47198. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47199. */
  47200. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47201. /**
  47202. * Gets camera class name
  47203. * @returns VRDeviceOrientationGamepadCamera
  47204. */
  47205. getClassName(): string;
  47206. }
  47207. }
  47208. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  47209. import { Scene } from "babylonjs/scene";
  47210. import { Texture } from "babylonjs/Materials/Textures/texture";
  47211. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  47212. /**
  47213. * A class extending Texture allowing drawing on a texture
  47214. * @see https://doc.babylonjs.com/how_to/dynamictexture
  47215. */
  47216. export class DynamicTexture extends Texture {
  47217. private _generateMipMaps;
  47218. private _canvas;
  47219. private _context;
  47220. /**
  47221. * Creates a DynamicTexture
  47222. * @param name defines the name of the texture
  47223. * @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
  47224. * @param scene defines the scene where you want the texture
  47225. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  47226. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  47227. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  47228. */
  47229. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  47230. /**
  47231. * Get the current class name of the texture useful for serialization or dynamic coding.
  47232. * @returns "DynamicTexture"
  47233. */
  47234. getClassName(): string;
  47235. /**
  47236. * Gets the current state of canRescale
  47237. */
  47238. get canRescale(): boolean;
  47239. private _recreate;
  47240. /**
  47241. * Scales the texture
  47242. * @param ratio the scale factor to apply to both width and height
  47243. */
  47244. scale(ratio: number): void;
  47245. /**
  47246. * Resizes the texture
  47247. * @param width the new width
  47248. * @param height the new height
  47249. */
  47250. scaleTo(width: number, height: number): void;
  47251. /**
  47252. * Gets the context of the canvas used by the texture
  47253. * @returns the canvas context of the dynamic texture
  47254. */
  47255. getContext(): CanvasRenderingContext2D;
  47256. /**
  47257. * Clears the texture
  47258. */
  47259. clear(): void;
  47260. /**
  47261. * Updates the texture
  47262. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  47263. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  47264. */
  47265. update(invertY?: boolean, premulAlpha?: boolean): void;
  47266. /**
  47267. * Draws text onto the texture
  47268. * @param text defines the text to be drawn
  47269. * @param x defines the placement of the text from the left
  47270. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  47271. * @param font defines the font to be used with font-style, font-size, font-name
  47272. * @param color defines the color used for the text
  47273. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  47274. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  47275. * @param update defines whether texture is immediately update (default is true)
  47276. */
  47277. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  47278. /**
  47279. * Clones the texture
  47280. * @returns the clone of the texture.
  47281. */
  47282. clone(): DynamicTexture;
  47283. /**
  47284. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  47285. * @returns a serialized dynamic texture object
  47286. */
  47287. serialize(): any;
  47288. private _IsCanvasElement;
  47289. /** @hidden */
  47290. _rebuild(): void;
  47291. }
  47292. }
  47293. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  47294. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47295. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47296. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47297. /** @hidden */
  47298. export var imageProcessingPixelShader: {
  47299. name: string;
  47300. shader: string;
  47301. };
  47302. }
  47303. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  47304. import { Nullable } from "babylonjs/types";
  47305. import { Color4 } from "babylonjs/Maths/math.color";
  47306. import { Camera } from "babylonjs/Cameras/camera";
  47307. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47308. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47309. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47310. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47311. import { Engine } from "babylonjs/Engines/engine";
  47312. import "babylonjs/Shaders/imageProcessing.fragment";
  47313. import "babylonjs/Shaders/postprocess.vertex";
  47314. /**
  47315. * ImageProcessingPostProcess
  47316. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  47317. */
  47318. export class ImageProcessingPostProcess extends PostProcess {
  47319. /**
  47320. * Default configuration related to image processing available in the PBR Material.
  47321. */
  47322. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47323. /**
  47324. * Gets the image processing configuration used either in this material.
  47325. */
  47326. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  47327. /**
  47328. * Sets the Default image processing configuration used either in the this material.
  47329. *
  47330. * If sets to null, the scene one is in use.
  47331. */
  47332. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  47333. /**
  47334. * Keep track of the image processing observer to allow dispose and replace.
  47335. */
  47336. private _imageProcessingObserver;
  47337. /**
  47338. * Attaches a new image processing configuration to the PBR Material.
  47339. * @param configuration
  47340. */
  47341. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  47342. /**
  47343. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  47344. */
  47345. get colorCurves(): Nullable<ColorCurves>;
  47346. /**
  47347. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  47348. */
  47349. set colorCurves(value: Nullable<ColorCurves>);
  47350. /**
  47351. * Gets wether the color curves effect is enabled.
  47352. */
  47353. get colorCurvesEnabled(): boolean;
  47354. /**
  47355. * Sets wether the color curves effect is enabled.
  47356. */
  47357. set colorCurvesEnabled(value: boolean);
  47358. /**
  47359. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  47360. */
  47361. get colorGradingTexture(): Nullable<BaseTexture>;
  47362. /**
  47363. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  47364. */
  47365. set colorGradingTexture(value: Nullable<BaseTexture>);
  47366. /**
  47367. * Gets wether the color grading effect is enabled.
  47368. */
  47369. get colorGradingEnabled(): boolean;
  47370. /**
  47371. * Gets wether the color grading effect is enabled.
  47372. */
  47373. set colorGradingEnabled(value: boolean);
  47374. /**
  47375. * Gets exposure used in the effect.
  47376. */
  47377. get exposure(): number;
  47378. /**
  47379. * Sets exposure used in the effect.
  47380. */
  47381. set exposure(value: number);
  47382. /**
  47383. * Gets wether tonemapping is enabled or not.
  47384. */
  47385. get toneMappingEnabled(): boolean;
  47386. /**
  47387. * Sets wether tonemapping is enabled or not
  47388. */
  47389. set toneMappingEnabled(value: boolean);
  47390. /**
  47391. * Gets the type of tone mapping effect.
  47392. */
  47393. get toneMappingType(): number;
  47394. /**
  47395. * Sets the type of tone mapping effect.
  47396. */
  47397. set toneMappingType(value: number);
  47398. /**
  47399. * Gets contrast used in the effect.
  47400. */
  47401. get contrast(): number;
  47402. /**
  47403. * Sets contrast used in the effect.
  47404. */
  47405. set contrast(value: number);
  47406. /**
  47407. * Gets Vignette stretch size.
  47408. */
  47409. get vignetteStretch(): number;
  47410. /**
  47411. * Sets Vignette stretch size.
  47412. */
  47413. set vignetteStretch(value: number);
  47414. /**
  47415. * Gets Vignette centre X Offset.
  47416. */
  47417. get vignetteCentreX(): number;
  47418. /**
  47419. * Sets Vignette centre X Offset.
  47420. */
  47421. set vignetteCentreX(value: number);
  47422. /**
  47423. * Gets Vignette centre Y Offset.
  47424. */
  47425. get vignetteCentreY(): number;
  47426. /**
  47427. * Sets Vignette centre Y Offset.
  47428. */
  47429. set vignetteCentreY(value: number);
  47430. /**
  47431. * Gets Vignette weight or intensity of the vignette effect.
  47432. */
  47433. get vignetteWeight(): number;
  47434. /**
  47435. * Sets Vignette weight or intensity of the vignette effect.
  47436. */
  47437. set vignetteWeight(value: number);
  47438. /**
  47439. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  47440. * if vignetteEnabled is set to true.
  47441. */
  47442. get vignetteColor(): Color4;
  47443. /**
  47444. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  47445. * if vignetteEnabled is set to true.
  47446. */
  47447. set vignetteColor(value: Color4);
  47448. /**
  47449. * Gets Camera field of view used by the Vignette effect.
  47450. */
  47451. get vignetteCameraFov(): number;
  47452. /**
  47453. * Sets Camera field of view used by the Vignette effect.
  47454. */
  47455. set vignetteCameraFov(value: number);
  47456. /**
  47457. * Gets the vignette blend mode allowing different kind of effect.
  47458. */
  47459. get vignetteBlendMode(): number;
  47460. /**
  47461. * Sets the vignette blend mode allowing different kind of effect.
  47462. */
  47463. set vignetteBlendMode(value: number);
  47464. /**
  47465. * Gets wether the vignette effect is enabled.
  47466. */
  47467. get vignetteEnabled(): boolean;
  47468. /**
  47469. * Sets wether the vignette effect is enabled.
  47470. */
  47471. set vignetteEnabled(value: boolean);
  47472. private _fromLinearSpace;
  47473. /**
  47474. * Gets wether the input of the processing is in Gamma or Linear Space.
  47475. */
  47476. get fromLinearSpace(): boolean;
  47477. /**
  47478. * Sets wether the input of the processing is in Gamma or Linear Space.
  47479. */
  47480. set fromLinearSpace(value: boolean);
  47481. /**
  47482. * Defines cache preventing GC.
  47483. */
  47484. private _defines;
  47485. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  47486. /**
  47487. * "ImageProcessingPostProcess"
  47488. * @returns "ImageProcessingPostProcess"
  47489. */
  47490. getClassName(): string;
  47491. protected _updateParameters(): void;
  47492. dispose(camera?: Camera): void;
  47493. }
  47494. }
  47495. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  47496. import { Scene } from "babylonjs/scene";
  47497. import { Color3 } from "babylonjs/Maths/math.color";
  47498. import { Mesh } from "babylonjs/Meshes/mesh";
  47499. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  47500. import { Nullable } from "babylonjs/types";
  47501. /**
  47502. * Class containing static functions to help procedurally build meshes
  47503. */
  47504. export class GroundBuilder {
  47505. /**
  47506. * Creates a ground mesh
  47507. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  47508. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  47509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47510. * @param name defines the name of the mesh
  47511. * @param options defines the options used to create the mesh
  47512. * @param scene defines the hosting scene
  47513. * @returns the ground mesh
  47514. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  47515. */
  47516. static CreateGround(name: string, options: {
  47517. width?: number;
  47518. height?: number;
  47519. subdivisions?: number;
  47520. subdivisionsX?: number;
  47521. subdivisionsY?: number;
  47522. updatable?: boolean;
  47523. }, scene: any): Mesh;
  47524. /**
  47525. * Creates a tiled ground mesh
  47526. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  47527. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  47528. * * 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
  47529. * * 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
  47530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47531. * @param name defines the name of the mesh
  47532. * @param options defines the options used to create the mesh
  47533. * @param scene defines the hosting scene
  47534. * @returns the tiled ground mesh
  47535. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  47536. */
  47537. static CreateTiledGround(name: string, options: {
  47538. xmin: number;
  47539. zmin: number;
  47540. xmax: number;
  47541. zmax: number;
  47542. subdivisions?: {
  47543. w: number;
  47544. h: number;
  47545. };
  47546. precision?: {
  47547. w: number;
  47548. h: number;
  47549. };
  47550. updatable?: boolean;
  47551. }, scene?: Nullable<Scene>): Mesh;
  47552. /**
  47553. * Creates a ground mesh from a height map
  47554. * * The parameter `url` sets the URL of the height map image resource.
  47555. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  47556. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  47557. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  47558. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  47559. * * 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.
  47560. * * 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).
  47561. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  47562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47563. * @param name defines the name of the mesh
  47564. * @param url defines the url to the height map
  47565. * @param options defines the options used to create the mesh
  47566. * @param scene defines the hosting scene
  47567. * @returns the ground mesh
  47568. * @see https://doc.babylonjs.com/babylon101/height_map
  47569. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  47570. */
  47571. static CreateGroundFromHeightMap(name: string, url: string, options: {
  47572. width?: number;
  47573. height?: number;
  47574. subdivisions?: number;
  47575. minHeight?: number;
  47576. maxHeight?: number;
  47577. colorFilter?: Color3;
  47578. alphaFilter?: number;
  47579. updatable?: boolean;
  47580. onReady?: (mesh: GroundMesh) => void;
  47581. }, scene?: Nullable<Scene>): GroundMesh;
  47582. }
  47583. }
  47584. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  47585. import { Vector4 } from "babylonjs/Maths/math.vector";
  47586. import { Mesh } from "babylonjs/Meshes/mesh";
  47587. /**
  47588. * Class containing static functions to help procedurally build meshes
  47589. */
  47590. export class TorusBuilder {
  47591. /**
  47592. * Creates a torus mesh
  47593. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  47594. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  47595. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  47596. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47597. * * 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
  47598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47599. * @param name defines the name of the mesh
  47600. * @param options defines the options used to create the mesh
  47601. * @param scene defines the hosting scene
  47602. * @returns the torus mesh
  47603. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  47604. */
  47605. static CreateTorus(name: string, options: {
  47606. diameter?: number;
  47607. thickness?: number;
  47608. tessellation?: number;
  47609. updatable?: boolean;
  47610. sideOrientation?: number;
  47611. frontUVs?: Vector4;
  47612. backUVs?: Vector4;
  47613. }, scene: any): Mesh;
  47614. }
  47615. }
  47616. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  47617. import { Vector4 } from "babylonjs/Maths/math.vector";
  47618. import { Color4 } from "babylonjs/Maths/math.color";
  47619. import { Mesh } from "babylonjs/Meshes/mesh";
  47620. /**
  47621. * Class containing static functions to help procedurally build meshes
  47622. */
  47623. export class CylinderBuilder {
  47624. /**
  47625. * Creates a cylinder or a cone mesh
  47626. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  47627. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  47628. * * 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.
  47629. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  47630. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  47631. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  47632. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  47633. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  47634. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  47635. * * 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).
  47636. * * 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
  47637. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  47638. * * 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
  47639. * * 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.
  47640. * * If `enclose` is false, a ring surface is one element.
  47641. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  47642. * * 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
  47643. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47644. * * 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
  47645. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47646. * @param name defines the name of the mesh
  47647. * @param options defines the options used to create the mesh
  47648. * @param scene defines the hosting scene
  47649. * @returns the cylinder mesh
  47650. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  47651. */
  47652. static CreateCylinder(name: string, options: {
  47653. height?: number;
  47654. diameterTop?: number;
  47655. diameterBottom?: number;
  47656. diameter?: number;
  47657. tessellation?: number;
  47658. subdivisions?: number;
  47659. arc?: number;
  47660. faceColors?: Color4[];
  47661. faceUV?: Vector4[];
  47662. updatable?: boolean;
  47663. hasRings?: boolean;
  47664. enclose?: boolean;
  47665. cap?: number;
  47666. sideOrientation?: number;
  47667. frontUVs?: Vector4;
  47668. backUVs?: Vector4;
  47669. }, scene: any): Mesh;
  47670. }
  47671. }
  47672. declare module "babylonjs/XR/webXRTypes" {
  47673. import { Nullable } from "babylonjs/types";
  47674. import { IDisposable } from "babylonjs/scene";
  47675. /**
  47676. * States of the webXR experience
  47677. */
  47678. export enum WebXRState {
  47679. /**
  47680. * Transitioning to being in XR mode
  47681. */
  47682. ENTERING_XR = 0,
  47683. /**
  47684. * Transitioning to non XR mode
  47685. */
  47686. EXITING_XR = 1,
  47687. /**
  47688. * In XR mode and presenting
  47689. */
  47690. IN_XR = 2,
  47691. /**
  47692. * Not entered XR mode
  47693. */
  47694. NOT_IN_XR = 3
  47695. }
  47696. /**
  47697. * Abstraction of the XR render target
  47698. */
  47699. export interface WebXRRenderTarget extends IDisposable {
  47700. /**
  47701. * xrpresent context of the canvas which can be used to display/mirror xr content
  47702. */
  47703. canvasContext: WebGLRenderingContext;
  47704. /**
  47705. * xr layer for the canvas
  47706. */
  47707. xrLayer: Nullable<XRWebGLLayer>;
  47708. /**
  47709. * Initializes the xr layer for the session
  47710. * @param xrSession xr session
  47711. * @returns a promise that will resolve once the XR Layer has been created
  47712. */
  47713. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47714. }
  47715. }
  47716. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  47717. import { Nullable } from "babylonjs/types";
  47718. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47719. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47720. /**
  47721. * COnfiguration object for WebXR output canvas
  47722. */
  47723. export class WebXRManagedOutputCanvasOptions {
  47724. /**
  47725. * An optional canvas in case you wish to create it yourself and provide it here.
  47726. * If not provided, a new canvas will be created
  47727. */
  47728. canvasElement?: HTMLCanvasElement;
  47729. /**
  47730. * Options for this XR Layer output
  47731. */
  47732. canvasOptions?: XRWebGLLayerOptions;
  47733. /**
  47734. * CSS styling for a newly created canvas (if not provided)
  47735. */
  47736. newCanvasCssStyle?: string;
  47737. /**
  47738. * Get the default values of the configuration object
  47739. * @returns default values of this configuration object
  47740. */
  47741. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  47742. }
  47743. /**
  47744. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  47745. */
  47746. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  47747. private _options;
  47748. private _canvas;
  47749. private _engine;
  47750. /**
  47751. * Rendering context of the canvas which can be used to display/mirror xr content
  47752. */
  47753. canvasContext: WebGLRenderingContext;
  47754. /**
  47755. * xr layer for the canvas
  47756. */
  47757. xrLayer: Nullable<XRWebGLLayer>;
  47758. /**
  47759. * Initializes the canvas to be added/removed upon entering/exiting xr
  47760. * @param _xrSessionManager The XR Session manager
  47761. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  47762. */
  47763. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  47764. /**
  47765. * Disposes of the object
  47766. */
  47767. dispose(): void;
  47768. /**
  47769. * Initializes the xr layer for the session
  47770. * @param xrSession xr session
  47771. * @returns a promise that will resolve once the XR Layer has been created
  47772. */
  47773. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47774. private _addCanvas;
  47775. private _removeCanvas;
  47776. private _setManagedOutputCanvas;
  47777. }
  47778. }
  47779. declare module "babylonjs/XR/webXRSessionManager" {
  47780. import { Observable } from "babylonjs/Misc/observable";
  47781. import { Nullable } from "babylonjs/types";
  47782. import { IDisposable, Scene } from "babylonjs/scene";
  47783. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47784. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47785. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  47786. /**
  47787. * Manages an XRSession to work with Babylon's engine
  47788. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  47789. */
  47790. export class WebXRSessionManager implements IDisposable {
  47791. /** The scene which the session should be created for */
  47792. scene: Scene;
  47793. private _referenceSpace;
  47794. private _rttProvider;
  47795. private _sessionEnded;
  47796. private _xrNavigator;
  47797. private baseLayer;
  47798. /**
  47799. * The base reference space from which the session started. good if you want to reset your
  47800. * reference space
  47801. */
  47802. baseReferenceSpace: XRReferenceSpace;
  47803. /**
  47804. * Current XR frame
  47805. */
  47806. currentFrame: Nullable<XRFrame>;
  47807. /** WebXR timestamp updated every frame */
  47808. currentTimestamp: number;
  47809. /**
  47810. * Used just in case of a failure to initialize an immersive session.
  47811. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  47812. */
  47813. defaultHeightCompensation: number;
  47814. /**
  47815. * Fires every time a new xrFrame arrives which can be used to update the camera
  47816. */
  47817. onXRFrameObservable: Observable<XRFrame>;
  47818. /**
  47819. * Fires when the reference space changed
  47820. */
  47821. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  47822. /**
  47823. * Fires when the xr session is ended either by the device or manually done
  47824. */
  47825. onXRSessionEnded: Observable<any>;
  47826. /**
  47827. * Fires when the xr session is ended either by the device or manually done
  47828. */
  47829. onXRSessionInit: Observable<XRSession>;
  47830. /**
  47831. * Underlying xr session
  47832. */
  47833. session: XRSession;
  47834. /**
  47835. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  47836. * or get the offset the player is currently at.
  47837. */
  47838. viewerReferenceSpace: XRReferenceSpace;
  47839. /**
  47840. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  47841. * @param scene The scene which the session should be created for
  47842. */
  47843. constructor(
  47844. /** The scene which the session should be created for */
  47845. scene: Scene);
  47846. /**
  47847. * The current reference space used in this session. This reference space can constantly change!
  47848. * It is mainly used to offset the camera's position.
  47849. */
  47850. get referenceSpace(): XRReferenceSpace;
  47851. /**
  47852. * Set a new reference space and triggers the observable
  47853. */
  47854. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  47855. /**
  47856. * Disposes of the session manager
  47857. */
  47858. dispose(): void;
  47859. /**
  47860. * Stops the xrSession and restores the render loop
  47861. * @returns Promise which resolves after it exits XR
  47862. */
  47863. exitXRAsync(): Promise<void>;
  47864. /**
  47865. * Gets the correct render target texture to be rendered this frame for this eye
  47866. * @param eye the eye for which to get the render target
  47867. * @returns the render target for the specified eye
  47868. */
  47869. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  47870. /**
  47871. * Creates a WebXRRenderTarget object for the XR session
  47872. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  47873. * @param options optional options to provide when creating a new render target
  47874. * @returns a WebXR render target to which the session can render
  47875. */
  47876. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  47877. /**
  47878. * Initializes the manager
  47879. * After initialization enterXR can be called to start an XR session
  47880. * @returns Promise which resolves after it is initialized
  47881. */
  47882. initializeAsync(): Promise<void>;
  47883. /**
  47884. * Initializes an xr session
  47885. * @param xrSessionMode mode to initialize
  47886. * @param xrSessionInit defines optional and required values to pass to the session builder
  47887. * @returns a promise which will resolve once the session has been initialized
  47888. */
  47889. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  47890. /**
  47891. * Checks if a session would be supported for the creation options specified
  47892. * @param sessionMode session mode to check if supported eg. immersive-vr
  47893. * @returns A Promise that resolves to true if supported and false if not
  47894. */
  47895. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47896. /**
  47897. * Resets the reference space to the one started the session
  47898. */
  47899. resetReferenceSpace(): void;
  47900. /**
  47901. * Starts rendering to the xr layer
  47902. */
  47903. runXRRenderLoop(): void;
  47904. /**
  47905. * Sets the reference space on the xr session
  47906. * @param referenceSpaceType space to set
  47907. * @returns a promise that will resolve once the reference space has been set
  47908. */
  47909. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  47910. /**
  47911. * Updates the render state of the session
  47912. * @param state state to set
  47913. * @returns a promise that resolves once the render state has been updated
  47914. */
  47915. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  47916. /**
  47917. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  47918. * @param sessionMode defines the session to test
  47919. * @returns a promise with boolean as final value
  47920. */
  47921. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47922. private _createRenderTargetTexture;
  47923. }
  47924. }
  47925. declare module "babylonjs/XR/webXRCamera" {
  47926. import { Matrix } from "babylonjs/Maths/math.vector";
  47927. import { Scene } from "babylonjs/scene";
  47928. import { Camera } from "babylonjs/Cameras/camera";
  47929. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47930. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47931. /**
  47932. * WebXR Camera which holds the views for the xrSession
  47933. * @see https://doc.babylonjs.com/how_to/webxr_camera
  47934. */
  47935. export class WebXRCamera extends FreeCamera {
  47936. private _xrSessionManager;
  47937. private _firstFrame;
  47938. private _referenceQuaternion;
  47939. private _referencedPosition;
  47940. private _xrInvPositionCache;
  47941. private _xrInvQuaternionCache;
  47942. /**
  47943. * Should position compensation execute on first frame.
  47944. * This is used when copying the position from a native (non XR) camera
  47945. */
  47946. compensateOnFirstFrame: boolean;
  47947. /**
  47948. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47949. * @param name the name of the camera
  47950. * @param scene the scene to add the camera to
  47951. * @param _xrSessionManager a constructed xr session manager
  47952. */
  47953. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47954. /**
  47955. * Return the user's height, unrelated to the current ground.
  47956. * This will be the y position of this camera, when ground level is 0.
  47957. */
  47958. get realWorldHeight(): number;
  47959. /** @hidden */
  47960. _updateForDualEyeDebugging(): void;
  47961. /**
  47962. * Sets this camera's transformation based on a non-vr camera
  47963. * @param otherCamera the non-vr camera to copy the transformation from
  47964. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47965. */
  47966. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47967. /**
  47968. * Gets the current instance class name ("WebXRCamera").
  47969. * @returns the class name
  47970. */
  47971. getClassName(): string;
  47972. /**
  47973. * Overriding the _getViewMatrix function, as it is computed by WebXR
  47974. */
  47975. _getViewMatrix(): Matrix;
  47976. private _updateFromXRSession;
  47977. private _updateNumberOfRigCameras;
  47978. private _updateReferenceSpace;
  47979. private _updateReferenceSpaceOffset;
  47980. }
  47981. }
  47982. declare module "babylonjs/XR/webXRFeaturesManager" {
  47983. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47984. import { IDisposable } from "babylonjs/scene";
  47985. /**
  47986. * Defining the interface required for a (webxr) feature
  47987. */
  47988. export interface IWebXRFeature extends IDisposable {
  47989. /**
  47990. * Is this feature attached
  47991. */
  47992. attached: boolean;
  47993. /**
  47994. * Should auto-attach be disabled?
  47995. */
  47996. disableAutoAttach: boolean;
  47997. /**
  47998. * Attach the feature to the session
  47999. * Will usually be called by the features manager
  48000. *
  48001. * @param force should attachment be forced (even when already attached)
  48002. * @returns true if successful.
  48003. */
  48004. attach(force?: boolean): boolean;
  48005. /**
  48006. * Detach the feature from the session
  48007. * Will usually be called by the features manager
  48008. *
  48009. * @returns true if successful.
  48010. */
  48011. detach(): boolean;
  48012. }
  48013. /**
  48014. * A list of the currently available features without referencing them
  48015. */
  48016. export class WebXRFeatureName {
  48017. /**
  48018. * The name of the anchor system feature
  48019. */
  48020. static ANCHOR_SYSTEM: string;
  48021. /**
  48022. * The name of the background remover feature
  48023. */
  48024. static BACKGROUND_REMOVER: string;
  48025. /**
  48026. * The name of the hit test feature
  48027. */
  48028. static HIT_TEST: string;
  48029. /**
  48030. * physics impostors for xr controllers feature
  48031. */
  48032. static PHYSICS_CONTROLLERS: string;
  48033. /**
  48034. * The name of the plane detection feature
  48035. */
  48036. static PLANE_DETECTION: string;
  48037. /**
  48038. * The name of the pointer selection feature
  48039. */
  48040. static POINTER_SELECTION: string;
  48041. /**
  48042. * The name of the teleportation feature
  48043. */
  48044. static TELEPORTATION: string;
  48045. }
  48046. /**
  48047. * Defining the constructor of a feature. Used to register the modules.
  48048. */
  48049. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  48050. /**
  48051. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  48052. * It is mainly used in AR sessions.
  48053. *
  48054. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  48055. */
  48056. export class WebXRFeaturesManager implements IDisposable {
  48057. private _xrSessionManager;
  48058. private static readonly _AvailableFeatures;
  48059. private _features;
  48060. /**
  48061. * constructs a new features manages.
  48062. *
  48063. * @param _xrSessionManager an instance of WebXRSessionManager
  48064. */
  48065. constructor(_xrSessionManager: WebXRSessionManager);
  48066. /**
  48067. * Used to register a module. After calling this function a developer can use this feature in the scene.
  48068. * Mainly used internally.
  48069. *
  48070. * @param featureName the name of the feature to register
  48071. * @param constructorFunction the function used to construct the module
  48072. * @param version the (babylon) version of the module
  48073. * @param stable is that a stable version of this module
  48074. */
  48075. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  48076. /**
  48077. * Returns a constructor of a specific feature.
  48078. *
  48079. * @param featureName the name of the feature to construct
  48080. * @param version the version of the feature to load
  48081. * @param xrSessionManager the xrSessionManager. Used to construct the module
  48082. * @param options optional options provided to the module.
  48083. * @returns a function that, when called, will return a new instance of this feature
  48084. */
  48085. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  48086. /**
  48087. * Can be used to return the list of features currently registered
  48088. *
  48089. * @returns an Array of available features
  48090. */
  48091. static GetAvailableFeatures(): string[];
  48092. /**
  48093. * Gets the versions available for a specific feature
  48094. * @param featureName the name of the feature
  48095. * @returns an array with the available versions
  48096. */
  48097. static GetAvailableVersions(featureName: string): string[];
  48098. /**
  48099. * Return the latest unstable version of this feature
  48100. * @param featureName the name of the feature to search
  48101. * @returns the version number. if not found will return -1
  48102. */
  48103. static GetLatestVersionOfFeature(featureName: string): number;
  48104. /**
  48105. * Return the latest stable version of this feature
  48106. * @param featureName the name of the feature to search
  48107. * @returns the version number. if not found will return -1
  48108. */
  48109. static GetStableVersionOfFeature(featureName: string): number;
  48110. /**
  48111. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  48112. * Can be used during a session to start a feature
  48113. * @param featureName the name of feature to attach
  48114. */
  48115. attachFeature(featureName: string): void;
  48116. /**
  48117. * Can be used inside a session or when the session ends to detach a specific feature
  48118. * @param featureName the name of the feature to detach
  48119. */
  48120. detachFeature(featureName: string): void;
  48121. /**
  48122. * Used to disable an already-enabled feature
  48123. * The feature will be disposed and will be recreated once enabled.
  48124. * @param featureName the feature to disable
  48125. * @returns true if disable was successful
  48126. */
  48127. disableFeature(featureName: string | {
  48128. Name: string;
  48129. }): boolean;
  48130. /**
  48131. * dispose this features manager
  48132. */
  48133. dispose(): void;
  48134. /**
  48135. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  48136. * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.
  48137. *
  48138. * @param featureName the name of the feature to load or the class of the feature
  48139. * @param version optional version to load. if not provided the latest version will be enabled
  48140. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  48141. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  48142. * @returns a new constructed feature or throws an error if feature not found.
  48143. */
  48144. enableFeature(featureName: string | {
  48145. Name: string;
  48146. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  48147. /**
  48148. * get the implementation of an enabled feature.
  48149. * @param featureName the name of the feature to load
  48150. * @returns the feature class, if found
  48151. */
  48152. getEnabledFeature(featureName: string): IWebXRFeature;
  48153. /**
  48154. * Get the list of enabled features
  48155. * @returns an array of enabled features
  48156. */
  48157. getEnabledFeatures(): string[];
  48158. }
  48159. }
  48160. declare module "babylonjs/XR/webXRExperienceHelper" {
  48161. import { Observable } from "babylonjs/Misc/observable";
  48162. import { IDisposable, Scene } from "babylonjs/scene";
  48163. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48164. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  48165. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48166. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  48167. /**
  48168. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  48169. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  48170. */
  48171. export class WebXRExperienceHelper implements IDisposable {
  48172. private scene;
  48173. private _nonVRCamera;
  48174. private _originalSceneAutoClear;
  48175. private _supported;
  48176. /**
  48177. * Camera used to render xr content
  48178. */
  48179. camera: WebXRCamera;
  48180. /** A features manager for this xr session */
  48181. featuresManager: WebXRFeaturesManager;
  48182. /**
  48183. * Observers registered here will be triggered after the camera's initial transformation is set
  48184. * This can be used to set a different ground level or an extra rotation.
  48185. *
  48186. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  48187. * to the position set after this observable is done executing.
  48188. */
  48189. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  48190. /**
  48191. * Fires when the state of the experience helper has changed
  48192. */
  48193. onStateChangedObservable: Observable<WebXRState>;
  48194. /** Session manager used to keep track of xr session */
  48195. sessionManager: WebXRSessionManager;
  48196. /**
  48197. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  48198. */
  48199. state: WebXRState;
  48200. /**
  48201. * Creates a WebXRExperienceHelper
  48202. * @param scene The scene the helper should be created in
  48203. */
  48204. private constructor();
  48205. /**
  48206. * Creates the experience helper
  48207. * @param scene the scene to attach the experience helper to
  48208. * @returns a promise for the experience helper
  48209. */
  48210. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  48211. /**
  48212. * Disposes of the experience helper
  48213. */
  48214. dispose(): void;
  48215. /**
  48216. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  48217. * @param sessionMode options for the XR session
  48218. * @param referenceSpaceType frame of reference of the XR session
  48219. * @param renderTarget the output canvas that will be used to enter XR mode
  48220. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  48221. * @returns promise that resolves after xr mode has entered
  48222. */
  48223. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  48224. /**
  48225. * Exits XR mode and returns the scene to its original state
  48226. * @returns promise that resolves after xr mode has exited
  48227. */
  48228. exitXRAsync(): Promise<void>;
  48229. private _nonXRToXRCamera;
  48230. private _setState;
  48231. }
  48232. }
  48233. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  48234. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48235. import { Observable } from "babylonjs/Misc/observable";
  48236. import { IDisposable } from "babylonjs/scene";
  48237. /**
  48238. * X-Y values for axes in WebXR
  48239. */
  48240. export interface IWebXRMotionControllerAxesValue {
  48241. /**
  48242. * The value of the x axis
  48243. */
  48244. x: number;
  48245. /**
  48246. * The value of the y-axis
  48247. */
  48248. y: number;
  48249. }
  48250. /**
  48251. * changed / previous values for the values of this component
  48252. */
  48253. export interface IWebXRMotionControllerComponentChangesValues<T> {
  48254. /**
  48255. * current (this frame) value
  48256. */
  48257. current: T;
  48258. /**
  48259. * previous (last change) value
  48260. */
  48261. previous: T;
  48262. }
  48263. /**
  48264. * Represents changes in the component between current frame and last values recorded
  48265. */
  48266. export interface IWebXRMotionControllerComponentChanges {
  48267. /**
  48268. * will be populated with previous and current values if axes changed
  48269. */
  48270. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  48271. /**
  48272. * will be populated with previous and current values if pressed changed
  48273. */
  48274. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48275. /**
  48276. * will be populated with previous and current values if touched changed
  48277. */
  48278. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48279. /**
  48280. * will be populated with previous and current values if value changed
  48281. */
  48282. value?: IWebXRMotionControllerComponentChangesValues<number>;
  48283. }
  48284. /**
  48285. * This class represents a single component (for example button or thumbstick) of a motion controller
  48286. */
  48287. export class WebXRControllerComponent implements IDisposable {
  48288. /**
  48289. * the id of this component
  48290. */
  48291. id: string;
  48292. /**
  48293. * the type of the component
  48294. */
  48295. type: MotionControllerComponentType;
  48296. private _buttonIndex;
  48297. private _axesIndices;
  48298. private _axes;
  48299. private _changes;
  48300. private _currentValue;
  48301. private _hasChanges;
  48302. private _pressed;
  48303. private _touched;
  48304. /**
  48305. * button component type
  48306. */
  48307. static BUTTON_TYPE: MotionControllerComponentType;
  48308. /**
  48309. * squeeze component type
  48310. */
  48311. static SQUEEZE_TYPE: MotionControllerComponentType;
  48312. /**
  48313. * Thumbstick component type
  48314. */
  48315. static THUMBSTICK_TYPE: MotionControllerComponentType;
  48316. /**
  48317. * Touchpad component type
  48318. */
  48319. static TOUCHPAD_TYPE: MotionControllerComponentType;
  48320. /**
  48321. * trigger component type
  48322. */
  48323. static TRIGGER_TYPE: MotionControllerComponentType;
  48324. /**
  48325. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  48326. * the axes data changes
  48327. */
  48328. onAxisValueChangedObservable: Observable<{
  48329. x: number;
  48330. y: number;
  48331. }>;
  48332. /**
  48333. * Observers registered here will be triggered when the state of a button changes
  48334. * State change is either pressed / touched / value
  48335. */
  48336. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  48337. /**
  48338. * Creates a new component for a motion controller.
  48339. * It is created by the motion controller itself
  48340. *
  48341. * @param id the id of this component
  48342. * @param type the type of the component
  48343. * @param _buttonIndex index in the buttons array of the gamepad
  48344. * @param _axesIndices indices of the values in the axes array of the gamepad
  48345. */
  48346. constructor(
  48347. /**
  48348. * the id of this component
  48349. */
  48350. id: string,
  48351. /**
  48352. * the type of the component
  48353. */
  48354. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  48355. /**
  48356. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  48357. */
  48358. get axes(): IWebXRMotionControllerAxesValue;
  48359. /**
  48360. * Get the changes. Elements will be populated only if they changed with their previous and current value
  48361. */
  48362. get changes(): IWebXRMotionControllerComponentChanges;
  48363. /**
  48364. * Return whether or not the component changed the last frame
  48365. */
  48366. get hasChanges(): boolean;
  48367. /**
  48368. * is the button currently pressed
  48369. */
  48370. get pressed(): boolean;
  48371. /**
  48372. * is the button currently touched
  48373. */
  48374. get touched(): boolean;
  48375. /**
  48376. * Get the current value of this component
  48377. */
  48378. get value(): number;
  48379. /**
  48380. * Dispose this component
  48381. */
  48382. dispose(): void;
  48383. /**
  48384. * Are there axes correlating to this component
  48385. * @return true is axes data is available
  48386. */
  48387. isAxes(): boolean;
  48388. /**
  48389. * Is this component a button (hence - pressable)
  48390. * @returns true if can be pressed
  48391. */
  48392. isButton(): boolean;
  48393. /**
  48394. * update this component using the gamepad object it is in. Called on every frame
  48395. * @param nativeController the native gamepad controller object
  48396. */
  48397. update(nativeController: IMinimalMotionControllerObject): void;
  48398. }
  48399. }
  48400. declare module "babylonjs/Loading/sceneLoader" {
  48401. import { Observable } from "babylonjs/Misc/observable";
  48402. import { Nullable } from "babylonjs/types";
  48403. import { Scene } from "babylonjs/scene";
  48404. import { Engine } from "babylonjs/Engines/engine";
  48405. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48406. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  48407. import { AssetContainer } from "babylonjs/assetContainer";
  48408. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  48409. import { Skeleton } from "babylonjs/Bones/skeleton";
  48410. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  48411. import { WebRequest } from "babylonjs/Misc/webRequest";
  48412. /**
  48413. * Interface used to represent data loading progression
  48414. */
  48415. export interface ISceneLoaderProgressEvent {
  48416. /**
  48417. * Defines if data length to load can be evaluated
  48418. */
  48419. readonly lengthComputable: boolean;
  48420. /**
  48421. * Defines the loaded data length
  48422. */
  48423. readonly loaded: number;
  48424. /**
  48425. * Defines the data length to load
  48426. */
  48427. readonly total: number;
  48428. }
  48429. /**
  48430. * Interface used by SceneLoader plugins to define supported file extensions
  48431. */
  48432. export interface ISceneLoaderPluginExtensions {
  48433. /**
  48434. * Defines the list of supported extensions
  48435. */
  48436. [extension: string]: {
  48437. isBinary: boolean;
  48438. };
  48439. }
  48440. /**
  48441. * Interface used by SceneLoader plugin factory
  48442. */
  48443. export interface ISceneLoaderPluginFactory {
  48444. /**
  48445. * Defines the name of the factory
  48446. */
  48447. name: string;
  48448. /**
  48449. * Function called to create a new plugin
  48450. * @return the new plugin
  48451. */
  48452. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  48453. /**
  48454. * The callback that returns true if the data can be directly loaded.
  48455. * @param data string containing the file data
  48456. * @returns if the data can be loaded directly
  48457. */
  48458. canDirectLoad?(data: string): boolean;
  48459. }
  48460. /**
  48461. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  48462. */
  48463. export interface ISceneLoaderPluginBase {
  48464. /**
  48465. * The friendly name of this plugin.
  48466. */
  48467. name: string;
  48468. /**
  48469. * The file extensions supported by this plugin.
  48470. */
  48471. extensions: string | ISceneLoaderPluginExtensions;
  48472. /**
  48473. * The callback called when loading from a url.
  48474. * @param scene scene loading this url
  48475. * @param url url to load
  48476. * @param onSuccess callback called when the file successfully loads
  48477. * @param onProgress callback called while file is loading (if the server supports this mode)
  48478. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  48479. * @param onError callback called when the file fails to load
  48480. * @returns a file request object
  48481. */
  48482. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48483. /**
  48484. * The callback called when loading from a file object.
  48485. * @param scene scene loading this file
  48486. * @param file defines the file to load
  48487. * @param onSuccess defines the callback to call when data is loaded
  48488. * @param onProgress defines the callback to call during loading process
  48489. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  48490. * @param onError defines the callback to call when an error occurs
  48491. * @returns a file request object
  48492. */
  48493. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48494. /**
  48495. * The callback that returns true if the data can be directly loaded.
  48496. * @param data string containing the file data
  48497. * @returns if the data can be loaded directly
  48498. */
  48499. canDirectLoad?(data: string): boolean;
  48500. /**
  48501. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  48502. * @param scene scene loading this data
  48503. * @param data string containing the data
  48504. * @returns data to pass to the plugin
  48505. */
  48506. directLoad?(scene: Scene, data: string): any;
  48507. /**
  48508. * The callback that allows custom handling of the root url based on the response url.
  48509. * @param rootUrl the original root url
  48510. * @param responseURL the response url if available
  48511. * @returns the new root url
  48512. */
  48513. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  48514. }
  48515. /**
  48516. * Interface used to define a SceneLoader plugin
  48517. */
  48518. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  48519. /**
  48520. * Import meshes into a scene.
  48521. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48522. * @param scene The scene to import into
  48523. * @param data The data to import
  48524. * @param rootUrl The root url for scene and resources
  48525. * @param meshes The meshes array to import into
  48526. * @param particleSystems The particle systems array to import into
  48527. * @param skeletons The skeletons array to import into
  48528. * @param onError The callback when import fails
  48529. * @returns True if successful or false otherwise
  48530. */
  48531. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  48532. /**
  48533. * Load into a scene.
  48534. * @param scene The scene to load into
  48535. * @param data The data to import
  48536. * @param rootUrl The root url for scene and resources
  48537. * @param onError The callback when import fails
  48538. * @returns True if successful or false otherwise
  48539. */
  48540. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  48541. /**
  48542. * Load into an asset container.
  48543. * @param scene The scene to load into
  48544. * @param data The data to import
  48545. * @param rootUrl The root url for scene and resources
  48546. * @param onError The callback when import fails
  48547. * @returns The loaded asset container
  48548. */
  48549. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  48550. }
  48551. /**
  48552. * Interface used to define an async SceneLoader plugin
  48553. */
  48554. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  48555. /**
  48556. * Import meshes into a scene.
  48557. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48558. * @param scene The scene to import into
  48559. * @param data The data to import
  48560. * @param rootUrl The root url for scene and resources
  48561. * @param onProgress The callback when the load progresses
  48562. * @param fileName Defines the name of the file to load
  48563. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  48564. */
  48565. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  48566. meshes: AbstractMesh[];
  48567. particleSystems: IParticleSystem[];
  48568. skeletons: Skeleton[];
  48569. animationGroups: AnimationGroup[];
  48570. }>;
  48571. /**
  48572. * Load into a scene.
  48573. * @param scene The scene to load into
  48574. * @param data The data to import
  48575. * @param rootUrl The root url for scene and resources
  48576. * @param onProgress The callback when the load progresses
  48577. * @param fileName Defines the name of the file to load
  48578. * @returns Nothing
  48579. */
  48580. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  48581. /**
  48582. * Load into an asset container.
  48583. * @param scene The scene to load into
  48584. * @param data The data to import
  48585. * @param rootUrl The root url for scene and resources
  48586. * @param onProgress The callback when the load progresses
  48587. * @param fileName Defines the name of the file to load
  48588. * @returns The loaded asset container
  48589. */
  48590. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  48591. }
  48592. /**
  48593. * Mode that determines how to handle old animation groups before loading new ones.
  48594. */
  48595. export enum SceneLoaderAnimationGroupLoadingMode {
  48596. /**
  48597. * Reset all old animations to initial state then dispose them.
  48598. */
  48599. Clean = 0,
  48600. /**
  48601. * Stop all old animations.
  48602. */
  48603. Stop = 1,
  48604. /**
  48605. * Restart old animations from first frame.
  48606. */
  48607. Sync = 2,
  48608. /**
  48609. * Old animations remains untouched.
  48610. */
  48611. NoSync = 3
  48612. }
  48613. /**
  48614. * Class used to load scene from various file formats using registered plugins
  48615. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  48616. */
  48617. export class SceneLoader {
  48618. /**
  48619. * No logging while loading
  48620. */
  48621. static readonly NO_LOGGING: number;
  48622. /**
  48623. * Minimal logging while loading
  48624. */
  48625. static readonly MINIMAL_LOGGING: number;
  48626. /**
  48627. * Summary logging while loading
  48628. */
  48629. static readonly SUMMARY_LOGGING: number;
  48630. /**
  48631. * Detailled logging while loading
  48632. */
  48633. static readonly DETAILED_LOGGING: number;
  48634. /**
  48635. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  48636. */
  48637. static get ForceFullSceneLoadingForIncremental(): boolean;
  48638. static set ForceFullSceneLoadingForIncremental(value: boolean);
  48639. /**
  48640. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  48641. */
  48642. static get ShowLoadingScreen(): boolean;
  48643. static set ShowLoadingScreen(value: boolean);
  48644. /**
  48645. * Defines the current logging level (while loading the scene)
  48646. * @ignorenaming
  48647. */
  48648. static get loggingLevel(): number;
  48649. static set loggingLevel(value: number);
  48650. /**
  48651. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  48652. */
  48653. static get CleanBoneMatrixWeights(): boolean;
  48654. static set CleanBoneMatrixWeights(value: boolean);
  48655. /**
  48656. * Event raised when a plugin is used to load a scene
  48657. */
  48658. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48659. private static _registeredPlugins;
  48660. private static _getDefaultPlugin;
  48661. private static _getPluginForExtension;
  48662. private static _getPluginForDirectLoad;
  48663. private static _getPluginForFilename;
  48664. private static _getDirectLoad;
  48665. private static _loadData;
  48666. private static _getFileInfo;
  48667. /**
  48668. * Gets a plugin that can load the given extension
  48669. * @param extension defines the extension to load
  48670. * @returns a plugin or null if none works
  48671. */
  48672. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  48673. /**
  48674. * Gets a boolean indicating that the given extension can be loaded
  48675. * @param extension defines the extension to load
  48676. * @returns true if the extension is supported
  48677. */
  48678. static IsPluginForExtensionAvailable(extension: string): boolean;
  48679. /**
  48680. * Adds a new plugin to the list of registered plugins
  48681. * @param plugin defines the plugin to add
  48682. */
  48683. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  48684. /**
  48685. * Import meshes into a scene
  48686. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48687. * @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)
  48688. * @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)
  48689. * @param scene the instance of BABYLON.Scene to append to
  48690. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  48691. * @param onProgress a callback with a progress event for each file being loaded
  48692. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48693. * @param pluginExtension the extension used to determine the plugin
  48694. * @returns The loaded plugin
  48695. */
  48696. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48697. /**
  48698. * Import meshes into a scene
  48699. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48700. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  48701. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  48702. * @param scene the instance of BABYLON.Scene to append to
  48703. * @param onProgress a callback with a progress event for each file being loaded
  48704. * @param pluginExtension the extension used to determine the plugin
  48705. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  48706. */
  48707. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  48708. meshes: AbstractMesh[];
  48709. particleSystems: IParticleSystem[];
  48710. skeletons: Skeleton[];
  48711. animationGroups: AnimationGroup[];
  48712. }>;
  48713. /**
  48714. * Load a scene
  48715. * @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)
  48716. * @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)
  48717. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48718. * @param onSuccess a callback with the scene when import succeeds
  48719. * @param onProgress a callback with a progress event for each file being loaded
  48720. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48721. * @param pluginExtension the extension used to determine the plugin
  48722. * @returns The loaded plugin
  48723. */
  48724. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48725. /**
  48726. * Load a scene
  48727. * @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)
  48728. * @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)
  48729. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48730. * @param onProgress a callback with a progress event for each file being loaded
  48731. * @param pluginExtension the extension used to determine the plugin
  48732. * @returns The loaded scene
  48733. */
  48734. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48735. /**
  48736. * Append a scene
  48737. * @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)
  48738. * @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)
  48739. * @param scene is the instance of BABYLON.Scene to append to
  48740. * @param onSuccess a callback with the scene when import succeeds
  48741. * @param onProgress a callback with a progress event for each file being loaded
  48742. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48743. * @param pluginExtension the extension used to determine the plugin
  48744. * @returns The loaded plugin
  48745. */
  48746. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48747. /**
  48748. * Append a scene
  48749. * @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)
  48750. * @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)
  48751. * @param scene is the instance of BABYLON.Scene to append to
  48752. * @param onProgress a callback with a progress event for each file being loaded
  48753. * @param pluginExtension the extension used to determine the plugin
  48754. * @returns The given scene
  48755. */
  48756. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48757. /**
  48758. * Load a scene into an asset container
  48759. * @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)
  48760. * @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)
  48761. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48762. * @param onSuccess a callback with the scene when import succeeds
  48763. * @param onProgress a callback with a progress event for each file being loaded
  48764. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48765. * @param pluginExtension the extension used to determine the plugin
  48766. * @returns The loaded plugin
  48767. */
  48768. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48769. /**
  48770. * Load a scene into an asset container
  48771. * @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)
  48772. * @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)
  48773. * @param scene is the instance of Scene to append to
  48774. * @param onProgress a callback with a progress event for each file being loaded
  48775. * @param pluginExtension the extension used to determine the plugin
  48776. * @returns The loaded asset container
  48777. */
  48778. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  48779. /**
  48780. * Import animations from a file into a scene
  48781. * @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)
  48782. * @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)
  48783. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48784. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48785. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48786. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48787. * @param onSuccess a callback with the scene when import succeeds
  48788. * @param onProgress a callback with a progress event for each file being loaded
  48789. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48790. * @param pluginExtension the extension used to determine the plugin
  48791. */
  48792. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): void;
  48793. /**
  48794. * Import animations from a file into a scene
  48795. * @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)
  48796. * @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)
  48797. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48798. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48799. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48800. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48801. * @param onSuccess a callback with the scene when import succeeds
  48802. * @param onProgress a callback with a progress event for each file being loaded
  48803. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48804. * @param pluginExtension the extension used to determine the plugin
  48805. * @returns the updated scene with imported animations
  48806. */
  48807. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48808. }
  48809. }
  48810. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  48811. import { IDisposable, Scene } from "babylonjs/scene";
  48812. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  48813. import { Observable } from "babylonjs/Misc/observable";
  48814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48815. import { Nullable } from "babylonjs/types";
  48816. /**
  48817. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  48818. */
  48819. export type MotionControllerHandedness = "none" | "left" | "right";
  48820. /**
  48821. * The type of components available in motion controllers.
  48822. * This is not the name of the component.
  48823. */
  48824. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  48825. /**
  48826. * The state of a controller component
  48827. */
  48828. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  48829. /**
  48830. * The schema of motion controller layout.
  48831. * No object will be initialized using this interface
  48832. * This is used just to define the profile.
  48833. */
  48834. export interface IMotionControllerLayout {
  48835. /**
  48836. * Path to load the assets. Usually relative to the base path
  48837. */
  48838. assetPath: string;
  48839. /**
  48840. * Available components (unsorted)
  48841. */
  48842. components: {
  48843. /**
  48844. * A map of component Ids
  48845. */
  48846. [componentId: string]: {
  48847. /**
  48848. * The type of input the component outputs
  48849. */
  48850. type: MotionControllerComponentType;
  48851. /**
  48852. * The indices of this component in the gamepad object
  48853. */
  48854. gamepadIndices: {
  48855. /**
  48856. * Index of button
  48857. */
  48858. button?: number;
  48859. /**
  48860. * If available, index of x-axis
  48861. */
  48862. xAxis?: number;
  48863. /**
  48864. * If available, index of y-axis
  48865. */
  48866. yAxis?: number;
  48867. };
  48868. /**
  48869. * The mesh's root node name
  48870. */
  48871. rootNodeName: string;
  48872. /**
  48873. * Animation definitions for this model
  48874. */
  48875. visualResponses: {
  48876. [stateKey: string]: {
  48877. /**
  48878. * What property will be animated
  48879. */
  48880. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  48881. /**
  48882. * What states influence this visual response
  48883. */
  48884. states: MotionControllerComponentStateType[];
  48885. /**
  48886. * Type of animation - movement or visibility
  48887. */
  48888. valueNodeProperty: "transform" | "visibility";
  48889. /**
  48890. * Base node name to move. Its position will be calculated according to the min and max nodes
  48891. */
  48892. valueNodeName?: string;
  48893. /**
  48894. * Minimum movement node
  48895. */
  48896. minNodeName?: string;
  48897. /**
  48898. * Max movement node
  48899. */
  48900. maxNodeName?: string;
  48901. };
  48902. };
  48903. /**
  48904. * If touch enabled, what is the name of node to display user feedback
  48905. */
  48906. touchPointNodeName?: string;
  48907. };
  48908. };
  48909. /**
  48910. * Is it xr standard mapping or not
  48911. */
  48912. gamepadMapping: "" | "xr-standard";
  48913. /**
  48914. * Base root node of this entire model
  48915. */
  48916. rootNodeName: string;
  48917. /**
  48918. * Defines the main button component id
  48919. */
  48920. selectComponentId: string;
  48921. }
  48922. /**
  48923. * A definition for the layout map in the input profile
  48924. */
  48925. export interface IMotionControllerLayoutMap {
  48926. /**
  48927. * Layouts with handedness type as a key
  48928. */
  48929. [handedness: string]: IMotionControllerLayout;
  48930. }
  48931. /**
  48932. * The XR Input profile schema
  48933. * Profiles can be found here:
  48934. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48935. */
  48936. export interface IMotionControllerProfile {
  48937. /**
  48938. * fallback profiles for this profileId
  48939. */
  48940. fallbackProfileIds: string[];
  48941. /**
  48942. * The layout map, with handedness as key
  48943. */
  48944. layouts: IMotionControllerLayoutMap;
  48945. /**
  48946. * The id of this profile
  48947. * correlates to the profile(s) in the xrInput.profiles array
  48948. */
  48949. profileId: string;
  48950. }
  48951. /**
  48952. * A helper-interface for the 3 meshes needed for controller button animation
  48953. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48954. */
  48955. export interface IMotionControllerButtonMeshMap {
  48956. /**
  48957. * the mesh that defines the pressed value mesh position.
  48958. * This is used to find the max-position of this button
  48959. */
  48960. pressedMesh: AbstractMesh;
  48961. /**
  48962. * the mesh that defines the unpressed value mesh position.
  48963. * This is used to find the min (or initial) position of this button
  48964. */
  48965. unpressedMesh: AbstractMesh;
  48966. /**
  48967. * The mesh that will be changed when value changes
  48968. */
  48969. valueMesh: AbstractMesh;
  48970. }
  48971. /**
  48972. * A helper-interface for the 3 meshes needed for controller axis animation.
  48973. * This will be expanded when touchpad animations are fully supported
  48974. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48975. */
  48976. export interface IMotionControllerMeshMap {
  48977. /**
  48978. * the mesh that defines the maximum value mesh position.
  48979. */
  48980. maxMesh?: AbstractMesh;
  48981. /**
  48982. * the mesh that defines the minimum value mesh position.
  48983. */
  48984. minMesh?: AbstractMesh;
  48985. /**
  48986. * The mesh that will be changed when axis value changes
  48987. */
  48988. valueMesh: AbstractMesh;
  48989. }
  48990. /**
  48991. * The elements needed for change-detection of the gamepad objects in motion controllers
  48992. */
  48993. export interface IMinimalMotionControllerObject {
  48994. /**
  48995. * Available axes of this controller
  48996. */
  48997. axes: number[];
  48998. /**
  48999. * An array of available buttons
  49000. */
  49001. buttons: Array<{
  49002. /**
  49003. * Value of the button/trigger
  49004. */
  49005. value: number;
  49006. /**
  49007. * If the button/trigger is currently touched
  49008. */
  49009. touched: boolean;
  49010. /**
  49011. * If the button/trigger is currently pressed
  49012. */
  49013. pressed: boolean;
  49014. }>;
  49015. /**
  49016. * EXPERIMENTAL haptic support.
  49017. */
  49018. hapticActuators?: Array<{
  49019. pulse: (value: number, duration: number) => Promise<boolean>;
  49020. }>;
  49021. }
  49022. /**
  49023. * An Abstract Motion controller
  49024. * This class receives an xrInput and a profile layout and uses those to initialize the components
  49025. * Each component has an observable to check for changes in value and state
  49026. */
  49027. export abstract class WebXRAbstractMotionController implements IDisposable {
  49028. protected scene: Scene;
  49029. protected layout: IMotionControllerLayout;
  49030. /**
  49031. * The gamepad object correlating to this controller
  49032. */
  49033. gamepadObject: IMinimalMotionControllerObject;
  49034. /**
  49035. * handedness (left/right/none) of this controller
  49036. */
  49037. handedness: MotionControllerHandedness;
  49038. private _initComponent;
  49039. private _modelReady;
  49040. /**
  49041. * A map of components (WebXRControllerComponent) in this motion controller
  49042. * Components have a ComponentType and can also have both button and axis definitions
  49043. */
  49044. readonly components: {
  49045. [id: string]: WebXRControllerComponent;
  49046. };
  49047. /**
  49048. * Disable the model's animation. Can be set at any time.
  49049. */
  49050. disableAnimation: boolean;
  49051. /**
  49052. * Observers registered here will be triggered when the model of this controller is done loading
  49053. */
  49054. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  49055. /**
  49056. * The profile id of this motion controller
  49057. */
  49058. abstract profileId: string;
  49059. /**
  49060. * The root mesh of the model. It is null if the model was not yet initialized
  49061. */
  49062. rootMesh: Nullable<AbstractMesh>;
  49063. /**
  49064. * constructs a new abstract motion controller
  49065. * @param scene the scene to which the model of the controller will be added
  49066. * @param layout The profile layout to load
  49067. * @param gamepadObject The gamepad object correlating to this controller
  49068. * @param handedness handedness (left/right/none) of this controller
  49069. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  49070. */
  49071. constructor(scene: Scene, layout: IMotionControllerLayout,
  49072. /**
  49073. * The gamepad object correlating to this controller
  49074. */
  49075. gamepadObject: IMinimalMotionControllerObject,
  49076. /**
  49077. * handedness (left/right/none) of this controller
  49078. */
  49079. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  49080. /**
  49081. * Dispose this controller, the model mesh and all its components
  49082. */
  49083. dispose(): void;
  49084. /**
  49085. * Returns all components of specific type
  49086. * @param type the type to search for
  49087. * @return an array of components with this type
  49088. */
  49089. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  49090. /**
  49091. * get a component based an its component id as defined in layout.components
  49092. * @param id the id of the component
  49093. * @returns the component correlates to the id or undefined if not found
  49094. */
  49095. getComponent(id: string): WebXRControllerComponent;
  49096. /**
  49097. * Get the list of components available in this motion controller
  49098. * @returns an array of strings correlating to available components
  49099. */
  49100. getComponentIds(): string[];
  49101. /**
  49102. * Get the first component of specific type
  49103. * @param type type of component to find
  49104. * @return a controller component or null if not found
  49105. */
  49106. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  49107. /**
  49108. * Get the main (Select) component of this controller as defined in the layout
  49109. * @returns the main component of this controller
  49110. */
  49111. getMainComponent(): WebXRControllerComponent;
  49112. /**
  49113. * Loads the model correlating to this controller
  49114. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  49115. * @returns A promise fulfilled with the result of the model loading
  49116. */
  49117. loadModel(): Promise<boolean>;
  49118. /**
  49119. * Update this model using the current XRFrame
  49120. * @param xrFrame the current xr frame to use and update the model
  49121. */
  49122. updateFromXRFrame(xrFrame: XRFrame): void;
  49123. /**
  49124. * Backwards compatibility due to a deeply-integrated typo
  49125. */
  49126. get handness(): XREye;
  49127. /**
  49128. * Pulse (vibrate) this controller
  49129. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  49130. * Consecutive calls to this function will cancel the last pulse call
  49131. *
  49132. * @param value the strength of the pulse in 0.0...1.0 range
  49133. * @param duration Duration of the pulse in milliseconds
  49134. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  49135. * @returns a promise that will send true when the pulse has ended and false if the device doesn't support pulse or an error accrued
  49136. */
  49137. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  49138. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  49139. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  49140. /**
  49141. * Moves the axis on the controller mesh based on its current state
  49142. * @param axis the index of the axis
  49143. * @param axisValue the value of the axis which determines the meshes new position
  49144. * @hidden
  49145. */
  49146. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  49147. /**
  49148. * Update the model itself with the current frame data
  49149. * @param xrFrame the frame to use for updating the model mesh
  49150. */
  49151. protected updateModel(xrFrame: XRFrame): void;
  49152. /**
  49153. * Get the filename and path for this controller's model
  49154. * @returns a map of filename and path
  49155. */
  49156. protected abstract _getFilenameAndPath(): {
  49157. filename: string;
  49158. path: string;
  49159. };
  49160. /**
  49161. * This function is called before the mesh is loaded. It checks for loading constraints.
  49162. * For example, this function can check if the GLB loader is available
  49163. * If this function returns false, the generic controller will be loaded instead
  49164. * @returns Is the client ready to load the mesh
  49165. */
  49166. protected abstract _getModelLoadingConstraints(): boolean;
  49167. /**
  49168. * This function will be called after the model was successfully loaded and can be used
  49169. * for mesh transformations before it is available for the user
  49170. * @param meshes the loaded meshes
  49171. */
  49172. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  49173. /**
  49174. * Set the root mesh for this controller. Important for the WebXR controller class
  49175. * @param meshes the loaded meshes
  49176. */
  49177. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  49178. /**
  49179. * A function executed each frame that updates the mesh (if needed)
  49180. * @param xrFrame the current xrFrame
  49181. */
  49182. protected abstract _updateModel(xrFrame: XRFrame): void;
  49183. private _getGenericFilenameAndPath;
  49184. private _getGenericParentMesh;
  49185. }
  49186. }
  49187. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  49188. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49189. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49190. import { Scene } from "babylonjs/scene";
  49191. /**
  49192. * A generic trigger-only motion controller for WebXR
  49193. */
  49194. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  49195. /**
  49196. * Static version of the profile id of this controller
  49197. */
  49198. static ProfileId: string;
  49199. profileId: string;
  49200. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  49201. protected _getFilenameAndPath(): {
  49202. filename: string;
  49203. path: string;
  49204. };
  49205. protected _getModelLoadingConstraints(): boolean;
  49206. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  49207. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49208. protected _updateModel(): void;
  49209. }
  49210. }
  49211. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  49212. import { Vector4 } from "babylonjs/Maths/math.vector";
  49213. import { Mesh } from "babylonjs/Meshes/mesh";
  49214. import { Scene } from "babylonjs/scene";
  49215. import { Nullable } from "babylonjs/types";
  49216. /**
  49217. * Class containing static functions to help procedurally build meshes
  49218. */
  49219. export class SphereBuilder {
  49220. /**
  49221. * Creates a sphere mesh
  49222. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49223. * * 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`)
  49224. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49225. * * 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
  49226. * * 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)
  49227. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49228. * * 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
  49229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49230. * @param name defines the name of the mesh
  49231. * @param options defines the options used to create the mesh
  49232. * @param scene defines the hosting scene
  49233. * @returns the sphere mesh
  49234. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49235. */
  49236. static CreateSphere(name: string, options: {
  49237. segments?: number;
  49238. diameter?: number;
  49239. diameterX?: number;
  49240. diameterY?: number;
  49241. diameterZ?: number;
  49242. arc?: number;
  49243. slice?: number;
  49244. sideOrientation?: number;
  49245. frontUVs?: Vector4;
  49246. backUVs?: Vector4;
  49247. updatable?: boolean;
  49248. }, scene?: Nullable<Scene>): Mesh;
  49249. }
  49250. }
  49251. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  49252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49253. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49254. import { Scene } from "babylonjs/scene";
  49255. /**
  49256. * A profiled motion controller has its profile loaded from an online repository.
  49257. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  49258. */
  49259. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  49260. private _repositoryUrl;
  49261. private _buttonMeshMapping;
  49262. private _touchDots;
  49263. /**
  49264. * The profile ID of this controller. Will be populated when the controller initializes.
  49265. */
  49266. profileId: string;
  49267. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  49268. dispose(): void;
  49269. protected _getFilenameAndPath(): {
  49270. filename: string;
  49271. path: string;
  49272. };
  49273. protected _getModelLoadingConstraints(): boolean;
  49274. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  49275. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49276. protected _updateModel(_xrFrame: XRFrame): void;
  49277. }
  49278. }
  49279. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  49280. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49281. import { Scene } from "babylonjs/scene";
  49282. /**
  49283. * A construction function type to create a new controller based on an xrInput object
  49284. */
  49285. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  49286. /**
  49287. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  49288. *
  49289. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  49290. * it should be replaced with auto-loaded controllers.
  49291. *
  49292. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  49293. */
  49294. export class WebXRMotionControllerManager {
  49295. private static _AvailableControllers;
  49296. private static _Fallbacks;
  49297. private static _ProfileLoadingPromises;
  49298. private static _ProfilesList;
  49299. /**
  49300. * The base URL of the online controller repository. Can be changed at any time.
  49301. */
  49302. static BaseRepositoryUrl: string;
  49303. /**
  49304. * Which repository gets priority - local or online
  49305. */
  49306. static PrioritizeOnlineRepository: boolean;
  49307. /**
  49308. * Use the online repository, or use only locally-defined controllers
  49309. */
  49310. static UseOnlineRepository: boolean;
  49311. /**
  49312. * Clear the cache used for profile loading and reload when requested again
  49313. */
  49314. static ClearProfilesCache(): void;
  49315. /**
  49316. * Register the default fallbacks.
  49317. * This function is called automatically when this file is imported.
  49318. */
  49319. static DefaultFallbacks(): void;
  49320. /**
  49321. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  49322. * @param profileId the profile to which a fallback needs to be found
  49323. * @return an array with corresponding fallback profiles
  49324. */
  49325. static FindFallbackWithProfileId(profileId: string): string[];
  49326. /**
  49327. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  49328. * The order of search:
  49329. *
  49330. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  49331. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  49332. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  49333. * 4) return the generic trigger controller if none were found
  49334. *
  49335. * @param xrInput the xrInput to which a new controller is initialized
  49336. * @param scene the scene to which the model will be added
  49337. * @param forceProfile force a certain profile for this controller
  49338. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  49339. */
  49340. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  49341. /**
  49342. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  49343. *
  49344. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  49345. *
  49346. * @param type the profile type to register
  49347. * @param constructFunction the function to be called when loading this profile
  49348. */
  49349. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  49350. /**
  49351. * Register a fallback to a specific profile.
  49352. * @param profileId the profileId that will receive the fallbacks
  49353. * @param fallbacks A list of fallback profiles
  49354. */
  49355. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  49356. /**
  49357. * Will update the list of profiles available in the repository
  49358. * @return a promise that resolves to a map of profiles available online
  49359. */
  49360. static UpdateProfilesList(): Promise<{
  49361. [profile: string]: string;
  49362. }>;
  49363. private static _LoadProfileFromRepository;
  49364. private static _LoadProfilesFromAvailableControllers;
  49365. }
  49366. }
  49367. declare module "babylonjs/XR/webXRInputSource" {
  49368. import { Observable } from "babylonjs/Misc/observable";
  49369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49370. import { Ray } from "babylonjs/Culling/ray";
  49371. import { Scene } from "babylonjs/scene";
  49372. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49373. /**
  49374. * Configuration options for the WebXR controller creation
  49375. */
  49376. export interface IWebXRControllerOptions {
  49377. /**
  49378. * Should the controller mesh be animated when a user interacts with it
  49379. * The pressed buttons / thumbstick and touchpad animations will be disabled
  49380. */
  49381. disableMotionControllerAnimation?: boolean;
  49382. /**
  49383. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  49384. */
  49385. doNotLoadControllerMesh?: boolean;
  49386. /**
  49387. * Force a specific controller type for this controller.
  49388. * This can be used when creating your own profile or when testing different controllers
  49389. */
  49390. forceControllerProfile?: string;
  49391. /**
  49392. * Defines a rendering group ID for meshes that will be loaded.
  49393. * This is for the default controllers only.
  49394. */
  49395. renderingGroupId?: number;
  49396. }
  49397. /**
  49398. * Represents an XR controller
  49399. */
  49400. export class WebXRInputSource {
  49401. private _scene;
  49402. /** The underlying input source for the controller */
  49403. inputSource: XRInputSource;
  49404. private _options;
  49405. private _tmpVector;
  49406. private _uniqueId;
  49407. /**
  49408. * 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
  49409. */
  49410. grip?: AbstractMesh;
  49411. /**
  49412. * If available, this is the gamepad object related to this controller.
  49413. * Using this object it is possible to get click events and trackpad changes of the
  49414. * webxr controller that is currently being used.
  49415. */
  49416. motionController?: WebXRAbstractMotionController;
  49417. /**
  49418. * Event that fires when the controller is removed/disposed.
  49419. * The object provided as event data is this controller, after associated assets were disposed.
  49420. * uniqueId is still available.
  49421. */
  49422. onDisposeObservable: Observable<WebXRInputSource>;
  49423. /**
  49424. * Will be triggered when the mesh associated with the motion controller is done loading.
  49425. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  49426. * A shortened version of controller -> motion controller -> on mesh loaded.
  49427. */
  49428. onMeshLoadedObservable: Observable<AbstractMesh>;
  49429. /**
  49430. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  49431. */
  49432. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  49433. /**
  49434. * Pointer which can be used to select objects or attach a visible laser to
  49435. */
  49436. pointer: AbstractMesh;
  49437. /**
  49438. * Creates the input source object
  49439. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  49440. * @param _scene the scene which the controller should be associated to
  49441. * @param inputSource the underlying input source for the controller
  49442. * @param _options options for this controller creation
  49443. */
  49444. constructor(_scene: Scene,
  49445. /** The underlying input source for the controller */
  49446. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  49447. /**
  49448. * Get this controllers unique id
  49449. */
  49450. get uniqueId(): string;
  49451. /**
  49452. * Disposes of the object
  49453. */
  49454. dispose(): void;
  49455. /**
  49456. * Gets a world space ray coming from the pointer or grip
  49457. * @param result the resulting ray
  49458. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  49459. */
  49460. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  49461. /**
  49462. * Updates the controller pose based on the given XRFrame
  49463. * @param xrFrame xr frame to update the pose with
  49464. * @param referenceSpace reference space to use
  49465. */
  49466. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  49467. }
  49468. }
  49469. declare module "babylonjs/XR/webXRInput" {
  49470. import { Observable } from "babylonjs/Misc/observable";
  49471. import { IDisposable } from "babylonjs/scene";
  49472. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  49473. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49474. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49475. /**
  49476. * The schema for initialization options of the XR Input class
  49477. */
  49478. export interface IWebXRInputOptions {
  49479. /**
  49480. * If set to true no model will be automatically loaded
  49481. */
  49482. doNotLoadControllerMeshes?: boolean;
  49483. /**
  49484. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  49485. * If not found, the xr input profile data will be used.
  49486. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  49487. */
  49488. forceInputProfile?: string;
  49489. /**
  49490. * Do not send a request to the controller repository to load the profile.
  49491. *
  49492. * Instead, use the controllers available in babylon itself.
  49493. */
  49494. disableOnlineControllerRepository?: boolean;
  49495. /**
  49496. * A custom URL for the controllers repository
  49497. */
  49498. customControllersRepositoryURL?: string;
  49499. /**
  49500. * Should the controller model's components not move according to the user input
  49501. */
  49502. disableControllerAnimation?: boolean;
  49503. /**
  49504. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  49505. */
  49506. controllerOptions?: IWebXRControllerOptions;
  49507. }
  49508. /**
  49509. * XR input used to track XR inputs such as controllers/rays
  49510. */
  49511. export class WebXRInput implements IDisposable {
  49512. /**
  49513. * the xr session manager for this session
  49514. */
  49515. xrSessionManager: WebXRSessionManager;
  49516. /**
  49517. * the WebXR camera for this session. Mainly used for teleportation
  49518. */
  49519. xrCamera: WebXRCamera;
  49520. private readonly options;
  49521. /**
  49522. * XR controllers being tracked
  49523. */
  49524. controllers: Array<WebXRInputSource>;
  49525. private _frameObserver;
  49526. private _sessionEndedObserver;
  49527. private _sessionInitObserver;
  49528. /**
  49529. * Event when a controller has been connected/added
  49530. */
  49531. onControllerAddedObservable: Observable<WebXRInputSource>;
  49532. /**
  49533. * Event when a controller has been removed/disconnected
  49534. */
  49535. onControllerRemovedObservable: Observable<WebXRInputSource>;
  49536. /**
  49537. * Initializes the WebXRInput
  49538. * @param xrSessionManager the xr session manager for this session
  49539. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  49540. * @param options = initialization options for this xr input
  49541. */
  49542. constructor(
  49543. /**
  49544. * the xr session manager for this session
  49545. */
  49546. xrSessionManager: WebXRSessionManager,
  49547. /**
  49548. * the WebXR camera for this session. Mainly used for teleportation
  49549. */
  49550. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  49551. private _onInputSourcesChange;
  49552. private _addAndRemoveControllers;
  49553. /**
  49554. * Disposes of the object
  49555. */
  49556. dispose(): void;
  49557. }
  49558. }
  49559. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  49560. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  49561. import { Observable, EventState } from "babylonjs/Misc/observable";
  49562. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49563. /**
  49564. * This is the base class for all WebXR features.
  49565. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  49566. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  49567. */
  49568. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  49569. protected _xrSessionManager: WebXRSessionManager;
  49570. private _attached;
  49571. private _removeOnDetach;
  49572. /**
  49573. * Should auto-attach be disabled?
  49574. */
  49575. disableAutoAttach: boolean;
  49576. /**
  49577. * Construct a new (abstract) WebXR feature
  49578. * @param _xrSessionManager the xr session manager for this feature
  49579. */
  49580. constructor(_xrSessionManager: WebXRSessionManager);
  49581. /**
  49582. * Is this feature attached
  49583. */
  49584. get attached(): boolean;
  49585. /**
  49586. * attach this feature
  49587. *
  49588. * @param force should attachment be forced (even when already attached)
  49589. * @returns true if successful, false is failed or already attached
  49590. */
  49591. attach(force?: boolean): boolean;
  49592. /**
  49593. * detach this feature.
  49594. *
  49595. * @returns true if successful, false if failed or already detached
  49596. */
  49597. detach(): boolean;
  49598. /**
  49599. * Dispose this feature and all of the resources attached
  49600. */
  49601. dispose(): void;
  49602. /**
  49603. * This is used to register callbacks that will automatically be removed when detach is called.
  49604. * @param observable the observable to which the observer will be attached
  49605. * @param callback the callback to register
  49606. */
  49607. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  49608. /**
  49609. * Code in this function will be executed on each xrFrame received from the browser.
  49610. * This function will not execute after the feature is detached.
  49611. * @param _xrFrame the current frame
  49612. */
  49613. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  49614. }
  49615. }
  49616. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  49617. import { IDisposable, Scene } from "babylonjs/scene";
  49618. import { Nullable } from "babylonjs/types";
  49619. import { Observable } from "babylonjs/Misc/observable";
  49620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49621. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  49622. import { Camera } from "babylonjs/Cameras/camera";
  49623. /**
  49624. * Renders a layer on top of an existing scene
  49625. */
  49626. export class UtilityLayerRenderer implements IDisposable {
  49627. /** the original scene that will be rendered on top of */
  49628. originalScene: Scene;
  49629. private _pointerCaptures;
  49630. private _lastPointerEvents;
  49631. private static _DefaultUtilityLayer;
  49632. private static _DefaultKeepDepthUtilityLayer;
  49633. private _sharedGizmoLight;
  49634. private _renderCamera;
  49635. /**
  49636. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  49637. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  49638. * @returns the camera that is used when rendering the utility layer
  49639. */
  49640. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  49641. /**
  49642. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  49643. * @param cam the camera that should be used when rendering the utility layer
  49644. */
  49645. setRenderCamera(cam: Nullable<Camera>): void;
  49646. /**
  49647. * @hidden
  49648. * Light which used by gizmos to get light shading
  49649. */
  49650. _getSharedGizmoLight(): HemisphericLight;
  49651. /**
  49652. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  49653. */
  49654. pickUtilitySceneFirst: boolean;
  49655. /**
  49656. * 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)
  49657. */
  49658. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  49659. /**
  49660. * 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)
  49661. */
  49662. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  49663. /**
  49664. * The scene that is rendered on top of the original scene
  49665. */
  49666. utilityLayerScene: Scene;
  49667. /**
  49668. * If the utility layer should automatically be rendered on top of existing scene
  49669. */
  49670. shouldRender: boolean;
  49671. /**
  49672. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  49673. */
  49674. onlyCheckPointerDownEvents: boolean;
  49675. /**
  49676. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  49677. */
  49678. processAllEvents: boolean;
  49679. /**
  49680. * Observable raised when the pointer move from the utility layer scene to the main scene
  49681. */
  49682. onPointerOutObservable: Observable<number>;
  49683. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  49684. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  49685. private _afterRenderObserver;
  49686. private _sceneDisposeObserver;
  49687. private _originalPointerObserver;
  49688. /**
  49689. * Instantiates a UtilityLayerRenderer
  49690. * @param originalScene the original scene that will be rendered on top of
  49691. * @param handleEvents boolean indicating if the utility layer should handle events
  49692. */
  49693. constructor(
  49694. /** the original scene that will be rendered on top of */
  49695. originalScene: Scene, handleEvents?: boolean);
  49696. private _notifyObservers;
  49697. /**
  49698. * Renders the utility layers scene on top of the original scene
  49699. */
  49700. render(): void;
  49701. /**
  49702. * Disposes of the renderer
  49703. */
  49704. dispose(): void;
  49705. private _updateCamera;
  49706. }
  49707. }
  49708. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  49709. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49710. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49711. import { WebXRInput } from "babylonjs/XR/webXRInput";
  49712. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  49713. import { Scene } from "babylonjs/scene";
  49714. import { Nullable } from "babylonjs/types";
  49715. import { Color3 } from "babylonjs/Maths/math.color";
  49716. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  49717. /**
  49718. * Options interface for the pointer selection module
  49719. */
  49720. export interface IWebXRControllerPointerSelectionOptions {
  49721. /**
  49722. * if provided, this scene will be used to render meshes.
  49723. */
  49724. customUtilityLayerScene?: Scene;
  49725. /**
  49726. * Disable the pointer up event when the xr controller in screen and gaze mode is disposed (meaning - when the user removed the finger from the screen)
  49727. * If not disabled, the last picked point will be used to execute a pointer up event
  49728. * If disabled, pointer up event will be triggered right after the pointer down event.
  49729. * Used in screen and gaze target ray mode only
  49730. */
  49731. disablePointerUpOnTouchOut: boolean;
  49732. /**
  49733. * For gaze mode (time to select instead of press)
  49734. */
  49735. forceGazeMode: boolean;
  49736. /**
  49737. * Factor to be applied to the pointer-moved function in the gaze mode. How sensitive should the gaze mode be when checking if the pointer moved
  49738. * to start a new countdown to the pointer down event.
  49739. * Defaults to 1.
  49740. */
  49741. gazeModePointerMovedFactor?: number;
  49742. /**
  49743. * Different button type to use instead of the main component
  49744. */
  49745. overrideButtonId?: string;
  49746. /**
  49747. * use this rendering group id for the meshes (optional)
  49748. */
  49749. renderingGroupId?: number;
  49750. /**
  49751. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  49752. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  49753. * 3000 means 3 seconds between pointing at something and selecting it
  49754. */
  49755. timeToSelect?: number;
  49756. /**
  49757. * Should meshes created here be added to a utility layer or the main scene
  49758. */
  49759. useUtilityLayer?: boolean;
  49760. /**
  49761. * the xr input to use with this pointer selection
  49762. */
  49763. xrInput: WebXRInput;
  49764. }
  49765. /**
  49766. * A module that will enable pointer selection for motion controllers of XR Input Sources
  49767. */
  49768. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  49769. private readonly _options;
  49770. private static _idCounter;
  49771. private _attachController;
  49772. private _controllers;
  49773. private _scene;
  49774. private _tmpVectorForPickCompare;
  49775. /**
  49776. * The module's name
  49777. */
  49778. static readonly Name: string;
  49779. /**
  49780. * The (Babylon) version of this module.
  49781. * This is an integer representing the implementation version.
  49782. * This number does not correspond to the WebXR specs version
  49783. */
  49784. static readonly Version: number;
  49785. /**
  49786. * Disable lighting on the laser pointer (so it will always be visible)
  49787. */
  49788. disablePointerLighting: boolean;
  49789. /**
  49790. * Disable lighting on the selection mesh (so it will always be visible)
  49791. */
  49792. disableSelectionMeshLighting: boolean;
  49793. /**
  49794. * Should the laser pointer be displayed
  49795. */
  49796. displayLaserPointer: boolean;
  49797. /**
  49798. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  49799. */
  49800. displaySelectionMesh: boolean;
  49801. /**
  49802. * This color will be set to the laser pointer when selection is triggered
  49803. */
  49804. laserPointerPickedColor: Color3;
  49805. /**
  49806. * Default color of the laser pointer
  49807. */
  49808. laserPointerDefaultColor: Color3;
  49809. /**
  49810. * default color of the selection ring
  49811. */
  49812. selectionMeshDefaultColor: Color3;
  49813. /**
  49814. * This color will be applied to the selection ring when selection is triggered
  49815. */
  49816. selectionMeshPickedColor: Color3;
  49817. /**
  49818. * Optional filter to be used for ray selection. This predicate shares behavior with
  49819. * scene.pointerMovePredicate which takes priority if it is also assigned.
  49820. */
  49821. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49822. /**
  49823. * constructs a new background remover module
  49824. * @param _xrSessionManager the session manager for this module
  49825. * @param _options read-only options to be used in this module
  49826. */
  49827. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  49828. /**
  49829. * attach this feature
  49830. * Will usually be called by the features manager
  49831. *
  49832. * @returns true if successful.
  49833. */
  49834. attach(): boolean;
  49835. /**
  49836. * detach this feature.
  49837. * Will usually be called by the features manager
  49838. *
  49839. * @returns true if successful.
  49840. */
  49841. detach(): boolean;
  49842. /**
  49843. * Will get the mesh under a specific pointer.
  49844. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  49845. * @param controllerId the controllerId to check
  49846. * @returns The mesh under pointer or null if no mesh is under the pointer
  49847. */
  49848. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  49849. /**
  49850. * Get the xr controller that correlates to the pointer id in the pointer event
  49851. *
  49852. * @param id the pointer id to search for
  49853. * @returns the controller that correlates to this id or null if not found
  49854. */
  49855. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  49856. protected _onXRFrame(_xrFrame: XRFrame): void;
  49857. private _attachGazeMode;
  49858. private _attachScreenRayMode;
  49859. private _attachTrackedPointerRayMode;
  49860. private _convertNormalToDirectionOfRay;
  49861. private _detachController;
  49862. private _generateNewMeshPair;
  49863. private _pickingMoved;
  49864. private _updatePointerDistance;
  49865. /** @hidden */
  49866. get lasterPointerDefaultColor(): Color3;
  49867. }
  49868. }
  49869. declare module "babylonjs/XR/webXREnterExitUI" {
  49870. import { Nullable } from "babylonjs/types";
  49871. import { Observable } from "babylonjs/Misc/observable";
  49872. import { IDisposable, Scene } from "babylonjs/scene";
  49873. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  49874. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49875. /**
  49876. * Button which can be used to enter a different mode of XR
  49877. */
  49878. export class WebXREnterExitUIButton {
  49879. /** button element */
  49880. element: HTMLElement;
  49881. /** XR initialization options for the button */
  49882. sessionMode: XRSessionMode;
  49883. /** Reference space type */
  49884. referenceSpaceType: XRReferenceSpaceType;
  49885. /**
  49886. * Creates a WebXREnterExitUIButton
  49887. * @param element button element
  49888. * @param sessionMode XR initialization session mode
  49889. * @param referenceSpaceType the type of reference space to be used
  49890. */
  49891. constructor(
  49892. /** button element */
  49893. element: HTMLElement,
  49894. /** XR initialization options for the button */
  49895. sessionMode: XRSessionMode,
  49896. /** Reference space type */
  49897. referenceSpaceType: XRReferenceSpaceType);
  49898. /**
  49899. * Extendable function which can be used to update the button's visuals when the state changes
  49900. * @param activeButton the current active button in the UI
  49901. */
  49902. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  49903. }
  49904. /**
  49905. * Options to create the webXR UI
  49906. */
  49907. export class WebXREnterExitUIOptions {
  49908. /**
  49909. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  49910. */
  49911. customButtons?: Array<WebXREnterExitUIButton>;
  49912. /**
  49913. * A reference space type to use when creating the default button.
  49914. * Default is local-floor
  49915. */
  49916. referenceSpaceType?: XRReferenceSpaceType;
  49917. /**
  49918. * Context to enter xr with
  49919. */
  49920. renderTarget?: Nullable<WebXRRenderTarget>;
  49921. /**
  49922. * A session mode to use when creating the default button.
  49923. * Default is immersive-vr
  49924. */
  49925. sessionMode?: XRSessionMode;
  49926. /**
  49927. * A list of optional features to init the session with
  49928. */
  49929. optionalFeatures?: string[];
  49930. }
  49931. /**
  49932. * UI to allow the user to enter/exit XR mode
  49933. */
  49934. export class WebXREnterExitUI implements IDisposable {
  49935. private scene;
  49936. /** version of the options passed to this UI */
  49937. options: WebXREnterExitUIOptions;
  49938. private _activeButton;
  49939. private _buttons;
  49940. private _overlay;
  49941. /**
  49942. * Fired every time the active button is changed.
  49943. *
  49944. * When xr is entered via a button that launches xr that button will be the callback parameter
  49945. *
  49946. * When exiting xr the callback parameter will be null)
  49947. */
  49948. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49949. /**
  49950. *
  49951. * @param scene babylon scene object to use
  49952. * @param options (read-only) version of the options passed to this UI
  49953. */
  49954. private constructor();
  49955. /**
  49956. * Creates UI to allow the user to enter/exit XR mode
  49957. * @param scene the scene to add the ui to
  49958. * @param helper the xr experience helper to enter/exit xr with
  49959. * @param options options to configure the UI
  49960. * @returns the created ui
  49961. */
  49962. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49963. /**
  49964. * Disposes of the XR UI component
  49965. */
  49966. dispose(): void;
  49967. private _updateButtons;
  49968. }
  49969. }
  49970. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  49971. import { Vector3 } from "babylonjs/Maths/math.vector";
  49972. import { Color4 } from "babylonjs/Maths/math.color";
  49973. import { Nullable } from "babylonjs/types";
  49974. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  49975. import { Scene } from "babylonjs/scene";
  49976. /**
  49977. * Class containing static functions to help procedurally build meshes
  49978. */
  49979. export class LinesBuilder {
  49980. /**
  49981. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49982. * * 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
  49983. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49984. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49985. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49986. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49987. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49988. * * 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
  49989. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49991. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49992. * @param name defines the name of the new line system
  49993. * @param options defines the options used to create the line system
  49994. * @param scene defines the hosting scene
  49995. * @returns a new line system mesh
  49996. */
  49997. static CreateLineSystem(name: string, options: {
  49998. lines: Vector3[][];
  49999. updatable?: boolean;
  50000. instance?: Nullable<LinesMesh>;
  50001. colors?: Nullable<Color4[][]>;
  50002. useVertexAlpha?: boolean;
  50003. }, scene: Nullable<Scene>): LinesMesh;
  50004. /**
  50005. * Creates a line mesh
  50006. * 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
  50007. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50008. * * The parameter `points` is an array successive Vector3
  50009. * * 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
  50010. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50011. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50012. * * When updating an instance, remember that only point positions can change, not the number of points
  50013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50014. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50015. * @param name defines the name of the new line system
  50016. * @param options defines the options used to create the line system
  50017. * @param scene defines the hosting scene
  50018. * @returns a new line mesh
  50019. */
  50020. static CreateLines(name: string, options: {
  50021. points: Vector3[];
  50022. updatable?: boolean;
  50023. instance?: Nullable<LinesMesh>;
  50024. colors?: Color4[];
  50025. useVertexAlpha?: boolean;
  50026. }, scene?: Nullable<Scene>): LinesMesh;
  50027. /**
  50028. * Creates a dashed line mesh
  50029. * * 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
  50030. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50031. * * The parameter `points` is an array successive Vector3
  50032. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50033. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50034. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50035. * * 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
  50036. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50037. * * When updating an instance, remember that only point positions can change, not the number of points
  50038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50039. * @param name defines the name of the mesh
  50040. * @param options defines the options used to create the mesh
  50041. * @param scene defines the hosting scene
  50042. * @returns the dashed line mesh
  50043. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50044. */
  50045. static CreateDashedLines(name: string, options: {
  50046. points: Vector3[];
  50047. dashSize?: number;
  50048. gapSize?: number;
  50049. dashNb?: number;
  50050. updatable?: boolean;
  50051. instance?: LinesMesh;
  50052. useVertexAlpha?: boolean;
  50053. }, scene?: Nullable<Scene>): LinesMesh;
  50054. }
  50055. }
  50056. declare module "babylonjs/Misc/timer" {
  50057. import { Observable, Observer } from "babylonjs/Misc/observable";
  50058. import { Nullable } from "babylonjs/types";
  50059. import { IDisposable } from "babylonjs/scene";
  50060. /**
  50061. * Construction options for a timer
  50062. */
  50063. export interface ITimerOptions<T> {
  50064. /**
  50065. * Time-to-end
  50066. */
  50067. timeout: number;
  50068. /**
  50069. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  50070. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  50071. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  50072. */
  50073. contextObservable: Observable<T>;
  50074. /**
  50075. * Optional parameters when adding an observer to the observable
  50076. */
  50077. observableParameters?: {
  50078. mask?: number;
  50079. insertFirst?: boolean;
  50080. scope?: any;
  50081. };
  50082. /**
  50083. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  50084. */
  50085. breakCondition?: (data?: ITimerData<T>) => boolean;
  50086. /**
  50087. * Will be triggered when the time condition has met
  50088. */
  50089. onEnded?: (data: ITimerData<any>) => void;
  50090. /**
  50091. * Will be triggered when the break condition has met (prematurely ended)
  50092. */
  50093. onAborted?: (data: ITimerData<any>) => void;
  50094. /**
  50095. * Optional function to execute on each tick (or count)
  50096. */
  50097. onTick?: (data: ITimerData<any>) => void;
  50098. }
  50099. /**
  50100. * An interface defining the data sent by the timer
  50101. */
  50102. export interface ITimerData<T> {
  50103. /**
  50104. * When did it start
  50105. */
  50106. startTime: number;
  50107. /**
  50108. * Time now
  50109. */
  50110. currentTime: number;
  50111. /**
  50112. * Time passed since started
  50113. */
  50114. deltaTime: number;
  50115. /**
  50116. * How much is completed, in [0.0...1.0].
  50117. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  50118. */
  50119. completeRate: number;
  50120. /**
  50121. * What the registered observable sent in the last count
  50122. */
  50123. payload: T;
  50124. }
  50125. /**
  50126. * The current state of the timer
  50127. */
  50128. export enum TimerState {
  50129. /**
  50130. * Timer initialized, not yet started
  50131. */
  50132. INIT = 0,
  50133. /**
  50134. * Timer started and counting
  50135. */
  50136. STARTED = 1,
  50137. /**
  50138. * Timer ended (whether aborted or time reached)
  50139. */
  50140. ENDED = 2
  50141. }
  50142. /**
  50143. * A simple version of the timer. Will take options and start the timer immediately after calling it
  50144. *
  50145. * @param options options with which to initialize this timer
  50146. */
  50147. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  50148. /**
  50149. * An advanced implementation of a timer class
  50150. */
  50151. export class AdvancedTimer<T = any> implements IDisposable {
  50152. /**
  50153. * Will notify each time the timer calculates the remaining time
  50154. */
  50155. onEachCountObservable: Observable<ITimerData<T>>;
  50156. /**
  50157. * Will trigger when the timer was aborted due to the break condition
  50158. */
  50159. onTimerAbortedObservable: Observable<ITimerData<T>>;
  50160. /**
  50161. * Will trigger when the timer ended successfully
  50162. */
  50163. onTimerEndedObservable: Observable<ITimerData<T>>;
  50164. /**
  50165. * Will trigger when the timer state has changed
  50166. */
  50167. onStateChangedObservable: Observable<TimerState>;
  50168. private _observer;
  50169. private _contextObservable;
  50170. private _observableParameters;
  50171. private _startTime;
  50172. private _timer;
  50173. private _state;
  50174. private _breakCondition;
  50175. private _timeToEnd;
  50176. private _breakOnNextTick;
  50177. /**
  50178. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  50179. * @param options construction options for this advanced timer
  50180. */
  50181. constructor(options: ITimerOptions<T>);
  50182. /**
  50183. * set a breaking condition for this timer. Default is to never break during count
  50184. * @param predicate the new break condition. Returns true to break, false otherwise
  50185. */
  50186. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  50187. /**
  50188. * Reset ALL associated observables in this advanced timer
  50189. */
  50190. clearObservables(): void;
  50191. /**
  50192. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  50193. *
  50194. * @param timeToEnd how much time to measure until timer ended
  50195. */
  50196. start(timeToEnd?: number): void;
  50197. /**
  50198. * Will force a stop on the next tick.
  50199. */
  50200. stop(): void;
  50201. /**
  50202. * Dispose this timer, clearing all resources
  50203. */
  50204. dispose(): void;
  50205. private _setState;
  50206. private _tick;
  50207. private _stop;
  50208. }
  50209. }
  50210. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  50211. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50212. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50213. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50215. import { Vector3 } from "babylonjs/Maths/math.vector";
  50216. import { Material } from "babylonjs/Materials/material";
  50217. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50218. import { Scene } from "babylonjs/scene";
  50219. /**
  50220. * The options container for the teleportation module
  50221. */
  50222. export interface IWebXRTeleportationOptions {
  50223. /**
  50224. * if provided, this scene will be used to render meshes.
  50225. */
  50226. customUtilityLayerScene?: Scene;
  50227. /**
  50228. * Values to configure the default target mesh
  50229. */
  50230. defaultTargetMeshOptions?: {
  50231. /**
  50232. * Fill color of the teleportation area
  50233. */
  50234. teleportationFillColor?: string;
  50235. /**
  50236. * Border color for the teleportation area
  50237. */
  50238. teleportationBorderColor?: string;
  50239. /**
  50240. * Disable the mesh's animation sequence
  50241. */
  50242. disableAnimation?: boolean;
  50243. /**
  50244. * Disable lighting on the material or the ring and arrow
  50245. */
  50246. disableLighting?: boolean;
  50247. /**
  50248. * Override the default material of the torus and arrow
  50249. */
  50250. torusArrowMaterial?: Material;
  50251. };
  50252. /**
  50253. * A list of meshes to use as floor meshes.
  50254. * Meshes can be added and removed after initializing the feature using the
  50255. * addFloorMesh and removeFloorMesh functions
  50256. * If empty, rotation will still work
  50257. */
  50258. floorMeshes?: AbstractMesh[];
  50259. /**
  50260. * use this rendering group id for the meshes (optional)
  50261. */
  50262. renderingGroupId?: number;
  50263. /**
  50264. * Should teleportation move only to snap points
  50265. */
  50266. snapPointsOnly?: boolean;
  50267. /**
  50268. * An array of points to which the teleportation will snap to.
  50269. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  50270. */
  50271. snapPositions?: Vector3[];
  50272. /**
  50273. * How close should the teleportation ray be in order to snap to position.
  50274. * Default to 0.8 units (meters)
  50275. */
  50276. snapToPositionRadius?: number;
  50277. /**
  50278. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  50279. * If you want to support rotation, make sure your mesh has a direction indicator.
  50280. *
  50281. * When left untouched, the default mesh will be initialized.
  50282. */
  50283. teleportationTargetMesh?: AbstractMesh;
  50284. /**
  50285. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  50286. */
  50287. timeToTeleport?: number;
  50288. /**
  50289. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  50290. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  50291. */
  50292. useMainComponentOnly?: boolean;
  50293. /**
  50294. * Should meshes created here be added to a utility layer or the main scene
  50295. */
  50296. useUtilityLayer?: boolean;
  50297. /**
  50298. * Babylon XR Input class for controller
  50299. */
  50300. xrInput: WebXRInput;
  50301. }
  50302. /**
  50303. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  50304. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  50305. * the input of the attached controllers.
  50306. */
  50307. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  50308. private _options;
  50309. private _controllers;
  50310. private _currentTeleportationControllerId;
  50311. private _floorMeshes;
  50312. private _quadraticBezierCurve;
  50313. private _selectionFeature;
  50314. private _snapToPositions;
  50315. private _snappedToPoint;
  50316. private _teleportationRingMaterial?;
  50317. private _tmpRay;
  50318. private _tmpVector;
  50319. /**
  50320. * The module's name
  50321. */
  50322. static readonly Name: string;
  50323. /**
  50324. * The (Babylon) version of this module.
  50325. * This is an integer representing the implementation version.
  50326. * This number does not correspond to the webxr specs version
  50327. */
  50328. static readonly Version: number;
  50329. /**
  50330. * Is movement backwards enabled
  50331. */
  50332. backwardsMovementEnabled: boolean;
  50333. /**
  50334. * Distance to travel when moving backwards
  50335. */
  50336. backwardsTeleportationDistance: number;
  50337. /**
  50338. * The distance from the user to the inspection point in the direction of the controller
  50339. * A higher number will allow the user to move further
  50340. * defaults to 5 (meters, in xr units)
  50341. */
  50342. parabolicCheckRadius: number;
  50343. /**
  50344. * Should the module support parabolic ray on top of direct ray
  50345. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  50346. * Very helpful when moving between floors / different heights
  50347. */
  50348. parabolicRayEnabled: boolean;
  50349. /**
  50350. * How much rotation should be applied when rotating right and left
  50351. */
  50352. rotationAngle: number;
  50353. /**
  50354. * Is rotation enabled when moving forward?
  50355. * Disabling this feature will prevent the user from deciding the direction when teleporting
  50356. */
  50357. rotationEnabled: boolean;
  50358. /**
  50359. * constructs a new anchor system
  50360. * @param _xrSessionManager an instance of WebXRSessionManager
  50361. * @param _options configuration object for this feature
  50362. */
  50363. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  50364. /**
  50365. * Get the snapPointsOnly flag
  50366. */
  50367. get snapPointsOnly(): boolean;
  50368. /**
  50369. * Sets the snapPointsOnly flag
  50370. * @param snapToPoints should teleportation be exclusively to snap points
  50371. */
  50372. set snapPointsOnly(snapToPoints: boolean);
  50373. /**
  50374. * Add a new mesh to the floor meshes array
  50375. * @param mesh the mesh to use as floor mesh
  50376. */
  50377. addFloorMesh(mesh: AbstractMesh): void;
  50378. /**
  50379. * Add a new snap-to point to fix teleportation to this position
  50380. * @param newSnapPoint The new Snap-To point
  50381. */
  50382. addSnapPoint(newSnapPoint: Vector3): void;
  50383. attach(): boolean;
  50384. detach(): boolean;
  50385. dispose(): void;
  50386. /**
  50387. * Remove a mesh from the floor meshes array
  50388. * @param mesh the mesh to remove
  50389. */
  50390. removeFloorMesh(mesh: AbstractMesh): void;
  50391. /**
  50392. * Remove a mesh from the floor meshes array using its name
  50393. * @param name the mesh name to remove
  50394. */
  50395. removeFloorMeshByName(name: string): void;
  50396. /**
  50397. * This function will iterate through the array, searching for this point or equal to it. It will then remove it from the snap-to array
  50398. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  50399. * @returns was the point found and removed or not
  50400. */
  50401. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  50402. /**
  50403. * This function sets a selection feature that will be disabled when
  50404. * the forward ray is shown and will be reattached when hidden.
  50405. * This is used to remove the selection rays when moving.
  50406. * @param selectionFeature the feature to disable when forward movement is enabled
  50407. */
  50408. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  50409. protected _onXRFrame(_xrFrame: XRFrame): void;
  50410. private _attachController;
  50411. private _createDefaultTargetMesh;
  50412. private _detachController;
  50413. private _findClosestSnapPointWithRadius;
  50414. private _setTargetMeshPosition;
  50415. private _setTargetMeshVisibility;
  50416. private _showParabolicPath;
  50417. private _teleportForward;
  50418. }
  50419. }
  50420. declare module "babylonjs/XR/webXRDefaultExperience" {
  50421. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50422. import { Scene } from "babylonjs/scene";
  50423. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  50424. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  50425. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50426. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  50427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50428. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  50429. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  50430. /**
  50431. * Options for the default xr helper
  50432. */
  50433. export class WebXRDefaultExperienceOptions {
  50434. /**
  50435. * Enable or disable default UI to enter XR
  50436. */
  50437. disableDefaultUI?: boolean;
  50438. /**
  50439. * Should teleportation not initialize. defaults to false.
  50440. */
  50441. disableTeleportation?: boolean;
  50442. /**
  50443. * Floor meshes that will be used for teleport
  50444. */
  50445. floorMeshes?: Array<AbstractMesh>;
  50446. /**
  50447. * If set to true, the first frame will not be used to reset position
  50448. * The first frame is mainly used when copying transformation from the old camera
  50449. * Mainly used in AR
  50450. */
  50451. ignoreNativeCameraTransformation?: boolean;
  50452. /**
  50453. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  50454. */
  50455. inputOptions?: IWebXRInputOptions;
  50456. /**
  50457. * optional configuration for the output canvas
  50458. */
  50459. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  50460. /**
  50461. * optional UI options. This can be used among other to change session mode and reference space type
  50462. */
  50463. uiOptions?: WebXREnterExitUIOptions;
  50464. /**
  50465. * When loading teleportation and pointer select, use stable versions instead of latest.
  50466. */
  50467. useStablePlugins?: boolean;
  50468. /**
  50469. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  50470. */
  50471. renderingGroupId?: number;
  50472. /**
  50473. * A list of optional features to init the session with
  50474. * If set to true, all features we support will be added
  50475. */
  50476. optionalFeatures?: boolean | string[];
  50477. }
  50478. /**
  50479. * Default experience which provides a similar setup to the previous webVRExperience
  50480. */
  50481. export class WebXRDefaultExperience {
  50482. /**
  50483. * Base experience
  50484. */
  50485. baseExperience: WebXRExperienceHelper;
  50486. /**
  50487. * Enables ui for entering/exiting xr
  50488. */
  50489. enterExitUI: WebXREnterExitUI;
  50490. /**
  50491. * Input experience extension
  50492. */
  50493. input: WebXRInput;
  50494. /**
  50495. * Enables laser pointer and selection
  50496. */
  50497. pointerSelection: WebXRControllerPointerSelection;
  50498. /**
  50499. * Default target xr should render to
  50500. */
  50501. renderTarget: WebXRRenderTarget;
  50502. /**
  50503. * Enables teleportation
  50504. */
  50505. teleportation: WebXRMotionControllerTeleportation;
  50506. private constructor();
  50507. /**
  50508. * Creates the default xr experience
  50509. * @param scene scene
  50510. * @param options options for basic configuration
  50511. * @returns resulting WebXRDefaultExperience
  50512. */
  50513. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50514. /**
  50515. * DIsposes of the experience helper
  50516. */
  50517. dispose(): void;
  50518. }
  50519. }
  50520. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  50521. import { Observable } from "babylonjs/Misc/observable";
  50522. import { Nullable } from "babylonjs/types";
  50523. import { Camera } from "babylonjs/Cameras/camera";
  50524. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  50525. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  50526. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  50527. import { Scene } from "babylonjs/scene";
  50528. import { Vector3 } from "babylonjs/Maths/math.vector";
  50529. import { Color3 } from "babylonjs/Maths/math.color";
  50530. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50531. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50532. import { Mesh } from "babylonjs/Meshes/mesh";
  50533. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  50534. import { EasingFunction } from "babylonjs/Animations/easing";
  50535. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  50536. import "babylonjs/Meshes/Builders/groundBuilder";
  50537. import "babylonjs/Meshes/Builders/torusBuilder";
  50538. import "babylonjs/Meshes/Builders/cylinderBuilder";
  50539. import "babylonjs/Gamepads/gamepadSceneComponent";
  50540. import "babylonjs/Animations/animatable";
  50541. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  50542. /**
  50543. * Options to modify the vr teleportation behavior.
  50544. */
  50545. export interface VRTeleportationOptions {
  50546. /**
  50547. * The name of the mesh which should be used as the teleportation floor. (default: null)
  50548. */
  50549. floorMeshName?: string;
  50550. /**
  50551. * A list of meshes to be used as the teleportation floor. (default: empty)
  50552. */
  50553. floorMeshes?: Mesh[];
  50554. /**
  50555. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  50556. */
  50557. teleportationMode?: number;
  50558. /**
  50559. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  50560. */
  50561. teleportationTime?: number;
  50562. /**
  50563. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  50564. */
  50565. teleportationSpeed?: number;
  50566. /**
  50567. * The easing function used in the animation or null for Linear. (default CircleEase)
  50568. */
  50569. easingFunction?: EasingFunction;
  50570. }
  50571. /**
  50572. * Options to modify the vr experience helper's behavior.
  50573. */
  50574. export interface VRExperienceHelperOptions extends WebVROptions {
  50575. /**
  50576. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  50577. */
  50578. createDeviceOrientationCamera?: boolean;
  50579. /**
  50580. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  50581. */
  50582. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  50583. /**
  50584. * Uses the main button on the controller to toggle the laser casted. (default: true)
  50585. */
  50586. laserToggle?: boolean;
  50587. /**
  50588. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  50589. */
  50590. floorMeshes?: Mesh[];
  50591. /**
  50592. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  50593. */
  50594. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  50595. /**
  50596. * Defines if WebXR should be used instead of WebVR (if available)
  50597. */
  50598. useXR?: boolean;
  50599. }
  50600. /**
  50601. * Event containing information after VR has been entered
  50602. */
  50603. export class OnAfterEnteringVRObservableEvent {
  50604. /**
  50605. * If entering vr was successful
  50606. */
  50607. success: boolean;
  50608. }
  50609. /**
  50610. * Helps to quickly add VR support to an existing scene.
  50611. * See https://doc.babylonjs.com/how_to/webvr_helper
  50612. */
  50613. export class VRExperienceHelper {
  50614. /** Options to modify the vr experience helper's behavior. */
  50615. webVROptions: VRExperienceHelperOptions;
  50616. private _scene;
  50617. private _position;
  50618. private _btnVR;
  50619. private _btnVRDisplayed;
  50620. private _webVRsupported;
  50621. private _webVRready;
  50622. private _webVRrequesting;
  50623. private _webVRpresenting;
  50624. private _hasEnteredVR;
  50625. private _fullscreenVRpresenting;
  50626. private _inputElement;
  50627. private _webVRCamera;
  50628. private _vrDeviceOrientationCamera;
  50629. private _deviceOrientationCamera;
  50630. private _existingCamera;
  50631. private _onKeyDown;
  50632. private _onVrDisplayPresentChange;
  50633. private _onVRDisplayChanged;
  50634. private _onVRRequestPresentStart;
  50635. private _onVRRequestPresentComplete;
  50636. /**
  50637. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  50638. */
  50639. enableGazeEvenWhenNoPointerLock: boolean;
  50640. /**
  50641. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  50642. */
  50643. exitVROnDoubleTap: boolean;
  50644. /**
  50645. * Observable raised right before entering VR.
  50646. */
  50647. onEnteringVRObservable: Observable<VRExperienceHelper>;
  50648. /**
  50649. * Observable raised when entering VR has completed.
  50650. */
  50651. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  50652. /**
  50653. * Observable raised when exiting VR.
  50654. */
  50655. onExitingVRObservable: Observable<VRExperienceHelper>;
  50656. /**
  50657. * Observable raised when controller mesh is loaded.
  50658. */
  50659. onControllerMeshLoadedObservable: Observable<WebVRController>;
  50660. /** Return this.onEnteringVRObservable
  50661. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  50662. */
  50663. get onEnteringVR(): Observable<VRExperienceHelper>;
  50664. /** Return this.onExitingVRObservable
  50665. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  50666. */
  50667. get onExitingVR(): Observable<VRExperienceHelper>;
  50668. /** Return this.onControllerMeshLoadedObservable
  50669. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  50670. */
  50671. get onControllerMeshLoaded(): Observable<WebVRController>;
  50672. private _rayLength;
  50673. private _useCustomVRButton;
  50674. private _teleportationRequested;
  50675. private _teleportActive;
  50676. private _floorMeshName;
  50677. private _floorMeshesCollection;
  50678. private _teleportationMode;
  50679. private _teleportationTime;
  50680. private _teleportationSpeed;
  50681. private _teleportationEasing;
  50682. private _rotationAllowed;
  50683. private _teleportBackwardsVector;
  50684. private _teleportationTarget;
  50685. private _isDefaultTeleportationTarget;
  50686. private _postProcessMove;
  50687. private _teleportationFillColor;
  50688. private _teleportationBorderColor;
  50689. private _rotationAngle;
  50690. private _haloCenter;
  50691. private _cameraGazer;
  50692. private _padSensibilityUp;
  50693. private _padSensibilityDown;
  50694. private _leftController;
  50695. private _rightController;
  50696. private _gazeColor;
  50697. private _laserColor;
  50698. private _pickedLaserColor;
  50699. private _pickedGazeColor;
  50700. /**
  50701. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  50702. */
  50703. onNewMeshSelected: Observable<AbstractMesh>;
  50704. /**
  50705. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  50706. * This observable will provide the mesh and the controller used to select the mesh
  50707. */
  50708. onMeshSelectedWithController: Observable<{
  50709. mesh: AbstractMesh;
  50710. controller: WebVRController;
  50711. }>;
  50712. /**
  50713. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  50714. */
  50715. onNewMeshPicked: Observable<PickingInfo>;
  50716. private _circleEase;
  50717. /**
  50718. * Observable raised before camera teleportation
  50719. */
  50720. onBeforeCameraTeleport: Observable<Vector3>;
  50721. /**
  50722. * Observable raised after camera teleportation
  50723. */
  50724. onAfterCameraTeleport: Observable<Vector3>;
  50725. /**
  50726. * Observable raised when current selected mesh gets unselected
  50727. */
  50728. onSelectedMeshUnselected: Observable<AbstractMesh>;
  50729. private _raySelectionPredicate;
  50730. /**
  50731. * To be optionaly changed by user to define custom ray selection
  50732. */
  50733. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50734. /**
  50735. * To be optionaly changed by user to define custom selection logic (after ray selection)
  50736. */
  50737. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50738. /**
  50739. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  50740. */
  50741. teleportationEnabled: boolean;
  50742. private _defaultHeight;
  50743. private _teleportationInitialized;
  50744. private _interactionsEnabled;
  50745. private _interactionsRequested;
  50746. private _displayGaze;
  50747. private _displayLaserPointer;
  50748. /**
  50749. * The mesh used to display where the user is going to teleport.
  50750. */
  50751. get teleportationTarget(): Mesh;
  50752. /**
  50753. * Sets the mesh to be used to display where the user is going to teleport.
  50754. */
  50755. set teleportationTarget(value: Mesh);
  50756. /**
  50757. * 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
  50758. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  50759. * See https://doc.babylonjs.com/resources/baking_transformations
  50760. */
  50761. get gazeTrackerMesh(): Mesh;
  50762. set gazeTrackerMesh(value: Mesh);
  50763. /**
  50764. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  50765. */
  50766. updateGazeTrackerScale: boolean;
  50767. /**
  50768. * If the gaze trackers color should be updated when selecting meshes
  50769. */
  50770. updateGazeTrackerColor: boolean;
  50771. /**
  50772. * If the controller laser color should be updated when selecting meshes
  50773. */
  50774. updateControllerLaserColor: boolean;
  50775. /**
  50776. * The gaze tracking mesh corresponding to the left controller
  50777. */
  50778. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  50779. /**
  50780. * The gaze tracking mesh corresponding to the right controller
  50781. */
  50782. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  50783. /**
  50784. * If the ray of the gaze should be displayed.
  50785. */
  50786. get displayGaze(): boolean;
  50787. /**
  50788. * Sets if the ray of the gaze should be displayed.
  50789. */
  50790. set displayGaze(value: boolean);
  50791. /**
  50792. * If the ray of the LaserPointer should be displayed.
  50793. */
  50794. get displayLaserPointer(): boolean;
  50795. /**
  50796. * Sets if the ray of the LaserPointer should be displayed.
  50797. */
  50798. set displayLaserPointer(value: boolean);
  50799. /**
  50800. * The deviceOrientationCamera used as the camera when not in VR.
  50801. */
  50802. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  50803. /**
  50804. * Based on the current WebVR support, returns the current VR camera used.
  50805. */
  50806. get currentVRCamera(): Nullable<Camera>;
  50807. /**
  50808. * The webVRCamera which is used when in VR.
  50809. */
  50810. get webVRCamera(): WebVRFreeCamera;
  50811. /**
  50812. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  50813. */
  50814. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  50815. /**
  50816. * The html button that is used to trigger entering into VR.
  50817. */
  50818. get vrButton(): Nullable<HTMLButtonElement>;
  50819. private get _teleportationRequestInitiated();
  50820. /**
  50821. * Defines whether or not Pointer lock should be requested when switching to
  50822. * full screen.
  50823. */
  50824. requestPointerLockOnFullScreen: boolean;
  50825. /**
  50826. * If asking to force XR, this will be populated with the default xr experience
  50827. */
  50828. xr: WebXRDefaultExperience;
  50829. /**
  50830. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  50831. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  50832. */
  50833. xrTestDone: boolean;
  50834. /**
  50835. * Instantiates a VRExperienceHelper.
  50836. * Helps to quickly add VR support to an existing scene.
  50837. * @param scene The scene the VRExperienceHelper belongs to.
  50838. * @param webVROptions Options to modify the vr experience helper's behavior.
  50839. */
  50840. constructor(scene: Scene,
  50841. /** Options to modify the vr experience helper's behavior. */
  50842. webVROptions?: VRExperienceHelperOptions);
  50843. private completeVRInit;
  50844. private _onDefaultMeshLoaded;
  50845. private _onResize;
  50846. private _onFullscreenChange;
  50847. /**
  50848. * Gets a value indicating if we are currently in VR mode.
  50849. */
  50850. get isInVRMode(): boolean;
  50851. private onVrDisplayPresentChange;
  50852. private onVRDisplayChanged;
  50853. private moveButtonToBottomRight;
  50854. private displayVRButton;
  50855. private updateButtonVisibility;
  50856. private _cachedAngularSensibility;
  50857. /**
  50858. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  50859. * Otherwise, will use the fullscreen API.
  50860. */
  50861. enterVR(): void;
  50862. /**
  50863. * Attempt to exit VR, or fullscreen.
  50864. */
  50865. exitVR(): void;
  50866. /**
  50867. * The position of the vr experience helper.
  50868. */
  50869. get position(): Vector3;
  50870. /**
  50871. * Sets the position of the vr experience helper.
  50872. */
  50873. set position(value: Vector3);
  50874. /**
  50875. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  50876. */
  50877. enableInteractions(): void;
  50878. private get _noControllerIsActive();
  50879. private beforeRender;
  50880. private _isTeleportationFloor;
  50881. /**
  50882. * Adds a floor mesh to be used for teleportation.
  50883. * @param floorMesh the mesh to be used for teleportation.
  50884. */
  50885. addFloorMesh(floorMesh: Mesh): void;
  50886. /**
  50887. * Removes a floor mesh from being used for teleportation.
  50888. * @param floorMesh the mesh to be removed.
  50889. */
  50890. removeFloorMesh(floorMesh: Mesh): void;
  50891. /**
  50892. * Enables interactions and teleportation using the VR controllers and gaze.
  50893. * @param vrTeleportationOptions options to modify teleportation behavior.
  50894. */
  50895. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  50896. private _onNewGamepadConnected;
  50897. private _tryEnableInteractionOnController;
  50898. private _onNewGamepadDisconnected;
  50899. private _enableInteractionOnController;
  50900. private _checkTeleportWithRay;
  50901. private _checkRotate;
  50902. private _checkTeleportBackwards;
  50903. private _enableTeleportationOnController;
  50904. private _createTeleportationCircles;
  50905. private _displayTeleportationTarget;
  50906. private _hideTeleportationTarget;
  50907. private _rotateCamera;
  50908. private _moveTeleportationSelectorTo;
  50909. private _workingVector;
  50910. private _workingQuaternion;
  50911. private _workingMatrix;
  50912. /**
  50913. * Time Constant Teleportation Mode
  50914. */
  50915. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  50916. /**
  50917. * Speed Constant Teleportation Mode
  50918. */
  50919. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  50920. /**
  50921. * Teleports the users feet to the desired location
  50922. * @param location The location where the user's feet should be placed
  50923. */
  50924. teleportCamera(location: Vector3): void;
  50925. private _convertNormalToDirectionOfRay;
  50926. private _castRayAndSelectObject;
  50927. private _notifySelectedMeshUnselected;
  50928. /**
  50929. * Permanently set new colors for the laser pointer
  50930. * @param color the new laser color
  50931. * @param pickedColor the new laser color when picked mesh detected
  50932. */
  50933. setLaserColor(color: Color3, pickedColor?: Color3): void;
  50934. /**
  50935. * Set lighting enabled / disabled on the laser pointer of both controllers
  50936. * @param enabled should the lighting be enabled on the laser pointer
  50937. */
  50938. setLaserLightingState(enabled?: boolean): void;
  50939. /**
  50940. * Permanently set new colors for the gaze pointer
  50941. * @param color the new gaze color
  50942. * @param pickedColor the new gaze color when picked mesh detected
  50943. */
  50944. setGazeColor(color: Color3, pickedColor?: Color3): void;
  50945. /**
  50946. * Sets the color of the laser ray from the vr controllers.
  50947. * @param color new color for the ray.
  50948. */
  50949. changeLaserColor(color: Color3): void;
  50950. /**
  50951. * Sets the color of the ray from the vr headsets gaze.
  50952. * @param color new color for the ray.
  50953. */
  50954. changeGazeColor(color: Color3): void;
  50955. /**
  50956. * Exits VR and disposes of the vr experience helper
  50957. */
  50958. dispose(): void;
  50959. /**
  50960. * Gets the name of the VRExperienceHelper class
  50961. * @returns "VRExperienceHelper"
  50962. */
  50963. getClassName(): string;
  50964. }
  50965. }
  50966. declare module "babylonjs/Cameras/VR/index" {
  50967. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  50968. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  50969. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  50970. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  50971. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  50972. export * from "babylonjs/Cameras/VR/webVRCamera";
  50973. }
  50974. declare module "babylonjs/Cameras/RigModes/index" {
  50975. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  50976. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  50977. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  50978. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  50979. }
  50980. declare module "babylonjs/Cameras/index" {
  50981. export * from "babylonjs/Cameras/Inputs/index";
  50982. export * from "babylonjs/Cameras/cameraInputsManager";
  50983. export * from "babylonjs/Cameras/camera";
  50984. export * from "babylonjs/Cameras/targetCamera";
  50985. export * from "babylonjs/Cameras/freeCamera";
  50986. export * from "babylonjs/Cameras/freeCameraInputsManager";
  50987. export * from "babylonjs/Cameras/touchCamera";
  50988. export * from "babylonjs/Cameras/arcRotateCamera";
  50989. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  50990. export * from "babylonjs/Cameras/deviceOrientationCamera";
  50991. export * from "babylonjs/Cameras/flyCamera";
  50992. export * from "babylonjs/Cameras/flyCameraInputsManager";
  50993. export * from "babylonjs/Cameras/followCamera";
  50994. export * from "babylonjs/Cameras/followCameraInputsManager";
  50995. export * from "babylonjs/Cameras/gamepadCamera";
  50996. export * from "babylonjs/Cameras/Stereoscopic/index";
  50997. export * from "babylonjs/Cameras/universalCamera";
  50998. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  50999. export * from "babylonjs/Cameras/VR/index";
  51000. export * from "babylonjs/Cameras/RigModes/index";
  51001. }
  51002. declare module "babylonjs/Collisions/index" {
  51003. export * from "babylonjs/Collisions/collider";
  51004. export * from "babylonjs/Collisions/collisionCoordinator";
  51005. export * from "babylonjs/Collisions/pickingInfo";
  51006. export * from "babylonjs/Collisions/intersectionInfo";
  51007. export * from "babylonjs/Collisions/meshCollisionData";
  51008. }
  51009. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  51010. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  51011. import { Vector3 } from "babylonjs/Maths/math.vector";
  51012. import { Ray } from "babylonjs/Culling/ray";
  51013. import { Plane } from "babylonjs/Maths/math.plane";
  51014. /**
  51015. * Contains an array of blocks representing the octree
  51016. */
  51017. export interface IOctreeContainer<T> {
  51018. /**
  51019. * Blocks within the octree
  51020. */
  51021. blocks: Array<OctreeBlock<T>>;
  51022. }
  51023. /**
  51024. * Class used to store a cell in an octree
  51025. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51026. */
  51027. export class OctreeBlock<T> {
  51028. /**
  51029. * Gets the content of the current block
  51030. */
  51031. entries: T[];
  51032. /**
  51033. * Gets the list of block children
  51034. */
  51035. blocks: Array<OctreeBlock<T>>;
  51036. private _depth;
  51037. private _maxDepth;
  51038. private _capacity;
  51039. private _minPoint;
  51040. private _maxPoint;
  51041. private _boundingVectors;
  51042. private _creationFunc;
  51043. /**
  51044. * Creates a new block
  51045. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  51046. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  51047. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51048. * @param depth defines the current depth of this block in the octree
  51049. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  51050. * @param creationFunc defines a callback to call when an element is added to the block
  51051. */
  51052. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  51053. /**
  51054. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51055. */
  51056. get capacity(): number;
  51057. /**
  51058. * Gets the minimum vector (in world space) of the block's bounding box
  51059. */
  51060. get minPoint(): Vector3;
  51061. /**
  51062. * Gets the maximum vector (in world space) of the block's bounding box
  51063. */
  51064. get maxPoint(): Vector3;
  51065. /**
  51066. * Add a new element to this block
  51067. * @param entry defines the element to add
  51068. */
  51069. addEntry(entry: T): void;
  51070. /**
  51071. * Remove an element from this block
  51072. * @param entry defines the element to remove
  51073. */
  51074. removeEntry(entry: T): void;
  51075. /**
  51076. * Add an array of elements to this block
  51077. * @param entries defines the array of elements to add
  51078. */
  51079. addEntries(entries: T[]): void;
  51080. /**
  51081. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  51082. * @param frustumPlanes defines the frustum planes to test
  51083. * @param selection defines the array to store current content if selection is positive
  51084. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51085. */
  51086. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51087. /**
  51088. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  51089. * @param sphereCenter defines the bounding sphere center
  51090. * @param sphereRadius defines the bounding sphere radius
  51091. * @param selection defines the array to store current content if selection is positive
  51092. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51093. */
  51094. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51095. /**
  51096. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  51097. * @param ray defines the ray to test with
  51098. * @param selection defines the array to store current content if selection is positive
  51099. */
  51100. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  51101. /**
  51102. * Subdivide the content into child blocks (this block will then be empty)
  51103. */
  51104. createInnerBlocks(): void;
  51105. /**
  51106. * @hidden
  51107. */
  51108. 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;
  51109. }
  51110. }
  51111. declare module "babylonjs/Culling/Octrees/octree" {
  51112. import { SmartArray } from "babylonjs/Misc/smartArray";
  51113. import { Vector3 } from "babylonjs/Maths/math.vector";
  51114. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51115. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51116. import { Ray } from "babylonjs/Culling/ray";
  51117. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  51118. import { Plane } from "babylonjs/Maths/math.plane";
  51119. /**
  51120. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  51121. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51122. */
  51123. export class Octree<T> {
  51124. /** 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.) */
  51125. maxDepth: number;
  51126. /**
  51127. * Blocks within the octree containing objects
  51128. */
  51129. blocks: Array<OctreeBlock<T>>;
  51130. /**
  51131. * Content stored in the octree
  51132. */
  51133. dynamicContent: T[];
  51134. private _maxBlockCapacity;
  51135. private _selectionContent;
  51136. private _creationFunc;
  51137. /**
  51138. * Creates a octree
  51139. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51140. * @param creationFunc function to be used to instatiate the octree
  51141. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  51142. * @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.)
  51143. */
  51144. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  51145. /** 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.) */
  51146. maxDepth?: number);
  51147. /**
  51148. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  51149. * @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);
  51150. * @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);
  51151. * @param entries meshes to be added to the octree blocks
  51152. */
  51153. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  51154. /**
  51155. * Adds a mesh to the octree
  51156. * @param entry Mesh to add to the octree
  51157. */
  51158. addMesh(entry: T): void;
  51159. /**
  51160. * Remove an element from the octree
  51161. * @param entry defines the element to remove
  51162. */
  51163. removeMesh(entry: T): void;
  51164. /**
  51165. * Selects an array of meshes within the frustum
  51166. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  51167. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  51168. * @returns array of meshes within the frustum
  51169. */
  51170. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  51171. /**
  51172. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  51173. * @param sphereCenter defines the bounding sphere center
  51174. * @param sphereRadius defines the bounding sphere radius
  51175. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51176. * @returns an array of objects that intersect the sphere
  51177. */
  51178. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  51179. /**
  51180. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  51181. * @param ray defines the ray to test with
  51182. * @returns array of intersected objects
  51183. */
  51184. intersectsRay(ray: Ray): SmartArray<T>;
  51185. /**
  51186. * Adds a mesh into the octree block if it intersects the block
  51187. */
  51188. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  51189. /**
  51190. * Adds a submesh into the octree block if it intersects the block
  51191. */
  51192. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  51193. }
  51194. }
  51195. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  51196. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  51197. import { Scene } from "babylonjs/scene";
  51198. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51200. import { Ray } from "babylonjs/Culling/ray";
  51201. import { Octree } from "babylonjs/Culling/Octrees/octree";
  51202. import { Collider } from "babylonjs/Collisions/collider";
  51203. module "babylonjs/scene" {
  51204. interface Scene {
  51205. /**
  51206. * @hidden
  51207. * Backing Filed
  51208. */
  51209. _selectionOctree: Octree<AbstractMesh>;
  51210. /**
  51211. * Gets the octree used to boost mesh selection (picking)
  51212. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51213. */
  51214. selectionOctree: Octree<AbstractMesh>;
  51215. /**
  51216. * Creates or updates the octree used to boost selection (picking)
  51217. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51218. * @param maxCapacity defines the maximum capacity per leaf
  51219. * @param maxDepth defines the maximum depth of the octree
  51220. * @returns an octree of AbstractMesh
  51221. */
  51222. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  51223. }
  51224. }
  51225. module "babylonjs/Meshes/abstractMesh" {
  51226. interface AbstractMesh {
  51227. /**
  51228. * @hidden
  51229. * Backing Field
  51230. */
  51231. _submeshesOctree: Octree<SubMesh>;
  51232. /**
  51233. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  51234. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  51235. * @param maxCapacity defines the maximum size of each block (64 by default)
  51236. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  51237. * @returns the new octree
  51238. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  51239. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51240. */
  51241. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  51242. }
  51243. }
  51244. /**
  51245. * Defines the octree scene component responsible to manage any octrees
  51246. * in a given scene.
  51247. */
  51248. export class OctreeSceneComponent {
  51249. /**
  51250. * The component name help to identify the component in the list of scene components.
  51251. */
  51252. readonly name: string;
  51253. /**
  51254. * The scene the component belongs to.
  51255. */
  51256. scene: Scene;
  51257. /**
  51258. * Indicates if the meshes have been checked to make sure they are isEnabled()
  51259. */
  51260. readonly checksIsEnabled: boolean;
  51261. /**
  51262. * Creates a new instance of the component for the given scene
  51263. * @param scene Defines the scene to register the component in
  51264. */
  51265. constructor(scene: Scene);
  51266. /**
  51267. * Registers the component in a given scene
  51268. */
  51269. register(): void;
  51270. /**
  51271. * Return the list of active meshes
  51272. * @returns the list of active meshes
  51273. */
  51274. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  51275. /**
  51276. * Return the list of active sub meshes
  51277. * @param mesh The mesh to get the candidates sub meshes from
  51278. * @returns the list of active sub meshes
  51279. */
  51280. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  51281. private _tempRay;
  51282. /**
  51283. * Return the list of sub meshes intersecting with a given local ray
  51284. * @param mesh defines the mesh to find the submesh for
  51285. * @param localRay defines the ray in local space
  51286. * @returns the list of intersecting sub meshes
  51287. */
  51288. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  51289. /**
  51290. * Return the list of sub meshes colliding with a collider
  51291. * @param mesh defines the mesh to find the submesh for
  51292. * @param collider defines the collider to evaluate the collision against
  51293. * @returns the list of colliding sub meshes
  51294. */
  51295. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  51296. /**
  51297. * Rebuilds the elements related to this component in case of
  51298. * context lost for instance.
  51299. */
  51300. rebuild(): void;
  51301. /**
  51302. * Disposes the component and the associated ressources.
  51303. */
  51304. dispose(): void;
  51305. }
  51306. }
  51307. declare module "babylonjs/Culling/Octrees/index" {
  51308. export * from "babylonjs/Culling/Octrees/octree";
  51309. export * from "babylonjs/Culling/Octrees/octreeBlock";
  51310. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  51311. }
  51312. declare module "babylonjs/Culling/index" {
  51313. export * from "babylonjs/Culling/boundingBox";
  51314. export * from "babylonjs/Culling/boundingInfo";
  51315. export * from "babylonjs/Culling/boundingSphere";
  51316. export * from "babylonjs/Culling/Octrees/index";
  51317. export * from "babylonjs/Culling/ray";
  51318. }
  51319. declare module "babylonjs/Gizmos/gizmo" {
  51320. import { Nullable } from "babylonjs/types";
  51321. import { IDisposable } from "babylonjs/scene";
  51322. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51323. import { Mesh } from "babylonjs/Meshes/mesh";
  51324. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51325. /**
  51326. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  51327. */
  51328. export class Gizmo implements IDisposable {
  51329. /** The utility layer the gizmo will be added to */
  51330. gizmoLayer: UtilityLayerRenderer;
  51331. /**
  51332. * The root mesh of the gizmo
  51333. */
  51334. _rootMesh: Mesh;
  51335. private _attachedMesh;
  51336. /**
  51337. * Ratio for the scale of the gizmo (Default: 1)
  51338. */
  51339. scaleRatio: number;
  51340. /**
  51341. * If a custom mesh has been set (Default: false)
  51342. */
  51343. protected _customMeshSet: boolean;
  51344. /**
  51345. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  51346. * * When set, interactions will be enabled
  51347. */
  51348. get attachedMesh(): Nullable<AbstractMesh>;
  51349. set attachedMesh(value: Nullable<AbstractMesh>);
  51350. /**
  51351. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  51352. * @param mesh The mesh to replace the default mesh of the gizmo
  51353. */
  51354. setCustomMesh(mesh: Mesh): void;
  51355. /**
  51356. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  51357. */
  51358. updateGizmoRotationToMatchAttachedMesh: boolean;
  51359. /**
  51360. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  51361. */
  51362. updateGizmoPositionToMatchAttachedMesh: boolean;
  51363. /**
  51364. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  51365. */
  51366. updateScale: boolean;
  51367. protected _interactionsEnabled: boolean;
  51368. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51369. private _beforeRenderObserver;
  51370. private _tempVector;
  51371. /**
  51372. * Creates a gizmo
  51373. * @param gizmoLayer The utility layer the gizmo will be added to
  51374. */
  51375. constructor(
  51376. /** The utility layer the gizmo will be added to */
  51377. gizmoLayer?: UtilityLayerRenderer);
  51378. /**
  51379. * Updates the gizmo to match the attached mesh's position/rotation
  51380. */
  51381. protected _update(): void;
  51382. /**
  51383. * Disposes of the gizmo
  51384. */
  51385. dispose(): void;
  51386. }
  51387. }
  51388. declare module "babylonjs/Gizmos/planeDragGizmo" {
  51389. import { Observable } from "babylonjs/Misc/observable";
  51390. import { Nullable } from "babylonjs/types";
  51391. import { Vector3 } from "babylonjs/Maths/math.vector";
  51392. import { Color3 } from "babylonjs/Maths/math.color";
  51393. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51394. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51395. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51396. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51397. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51398. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51399. import { Scene } from "babylonjs/scene";
  51400. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51401. /**
  51402. * Single plane drag gizmo
  51403. */
  51404. export class PlaneDragGizmo extends Gizmo {
  51405. /**
  51406. * Drag behavior responsible for the gizmos dragging interactions
  51407. */
  51408. dragBehavior: PointerDragBehavior;
  51409. private _pointerObserver;
  51410. /**
  51411. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51412. */
  51413. snapDistance: number;
  51414. /**
  51415. * Event that fires each time the gizmo snaps to a new location.
  51416. * * snapDistance is the the change in distance
  51417. */
  51418. onSnapObservable: Observable<{
  51419. snapDistance: number;
  51420. }>;
  51421. private _plane;
  51422. private _coloredMaterial;
  51423. private _hoverMaterial;
  51424. private _isEnabled;
  51425. private _parent;
  51426. /** @hidden */
  51427. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  51428. /** @hidden */
  51429. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  51430. /**
  51431. * Creates a PlaneDragGizmo
  51432. * @param gizmoLayer The utility layer the gizmo will be added to
  51433. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  51434. * @param color The color of the gizmo
  51435. */
  51436. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  51437. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51438. /**
  51439. * If the gizmo is enabled
  51440. */
  51441. set isEnabled(value: boolean);
  51442. get isEnabled(): boolean;
  51443. /**
  51444. * Disposes of the gizmo
  51445. */
  51446. dispose(): void;
  51447. }
  51448. }
  51449. declare module "babylonjs/Gizmos/positionGizmo" {
  51450. import { Observable } from "babylonjs/Misc/observable";
  51451. import { Nullable } from "babylonjs/types";
  51452. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51453. import { Mesh } from "babylonjs/Meshes/mesh";
  51454. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51455. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  51456. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  51457. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51458. /**
  51459. * Gizmo that enables dragging a mesh along 3 axis
  51460. */
  51461. export class PositionGizmo extends Gizmo {
  51462. /**
  51463. * Internal gizmo used for interactions on the x axis
  51464. */
  51465. xGizmo: AxisDragGizmo;
  51466. /**
  51467. * Internal gizmo used for interactions on the y axis
  51468. */
  51469. yGizmo: AxisDragGizmo;
  51470. /**
  51471. * Internal gizmo used for interactions on the z axis
  51472. */
  51473. zGizmo: AxisDragGizmo;
  51474. /**
  51475. * Internal gizmo used for interactions on the yz plane
  51476. */
  51477. xPlaneGizmo: PlaneDragGizmo;
  51478. /**
  51479. * Internal gizmo used for interactions on the xz plane
  51480. */
  51481. yPlaneGizmo: PlaneDragGizmo;
  51482. /**
  51483. * Internal gizmo used for interactions on the xy plane
  51484. */
  51485. zPlaneGizmo: PlaneDragGizmo;
  51486. /**
  51487. * private variables
  51488. */
  51489. private _meshAttached;
  51490. private _updateGizmoRotationToMatchAttachedMesh;
  51491. private _snapDistance;
  51492. private _scaleRatio;
  51493. /** Fires an event when any of it's sub gizmos are dragged */
  51494. onDragStartObservable: Observable<unknown>;
  51495. /** Fires an event when any of it's sub gizmos are released from dragging */
  51496. onDragEndObservable: Observable<unknown>;
  51497. /**
  51498. * If set to true, planar drag is enabled
  51499. */
  51500. private _planarGizmoEnabled;
  51501. get attachedMesh(): Nullable<AbstractMesh>;
  51502. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51503. /**
  51504. * Creates a PositionGizmo
  51505. * @param gizmoLayer The utility layer the gizmo will be added to
  51506. */
  51507. constructor(gizmoLayer?: UtilityLayerRenderer);
  51508. /**
  51509. * If the planar drag gizmo is enabled
  51510. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  51511. */
  51512. set planarGizmoEnabled(value: boolean);
  51513. get planarGizmoEnabled(): boolean;
  51514. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51515. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51516. /**
  51517. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51518. */
  51519. set snapDistance(value: number);
  51520. get snapDistance(): number;
  51521. /**
  51522. * Ratio for the scale of the gizmo (Default: 1)
  51523. */
  51524. set scaleRatio(value: number);
  51525. get scaleRatio(): number;
  51526. /**
  51527. * Disposes of the gizmo
  51528. */
  51529. dispose(): void;
  51530. /**
  51531. * CustomMeshes are not supported by this gizmo
  51532. * @param mesh The mesh to replace the default mesh of the gizmo
  51533. */
  51534. setCustomMesh(mesh: Mesh): void;
  51535. }
  51536. }
  51537. declare module "babylonjs/Gizmos/axisDragGizmo" {
  51538. import { Observable } from "babylonjs/Misc/observable";
  51539. import { Nullable } from "babylonjs/types";
  51540. import { Vector3 } from "babylonjs/Maths/math.vector";
  51541. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51543. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51544. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51545. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51546. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51547. import { Scene } from "babylonjs/scene";
  51548. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51549. import { Color3 } from "babylonjs/Maths/math.color";
  51550. /**
  51551. * Single axis drag gizmo
  51552. */
  51553. export class AxisDragGizmo extends Gizmo {
  51554. /**
  51555. * Drag behavior responsible for the gizmos dragging interactions
  51556. */
  51557. dragBehavior: PointerDragBehavior;
  51558. private _pointerObserver;
  51559. /**
  51560. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51561. */
  51562. snapDistance: number;
  51563. /**
  51564. * Event that fires each time the gizmo snaps to a new location.
  51565. * * snapDistance is the the change in distance
  51566. */
  51567. onSnapObservable: Observable<{
  51568. snapDistance: number;
  51569. }>;
  51570. private _isEnabled;
  51571. private _parent;
  51572. private _arrow;
  51573. private _coloredMaterial;
  51574. private _hoverMaterial;
  51575. /** @hidden */
  51576. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  51577. /** @hidden */
  51578. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  51579. /**
  51580. * Creates an AxisDragGizmo
  51581. * @param gizmoLayer The utility layer the gizmo will be added to
  51582. * @param dragAxis The axis which the gizmo will be able to drag on
  51583. * @param color The color of the gizmo
  51584. */
  51585. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  51586. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51587. /**
  51588. * If the gizmo is enabled
  51589. */
  51590. set isEnabled(value: boolean);
  51591. get isEnabled(): boolean;
  51592. /**
  51593. * Disposes of the gizmo
  51594. */
  51595. dispose(): void;
  51596. }
  51597. }
  51598. declare module "babylonjs/Debug/axesViewer" {
  51599. import { Vector3 } from "babylonjs/Maths/math.vector";
  51600. import { Nullable } from "babylonjs/types";
  51601. import { Scene } from "babylonjs/scene";
  51602. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51603. /**
  51604. * The Axes viewer will show 3 axes in a specific point in space
  51605. */
  51606. export class AxesViewer {
  51607. private _xAxis;
  51608. private _yAxis;
  51609. private _zAxis;
  51610. private _scaleLinesFactor;
  51611. private _instanced;
  51612. /**
  51613. * Gets the hosting scene
  51614. */
  51615. scene: Scene;
  51616. /**
  51617. * Gets or sets a number used to scale line length
  51618. */
  51619. scaleLines: number;
  51620. /** Gets the node hierarchy used to render x-axis */
  51621. get xAxis(): TransformNode;
  51622. /** Gets the node hierarchy used to render y-axis */
  51623. get yAxis(): TransformNode;
  51624. /** Gets the node hierarchy used to render z-axis */
  51625. get zAxis(): TransformNode;
  51626. /**
  51627. * Creates a new AxesViewer
  51628. * @param scene defines the hosting scene
  51629. * @param scaleLines defines a number used to scale line length (1 by default)
  51630. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  51631. * @param xAxis defines the node hierarchy used to render the x-axis
  51632. * @param yAxis defines the node hierarchy used to render the y-axis
  51633. * @param zAxis defines the node hierarchy used to render the z-axis
  51634. */
  51635. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  51636. /**
  51637. * Force the viewer to update
  51638. * @param position defines the position of the viewer
  51639. * @param xaxis defines the x axis of the viewer
  51640. * @param yaxis defines the y axis of the viewer
  51641. * @param zaxis defines the z axis of the viewer
  51642. */
  51643. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  51644. /**
  51645. * Creates an instance of this axes viewer.
  51646. * @returns a new axes viewer with instanced meshes
  51647. */
  51648. createInstance(): AxesViewer;
  51649. /** Releases resources */
  51650. dispose(): void;
  51651. private static _SetRenderingGroupId;
  51652. }
  51653. }
  51654. declare module "babylonjs/Debug/boneAxesViewer" {
  51655. import { Nullable } from "babylonjs/types";
  51656. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  51657. import { Vector3 } from "babylonjs/Maths/math.vector";
  51658. import { Mesh } from "babylonjs/Meshes/mesh";
  51659. import { Bone } from "babylonjs/Bones/bone";
  51660. import { Scene } from "babylonjs/scene";
  51661. /**
  51662. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  51663. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  51664. */
  51665. export class BoneAxesViewer extends AxesViewer {
  51666. /**
  51667. * Gets or sets the target mesh where to display the axes viewer
  51668. */
  51669. mesh: Nullable<Mesh>;
  51670. /**
  51671. * Gets or sets the target bone where to display the axes viewer
  51672. */
  51673. bone: Nullable<Bone>;
  51674. /** Gets current position */
  51675. pos: Vector3;
  51676. /** Gets direction of X axis */
  51677. xaxis: Vector3;
  51678. /** Gets direction of Y axis */
  51679. yaxis: Vector3;
  51680. /** Gets direction of Z axis */
  51681. zaxis: Vector3;
  51682. /**
  51683. * Creates a new BoneAxesViewer
  51684. * @param scene defines the hosting scene
  51685. * @param bone defines the target bone
  51686. * @param mesh defines the target mesh
  51687. * @param scaleLines defines a scaling factor for line length (1 by default)
  51688. */
  51689. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  51690. /**
  51691. * Force the viewer to update
  51692. */
  51693. update(): void;
  51694. /** Releases resources */
  51695. dispose(): void;
  51696. }
  51697. }
  51698. declare module "babylonjs/Debug/debugLayer" {
  51699. import { Scene } from "babylonjs/scene";
  51700. /**
  51701. * Interface used to define scene explorer extensibility option
  51702. */
  51703. export interface IExplorerExtensibilityOption {
  51704. /**
  51705. * Define the option label
  51706. */
  51707. label: string;
  51708. /**
  51709. * Defines the action to execute on click
  51710. */
  51711. action: (entity: any) => void;
  51712. }
  51713. /**
  51714. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  51715. */
  51716. export interface IExplorerExtensibilityGroup {
  51717. /**
  51718. * Defines a predicate to test if a given type mut be extended
  51719. */
  51720. predicate: (entity: any) => boolean;
  51721. /**
  51722. * Gets the list of options added to a type
  51723. */
  51724. entries: IExplorerExtensibilityOption[];
  51725. }
  51726. /**
  51727. * Interface used to define the options to use to create the Inspector
  51728. */
  51729. export interface IInspectorOptions {
  51730. /**
  51731. * Display in overlay mode (default: false)
  51732. */
  51733. overlay?: boolean;
  51734. /**
  51735. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  51736. */
  51737. globalRoot?: HTMLElement;
  51738. /**
  51739. * Display the Scene explorer
  51740. */
  51741. showExplorer?: boolean;
  51742. /**
  51743. * Display the property inspector
  51744. */
  51745. showInspector?: boolean;
  51746. /**
  51747. * Display in embed mode (both panes on the right)
  51748. */
  51749. embedMode?: boolean;
  51750. /**
  51751. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  51752. */
  51753. handleResize?: boolean;
  51754. /**
  51755. * Allow the panes to popup (default: true)
  51756. */
  51757. enablePopup?: boolean;
  51758. /**
  51759. * Allow the panes to be closed by users (default: true)
  51760. */
  51761. enableClose?: boolean;
  51762. /**
  51763. * Optional list of extensibility entries
  51764. */
  51765. explorerExtensibility?: IExplorerExtensibilityGroup[];
  51766. /**
  51767. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  51768. */
  51769. inspectorURL?: string;
  51770. /**
  51771. * Optional initial tab (default to DebugLayerTab.Properties)
  51772. */
  51773. initialTab?: DebugLayerTab;
  51774. }
  51775. module "babylonjs/scene" {
  51776. interface Scene {
  51777. /**
  51778. * @hidden
  51779. * Backing field
  51780. */
  51781. _debugLayer: DebugLayer;
  51782. /**
  51783. * Gets the debug layer (aka Inspector) associated with the scene
  51784. * @see https://doc.babylonjs.com/features/playground_debuglayer
  51785. */
  51786. debugLayer: DebugLayer;
  51787. }
  51788. }
  51789. /**
  51790. * Enum of inspector action tab
  51791. */
  51792. export enum DebugLayerTab {
  51793. /**
  51794. * Properties tag (default)
  51795. */
  51796. Properties = 0,
  51797. /**
  51798. * Debug tab
  51799. */
  51800. Debug = 1,
  51801. /**
  51802. * Statistics tab
  51803. */
  51804. Statistics = 2,
  51805. /**
  51806. * Tools tab
  51807. */
  51808. Tools = 3,
  51809. /**
  51810. * Settings tab
  51811. */
  51812. Settings = 4
  51813. }
  51814. /**
  51815. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51816. * what is happening in your scene
  51817. * @see https://doc.babylonjs.com/features/playground_debuglayer
  51818. */
  51819. export class DebugLayer {
  51820. /**
  51821. * Define the url to get the inspector script from.
  51822. * By default it uses the babylonjs CDN.
  51823. * @ignoreNaming
  51824. */
  51825. static InspectorURL: string;
  51826. private _scene;
  51827. private BJSINSPECTOR;
  51828. private _onPropertyChangedObservable?;
  51829. /**
  51830. * Observable triggered when a property is changed through the inspector.
  51831. */
  51832. get onPropertyChangedObservable(): any;
  51833. /**
  51834. * Instantiates a new debug layer.
  51835. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51836. * what is happening in your scene
  51837. * @see https://doc.babylonjs.com/features/playground_debuglayer
  51838. * @param scene Defines the scene to inspect
  51839. */
  51840. constructor(scene: Scene);
  51841. /** Creates the inspector window. */
  51842. private _createInspector;
  51843. /**
  51844. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  51845. * @param entity defines the entity to select
  51846. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  51847. */
  51848. select(entity: any, lineContainerTitles?: string | string[]): void;
  51849. /** Get the inspector from bundle or global */
  51850. private _getGlobalInspector;
  51851. /**
  51852. * Get if the inspector is visible or not.
  51853. * @returns true if visible otherwise, false
  51854. */
  51855. isVisible(): boolean;
  51856. /**
  51857. * Hide the inspector and close its window.
  51858. */
  51859. hide(): void;
  51860. /**
  51861. * Update the scene in the inspector
  51862. */
  51863. setAsActiveScene(): void;
  51864. /**
  51865. * Launch the debugLayer.
  51866. * @param config Define the configuration of the inspector
  51867. * @return a promise fulfilled when the debug layer is visible
  51868. */
  51869. show(config?: IInspectorOptions): Promise<DebugLayer>;
  51870. }
  51871. }
  51872. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  51873. import { Nullable } from "babylonjs/types";
  51874. import { Scene } from "babylonjs/scene";
  51875. import { Vector4 } from "babylonjs/Maths/math.vector";
  51876. import { Color4 } from "babylonjs/Maths/math.color";
  51877. import { Mesh } from "babylonjs/Meshes/mesh";
  51878. /**
  51879. * Class containing static functions to help procedurally build meshes
  51880. */
  51881. export class BoxBuilder {
  51882. /**
  51883. * Creates a box mesh
  51884. * * The parameter `size` sets the size (float) of each box side (default 1)
  51885. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  51886. * * 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)
  51887. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51888. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51889. * * 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
  51890. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51891. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51892. * @param name defines the name of the mesh
  51893. * @param options defines the options used to create the mesh
  51894. * @param scene defines the hosting scene
  51895. * @returns the box mesh
  51896. */
  51897. static CreateBox(name: string, options: {
  51898. size?: number;
  51899. width?: number;
  51900. height?: number;
  51901. depth?: number;
  51902. faceUV?: Vector4[];
  51903. faceColors?: Color4[];
  51904. sideOrientation?: number;
  51905. frontUVs?: Vector4;
  51906. backUVs?: Vector4;
  51907. wrap?: boolean;
  51908. topBaseAt?: number;
  51909. bottomBaseAt?: number;
  51910. updatable?: boolean;
  51911. }, scene?: Nullable<Scene>): Mesh;
  51912. }
  51913. }
  51914. declare module "babylonjs/Debug/physicsViewer" {
  51915. import { Nullable } from "babylonjs/types";
  51916. import { Scene } from "babylonjs/scene";
  51917. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51918. import { Mesh } from "babylonjs/Meshes/mesh";
  51919. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51920. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51921. /**
  51922. * Used to show the physics impostor around the specific mesh
  51923. */
  51924. export class PhysicsViewer {
  51925. /** @hidden */
  51926. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  51927. /** @hidden */
  51928. protected _meshes: Array<Nullable<AbstractMesh>>;
  51929. /** @hidden */
  51930. protected _scene: Nullable<Scene>;
  51931. /** @hidden */
  51932. protected _numMeshes: number;
  51933. /** @hidden */
  51934. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  51935. private _renderFunction;
  51936. private _utilityLayer;
  51937. private _debugBoxMesh;
  51938. private _debugSphereMesh;
  51939. private _debugCylinderMesh;
  51940. private _debugMaterial;
  51941. private _debugMeshMeshes;
  51942. /**
  51943. * Creates a new PhysicsViewer
  51944. * @param scene defines the hosting scene
  51945. */
  51946. constructor(scene: Scene);
  51947. /** @hidden */
  51948. protected _updateDebugMeshes(): void;
  51949. /**
  51950. * Renders a specified physic impostor
  51951. * @param impostor defines the impostor to render
  51952. * @param targetMesh defines the mesh represented by the impostor
  51953. * @returns the new debug mesh used to render the impostor
  51954. */
  51955. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  51956. /**
  51957. * Hides a specified physic impostor
  51958. * @param impostor defines the impostor to hide
  51959. */
  51960. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  51961. private _getDebugMaterial;
  51962. private _getDebugBoxMesh;
  51963. private _getDebugSphereMesh;
  51964. private _getDebugCylinderMesh;
  51965. private _getDebugMeshMesh;
  51966. private _getDebugMesh;
  51967. /** Releases all resources */
  51968. dispose(): void;
  51969. }
  51970. }
  51971. declare module "babylonjs/Debug/rayHelper" {
  51972. import { Nullable } from "babylonjs/types";
  51973. import { Ray } from "babylonjs/Culling/ray";
  51974. import { Vector3 } from "babylonjs/Maths/math.vector";
  51975. import { Color3 } from "babylonjs/Maths/math.color";
  51976. import { Scene } from "babylonjs/scene";
  51977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51978. import "babylonjs/Meshes/Builders/linesBuilder";
  51979. /**
  51980. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51981. * in order to better appreciate the issue one might have.
  51982. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  51983. */
  51984. export class RayHelper {
  51985. /**
  51986. * Defines the ray we are currently tryin to visualize.
  51987. */
  51988. ray: Nullable<Ray>;
  51989. private _renderPoints;
  51990. private _renderLine;
  51991. private _renderFunction;
  51992. private _scene;
  51993. private _updateToMeshFunction;
  51994. private _attachedToMesh;
  51995. private _meshSpaceDirection;
  51996. private _meshSpaceOrigin;
  51997. /**
  51998. * Helper function to create a colored helper in a scene in one line.
  51999. * @param ray Defines the ray we are currently tryin to visualize
  52000. * @param scene Defines the scene the ray is used in
  52001. * @param color Defines the color we want to see the ray in
  52002. * @returns The newly created ray helper.
  52003. */
  52004. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  52005. /**
  52006. * Instantiate a new ray helper.
  52007. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52008. * in order to better appreciate the issue one might have.
  52009. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52010. * @param ray Defines the ray we are currently tryin to visualize
  52011. */
  52012. constructor(ray: Ray);
  52013. /**
  52014. * Shows the ray we are willing to debug.
  52015. * @param scene Defines the scene the ray needs to be rendered in
  52016. * @param color Defines the color the ray needs to be rendered in
  52017. */
  52018. show(scene: Scene, color?: Color3): void;
  52019. /**
  52020. * Hides the ray we are debugging.
  52021. */
  52022. hide(): void;
  52023. private _render;
  52024. /**
  52025. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  52026. * @param mesh Defines the mesh we want the helper attached to
  52027. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  52028. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  52029. * @param length Defines the length of the ray
  52030. */
  52031. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  52032. /**
  52033. * Detach the ray helper from the mesh it has previously been attached to.
  52034. */
  52035. detachFromMesh(): void;
  52036. private _updateToMesh;
  52037. /**
  52038. * Dispose the helper and release its associated resources.
  52039. */
  52040. dispose(): void;
  52041. }
  52042. }
  52043. declare module "babylonjs/Debug/skeletonViewer" {
  52044. import { Color3 } from "babylonjs/Maths/math.color";
  52045. import { Scene } from "babylonjs/scene";
  52046. import { Nullable } from "babylonjs/types";
  52047. import { Skeleton } from "babylonjs/Bones/skeleton";
  52048. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52049. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52050. /**
  52051. * Class used to render a debug view of a given skeleton
  52052. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  52053. */
  52054. export class SkeletonViewer {
  52055. /** defines the skeleton to render */
  52056. skeleton: Skeleton;
  52057. /** defines the mesh attached to the skeleton */
  52058. mesh: AbstractMesh;
  52059. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  52060. autoUpdateBonesMatrices: boolean;
  52061. /** defines the rendering group id to use with the viewer */
  52062. renderingGroupId: number;
  52063. /** Gets or sets the color used to render the skeleton */
  52064. color: Color3;
  52065. private _scene;
  52066. private _debugLines;
  52067. private _debugMesh;
  52068. private _isEnabled;
  52069. private _renderFunction;
  52070. private _utilityLayer;
  52071. /**
  52072. * Returns the mesh used to render the bones
  52073. */
  52074. get debugMesh(): Nullable<LinesMesh>;
  52075. /**
  52076. * Creates a new SkeletonViewer
  52077. * @param skeleton defines the skeleton to render
  52078. * @param mesh defines the mesh attached to the skeleton
  52079. * @param scene defines the hosting scene
  52080. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  52081. * @param renderingGroupId defines the rendering group id to use with the viewer
  52082. */
  52083. constructor(
  52084. /** defines the skeleton to render */
  52085. skeleton: Skeleton,
  52086. /** defines the mesh attached to the skeleton */
  52087. mesh: AbstractMesh, scene: Scene,
  52088. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  52089. autoUpdateBonesMatrices?: boolean,
  52090. /** defines the rendering group id to use with the viewer */
  52091. renderingGroupId?: number);
  52092. /** Gets or sets a boolean indicating if the viewer is enabled */
  52093. set isEnabled(value: boolean);
  52094. get isEnabled(): boolean;
  52095. private _getBonePosition;
  52096. private _getLinesForBonesWithLength;
  52097. private _getLinesForBonesNoLength;
  52098. /** Update the viewer to sync with current skeleton state */
  52099. update(): void;
  52100. /** Release associated resources */
  52101. dispose(): void;
  52102. }
  52103. }
  52104. declare module "babylonjs/Debug/index" {
  52105. export * from "babylonjs/Debug/axesViewer";
  52106. export * from "babylonjs/Debug/boneAxesViewer";
  52107. export * from "babylonjs/Debug/debugLayer";
  52108. export * from "babylonjs/Debug/physicsViewer";
  52109. export * from "babylonjs/Debug/rayHelper";
  52110. export * from "babylonjs/Debug/skeletonViewer";
  52111. }
  52112. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  52113. /**
  52114. * Enum for Device Types
  52115. */
  52116. export enum DeviceType {
  52117. /** Generic */
  52118. Generic = 0,
  52119. /** Keyboard */
  52120. Keyboard = 1,
  52121. /** Mouse */
  52122. Mouse = 2,
  52123. /** Touch Pointers */
  52124. Touch = 3,
  52125. /** PS4 Dual Shock */
  52126. DualShock = 4,
  52127. /** Xbox */
  52128. Xbox = 5,
  52129. /** Switch Controller */
  52130. Switch = 6
  52131. }
  52132. /**
  52133. * Enum for All Pointers (Touch/Mouse)
  52134. */
  52135. export enum PointerInput {
  52136. /** Horizontal Axis */
  52137. Horizontal = 0,
  52138. /** Vertical Axis */
  52139. Vertical = 1,
  52140. /** Left Click or Touch */
  52141. LeftClick = 2,
  52142. /** Middle Click */
  52143. MiddleClick = 3,
  52144. /** Right Click */
  52145. RightClick = 4,
  52146. /** Browser Back */
  52147. BrowserBack = 5,
  52148. /** Browser Forward */
  52149. BrowserForward = 6
  52150. }
  52151. /**
  52152. * Enum for Dual Shock Gamepad
  52153. */
  52154. export enum DualShockInput {
  52155. /** Cross */
  52156. Cross = 0,
  52157. /** Circle */
  52158. Circle = 1,
  52159. /** Square */
  52160. Square = 2,
  52161. /** Triangle */
  52162. Triangle = 3,
  52163. /** L1 */
  52164. L1 = 4,
  52165. /** R1 */
  52166. R1 = 5,
  52167. /** L2 */
  52168. L2 = 6,
  52169. /** R2 */
  52170. R2 = 7,
  52171. /** Share */
  52172. Share = 8,
  52173. /** Options */
  52174. Options = 9,
  52175. /** L3 */
  52176. L3 = 10,
  52177. /** R3 */
  52178. R3 = 11,
  52179. /** DPadUp */
  52180. DPadUp = 12,
  52181. /** DPadDown */
  52182. DPadDown = 13,
  52183. /** DPadLeft */
  52184. DPadLeft = 14,
  52185. /** DRight */
  52186. DPadRight = 15,
  52187. /** Home */
  52188. Home = 16,
  52189. /** TouchPad */
  52190. TouchPad = 17,
  52191. /** LStickXAxis */
  52192. LStickXAxis = 18,
  52193. /** LStickYAxis */
  52194. LStickYAxis = 19,
  52195. /** RStickXAxis */
  52196. RStickXAxis = 20,
  52197. /** RStickYAxis */
  52198. RStickYAxis = 21
  52199. }
  52200. /**
  52201. * Enum for Xbox Gamepad
  52202. */
  52203. export enum XboxInput {
  52204. /** A */
  52205. A = 0,
  52206. /** B */
  52207. B = 1,
  52208. /** X */
  52209. X = 2,
  52210. /** Y */
  52211. Y = 3,
  52212. /** LB */
  52213. LB = 4,
  52214. /** RB */
  52215. RB = 5,
  52216. /** LT */
  52217. LT = 6,
  52218. /** RT */
  52219. RT = 7,
  52220. /** Back */
  52221. Back = 8,
  52222. /** Start */
  52223. Start = 9,
  52224. /** LS */
  52225. LS = 10,
  52226. /** RS */
  52227. RS = 11,
  52228. /** DPadUp */
  52229. DPadUp = 12,
  52230. /** DPadDown */
  52231. DPadDown = 13,
  52232. /** DPadLeft */
  52233. DPadLeft = 14,
  52234. /** DRight */
  52235. DPadRight = 15,
  52236. /** Home */
  52237. Home = 16,
  52238. /** LStickXAxis */
  52239. LStickXAxis = 17,
  52240. /** LStickYAxis */
  52241. LStickYAxis = 18,
  52242. /** RStickXAxis */
  52243. RStickXAxis = 19,
  52244. /** RStickYAxis */
  52245. RStickYAxis = 20
  52246. }
  52247. /**
  52248. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  52249. */
  52250. export enum SwitchInput {
  52251. /** B */
  52252. B = 0,
  52253. /** A */
  52254. A = 1,
  52255. /** Y */
  52256. Y = 2,
  52257. /** X */
  52258. X = 3,
  52259. /** L */
  52260. L = 4,
  52261. /** R */
  52262. R = 5,
  52263. /** ZL */
  52264. ZL = 6,
  52265. /** ZR */
  52266. ZR = 7,
  52267. /** Minus */
  52268. Minus = 8,
  52269. /** Plus */
  52270. Plus = 9,
  52271. /** LS */
  52272. LS = 10,
  52273. /** RS */
  52274. RS = 11,
  52275. /** DPadUp */
  52276. DPadUp = 12,
  52277. /** DPadDown */
  52278. DPadDown = 13,
  52279. /** DPadLeft */
  52280. DPadLeft = 14,
  52281. /** DRight */
  52282. DPadRight = 15,
  52283. /** Home */
  52284. Home = 16,
  52285. /** Capture */
  52286. Capture = 17,
  52287. /** LStickXAxis */
  52288. LStickXAxis = 18,
  52289. /** LStickYAxis */
  52290. LStickYAxis = 19,
  52291. /** RStickXAxis */
  52292. RStickXAxis = 20,
  52293. /** RStickYAxis */
  52294. RStickYAxis = 21
  52295. }
  52296. }
  52297. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  52298. import { Engine } from "babylonjs/Engines/engine";
  52299. import { IDisposable } from "babylonjs/scene";
  52300. import { Nullable } from "babylonjs/types";
  52301. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52302. /**
  52303. * This class will take all inputs from Keyboard, Pointer, and
  52304. * any Gamepads and provide a polling system that all devices
  52305. * will use. This class assumes that there will only be one
  52306. * pointer device and one keyboard.
  52307. */
  52308. export class DeviceInputSystem implements IDisposable {
  52309. /**
  52310. * Callback to be triggered when a device is connected
  52311. */
  52312. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  52313. /**
  52314. * Callback to be triggered when a device is disconnected
  52315. */
  52316. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  52317. /**
  52318. * Callback to be triggered when event driven input is updated
  52319. */
  52320. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  52321. private _inputs;
  52322. private _gamepads;
  52323. private _keyboardActive;
  52324. private _pointerActive;
  52325. private _elementToAttachTo;
  52326. private _keyboardDownEvent;
  52327. private _keyboardUpEvent;
  52328. private _pointerMoveEvent;
  52329. private _pointerDownEvent;
  52330. private _pointerUpEvent;
  52331. private _gamepadConnectedEvent;
  52332. private _gamepadDisconnectedEvent;
  52333. private static _MAX_KEYCODES;
  52334. private static _MAX_POINTER_INPUTS;
  52335. private constructor();
  52336. /**
  52337. * Creates a new DeviceInputSystem instance
  52338. * @param engine Engine to pull input element from
  52339. * @returns The new instance
  52340. */
  52341. static Create(engine: Engine): DeviceInputSystem;
  52342. /**
  52343. * Checks for current device input value, given an id and input index
  52344. * @param deviceName Id of connected device
  52345. * @param inputIndex Index of device input
  52346. * @returns Current value of input
  52347. */
  52348. /**
  52349. * Checks for current device input value, given an id and input index
  52350. * @param deviceType Enum specifiying device type
  52351. * @param deviceSlot "Slot" or index that device is referenced in
  52352. * @param inputIndex Id of input to be checked
  52353. * @returns Current value of input
  52354. */
  52355. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  52356. /**
  52357. * Dispose of all the eventlisteners
  52358. */
  52359. dispose(): void;
  52360. /**
  52361. * Add device and inputs to device array
  52362. * @param deviceType Enum specifiying device type
  52363. * @param deviceSlot "Slot" or index that device is referenced in
  52364. * @param numberOfInputs Number of input entries to create for given device
  52365. */
  52366. private _registerDevice;
  52367. /**
  52368. * Given a specific device name, remove that device from the device map
  52369. * @param deviceType Enum specifiying device type
  52370. * @param deviceSlot "Slot" or index that device is referenced in
  52371. */
  52372. private _unregisterDevice;
  52373. /**
  52374. * Handle all actions that come from keyboard interaction
  52375. */
  52376. private _handleKeyActions;
  52377. /**
  52378. * Handle all actions that come from pointer interaction
  52379. */
  52380. private _handlePointerActions;
  52381. /**
  52382. * Handle all actions that come from gamepad interaction
  52383. */
  52384. private _handleGamepadActions;
  52385. /**
  52386. * Update all non-event based devices with each frame
  52387. * @param deviceType Enum specifiying device type
  52388. * @param deviceSlot "Slot" or index that device is referenced in
  52389. * @param inputIndex Id of input to be checked
  52390. */
  52391. private _updateDevice;
  52392. /**
  52393. * Gets DeviceType from the device name
  52394. * @param deviceName Name of Device from DeviceInputSystem
  52395. * @returns DeviceType enum value
  52396. */
  52397. private _getGamepadDeviceType;
  52398. }
  52399. }
  52400. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  52401. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52402. /**
  52403. * Type to handle enforcement of inputs
  52404. */
  52405. export type DeviceInput<T extends DeviceType> = T extends DeviceType.Keyboard | DeviceType.Generic ? number : T extends DeviceType.Mouse | DeviceType.Touch ? PointerInput : T extends DeviceType.DualShock ? DualShockInput : T extends DeviceType.Xbox ? XboxInput : T extends DeviceType.Switch ? SwitchInput : never;
  52406. }
  52407. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  52408. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  52409. import { Engine } from "babylonjs/Engines/engine";
  52410. import { IDisposable } from "babylonjs/scene";
  52411. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52412. import { Nullable } from "babylonjs/types";
  52413. import { Observable } from "babylonjs/Misc/observable";
  52414. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  52415. /**
  52416. * Class that handles all input for a specific device
  52417. */
  52418. export class DeviceSource<T extends DeviceType> {
  52419. /** Type of device */
  52420. readonly deviceType: DeviceType;
  52421. /** "Slot" or index that device is referenced in */
  52422. readonly deviceSlot: number;
  52423. /**
  52424. * Observable to handle device input changes per device
  52425. */
  52426. readonly onInputChangedObservable: Observable<{
  52427. inputIndex: DeviceInput<T>;
  52428. previousState: Nullable<number>;
  52429. currentState: Nullable<number>;
  52430. }>;
  52431. private readonly _deviceInputSystem;
  52432. /**
  52433. * Default Constructor
  52434. * @param deviceInputSystem Reference to DeviceInputSystem
  52435. * @param deviceType Type of device
  52436. * @param deviceSlot "Slot" or index that device is referenced in
  52437. */
  52438. constructor(deviceInputSystem: DeviceInputSystem,
  52439. /** Type of device */
  52440. deviceType: DeviceType,
  52441. /** "Slot" or index that device is referenced in */
  52442. deviceSlot?: number);
  52443. /**
  52444. * Get input for specific input
  52445. * @param inputIndex index of specific input on device
  52446. * @returns Input value from DeviceInputSystem
  52447. */
  52448. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  52449. }
  52450. /**
  52451. * Class to keep track of devices
  52452. */
  52453. export class DeviceSourceManager implements IDisposable {
  52454. /**
  52455. * Observable to be triggered when before a device is connected
  52456. */
  52457. readonly onBeforeDeviceConnectedObservable: Observable<{
  52458. deviceType: DeviceType;
  52459. deviceSlot: number;
  52460. }>;
  52461. /**
  52462. * Observable to be triggered when before a device is disconnected
  52463. */
  52464. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  52465. deviceType: DeviceType;
  52466. deviceSlot: number;
  52467. }>;
  52468. /**
  52469. * Observable to be triggered when after a device is connected
  52470. */
  52471. readonly onAfterDeviceConnectedObservable: Observable<{
  52472. deviceType: DeviceType;
  52473. deviceSlot: number;
  52474. }>;
  52475. /**
  52476. * Observable to be triggered when after a device is disconnected
  52477. */
  52478. readonly onAfterDeviceDisconnectedObservable: Observable<{
  52479. deviceType: DeviceType;
  52480. deviceSlot: number;
  52481. }>;
  52482. private readonly _devices;
  52483. private readonly _firstDevice;
  52484. private readonly _deviceInputSystem;
  52485. /**
  52486. * Default Constructor
  52487. * @param engine engine to pull input element from
  52488. */
  52489. constructor(engine: Engine);
  52490. /**
  52491. * Gets a DeviceSource, given a type and slot
  52492. * @param deviceType Enum specifying device type
  52493. * @param deviceSlot "Slot" or index that device is referenced in
  52494. * @returns DeviceSource object
  52495. */
  52496. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  52497. /**
  52498. * Gets an array of DeviceSource objects for a given device type
  52499. * @param deviceType Enum specifying device type
  52500. * @returns Array of DeviceSource objects
  52501. */
  52502. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  52503. /**
  52504. * Dispose of DeviceInputSystem and other parts
  52505. */
  52506. dispose(): void;
  52507. /**
  52508. * Function to add device name to device list
  52509. * @param deviceType Enum specifying device type
  52510. * @param deviceSlot "Slot" or index that device is referenced in
  52511. */
  52512. private _addDevice;
  52513. /**
  52514. * Function to remove device name to device list
  52515. * @param deviceType Enum specifying device type
  52516. * @param deviceSlot "Slot" or index that device is referenced in
  52517. */
  52518. private _removeDevice;
  52519. /**
  52520. * Updates array storing first connected device of each type
  52521. * @param type Type of Device
  52522. */
  52523. private _updateFirstDevices;
  52524. }
  52525. }
  52526. declare module "babylonjs/DeviceInput/index" {
  52527. export * from "babylonjs/DeviceInput/deviceInputSystem";
  52528. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52529. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  52530. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  52531. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  52532. }
  52533. declare module "babylonjs/Engines/nullEngine" {
  52534. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  52535. import { Engine } from "babylonjs/Engines/engine";
  52536. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  52537. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  52538. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52539. import { Effect } from "babylonjs/Materials/effect";
  52540. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  52541. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  52542. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  52543. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  52544. /**
  52545. * Options to create the null engine
  52546. */
  52547. export class NullEngineOptions {
  52548. /**
  52549. * Render width (Default: 512)
  52550. */
  52551. renderWidth: number;
  52552. /**
  52553. * Render height (Default: 256)
  52554. */
  52555. renderHeight: number;
  52556. /**
  52557. * Texture size (Default: 512)
  52558. */
  52559. textureSize: number;
  52560. /**
  52561. * If delta time between frames should be constant
  52562. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52563. */
  52564. deterministicLockstep: boolean;
  52565. /**
  52566. * Maximum about of steps between frames (Default: 4)
  52567. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52568. */
  52569. lockstepMaxSteps: number;
  52570. }
  52571. /**
  52572. * The null engine class provides support for headless version of babylon.js.
  52573. * This can be used in server side scenario or for testing purposes
  52574. */
  52575. export class NullEngine extends Engine {
  52576. private _options;
  52577. /**
  52578. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  52579. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52580. * @returns true if engine is in deterministic lock step mode
  52581. */
  52582. isDeterministicLockStep(): boolean;
  52583. /**
  52584. * Gets the max steps when engine is running in deterministic lock step
  52585. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52586. * @returns the max steps
  52587. */
  52588. getLockstepMaxSteps(): number;
  52589. /**
  52590. * Gets the current hardware scaling level.
  52591. * By default the hardware scaling level is computed from the window device ratio.
  52592. * 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.
  52593. * @returns a number indicating the current hardware scaling level
  52594. */
  52595. getHardwareScalingLevel(): number;
  52596. constructor(options?: NullEngineOptions);
  52597. /**
  52598. * Creates a vertex buffer
  52599. * @param vertices the data for the vertex buffer
  52600. * @returns the new WebGL static buffer
  52601. */
  52602. createVertexBuffer(vertices: FloatArray): DataBuffer;
  52603. /**
  52604. * Creates a new index buffer
  52605. * @param indices defines the content of the index buffer
  52606. * @param updatable defines if the index buffer must be updatable
  52607. * @returns a new webGL buffer
  52608. */
  52609. createIndexBuffer(indices: IndicesArray): DataBuffer;
  52610. /**
  52611. * Clear the current render buffer or the current render target (if any is set up)
  52612. * @param color defines the color to use
  52613. * @param backBuffer defines if the back buffer must be cleared
  52614. * @param depth defines if the depth buffer must be cleared
  52615. * @param stencil defines if the stencil buffer must be cleared
  52616. */
  52617. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52618. /**
  52619. * Gets the current render width
  52620. * @param useScreen defines if screen size must be used (or the current render target if any)
  52621. * @returns a number defining the current render width
  52622. */
  52623. getRenderWidth(useScreen?: boolean): number;
  52624. /**
  52625. * Gets the current render height
  52626. * @param useScreen defines if screen size must be used (or the current render target if any)
  52627. * @returns a number defining the current render height
  52628. */
  52629. getRenderHeight(useScreen?: boolean): number;
  52630. /**
  52631. * Set the WebGL's viewport
  52632. * @param viewport defines the viewport element to be used
  52633. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  52634. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  52635. */
  52636. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  52637. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  52638. /**
  52639. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  52640. * @param pipelineContext defines the pipeline context to use
  52641. * @param uniformsNames defines the list of uniform names
  52642. * @returns an array of webGL uniform locations
  52643. */
  52644. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  52645. /**
  52646. * Gets the lsit of active attributes for a given webGL program
  52647. * @param pipelineContext defines the pipeline context to use
  52648. * @param attributesNames defines the list of attribute names to get
  52649. * @returns an array of indices indicating the offset of each attribute
  52650. */
  52651. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52652. /**
  52653. * Binds an effect to the webGL context
  52654. * @param effect defines the effect to bind
  52655. */
  52656. bindSamplers(effect: Effect): void;
  52657. /**
  52658. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  52659. * @param effect defines the effect to activate
  52660. */
  52661. enableEffect(effect: Effect): void;
  52662. /**
  52663. * Set various states to the webGL context
  52664. * @param culling defines backface culling state
  52665. * @param zOffset defines the value to apply to zOffset (0 by default)
  52666. * @param force defines if states must be applied even if cache is up to date
  52667. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  52668. */
  52669. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52670. /**
  52671. * Set the value of an uniform to an array of int32
  52672. * @param uniform defines the webGL uniform location where to store the value
  52673. * @param array defines the array of int32 to store
  52674. */
  52675. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52676. /**
  52677. * Set the value of an uniform to an array of int32 (stored as vec2)
  52678. * @param uniform defines the webGL uniform location where to store the value
  52679. * @param array defines the array of int32 to store
  52680. */
  52681. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52682. /**
  52683. * Set the value of an uniform to an array of int32 (stored as vec3)
  52684. * @param uniform defines the webGL uniform location where to store the value
  52685. * @param array defines the array of int32 to store
  52686. */
  52687. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52688. /**
  52689. * Set the value of an uniform to an array of int32 (stored as vec4)
  52690. * @param uniform defines the webGL uniform location where to store the value
  52691. * @param array defines the array of int32 to store
  52692. */
  52693. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52694. /**
  52695. * Set the value of an uniform to an array of float32
  52696. * @param uniform defines the webGL uniform location where to store the value
  52697. * @param array defines the array of float32 to store
  52698. */
  52699. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52700. /**
  52701. * Set the value of an uniform to an array of float32 (stored as vec2)
  52702. * @param uniform defines the webGL uniform location where to store the value
  52703. * @param array defines the array of float32 to store
  52704. */
  52705. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52706. /**
  52707. * Set the value of an uniform to an array of float32 (stored as vec3)
  52708. * @param uniform defines the webGL uniform location where to store the value
  52709. * @param array defines the array of float32 to store
  52710. */
  52711. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52712. /**
  52713. * Set the value of an uniform to an array of float32 (stored as vec4)
  52714. * @param uniform defines the webGL uniform location where to store the value
  52715. * @param array defines the array of float32 to store
  52716. */
  52717. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52718. /**
  52719. * Set the value of an uniform to an array of number
  52720. * @param uniform defines the webGL uniform location where to store the value
  52721. * @param array defines the array of number to store
  52722. */
  52723. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52724. /**
  52725. * Set the value of an uniform to an array of number (stored as vec2)
  52726. * @param uniform defines the webGL uniform location where to store the value
  52727. * @param array defines the array of number to store
  52728. */
  52729. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52730. /**
  52731. * Set the value of an uniform to an array of number (stored as vec3)
  52732. * @param uniform defines the webGL uniform location where to store the value
  52733. * @param array defines the array of number to store
  52734. */
  52735. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52736. /**
  52737. * Set the value of an uniform to an array of number (stored as vec4)
  52738. * @param uniform defines the webGL uniform location where to store the value
  52739. * @param array defines the array of number to store
  52740. */
  52741. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52742. /**
  52743. * Set the value of an uniform to an array of float32 (stored as matrices)
  52744. * @param uniform defines the webGL uniform location where to store the value
  52745. * @param matrices defines the array of float32 to store
  52746. */
  52747. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52748. /**
  52749. * Set the value of an uniform to a matrix (3x3)
  52750. * @param uniform defines the webGL uniform location where to store the value
  52751. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  52752. */
  52753. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52754. /**
  52755. * Set the value of an uniform to a matrix (2x2)
  52756. * @param uniform defines the webGL uniform location where to store the value
  52757. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  52758. */
  52759. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52760. /**
  52761. * Set the value of an uniform to a number (float)
  52762. * @param uniform defines the webGL uniform location where to store the value
  52763. * @param value defines the float number to store
  52764. */
  52765. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52766. /**
  52767. * Set the value of an uniform to a vec2
  52768. * @param uniform defines the webGL uniform location where to store the value
  52769. * @param x defines the 1st component of the value
  52770. * @param y defines the 2nd component of the value
  52771. */
  52772. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52773. /**
  52774. * Set the value of an uniform to a vec3
  52775. * @param uniform defines the webGL uniform location where to store the value
  52776. * @param x defines the 1st component of the value
  52777. * @param y defines the 2nd component of the value
  52778. * @param z defines the 3rd component of the value
  52779. */
  52780. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52781. /**
  52782. * Set the value of an uniform to a boolean
  52783. * @param uniform defines the webGL uniform location where to store the value
  52784. * @param bool defines the boolean to store
  52785. */
  52786. setBool(uniform: WebGLUniformLocation, bool: number): void;
  52787. /**
  52788. * Set the value of an uniform to a vec4
  52789. * @param uniform defines the webGL uniform location where to store the value
  52790. * @param x defines the 1st component of the value
  52791. * @param y defines the 2nd component of the value
  52792. * @param z defines the 3rd component of the value
  52793. * @param w defines the 4th component of the value
  52794. */
  52795. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52796. /**
  52797. * Sets the current alpha mode
  52798. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  52799. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52800. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52801. */
  52802. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52803. /**
  52804. * Bind webGl buffers directly to the webGL context
  52805. * @param vertexBuffers defines the vertex buffer to bind
  52806. * @param indexBuffer defines the index buffer to bind
  52807. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  52808. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  52809. * @param effect defines the effect associated with the vertex buffer
  52810. */
  52811. bindBuffers(vertexBuffers: {
  52812. [key: string]: VertexBuffer;
  52813. }, indexBuffer: DataBuffer, effect: Effect): void;
  52814. /**
  52815. * Force the entire cache to be cleared
  52816. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  52817. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  52818. */
  52819. wipeCaches(bruteForce?: boolean): void;
  52820. /**
  52821. * Send a draw order
  52822. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  52823. * @param indexStart defines the starting index
  52824. * @param indexCount defines the number of index to draw
  52825. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52826. */
  52827. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  52828. /**
  52829. * Draw a list of indexed primitives
  52830. * @param fillMode defines the primitive to use
  52831. * @param indexStart defines the starting index
  52832. * @param indexCount defines the number of index to draw
  52833. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52834. */
  52835. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52836. /**
  52837. * Draw a list of unindexed primitives
  52838. * @param fillMode defines the primitive to use
  52839. * @param verticesStart defines the index of first vertex to draw
  52840. * @param verticesCount defines the count of vertices to draw
  52841. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52842. */
  52843. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52844. /** @hidden */
  52845. _createTexture(): WebGLTexture;
  52846. /** @hidden */
  52847. _releaseTexture(texture: InternalTexture): void;
  52848. /**
  52849. * Usually called from Texture.ts.
  52850. * Passed information to create a WebGLTexture
  52851. * @param urlArg defines a value which contains one of the following:
  52852. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52853. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52854. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52855. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52856. * @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)
  52857. * @param scene needed for loading to the correct scene
  52858. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52859. * @param onLoad optional callback to be called upon successful completion
  52860. * @param onError optional callback to be called upon failure
  52861. * @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
  52862. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52863. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52864. * @param forcedExtension defines the extension to use to pick the right loader
  52865. * @param mimeType defines an optional mime type
  52866. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52867. */
  52868. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  52869. /**
  52870. * Creates a new render target texture
  52871. * @param size defines the size of the texture
  52872. * @param options defines the options used to create the texture
  52873. * @returns a new render target texture stored in an InternalTexture
  52874. */
  52875. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  52876. /**
  52877. * Update the sampling mode of a given texture
  52878. * @param samplingMode defines the required sampling mode
  52879. * @param texture defines the texture to update
  52880. */
  52881. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52882. /**
  52883. * Binds the frame buffer to the specified texture.
  52884. * @param texture The texture to render to or null for the default canvas
  52885. * @param faceIndex The face of the texture to render to in case of cube texture
  52886. * @param requiredWidth The width of the target to render to
  52887. * @param requiredHeight The height of the target to render to
  52888. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  52889. * @param lodLevel defines le lod level to bind to the frame buffer
  52890. */
  52891. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52892. /**
  52893. * Unbind the current render target texture from the webGL context
  52894. * @param texture defines the render target texture to unbind
  52895. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52896. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52897. */
  52898. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52899. /**
  52900. * Creates a dynamic vertex buffer
  52901. * @param vertices the data for the dynamic vertex buffer
  52902. * @returns the new WebGL dynamic buffer
  52903. */
  52904. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  52905. /**
  52906. * Update the content of a dynamic texture
  52907. * @param texture defines the texture to update
  52908. * @param canvas defines the canvas containing the source
  52909. * @param invertY defines if data must be stored with Y axis inverted
  52910. * @param premulAlpha defines if alpha is stored as premultiplied
  52911. * @param format defines the format of the data
  52912. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  52913. */
  52914. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  52915. /**
  52916. * Gets a boolean indicating if all created effects are ready
  52917. * @returns true if all effects are ready
  52918. */
  52919. areAllEffectsReady(): boolean;
  52920. /**
  52921. * @hidden
  52922. * Get the current error code of the webGL context
  52923. * @returns the error code
  52924. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52925. */
  52926. getError(): number;
  52927. /** @hidden */
  52928. _getUnpackAlignement(): number;
  52929. /** @hidden */
  52930. _unpackFlipY(value: boolean): void;
  52931. /**
  52932. * Update a dynamic index buffer
  52933. * @param indexBuffer defines the target index buffer
  52934. * @param indices defines the data to update
  52935. * @param offset defines the offset in the target index buffer where update should start
  52936. */
  52937. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52938. /**
  52939. * Updates a dynamic vertex buffer.
  52940. * @param vertexBuffer the vertex buffer to update
  52941. * @param vertices the data used to update the vertex buffer
  52942. * @param byteOffset the byte offset of the data (optional)
  52943. * @param byteLength the byte length of the data (optional)
  52944. */
  52945. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52946. /** @hidden */
  52947. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52948. /** @hidden */
  52949. _bindTexture(channel: number, texture: InternalTexture): void;
  52950. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52951. /**
  52952. * 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
  52953. */
  52954. releaseEffects(): void;
  52955. displayLoadingUI(): void;
  52956. hideLoadingUI(): void;
  52957. /** @hidden */
  52958. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52959. /** @hidden */
  52960. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52961. /** @hidden */
  52962. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52963. /** @hidden */
  52964. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52965. }
  52966. }
  52967. declare module "babylonjs/Instrumentation/timeToken" {
  52968. import { Nullable } from "babylonjs/types";
  52969. /**
  52970. * @hidden
  52971. **/
  52972. export class _TimeToken {
  52973. _startTimeQuery: Nullable<WebGLQuery>;
  52974. _endTimeQuery: Nullable<WebGLQuery>;
  52975. _timeElapsedQuery: Nullable<WebGLQuery>;
  52976. _timeElapsedQueryEnded: boolean;
  52977. }
  52978. }
  52979. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  52980. import { Nullable, int } from "babylonjs/types";
  52981. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  52982. /** @hidden */
  52983. export class _OcclusionDataStorage {
  52984. /** @hidden */
  52985. occlusionInternalRetryCounter: number;
  52986. /** @hidden */
  52987. isOcclusionQueryInProgress: boolean;
  52988. /** @hidden */
  52989. isOccluded: boolean;
  52990. /** @hidden */
  52991. occlusionRetryCount: number;
  52992. /** @hidden */
  52993. occlusionType: number;
  52994. /** @hidden */
  52995. occlusionQueryAlgorithmType: number;
  52996. }
  52997. module "babylonjs/Engines/engine" {
  52998. interface Engine {
  52999. /**
  53000. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  53001. * @return the new query
  53002. */
  53003. createQuery(): WebGLQuery;
  53004. /**
  53005. * Delete and release a webGL query
  53006. * @param query defines the query to delete
  53007. * @return the current engine
  53008. */
  53009. deleteQuery(query: WebGLQuery): Engine;
  53010. /**
  53011. * Check if a given query has resolved and got its value
  53012. * @param query defines the query to check
  53013. * @returns true if the query got its value
  53014. */
  53015. isQueryResultAvailable(query: WebGLQuery): boolean;
  53016. /**
  53017. * Gets the value of a given query
  53018. * @param query defines the query to check
  53019. * @returns the value of the query
  53020. */
  53021. getQueryResult(query: WebGLQuery): number;
  53022. /**
  53023. * Initiates an occlusion query
  53024. * @param algorithmType defines the algorithm to use
  53025. * @param query defines the query to use
  53026. * @returns the current engine
  53027. * @see https://doc.babylonjs.com/features/occlusionquery
  53028. */
  53029. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  53030. /**
  53031. * Ends an occlusion query
  53032. * @see https://doc.babylonjs.com/features/occlusionquery
  53033. * @param algorithmType defines the algorithm to use
  53034. * @returns the current engine
  53035. */
  53036. endOcclusionQuery(algorithmType: number): Engine;
  53037. /**
  53038. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  53039. * Please note that only one query can be issued at a time
  53040. * @returns a time token used to track the time span
  53041. */
  53042. startTimeQuery(): Nullable<_TimeToken>;
  53043. /**
  53044. * Ends a time query
  53045. * @param token defines the token used to measure the time span
  53046. * @returns the time spent (in ns)
  53047. */
  53048. endTimeQuery(token: _TimeToken): int;
  53049. /** @hidden */
  53050. _currentNonTimestampToken: Nullable<_TimeToken>;
  53051. /** @hidden */
  53052. _createTimeQuery(): WebGLQuery;
  53053. /** @hidden */
  53054. _deleteTimeQuery(query: WebGLQuery): void;
  53055. /** @hidden */
  53056. _getGlAlgorithmType(algorithmType: number): number;
  53057. /** @hidden */
  53058. _getTimeQueryResult(query: WebGLQuery): any;
  53059. /** @hidden */
  53060. _getTimeQueryAvailability(query: WebGLQuery): any;
  53061. }
  53062. }
  53063. module "babylonjs/Meshes/abstractMesh" {
  53064. interface AbstractMesh {
  53065. /**
  53066. * Backing filed
  53067. * @hidden
  53068. */
  53069. __occlusionDataStorage: _OcclusionDataStorage;
  53070. /**
  53071. * Access property
  53072. * @hidden
  53073. */
  53074. _occlusionDataStorage: _OcclusionDataStorage;
  53075. /**
  53076. * 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.
  53077. * The default value is -1 which means don't break the query and wait till the result
  53078. * @see https://doc.babylonjs.com/features/occlusionquery
  53079. */
  53080. occlusionRetryCount: number;
  53081. /**
  53082. * 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:
  53083. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  53084. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  53085. * * 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.
  53086. * @see https://doc.babylonjs.com/features/occlusionquery
  53087. */
  53088. occlusionType: number;
  53089. /**
  53090. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  53091. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  53092. * * 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.
  53093. * @see https://doc.babylonjs.com/features/occlusionquery
  53094. */
  53095. occlusionQueryAlgorithmType: number;
  53096. /**
  53097. * 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
  53098. * @see https://doc.babylonjs.com/features/occlusionquery
  53099. */
  53100. isOccluded: boolean;
  53101. /**
  53102. * Flag to check the progress status of the query
  53103. * @see https://doc.babylonjs.com/features/occlusionquery
  53104. */
  53105. isOcclusionQueryInProgress: boolean;
  53106. }
  53107. }
  53108. }
  53109. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  53110. import { Nullable } from "babylonjs/types";
  53111. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53112. /** @hidden */
  53113. export var _forceTransformFeedbackToBundle: boolean;
  53114. module "babylonjs/Engines/engine" {
  53115. interface Engine {
  53116. /**
  53117. * Creates a webGL transform feedback object
  53118. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  53119. * @returns the webGL transform feedback object
  53120. */
  53121. createTransformFeedback(): WebGLTransformFeedback;
  53122. /**
  53123. * Delete a webGL transform feedback object
  53124. * @param value defines the webGL transform feedback object to delete
  53125. */
  53126. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  53127. /**
  53128. * Bind a webGL transform feedback object to the webgl context
  53129. * @param value defines the webGL transform feedback object to bind
  53130. */
  53131. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  53132. /**
  53133. * Begins a transform feedback operation
  53134. * @param usePoints defines if points or triangles must be used
  53135. */
  53136. beginTransformFeedback(usePoints: boolean): void;
  53137. /**
  53138. * Ends a transform feedback operation
  53139. */
  53140. endTransformFeedback(): void;
  53141. /**
  53142. * Specify the varyings to use with transform feedback
  53143. * @param program defines the associated webGL program
  53144. * @param value defines the list of strings representing the varying names
  53145. */
  53146. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  53147. /**
  53148. * Bind a webGL buffer for a transform feedback operation
  53149. * @param value defines the webGL buffer to bind
  53150. */
  53151. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  53152. }
  53153. }
  53154. }
  53155. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  53156. import { Scene } from "babylonjs/scene";
  53157. import { Engine } from "babylonjs/Engines/engine";
  53158. import { Texture } from "babylonjs/Materials/Textures/texture";
  53159. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53160. import "babylonjs/Engines/Extensions/engine.multiRender";
  53161. /**
  53162. * Creation options of the multi render target texture.
  53163. */
  53164. export interface IMultiRenderTargetOptions {
  53165. /**
  53166. * Define if the texture needs to create mip maps after render.
  53167. */
  53168. generateMipMaps?: boolean;
  53169. /**
  53170. * Define the types of all the draw buffers we want to create
  53171. */
  53172. types?: number[];
  53173. /**
  53174. * Define the sampling modes of all the draw buffers we want to create
  53175. */
  53176. samplingModes?: number[];
  53177. /**
  53178. * Define if a depth buffer is required
  53179. */
  53180. generateDepthBuffer?: boolean;
  53181. /**
  53182. * Define if a stencil buffer is required
  53183. */
  53184. generateStencilBuffer?: boolean;
  53185. /**
  53186. * Define if a depth texture is required instead of a depth buffer
  53187. */
  53188. generateDepthTexture?: boolean;
  53189. /**
  53190. * Define the number of desired draw buffers
  53191. */
  53192. textureCount?: number;
  53193. /**
  53194. * Define if aspect ratio should be adapted to the texture or stay the scene one
  53195. */
  53196. doNotChangeAspectRatio?: boolean;
  53197. /**
  53198. * Define the default type of the buffers we are creating
  53199. */
  53200. defaultType?: number;
  53201. }
  53202. /**
  53203. * A multi render target, like a render target provides the ability to render to a texture.
  53204. * Unlike the render target, it can render to several draw buffers in one draw.
  53205. * This is specially interesting in deferred rendering or for any effects requiring more than
  53206. * just one color from a single pass.
  53207. */
  53208. export class MultiRenderTarget extends RenderTargetTexture {
  53209. private _internalTextures;
  53210. private _textures;
  53211. private _multiRenderTargetOptions;
  53212. private _count;
  53213. /**
  53214. * Get if draw buffers are currently supported by the used hardware and browser.
  53215. */
  53216. get isSupported(): boolean;
  53217. /**
  53218. * Get the list of textures generated by the multi render target.
  53219. */
  53220. get textures(): Texture[];
  53221. /**
  53222. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  53223. */
  53224. get count(): number;
  53225. /**
  53226. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  53227. */
  53228. get depthTexture(): Texture;
  53229. /**
  53230. * Set the wrapping mode on U of all the textures we are rendering to.
  53231. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  53232. */
  53233. set wrapU(wrap: number);
  53234. /**
  53235. * Set the wrapping mode on V of all the textures we are rendering to.
  53236. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  53237. */
  53238. set wrapV(wrap: number);
  53239. /**
  53240. * Instantiate a new multi render target texture.
  53241. * A multi render target, like a render target provides the ability to render to a texture.
  53242. * Unlike the render target, it can render to several draw buffers in one draw.
  53243. * This is specially interesting in deferred rendering or for any effects requiring more than
  53244. * just one color from a single pass.
  53245. * @param name Define the name of the texture
  53246. * @param size Define the size of the buffers to render to
  53247. * @param count Define the number of target we are rendering into
  53248. * @param scene Define the scene the texture belongs to
  53249. * @param options Define the options used to create the multi render target
  53250. */
  53251. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  53252. /** @hidden */
  53253. _rebuild(): void;
  53254. private _createInternalTextures;
  53255. private _createTextures;
  53256. /**
  53257. * Define the number of samples used if MSAA is enabled.
  53258. */
  53259. get samples(): number;
  53260. set samples(value: number);
  53261. /**
  53262. * Resize all the textures in the multi render target.
  53263. * Be carrefull as it will recreate all the data in the new texture.
  53264. * @param size Define the new size
  53265. */
  53266. resize(size: any): void;
  53267. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  53268. /**
  53269. * Dispose the render targets and their associated resources
  53270. */
  53271. dispose(): void;
  53272. /**
  53273. * Release all the underlying texture used as draw buffers.
  53274. */
  53275. releaseInternalTextures(): void;
  53276. }
  53277. }
  53278. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  53279. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53280. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  53281. import { Nullable } from "babylonjs/types";
  53282. module "babylonjs/Engines/thinEngine" {
  53283. interface ThinEngine {
  53284. /**
  53285. * Unbind a list of render target textures from the webGL context
  53286. * This is used only when drawBuffer extension or webGL2 are active
  53287. * @param textures defines the render target textures to unbind
  53288. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  53289. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  53290. */
  53291. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  53292. /**
  53293. * Create a multi render target texture
  53294. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  53295. * @param size defines the size of the texture
  53296. * @param options defines the creation options
  53297. * @returns the cube texture as an InternalTexture
  53298. */
  53299. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  53300. /**
  53301. * Update the sample count for a given multiple render target texture
  53302. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  53303. * @param textures defines the textures to update
  53304. * @param samples defines the sample count to set
  53305. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  53306. */
  53307. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  53308. /**
  53309. * Select a subsets of attachments to draw to.
  53310. * @param attachments gl attachments
  53311. */
  53312. bindAttachments(attachments: number[]): void;
  53313. }
  53314. }
  53315. }
  53316. declare module "babylonjs/Engines/Extensions/engine.views" {
  53317. import { Camera } from "babylonjs/Cameras/camera";
  53318. import { Nullable } from "babylonjs/types";
  53319. /**
  53320. * Class used to define an additional view for the engine
  53321. * @see https://doc.babylonjs.com/how_to/multi_canvases
  53322. */
  53323. export class EngineView {
  53324. /** Defines the canvas where to render the view */
  53325. target: HTMLCanvasElement;
  53326. /** Defines an optional camera used to render the view (will use active camera else) */
  53327. camera?: Camera;
  53328. }
  53329. module "babylonjs/Engines/engine" {
  53330. interface Engine {
  53331. /**
  53332. * Gets or sets the HTML element to use for attaching events
  53333. */
  53334. inputElement: Nullable<HTMLElement>;
  53335. /**
  53336. * Gets the current engine view
  53337. * @see https://doc.babylonjs.com/how_to/multi_canvases
  53338. */
  53339. activeView: Nullable<EngineView>;
  53340. /** Gets or sets the list of views */
  53341. views: EngineView[];
  53342. /**
  53343. * Register a new child canvas
  53344. * @param canvas defines the canvas to register
  53345. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  53346. * @returns the associated view
  53347. */
  53348. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  53349. /**
  53350. * Remove a registered child canvas
  53351. * @param canvas defines the canvas to remove
  53352. * @returns the current engine
  53353. */
  53354. unRegisterView(canvas: HTMLCanvasElement): Engine;
  53355. }
  53356. }
  53357. }
  53358. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  53359. import { Nullable } from "babylonjs/types";
  53360. module "babylonjs/Engines/engine" {
  53361. interface Engine {
  53362. /** @hidden */
  53363. _excludedCompressedTextures: string[];
  53364. /** @hidden */
  53365. _textureFormatInUse: string;
  53366. /**
  53367. * Gets the list of texture formats supported
  53368. */
  53369. readonly texturesSupported: Array<string>;
  53370. /**
  53371. * Gets the texture format in use
  53372. */
  53373. readonly textureFormatInUse: Nullable<string>;
  53374. /**
  53375. * Set the compressed texture extensions or file names to skip.
  53376. *
  53377. * @param skippedFiles defines the list of those texture files you want to skip
  53378. * Example: [".dds", ".env", "myfile.png"]
  53379. */
  53380. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  53381. /**
  53382. * Set the compressed texture format to use, based on the formats you have, and the formats
  53383. * supported by the hardware / browser.
  53384. *
  53385. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  53386. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  53387. * to API arguments needed to compressed textures. This puts the burden on the container
  53388. * generator to house the arcane code for determining these for current & future formats.
  53389. *
  53390. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  53391. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  53392. *
  53393. * Note: The result of this call is not taken into account when a texture is base64.
  53394. *
  53395. * @param formatsAvailable defines the list of those format families you have created
  53396. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  53397. *
  53398. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  53399. * @returns The extension selected.
  53400. */
  53401. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  53402. }
  53403. }
  53404. }
  53405. declare module "babylonjs/Engines/Extensions/index" {
  53406. export * from "babylonjs/Engines/Extensions/engine.alpha";
  53407. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  53408. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  53409. export * from "babylonjs/Engines/Extensions/engine.multiview";
  53410. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  53411. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  53412. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  53413. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  53414. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  53415. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  53416. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  53417. export * from "babylonjs/Engines/Extensions/engine.webVR";
  53418. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  53419. export * from "babylonjs/Engines/Extensions/engine.views";
  53420. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  53421. import "babylonjs/Engines/Extensions/engine.textureSelector";
  53422. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  53423. }
  53424. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  53425. import { Nullable } from "babylonjs/types";
  53426. /**
  53427. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  53428. */
  53429. export interface CubeMapInfo {
  53430. /**
  53431. * The pixel array for the front face.
  53432. * This is stored in format, left to right, up to down format.
  53433. */
  53434. front: Nullable<ArrayBufferView>;
  53435. /**
  53436. * The pixel array for the back face.
  53437. * This is stored in format, left to right, up to down format.
  53438. */
  53439. back: Nullable<ArrayBufferView>;
  53440. /**
  53441. * The pixel array for the left face.
  53442. * This is stored in format, left to right, up to down format.
  53443. */
  53444. left: Nullable<ArrayBufferView>;
  53445. /**
  53446. * The pixel array for the right face.
  53447. * This is stored in format, left to right, up to down format.
  53448. */
  53449. right: Nullable<ArrayBufferView>;
  53450. /**
  53451. * The pixel array for the up face.
  53452. * This is stored in format, left to right, up to down format.
  53453. */
  53454. up: Nullable<ArrayBufferView>;
  53455. /**
  53456. * The pixel array for the down face.
  53457. * This is stored in format, left to right, up to down format.
  53458. */
  53459. down: Nullable<ArrayBufferView>;
  53460. /**
  53461. * The size of the cubemap stored.
  53462. *
  53463. * Each faces will be size * size pixels.
  53464. */
  53465. size: number;
  53466. /**
  53467. * The format of the texture.
  53468. *
  53469. * RGBA, RGB.
  53470. */
  53471. format: number;
  53472. /**
  53473. * The type of the texture data.
  53474. *
  53475. * UNSIGNED_INT, FLOAT.
  53476. */
  53477. type: number;
  53478. /**
  53479. * Specifies whether the texture is in gamma space.
  53480. */
  53481. gammaSpace: boolean;
  53482. }
  53483. /**
  53484. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  53485. */
  53486. export class PanoramaToCubeMapTools {
  53487. private static FACE_LEFT;
  53488. private static FACE_RIGHT;
  53489. private static FACE_FRONT;
  53490. private static FACE_BACK;
  53491. private static FACE_DOWN;
  53492. private static FACE_UP;
  53493. /**
  53494. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  53495. *
  53496. * @param float32Array The source data.
  53497. * @param inputWidth The width of the input panorama.
  53498. * @param inputHeight The height of the input panorama.
  53499. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  53500. * @return The cubemap data
  53501. */
  53502. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  53503. private static CreateCubemapTexture;
  53504. private static CalcProjectionSpherical;
  53505. }
  53506. }
  53507. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  53508. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53509. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53510. import { Nullable } from "babylonjs/types";
  53511. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53512. /**
  53513. * Helper class dealing with the extraction of spherical polynomial dataArray
  53514. * from a cube map.
  53515. */
  53516. export class CubeMapToSphericalPolynomialTools {
  53517. private static FileFaces;
  53518. /**
  53519. * Converts a texture to the according Spherical Polynomial data.
  53520. * This extracts the first 3 orders only as they are the only one used in the lighting.
  53521. *
  53522. * @param texture The texture to extract the information from.
  53523. * @return The Spherical Polynomial data.
  53524. */
  53525. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  53526. /**
  53527. * Converts a cubemap to the according Spherical Polynomial data.
  53528. * This extracts the first 3 orders only as they are the only one used in the lighting.
  53529. *
  53530. * @param cubeInfo The Cube map to extract the information from.
  53531. * @return The Spherical Polynomial data.
  53532. */
  53533. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  53534. }
  53535. }
  53536. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  53537. import { Nullable } from "babylonjs/types";
  53538. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53539. module "babylonjs/Materials/Textures/baseTexture" {
  53540. interface BaseTexture {
  53541. /**
  53542. * Get the polynomial representation of the texture data.
  53543. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  53544. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  53545. */
  53546. sphericalPolynomial: Nullable<SphericalPolynomial>;
  53547. }
  53548. }
  53549. }
  53550. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  53551. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53552. /** @hidden */
  53553. export var rgbdEncodePixelShader: {
  53554. name: string;
  53555. shader: string;
  53556. };
  53557. }
  53558. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  53559. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53560. /** @hidden */
  53561. export var rgbdDecodePixelShader: {
  53562. name: string;
  53563. shader: string;
  53564. };
  53565. }
  53566. declare module "babylonjs/Misc/environmentTextureTools" {
  53567. import { Nullable } from "babylonjs/types";
  53568. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53569. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53570. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53571. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  53572. import "babylonjs/Engines/Extensions/engine.readTexture";
  53573. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53574. import "babylonjs/Shaders/rgbdEncode.fragment";
  53575. import "babylonjs/Shaders/rgbdDecode.fragment";
  53576. /**
  53577. * Raw texture data and descriptor sufficient for WebGL texture upload
  53578. */
  53579. export interface EnvironmentTextureInfo {
  53580. /**
  53581. * Version of the environment map
  53582. */
  53583. version: number;
  53584. /**
  53585. * Width of image
  53586. */
  53587. width: number;
  53588. /**
  53589. * Irradiance information stored in the file.
  53590. */
  53591. irradiance: any;
  53592. /**
  53593. * Specular information stored in the file.
  53594. */
  53595. specular: any;
  53596. }
  53597. /**
  53598. * Defines One Image in the file. It requires only the position in the file
  53599. * as well as the length.
  53600. */
  53601. interface BufferImageData {
  53602. /**
  53603. * Length of the image data.
  53604. */
  53605. length: number;
  53606. /**
  53607. * Position of the data from the null terminator delimiting the end of the JSON.
  53608. */
  53609. position: number;
  53610. }
  53611. /**
  53612. * Defines the specular data enclosed in the file.
  53613. * This corresponds to the version 1 of the data.
  53614. */
  53615. export interface EnvironmentTextureSpecularInfoV1 {
  53616. /**
  53617. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  53618. */
  53619. specularDataPosition?: number;
  53620. /**
  53621. * This contains all the images data needed to reconstruct the cubemap.
  53622. */
  53623. mipmaps: Array<BufferImageData>;
  53624. /**
  53625. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  53626. */
  53627. lodGenerationScale: number;
  53628. }
  53629. /**
  53630. * Sets of helpers addressing the serialization and deserialization of environment texture
  53631. * stored in a BabylonJS env file.
  53632. * Those files are usually stored as .env files.
  53633. */
  53634. export class EnvironmentTextureTools {
  53635. /**
  53636. * Magic number identifying the env file.
  53637. */
  53638. private static _MagicBytes;
  53639. /**
  53640. * Gets the environment info from an env file.
  53641. * @param data The array buffer containing the .env bytes.
  53642. * @returns the environment file info (the json header) if successfully parsed.
  53643. */
  53644. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  53645. /**
  53646. * Creates an environment texture from a loaded cube texture.
  53647. * @param texture defines the cube texture to convert in env file
  53648. * @return a promise containing the environment data if succesfull.
  53649. */
  53650. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  53651. /**
  53652. * Creates a JSON representation of the spherical data.
  53653. * @param texture defines the texture containing the polynomials
  53654. * @return the JSON representation of the spherical info
  53655. */
  53656. private static _CreateEnvTextureIrradiance;
  53657. /**
  53658. * Creates the ArrayBufferViews used for initializing environment texture image data.
  53659. * @param data the image data
  53660. * @param info parameters that determine what views will be created for accessing the underlying buffer
  53661. * @return the views described by info providing access to the underlying buffer
  53662. */
  53663. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  53664. /**
  53665. * Uploads the texture info contained in the env file to the GPU.
  53666. * @param texture defines the internal texture to upload to
  53667. * @param data defines the data to load
  53668. * @param info defines the texture info retrieved through the GetEnvInfo method
  53669. * @returns a promise
  53670. */
  53671. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  53672. private static _OnImageReadyAsync;
  53673. /**
  53674. * Uploads the levels of image data to the GPU.
  53675. * @param texture defines the internal texture to upload to
  53676. * @param imageData defines the array buffer views of image data [mipmap][face]
  53677. * @returns a promise
  53678. */
  53679. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  53680. /**
  53681. * Uploads spherical polynomials information to the texture.
  53682. * @param texture defines the texture we are trying to upload the information to
  53683. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  53684. */
  53685. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  53686. /** @hidden */
  53687. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53688. }
  53689. }
  53690. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  53691. /**
  53692. * Class used to inline functions in shader code
  53693. */
  53694. export class ShaderCodeInliner {
  53695. private static readonly _RegexpFindFunctionNameAndType;
  53696. private _sourceCode;
  53697. private _functionDescr;
  53698. private _numMaxIterations;
  53699. /** Gets or sets the token used to mark the functions to inline */
  53700. inlineToken: string;
  53701. /** Gets or sets the debug mode */
  53702. debug: boolean;
  53703. /** Gets the code after the inlining process */
  53704. get code(): string;
  53705. /**
  53706. * Initializes the inliner
  53707. * @param sourceCode shader code source to inline
  53708. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  53709. */
  53710. constructor(sourceCode: string, numMaxIterations?: number);
  53711. /**
  53712. * Start the processing of the shader code
  53713. */
  53714. processCode(): void;
  53715. private _collectFunctions;
  53716. private _processInlining;
  53717. private _extractBetweenMarkers;
  53718. private _skipWhitespaces;
  53719. private _removeComments;
  53720. private _replaceFunctionCallsByCode;
  53721. private _findBackward;
  53722. private _escapeRegExp;
  53723. private _replaceNames;
  53724. }
  53725. }
  53726. declare module "babylonjs/Engines/nativeEngine" {
  53727. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  53728. import { Engine } from "babylonjs/Engines/engine";
  53729. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53730. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53731. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53732. import { Effect } from "babylonjs/Materials/effect";
  53733. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53734. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  53735. import { IColor4Like } from "babylonjs/Maths/math.like";
  53736. import { Scene } from "babylonjs/scene";
  53737. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53738. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53739. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53740. /**
  53741. * Container for accessors for natively-stored mesh data buffers.
  53742. */
  53743. class NativeDataBuffer extends DataBuffer {
  53744. /**
  53745. * Accessor value used to identify/retrieve a natively-stored index buffer.
  53746. */
  53747. nativeIndexBuffer?: any;
  53748. /**
  53749. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  53750. */
  53751. nativeVertexBuffer?: any;
  53752. }
  53753. /** @hidden */
  53754. class NativeTexture extends InternalTexture {
  53755. getInternalTexture(): InternalTexture;
  53756. getViewCount(): number;
  53757. }
  53758. /** @hidden */
  53759. export class NativeEngine extends Engine {
  53760. private readonly _native;
  53761. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  53762. private readonly INVALID_HANDLE;
  53763. getHardwareScalingLevel(): number;
  53764. constructor();
  53765. dispose(): void;
  53766. /**
  53767. * Can be used to override the current requestAnimationFrame requester.
  53768. * @hidden
  53769. */
  53770. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  53771. /**
  53772. * Override default engine behavior.
  53773. * @param color
  53774. * @param backBuffer
  53775. * @param depth
  53776. * @param stencil
  53777. */
  53778. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  53779. /**
  53780. * Gets host document
  53781. * @returns the host document object
  53782. */
  53783. getHostDocument(): Nullable<Document>;
  53784. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53785. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  53786. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  53787. recordVertexArrayObject(vertexBuffers: {
  53788. [key: string]: VertexBuffer;
  53789. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  53790. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53791. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53792. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53793. /**
  53794. * Draw a list of indexed primitives
  53795. * @param fillMode defines the primitive to use
  53796. * @param indexStart defines the starting index
  53797. * @param indexCount defines the number of index to draw
  53798. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53799. */
  53800. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  53801. /**
  53802. * Draw a list of unindexed primitives
  53803. * @param fillMode defines the primitive to use
  53804. * @param verticesStart defines the index of first vertex to draw
  53805. * @param verticesCount defines the count of vertices to draw
  53806. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53807. */
  53808. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  53809. createPipelineContext(): IPipelineContext;
  53810. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  53811. /** @hidden */
  53812. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  53813. /** @hidden */
  53814. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  53815. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53816. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53817. protected _setProgram(program: WebGLProgram): void;
  53818. _releaseEffect(effect: Effect): void;
  53819. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  53820. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  53821. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  53822. bindSamplers(effect: Effect): void;
  53823. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  53824. getRenderWidth(useScreen?: boolean): number;
  53825. getRenderHeight(useScreen?: boolean): number;
  53826. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  53827. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53828. /**
  53829. * Set the z offset to apply to current rendering
  53830. * @param value defines the offset to apply
  53831. */
  53832. setZOffset(value: number): void;
  53833. /**
  53834. * Gets the current value of the zOffset
  53835. * @returns the current zOffset state
  53836. */
  53837. getZOffset(): number;
  53838. /**
  53839. * Enable or disable depth buffering
  53840. * @param enable defines the state to set
  53841. */
  53842. setDepthBuffer(enable: boolean): void;
  53843. /**
  53844. * Gets a boolean indicating if depth writing is enabled
  53845. * @returns the current depth writing state
  53846. */
  53847. getDepthWrite(): boolean;
  53848. /**
  53849. * Enable or disable depth writing
  53850. * @param enable defines the state to set
  53851. */
  53852. setDepthWrite(enable: boolean): void;
  53853. /**
  53854. * Enable or disable color writing
  53855. * @param enable defines the state to set
  53856. */
  53857. setColorWrite(enable: boolean): void;
  53858. /**
  53859. * Gets a boolean indicating if color writing is enabled
  53860. * @returns the current color writing state
  53861. */
  53862. getColorWrite(): boolean;
  53863. /**
  53864. * Sets alpha constants used by some alpha blending modes
  53865. * @param r defines the red component
  53866. * @param g defines the green component
  53867. * @param b defines the blue component
  53868. * @param a defines the alpha component
  53869. */
  53870. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  53871. /**
  53872. * Sets the current alpha mode
  53873. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  53874. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53875. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53876. */
  53877. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53878. /**
  53879. * Gets the current alpha mode
  53880. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53881. * @returns the current alpha mode
  53882. */
  53883. getAlphaMode(): number;
  53884. setInt(uniform: WebGLUniformLocation, int: number): void;
  53885. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53886. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53887. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53888. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53889. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53890. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  53891. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  53892. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  53893. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  53894. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  53895. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  53896. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  53897. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  53898. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53899. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53900. setFloat(uniform: WebGLUniformLocation, value: number): void;
  53901. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  53902. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  53903. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  53904. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  53905. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  53906. wipeCaches(bruteForce?: boolean): void;
  53907. _createTexture(): WebGLTexture;
  53908. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  53909. /**
  53910. * Usually called from Texture.ts.
  53911. * Passed information to create a WebGLTexture
  53912. * @param url defines a value which contains one of the following:
  53913. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53914. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53915. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53916. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53917. * @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)
  53918. * @param scene needed for loading to the correct scene
  53919. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53920. * @param onLoad optional callback to be called upon successful completion
  53921. * @param onError optional callback to be called upon failure
  53922. * @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
  53923. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53924. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53925. * @param forcedExtension defines the extension to use to pick the right loader
  53926. * @param mimeType defines an optional mime type
  53927. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53928. */
  53929. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  53930. /**
  53931. * Creates a cube texture
  53932. * @param rootUrl defines the url where the files to load is located
  53933. * @param scene defines the current scene
  53934. * @param files defines the list of files to load (1 per face)
  53935. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  53936. * @param onLoad defines an optional callback raised when the texture is loaded
  53937. * @param onError defines an optional callback raised if there is an issue to load the texture
  53938. * @param format defines the format of the data
  53939. * @param forcedExtension defines the extension to use to pick the right loader
  53940. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  53941. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53942. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53943. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  53944. * @returns the cube texture as an InternalTexture
  53945. */
  53946. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  53947. private _getSamplingFilter;
  53948. private static _GetNativeTextureFormat;
  53949. createRenderTargetTexture(size: number | {
  53950. width: number;
  53951. height: number;
  53952. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  53953. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53954. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53955. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53956. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  53957. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  53958. /**
  53959. * Updates a dynamic vertex buffer.
  53960. * @param vertexBuffer the vertex buffer to update
  53961. * @param data the data used to update the vertex buffer
  53962. * @param byteOffset the byte offset of the data (optional)
  53963. * @param byteLength the byte length of the data (optional)
  53964. */
  53965. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  53966. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  53967. private _updateAnisotropicLevel;
  53968. private _getAddressMode;
  53969. /** @hidden */
  53970. _bindTexture(channel: number, texture: InternalTexture): void;
  53971. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  53972. releaseEffects(): void;
  53973. /** @hidden */
  53974. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53975. /** @hidden */
  53976. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53977. /** @hidden */
  53978. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53979. /** @hidden */
  53980. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53981. }
  53982. }
  53983. declare module "babylonjs/Engines/index" {
  53984. export * from "babylonjs/Engines/constants";
  53985. export * from "babylonjs/Engines/engineCapabilities";
  53986. export * from "babylonjs/Engines/instancingAttributeInfo";
  53987. export * from "babylonjs/Engines/thinEngine";
  53988. export * from "babylonjs/Engines/engine";
  53989. export * from "babylonjs/Engines/engineStore";
  53990. export * from "babylonjs/Engines/nullEngine";
  53991. export * from "babylonjs/Engines/Extensions/index";
  53992. export * from "babylonjs/Engines/IPipelineContext";
  53993. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  53994. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  53995. export * from "babylonjs/Engines/nativeEngine";
  53996. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  53997. }
  53998. declare module "babylonjs/Events/clipboardEvents" {
  53999. /**
  54000. * Gather the list of clipboard event types as constants.
  54001. */
  54002. export class ClipboardEventTypes {
  54003. /**
  54004. * The clipboard event is fired when a copy command is active (pressed).
  54005. */
  54006. static readonly COPY: number;
  54007. /**
  54008. * The clipboard event is fired when a cut command is active (pressed).
  54009. */
  54010. static readonly CUT: number;
  54011. /**
  54012. * The clipboard event is fired when a paste command is active (pressed).
  54013. */
  54014. static readonly PASTE: number;
  54015. }
  54016. /**
  54017. * This class is used to store clipboard related info for the onClipboardObservable event.
  54018. */
  54019. export class ClipboardInfo {
  54020. /**
  54021. * Defines the type of event (BABYLON.ClipboardEventTypes)
  54022. */
  54023. type: number;
  54024. /**
  54025. * Defines the related dom event
  54026. */
  54027. event: ClipboardEvent;
  54028. /**
  54029. *Creates an instance of ClipboardInfo.
  54030. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  54031. * @param event Defines the related dom event
  54032. */
  54033. constructor(
  54034. /**
  54035. * Defines the type of event (BABYLON.ClipboardEventTypes)
  54036. */
  54037. type: number,
  54038. /**
  54039. * Defines the related dom event
  54040. */
  54041. event: ClipboardEvent);
  54042. /**
  54043. * Get the clipboard event's type from the keycode.
  54044. * @param keyCode Defines the keyCode for the current keyboard event.
  54045. * @return {number}
  54046. */
  54047. static GetTypeFromCharacter(keyCode: number): number;
  54048. }
  54049. }
  54050. declare module "babylonjs/Events/index" {
  54051. export * from "babylonjs/Events/keyboardEvents";
  54052. export * from "babylonjs/Events/pointerEvents";
  54053. export * from "babylonjs/Events/clipboardEvents";
  54054. }
  54055. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  54056. import { Scene } from "babylonjs/scene";
  54057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54058. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54059. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54060. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54061. /**
  54062. * Google Daydream controller
  54063. */
  54064. export class DaydreamController extends WebVRController {
  54065. /**
  54066. * Base Url for the controller model.
  54067. */
  54068. static MODEL_BASE_URL: string;
  54069. /**
  54070. * File name for the controller model.
  54071. */
  54072. static MODEL_FILENAME: string;
  54073. /**
  54074. * Gamepad Id prefix used to identify Daydream Controller.
  54075. */
  54076. static readonly GAMEPAD_ID_PREFIX: string;
  54077. /**
  54078. * Creates a new DaydreamController from a gamepad
  54079. * @param vrGamepad the gamepad that the controller should be created from
  54080. */
  54081. constructor(vrGamepad: any);
  54082. /**
  54083. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54084. * @param scene scene in which to add meshes
  54085. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54086. */
  54087. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54088. /**
  54089. * Called once for each button that changed state since the last frame
  54090. * @param buttonIdx Which button index changed
  54091. * @param state New state of the button
  54092. * @param changes Which properties on the state changed since last frame
  54093. */
  54094. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54095. }
  54096. }
  54097. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  54098. import { Scene } from "babylonjs/scene";
  54099. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54100. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54101. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54102. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54103. /**
  54104. * Gear VR Controller
  54105. */
  54106. export class GearVRController extends WebVRController {
  54107. /**
  54108. * Base Url for the controller model.
  54109. */
  54110. static MODEL_BASE_URL: string;
  54111. /**
  54112. * File name for the controller model.
  54113. */
  54114. static MODEL_FILENAME: string;
  54115. /**
  54116. * Gamepad Id prefix used to identify this controller.
  54117. */
  54118. static readonly GAMEPAD_ID_PREFIX: string;
  54119. private readonly _buttonIndexToObservableNameMap;
  54120. /**
  54121. * Creates a new GearVRController from a gamepad
  54122. * @param vrGamepad the gamepad that the controller should be created from
  54123. */
  54124. constructor(vrGamepad: any);
  54125. /**
  54126. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54127. * @param scene scene in which to add meshes
  54128. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54129. */
  54130. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54131. /**
  54132. * Called once for each button that changed state since the last frame
  54133. * @param buttonIdx Which button index changed
  54134. * @param state New state of the button
  54135. * @param changes Which properties on the state changed since last frame
  54136. */
  54137. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54138. }
  54139. }
  54140. declare module "babylonjs/Gamepads/Controllers/genericController" {
  54141. import { Scene } from "babylonjs/scene";
  54142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54143. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54144. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54145. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54146. /**
  54147. * Generic Controller
  54148. */
  54149. export class GenericController extends WebVRController {
  54150. /**
  54151. * Base Url for the controller model.
  54152. */
  54153. static readonly MODEL_BASE_URL: string;
  54154. /**
  54155. * File name for the controller model.
  54156. */
  54157. static readonly MODEL_FILENAME: string;
  54158. /**
  54159. * Creates a new GenericController from a gamepad
  54160. * @param vrGamepad the gamepad that the controller should be created from
  54161. */
  54162. constructor(vrGamepad: any);
  54163. /**
  54164. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54165. * @param scene scene in which to add meshes
  54166. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54167. */
  54168. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54169. /**
  54170. * Called once for each button that changed state since the last frame
  54171. * @param buttonIdx Which button index changed
  54172. * @param state New state of the button
  54173. * @param changes Which properties on the state changed since last frame
  54174. */
  54175. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54176. }
  54177. }
  54178. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  54179. import { Observable } from "babylonjs/Misc/observable";
  54180. import { Scene } from "babylonjs/scene";
  54181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54182. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54183. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54184. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54185. /**
  54186. * Oculus Touch Controller
  54187. */
  54188. export class OculusTouchController extends WebVRController {
  54189. /**
  54190. * Base Url for the controller model.
  54191. */
  54192. static MODEL_BASE_URL: string;
  54193. /**
  54194. * File name for the left controller model.
  54195. */
  54196. static MODEL_LEFT_FILENAME: string;
  54197. /**
  54198. * File name for the right controller model.
  54199. */
  54200. static MODEL_RIGHT_FILENAME: string;
  54201. /**
  54202. * Base Url for the Quest controller model.
  54203. */
  54204. static QUEST_MODEL_BASE_URL: string;
  54205. /**
  54206. * @hidden
  54207. * If the controllers are running on a device that needs the updated Quest controller models
  54208. */
  54209. static _IsQuest: boolean;
  54210. /**
  54211. * Fired when the secondary trigger on this controller is modified
  54212. */
  54213. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  54214. /**
  54215. * Fired when the thumb rest on this controller is modified
  54216. */
  54217. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  54218. /**
  54219. * Creates a new OculusTouchController from a gamepad
  54220. * @param vrGamepad the gamepad that the controller should be created from
  54221. */
  54222. constructor(vrGamepad: any);
  54223. /**
  54224. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54225. * @param scene scene in which to add meshes
  54226. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54227. */
  54228. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54229. /**
  54230. * Fired when the A button on this controller is modified
  54231. */
  54232. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54233. /**
  54234. * Fired when the B button on this controller is modified
  54235. */
  54236. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54237. /**
  54238. * Fired when the X button on this controller is modified
  54239. */
  54240. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54241. /**
  54242. * Fired when the Y button on this controller is modified
  54243. */
  54244. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54245. /**
  54246. * Called once for each button that changed state since the last frame
  54247. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  54248. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  54249. * 2) secondary trigger (same)
  54250. * 3) A (right) X (left), touch, pressed = value
  54251. * 4) B / Y
  54252. * 5) thumb rest
  54253. * @param buttonIdx Which button index changed
  54254. * @param state New state of the button
  54255. * @param changes Which properties on the state changed since last frame
  54256. */
  54257. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54258. }
  54259. }
  54260. declare module "babylonjs/Gamepads/Controllers/viveController" {
  54261. import { Scene } from "babylonjs/scene";
  54262. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54263. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54264. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54265. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54266. import { Observable } from "babylonjs/Misc/observable";
  54267. /**
  54268. * Vive Controller
  54269. */
  54270. export class ViveController extends WebVRController {
  54271. /**
  54272. * Base Url for the controller model.
  54273. */
  54274. static MODEL_BASE_URL: string;
  54275. /**
  54276. * File name for the controller model.
  54277. */
  54278. static MODEL_FILENAME: string;
  54279. /**
  54280. * Creates a new ViveController from a gamepad
  54281. * @param vrGamepad the gamepad that the controller should be created from
  54282. */
  54283. constructor(vrGamepad: any);
  54284. /**
  54285. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54286. * @param scene scene in which to add meshes
  54287. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54288. */
  54289. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54290. /**
  54291. * Fired when the left button on this controller is modified
  54292. */
  54293. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54294. /**
  54295. * Fired when the right button on this controller is modified
  54296. */
  54297. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54298. /**
  54299. * Fired when the menu button on this controller is modified
  54300. */
  54301. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54302. /**
  54303. * Called once for each button that changed state since the last frame
  54304. * Vive mapping:
  54305. * 0: touchpad
  54306. * 1: trigger
  54307. * 2: left AND right buttons
  54308. * 3: menu button
  54309. * @param buttonIdx Which button index changed
  54310. * @param state New state of the button
  54311. * @param changes Which properties on the state changed since last frame
  54312. */
  54313. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54314. }
  54315. }
  54316. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  54317. import { Observable } from "babylonjs/Misc/observable";
  54318. import { Scene } from "babylonjs/scene";
  54319. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54320. import { Ray } from "babylonjs/Culling/ray";
  54321. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54322. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54323. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54324. /**
  54325. * Defines the WindowsMotionController object that the state of the windows motion controller
  54326. */
  54327. export class WindowsMotionController extends WebVRController {
  54328. /**
  54329. * The base url used to load the left and right controller models
  54330. */
  54331. static MODEL_BASE_URL: string;
  54332. /**
  54333. * The name of the left controller model file
  54334. */
  54335. static MODEL_LEFT_FILENAME: string;
  54336. /**
  54337. * The name of the right controller model file
  54338. */
  54339. static MODEL_RIGHT_FILENAME: string;
  54340. /**
  54341. * The controller name prefix for this controller type
  54342. */
  54343. static readonly GAMEPAD_ID_PREFIX: string;
  54344. /**
  54345. * The controller id pattern for this controller type
  54346. */
  54347. private static readonly GAMEPAD_ID_PATTERN;
  54348. private _loadedMeshInfo;
  54349. protected readonly _mapping: {
  54350. buttons: string[];
  54351. buttonMeshNames: {
  54352. trigger: string;
  54353. menu: string;
  54354. grip: string;
  54355. thumbstick: string;
  54356. trackpad: string;
  54357. };
  54358. buttonObservableNames: {
  54359. trigger: string;
  54360. menu: string;
  54361. grip: string;
  54362. thumbstick: string;
  54363. trackpad: string;
  54364. };
  54365. axisMeshNames: string[];
  54366. pointingPoseMeshName: string;
  54367. };
  54368. /**
  54369. * Fired when the trackpad on this controller is clicked
  54370. */
  54371. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  54372. /**
  54373. * Fired when the trackpad on this controller is modified
  54374. */
  54375. onTrackpadValuesChangedObservable: Observable<StickValues>;
  54376. /**
  54377. * The current x and y values of this controller's trackpad
  54378. */
  54379. trackpad: StickValues;
  54380. /**
  54381. * Creates a new WindowsMotionController from a gamepad
  54382. * @param vrGamepad the gamepad that the controller should be created from
  54383. */
  54384. constructor(vrGamepad: any);
  54385. /**
  54386. * Fired when the trigger on this controller is modified
  54387. */
  54388. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54389. /**
  54390. * Fired when the menu button on this controller is modified
  54391. */
  54392. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54393. /**
  54394. * Fired when the grip button on this controller is modified
  54395. */
  54396. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54397. /**
  54398. * Fired when the thumbstick button on this controller is modified
  54399. */
  54400. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54401. /**
  54402. * Fired when the touchpad button on this controller is modified
  54403. */
  54404. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54405. /**
  54406. * Fired when the touchpad values on this controller are modified
  54407. */
  54408. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  54409. protected _updateTrackpad(): void;
  54410. /**
  54411. * Called once per frame by the engine.
  54412. */
  54413. update(): void;
  54414. /**
  54415. * Called once for each button that changed state since the last frame
  54416. * @param buttonIdx Which button index changed
  54417. * @param state New state of the button
  54418. * @param changes Which properties on the state changed since last frame
  54419. */
  54420. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54421. /**
  54422. * Moves the buttons on the controller mesh based on their current state
  54423. * @param buttonName the name of the button to move
  54424. * @param buttonValue the value of the button which determines the buttons new position
  54425. */
  54426. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  54427. /**
  54428. * Moves the axis on the controller mesh based on its current state
  54429. * @param axis the index of the axis
  54430. * @param axisValue the value of the axis which determines the meshes new position
  54431. * @hidden
  54432. */
  54433. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  54434. /**
  54435. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54436. * @param scene scene in which to add meshes
  54437. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54438. */
  54439. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  54440. /**
  54441. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  54442. * can be transformed by button presses and axes values, based on this._mapping.
  54443. *
  54444. * @param scene scene in which the meshes exist
  54445. * @param meshes list of meshes that make up the controller model to process
  54446. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  54447. */
  54448. private processModel;
  54449. private createMeshInfo;
  54450. /**
  54451. * Gets the ray of the controller in the direction the controller is pointing
  54452. * @param length the length the resulting ray should be
  54453. * @returns a ray in the direction the controller is pointing
  54454. */
  54455. getForwardRay(length?: number): Ray;
  54456. /**
  54457. * Disposes of the controller
  54458. */
  54459. dispose(): void;
  54460. }
  54461. /**
  54462. * This class represents a new windows motion controller in XR.
  54463. */
  54464. export class XRWindowsMotionController extends WindowsMotionController {
  54465. /**
  54466. * Changing the original WIndowsMotionController mapping to fir the new mapping
  54467. */
  54468. protected readonly _mapping: {
  54469. buttons: string[];
  54470. buttonMeshNames: {
  54471. trigger: string;
  54472. menu: string;
  54473. grip: string;
  54474. thumbstick: string;
  54475. trackpad: string;
  54476. };
  54477. buttonObservableNames: {
  54478. trigger: string;
  54479. menu: string;
  54480. grip: string;
  54481. thumbstick: string;
  54482. trackpad: string;
  54483. };
  54484. axisMeshNames: string[];
  54485. pointingPoseMeshName: string;
  54486. };
  54487. /**
  54488. * Construct a new XR-Based windows motion controller
  54489. *
  54490. * @param gamepadInfo the gamepad object from the browser
  54491. */
  54492. constructor(gamepadInfo: any);
  54493. /**
  54494. * holds the thumbstick values (X,Y)
  54495. */
  54496. thumbstickValues: StickValues;
  54497. /**
  54498. * Fired when the thumbstick on this controller is clicked
  54499. */
  54500. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  54501. /**
  54502. * Fired when the thumbstick on this controller is modified
  54503. */
  54504. onThumbstickValuesChangedObservable: Observable<StickValues>;
  54505. /**
  54506. * Fired when the touchpad button on this controller is modified
  54507. */
  54508. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  54509. /**
  54510. * Fired when the touchpad values on this controller are modified
  54511. */
  54512. onTrackpadValuesChangedObservable: Observable<StickValues>;
  54513. /**
  54514. * Fired when the thumbstick button on this controller is modified
  54515. * here to prevent breaking changes
  54516. */
  54517. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54518. /**
  54519. * updating the thumbstick(!) and not the trackpad.
  54520. * This is named this way due to the difference between WebVR and XR and to avoid
  54521. * changing the parent class.
  54522. */
  54523. protected _updateTrackpad(): void;
  54524. /**
  54525. * Disposes the class with joy
  54526. */
  54527. dispose(): void;
  54528. }
  54529. }
  54530. declare module "babylonjs/Gamepads/Controllers/index" {
  54531. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  54532. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  54533. export * from "babylonjs/Gamepads/Controllers/genericController";
  54534. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  54535. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54536. export * from "babylonjs/Gamepads/Controllers/viveController";
  54537. export * from "babylonjs/Gamepads/Controllers/webVRController";
  54538. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  54539. }
  54540. declare module "babylonjs/Gamepads/index" {
  54541. export * from "babylonjs/Gamepads/Controllers/index";
  54542. export * from "babylonjs/Gamepads/gamepad";
  54543. export * from "babylonjs/Gamepads/gamepadManager";
  54544. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  54545. export * from "babylonjs/Gamepads/xboxGamepad";
  54546. export * from "babylonjs/Gamepads/dualShockGamepad";
  54547. }
  54548. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  54549. import { Scene } from "babylonjs/scene";
  54550. import { Vector4 } from "babylonjs/Maths/math.vector";
  54551. import { Color4 } from "babylonjs/Maths/math.color";
  54552. import { Mesh } from "babylonjs/Meshes/mesh";
  54553. import { Nullable } from "babylonjs/types";
  54554. /**
  54555. * Class containing static functions to help procedurally build meshes
  54556. */
  54557. export class PolyhedronBuilder {
  54558. /**
  54559. * Creates a polyhedron mesh
  54560. * * 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
  54561. * * The parameter `size` (positive float, default 1) sets the polygon size
  54562. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54563. * * 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`
  54564. * * 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
  54565. * * 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)`)
  54566. * * 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
  54567. * * 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
  54568. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54569. * * 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
  54570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54571. * @param name defines the name of the mesh
  54572. * @param options defines the options used to create the mesh
  54573. * @param scene defines the hosting scene
  54574. * @returns the polyhedron mesh
  54575. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54576. */
  54577. static CreatePolyhedron(name: string, options: {
  54578. type?: number;
  54579. size?: number;
  54580. sizeX?: number;
  54581. sizeY?: number;
  54582. sizeZ?: number;
  54583. custom?: any;
  54584. faceUV?: Vector4[];
  54585. faceColors?: Color4[];
  54586. flat?: boolean;
  54587. updatable?: boolean;
  54588. sideOrientation?: number;
  54589. frontUVs?: Vector4;
  54590. backUVs?: Vector4;
  54591. }, scene?: Nullable<Scene>): Mesh;
  54592. }
  54593. }
  54594. declare module "babylonjs/Gizmos/scaleGizmo" {
  54595. import { Observable } from "babylonjs/Misc/observable";
  54596. import { Nullable } from "babylonjs/types";
  54597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54598. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54599. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  54600. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54601. /**
  54602. * Gizmo that enables scaling a mesh along 3 axis
  54603. */
  54604. export class ScaleGizmo extends Gizmo {
  54605. /**
  54606. * Internal gizmo used for interactions on the x axis
  54607. */
  54608. xGizmo: AxisScaleGizmo;
  54609. /**
  54610. * Internal gizmo used for interactions on the y axis
  54611. */
  54612. yGizmo: AxisScaleGizmo;
  54613. /**
  54614. * Internal gizmo used for interactions on the z axis
  54615. */
  54616. zGizmo: AxisScaleGizmo;
  54617. /**
  54618. * Internal gizmo used to scale all axis equally
  54619. */
  54620. uniformScaleGizmo: AxisScaleGizmo;
  54621. private _meshAttached;
  54622. private _updateGizmoRotationToMatchAttachedMesh;
  54623. private _snapDistance;
  54624. private _scaleRatio;
  54625. private _uniformScalingMesh;
  54626. private _octahedron;
  54627. private _sensitivity;
  54628. /** Fires an event when any of it's sub gizmos are dragged */
  54629. onDragStartObservable: Observable<unknown>;
  54630. /** Fires an event when any of it's sub gizmos are released from dragging */
  54631. onDragEndObservable: Observable<unknown>;
  54632. get attachedMesh(): Nullable<AbstractMesh>;
  54633. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54634. /**
  54635. * Creates a ScaleGizmo
  54636. * @param gizmoLayer The utility layer the gizmo will be added to
  54637. */
  54638. constructor(gizmoLayer?: UtilityLayerRenderer);
  54639. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54640. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54641. /**
  54642. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54643. */
  54644. set snapDistance(value: number);
  54645. get snapDistance(): number;
  54646. /**
  54647. * Ratio for the scale of the gizmo (Default: 1)
  54648. */
  54649. set scaleRatio(value: number);
  54650. get scaleRatio(): number;
  54651. /**
  54652. * Sensitivity factor for dragging (Default: 1)
  54653. */
  54654. set sensitivity(value: number);
  54655. get sensitivity(): number;
  54656. /**
  54657. * Disposes of the gizmo
  54658. */
  54659. dispose(): void;
  54660. }
  54661. }
  54662. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  54663. import { Observable } from "babylonjs/Misc/observable";
  54664. import { Nullable } from "babylonjs/types";
  54665. import { Vector3 } from "babylonjs/Maths/math.vector";
  54666. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54667. import { Mesh } from "babylonjs/Meshes/mesh";
  54668. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54669. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54670. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54671. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  54672. import { Color3 } from "babylonjs/Maths/math.color";
  54673. /**
  54674. * Single axis scale gizmo
  54675. */
  54676. export class AxisScaleGizmo extends Gizmo {
  54677. /**
  54678. * Drag behavior responsible for the gizmos dragging interactions
  54679. */
  54680. dragBehavior: PointerDragBehavior;
  54681. private _pointerObserver;
  54682. /**
  54683. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54684. */
  54685. snapDistance: number;
  54686. /**
  54687. * Event that fires each time the gizmo snaps to a new location.
  54688. * * snapDistance is the the change in distance
  54689. */
  54690. onSnapObservable: Observable<{
  54691. snapDistance: number;
  54692. }>;
  54693. /**
  54694. * If the scaling operation should be done on all axis (default: false)
  54695. */
  54696. uniformScaling: boolean;
  54697. /**
  54698. * Custom sensitivity value for the drag strength
  54699. */
  54700. sensitivity: number;
  54701. private _isEnabled;
  54702. private _parent;
  54703. private _arrow;
  54704. private _coloredMaterial;
  54705. private _hoverMaterial;
  54706. /**
  54707. * Creates an AxisScaleGizmo
  54708. * @param gizmoLayer The utility layer the gizmo will be added to
  54709. * @param dragAxis The axis which the gizmo will be able to scale on
  54710. * @param color The color of the gizmo
  54711. */
  54712. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  54713. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54714. /**
  54715. * If the gizmo is enabled
  54716. */
  54717. set isEnabled(value: boolean);
  54718. get isEnabled(): boolean;
  54719. /**
  54720. * Disposes of the gizmo
  54721. */
  54722. dispose(): void;
  54723. /**
  54724. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54725. * @param mesh The mesh to replace the default mesh of the gizmo
  54726. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  54727. */
  54728. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  54729. }
  54730. }
  54731. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  54732. import { Observable } from "babylonjs/Misc/observable";
  54733. import { Nullable } from "babylonjs/types";
  54734. import { Vector3 } from "babylonjs/Maths/math.vector";
  54735. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54736. import { Mesh } from "babylonjs/Meshes/mesh";
  54737. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54738. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54739. import { Color3 } from "babylonjs/Maths/math.color";
  54740. import "babylonjs/Meshes/Builders/boxBuilder";
  54741. /**
  54742. * Bounding box gizmo
  54743. */
  54744. export class BoundingBoxGizmo extends Gizmo {
  54745. private _lineBoundingBox;
  54746. private _rotateSpheresParent;
  54747. private _scaleBoxesParent;
  54748. private _boundingDimensions;
  54749. private _renderObserver;
  54750. private _pointerObserver;
  54751. private _scaleDragSpeed;
  54752. private _tmpQuaternion;
  54753. private _tmpVector;
  54754. private _tmpRotationMatrix;
  54755. /**
  54756. * 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)
  54757. */
  54758. ignoreChildren: boolean;
  54759. /**
  54760. * 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)
  54761. */
  54762. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  54763. /**
  54764. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  54765. */
  54766. rotationSphereSize: number;
  54767. /**
  54768. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  54769. */
  54770. scaleBoxSize: number;
  54771. /**
  54772. * 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)
  54773. */
  54774. fixedDragMeshScreenSize: boolean;
  54775. /**
  54776. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  54777. */
  54778. fixedDragMeshScreenSizeDistanceFactor: number;
  54779. /**
  54780. * Fired when a rotation sphere or scale box is dragged
  54781. */
  54782. onDragStartObservable: Observable<{}>;
  54783. /**
  54784. * Fired when a scale box is dragged
  54785. */
  54786. onScaleBoxDragObservable: Observable<{}>;
  54787. /**
  54788. * Fired when a scale box drag is ended
  54789. */
  54790. onScaleBoxDragEndObservable: Observable<{}>;
  54791. /**
  54792. * Fired when a rotation sphere is dragged
  54793. */
  54794. onRotationSphereDragObservable: Observable<{}>;
  54795. /**
  54796. * Fired when a rotation sphere drag is ended
  54797. */
  54798. onRotationSphereDragEndObservable: Observable<{}>;
  54799. /**
  54800. * 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)
  54801. */
  54802. scalePivot: Nullable<Vector3>;
  54803. /**
  54804. * Mesh used as a pivot to rotate the attached mesh
  54805. */
  54806. private _anchorMesh;
  54807. private _existingMeshScale;
  54808. private _dragMesh;
  54809. private pointerDragBehavior;
  54810. private coloredMaterial;
  54811. private hoverColoredMaterial;
  54812. /**
  54813. * Sets the color of the bounding box gizmo
  54814. * @param color the color to set
  54815. */
  54816. setColor(color: Color3): void;
  54817. /**
  54818. * Creates an BoundingBoxGizmo
  54819. * @param gizmoLayer The utility layer the gizmo will be added to
  54820. * @param color The color of the gizmo
  54821. */
  54822. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  54823. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54824. private _selectNode;
  54825. /**
  54826. * Updates the bounding box information for the Gizmo
  54827. */
  54828. updateBoundingBox(): void;
  54829. private _updateRotationSpheres;
  54830. private _updateScaleBoxes;
  54831. /**
  54832. * Enables rotation on the specified axis and disables rotation on the others
  54833. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  54834. */
  54835. setEnabledRotationAxis(axis: string): void;
  54836. /**
  54837. * Enables/disables scaling
  54838. * @param enable if scaling should be enabled
  54839. * @param homogeneousScaling defines if scaling should only be homogeneous
  54840. */
  54841. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  54842. private _updateDummy;
  54843. /**
  54844. * Enables a pointer drag behavior on the bounding box of the gizmo
  54845. */
  54846. enableDragBehavior(): void;
  54847. /**
  54848. * Disposes of the gizmo
  54849. */
  54850. dispose(): void;
  54851. /**
  54852. * 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)
  54853. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  54854. * @returns the bounding box mesh with the passed in mesh as a child
  54855. */
  54856. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  54857. /**
  54858. * CustomMeshes are not supported by this gizmo
  54859. * @param mesh The mesh to replace the default mesh of the gizmo
  54860. */
  54861. setCustomMesh(mesh: Mesh): void;
  54862. }
  54863. }
  54864. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  54865. import { Observable } from "babylonjs/Misc/observable";
  54866. import { Nullable } from "babylonjs/types";
  54867. import { Vector3 } from "babylonjs/Maths/math.vector";
  54868. import { Color3 } from "babylonjs/Maths/math.color";
  54869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54870. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54871. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54872. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54873. import "babylonjs/Meshes/Builders/linesBuilder";
  54874. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  54875. /**
  54876. * Single plane rotation gizmo
  54877. */
  54878. export class PlaneRotationGizmo extends Gizmo {
  54879. /**
  54880. * Drag behavior responsible for the gizmos dragging interactions
  54881. */
  54882. dragBehavior: PointerDragBehavior;
  54883. private _pointerObserver;
  54884. /**
  54885. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  54886. */
  54887. snapDistance: number;
  54888. /**
  54889. * Event that fires each time the gizmo snaps to a new location.
  54890. * * snapDistance is the the change in distance
  54891. */
  54892. onSnapObservable: Observable<{
  54893. snapDistance: number;
  54894. }>;
  54895. private _isEnabled;
  54896. private _parent;
  54897. /**
  54898. * Creates a PlaneRotationGizmo
  54899. * @param gizmoLayer The utility layer the gizmo will be added to
  54900. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  54901. * @param color The color of the gizmo
  54902. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54903. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54904. */
  54905. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  54906. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54907. /**
  54908. * If the gizmo is enabled
  54909. */
  54910. set isEnabled(value: boolean);
  54911. get isEnabled(): boolean;
  54912. /**
  54913. * Disposes of the gizmo
  54914. */
  54915. dispose(): void;
  54916. }
  54917. }
  54918. declare module "babylonjs/Gizmos/rotationGizmo" {
  54919. import { Observable } from "babylonjs/Misc/observable";
  54920. import { Nullable } from "babylonjs/types";
  54921. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54922. import { Mesh } from "babylonjs/Meshes/mesh";
  54923. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54924. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  54925. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54926. /**
  54927. * Gizmo that enables rotating a mesh along 3 axis
  54928. */
  54929. export class RotationGizmo extends Gizmo {
  54930. /**
  54931. * Internal gizmo used for interactions on the x axis
  54932. */
  54933. xGizmo: PlaneRotationGizmo;
  54934. /**
  54935. * Internal gizmo used for interactions on the y axis
  54936. */
  54937. yGizmo: PlaneRotationGizmo;
  54938. /**
  54939. * Internal gizmo used for interactions on the z axis
  54940. */
  54941. zGizmo: PlaneRotationGizmo;
  54942. /** Fires an event when any of it's sub gizmos are dragged */
  54943. onDragStartObservable: Observable<unknown>;
  54944. /** Fires an event when any of it's sub gizmos are released from dragging */
  54945. onDragEndObservable: Observable<unknown>;
  54946. private _meshAttached;
  54947. get attachedMesh(): Nullable<AbstractMesh>;
  54948. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54949. /**
  54950. * Creates a RotationGizmo
  54951. * @param gizmoLayer The utility layer the gizmo will be added to
  54952. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54953. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54954. */
  54955. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  54956. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54957. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54958. /**
  54959. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54960. */
  54961. set snapDistance(value: number);
  54962. get snapDistance(): number;
  54963. /**
  54964. * Ratio for the scale of the gizmo (Default: 1)
  54965. */
  54966. set scaleRatio(value: number);
  54967. get scaleRatio(): number;
  54968. /**
  54969. * Disposes of the gizmo
  54970. */
  54971. dispose(): void;
  54972. /**
  54973. * CustomMeshes are not supported by this gizmo
  54974. * @param mesh The mesh to replace the default mesh of the gizmo
  54975. */
  54976. setCustomMesh(mesh: Mesh): void;
  54977. }
  54978. }
  54979. declare module "babylonjs/Gizmos/gizmoManager" {
  54980. import { Observable } from "babylonjs/Misc/observable";
  54981. import { Nullable } from "babylonjs/types";
  54982. import { Scene, IDisposable } from "babylonjs/scene";
  54983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54984. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54985. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  54986. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  54987. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  54988. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  54989. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  54990. /**
  54991. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  54992. */
  54993. export class GizmoManager implements IDisposable {
  54994. private scene;
  54995. /**
  54996. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  54997. */
  54998. gizmos: {
  54999. positionGizmo: Nullable<PositionGizmo>;
  55000. rotationGizmo: Nullable<RotationGizmo>;
  55001. scaleGizmo: Nullable<ScaleGizmo>;
  55002. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  55003. };
  55004. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  55005. clearGizmoOnEmptyPointerEvent: boolean;
  55006. /** Fires an event when the manager is attached to a mesh */
  55007. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  55008. private _gizmosEnabled;
  55009. private _pointerObserver;
  55010. private _attachedMesh;
  55011. private _boundingBoxColor;
  55012. private _defaultUtilityLayer;
  55013. private _defaultKeepDepthUtilityLayer;
  55014. /**
  55015. * When bounding box gizmo is enabled, this can be used to track drag/end events
  55016. */
  55017. boundingBoxDragBehavior: SixDofDragBehavior;
  55018. /**
  55019. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  55020. */
  55021. attachableMeshes: Nullable<Array<AbstractMesh>>;
  55022. /**
  55023. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  55024. */
  55025. usePointerToAttachGizmos: boolean;
  55026. /**
  55027. * Utility layer that the bounding box gizmo belongs to
  55028. */
  55029. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  55030. /**
  55031. * Utility layer that all gizmos besides bounding box belong to
  55032. */
  55033. get utilityLayer(): UtilityLayerRenderer;
  55034. /**
  55035. * Instatiates a gizmo manager
  55036. * @param scene the scene to overlay the gizmos on top of
  55037. */
  55038. constructor(scene: Scene);
  55039. /**
  55040. * Attaches a set of gizmos to the specified mesh
  55041. * @param mesh The mesh the gizmo's should be attached to
  55042. */
  55043. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55044. /**
  55045. * If the position gizmo is enabled
  55046. */
  55047. set positionGizmoEnabled(value: boolean);
  55048. get positionGizmoEnabled(): boolean;
  55049. /**
  55050. * If the rotation gizmo is enabled
  55051. */
  55052. set rotationGizmoEnabled(value: boolean);
  55053. get rotationGizmoEnabled(): boolean;
  55054. /**
  55055. * If the scale gizmo is enabled
  55056. */
  55057. set scaleGizmoEnabled(value: boolean);
  55058. get scaleGizmoEnabled(): boolean;
  55059. /**
  55060. * If the boundingBox gizmo is enabled
  55061. */
  55062. set boundingBoxGizmoEnabled(value: boolean);
  55063. get boundingBoxGizmoEnabled(): boolean;
  55064. /**
  55065. * Disposes of the gizmo manager
  55066. */
  55067. dispose(): void;
  55068. }
  55069. }
  55070. declare module "babylonjs/Lights/directionalLight" {
  55071. import { Camera } from "babylonjs/Cameras/camera";
  55072. import { Scene } from "babylonjs/scene";
  55073. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55075. import { Light } from "babylonjs/Lights/light";
  55076. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55077. import { Effect } from "babylonjs/Materials/effect";
  55078. /**
  55079. * A directional light is defined by a direction (what a surprise!).
  55080. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  55081. * 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.
  55082. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55083. */
  55084. export class DirectionalLight extends ShadowLight {
  55085. private _shadowFrustumSize;
  55086. /**
  55087. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  55088. */
  55089. get shadowFrustumSize(): number;
  55090. /**
  55091. * Specifies a fix frustum size for the shadow generation.
  55092. */
  55093. set shadowFrustumSize(value: number);
  55094. private _shadowOrthoScale;
  55095. /**
  55096. * Gets the shadow projection scale against the optimal computed one.
  55097. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  55098. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  55099. */
  55100. get shadowOrthoScale(): number;
  55101. /**
  55102. * Sets the shadow projection scale against the optimal computed one.
  55103. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  55104. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  55105. */
  55106. set shadowOrthoScale(value: number);
  55107. /**
  55108. * Automatically compute the projection matrix to best fit (including all the casters)
  55109. * on each frame.
  55110. */
  55111. autoUpdateExtends: boolean;
  55112. /**
  55113. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  55114. * on each frame. autoUpdateExtends must be set to true for this to work
  55115. */
  55116. autoCalcShadowZBounds: boolean;
  55117. private _orthoLeft;
  55118. private _orthoRight;
  55119. private _orthoTop;
  55120. private _orthoBottom;
  55121. /**
  55122. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  55123. * The directional light is emitted from everywhere in the given direction.
  55124. * It can cast shadows.
  55125. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55126. * @param name The friendly name of the light
  55127. * @param direction The direction of the light
  55128. * @param scene The scene the light belongs to
  55129. */
  55130. constructor(name: string, direction: Vector3, scene: Scene);
  55131. /**
  55132. * Returns the string "DirectionalLight".
  55133. * @return The class name
  55134. */
  55135. getClassName(): string;
  55136. /**
  55137. * Returns the integer 1.
  55138. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55139. */
  55140. getTypeID(): number;
  55141. /**
  55142. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  55143. * Returns the DirectionalLight Shadow projection matrix.
  55144. */
  55145. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55146. /**
  55147. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  55148. * Returns the DirectionalLight Shadow projection matrix.
  55149. */
  55150. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  55151. /**
  55152. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  55153. * Returns the DirectionalLight Shadow projection matrix.
  55154. */
  55155. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55156. protected _buildUniformLayout(): void;
  55157. /**
  55158. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  55159. * @param effect The effect to update
  55160. * @param lightIndex The index of the light in the effect to update
  55161. * @returns The directional light
  55162. */
  55163. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  55164. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  55165. /**
  55166. * Gets the minZ used for shadow according to both the scene and the light.
  55167. *
  55168. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55169. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55170. * @param activeCamera The camera we are returning the min for
  55171. * @returns the depth min z
  55172. */
  55173. getDepthMinZ(activeCamera: Camera): number;
  55174. /**
  55175. * Gets the maxZ used for shadow according to both the scene and the light.
  55176. *
  55177. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55178. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55179. * @param activeCamera The camera we are returning the max for
  55180. * @returns the depth max z
  55181. */
  55182. getDepthMaxZ(activeCamera: Camera): number;
  55183. /**
  55184. * Prepares the list of defines specific to the light type.
  55185. * @param defines the list of defines
  55186. * @param lightIndex defines the index of the light for the effect
  55187. */
  55188. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55189. }
  55190. }
  55191. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  55192. import { Mesh } from "babylonjs/Meshes/mesh";
  55193. /**
  55194. * Class containing static functions to help procedurally build meshes
  55195. */
  55196. export class HemisphereBuilder {
  55197. /**
  55198. * Creates a hemisphere mesh
  55199. * @param name defines the name of the mesh
  55200. * @param options defines the options used to create the mesh
  55201. * @param scene defines the hosting scene
  55202. * @returns the hemisphere mesh
  55203. */
  55204. static CreateHemisphere(name: string, options: {
  55205. segments?: number;
  55206. diameter?: number;
  55207. sideOrientation?: number;
  55208. }, scene: any): Mesh;
  55209. }
  55210. }
  55211. declare module "babylonjs/Lights/spotLight" {
  55212. import { Nullable } from "babylonjs/types";
  55213. import { Scene } from "babylonjs/scene";
  55214. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55215. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55216. import { Effect } from "babylonjs/Materials/effect";
  55217. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55218. import { Light } from "babylonjs/Lights/light";
  55219. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55220. /**
  55221. * A spot light is defined by a position, a direction, an angle, and an exponent.
  55222. * These values define a cone of light starting from the position, emitting toward the direction.
  55223. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  55224. * and the exponent defines the speed of the decay of the light with distance (reach).
  55225. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55226. */
  55227. export class SpotLight extends ShadowLight {
  55228. private _angle;
  55229. private _innerAngle;
  55230. private _cosHalfAngle;
  55231. private _lightAngleScale;
  55232. private _lightAngleOffset;
  55233. /**
  55234. * Gets the cone angle of the spot light in Radians.
  55235. */
  55236. get angle(): number;
  55237. /**
  55238. * Sets the cone angle of the spot light in Radians.
  55239. */
  55240. set angle(value: number);
  55241. /**
  55242. * Only used in gltf falloff mode, this defines the angle where
  55243. * the directional falloff will start before cutting at angle which could be seen
  55244. * as outer angle.
  55245. */
  55246. get innerAngle(): number;
  55247. /**
  55248. * Only used in gltf falloff mode, this defines the angle where
  55249. * the directional falloff will start before cutting at angle which could be seen
  55250. * as outer angle.
  55251. */
  55252. set innerAngle(value: number);
  55253. private _shadowAngleScale;
  55254. /**
  55255. * Allows scaling the angle of the light for shadow generation only.
  55256. */
  55257. get shadowAngleScale(): number;
  55258. /**
  55259. * Allows scaling the angle of the light for shadow generation only.
  55260. */
  55261. set shadowAngleScale(value: number);
  55262. /**
  55263. * The light decay speed with the distance from the emission spot.
  55264. */
  55265. exponent: number;
  55266. private _projectionTextureMatrix;
  55267. /**
  55268. * Allows reading the projecton texture
  55269. */
  55270. get projectionTextureMatrix(): Matrix;
  55271. protected _projectionTextureLightNear: number;
  55272. /**
  55273. * Gets the near clip of the Spotlight for texture projection.
  55274. */
  55275. get projectionTextureLightNear(): number;
  55276. /**
  55277. * Sets the near clip of the Spotlight for texture projection.
  55278. */
  55279. set projectionTextureLightNear(value: number);
  55280. protected _projectionTextureLightFar: number;
  55281. /**
  55282. * Gets the far clip of the Spotlight for texture projection.
  55283. */
  55284. get projectionTextureLightFar(): number;
  55285. /**
  55286. * Sets the far clip of the Spotlight for texture projection.
  55287. */
  55288. set projectionTextureLightFar(value: number);
  55289. protected _projectionTextureUpDirection: Vector3;
  55290. /**
  55291. * Gets the Up vector of the Spotlight for texture projection.
  55292. */
  55293. get projectionTextureUpDirection(): Vector3;
  55294. /**
  55295. * Sets the Up vector of the Spotlight for texture projection.
  55296. */
  55297. set projectionTextureUpDirection(value: Vector3);
  55298. private _projectionTexture;
  55299. /**
  55300. * Gets the projection texture of the light.
  55301. */
  55302. get projectionTexture(): Nullable<BaseTexture>;
  55303. /**
  55304. * Sets the projection texture of the light.
  55305. */
  55306. set projectionTexture(value: Nullable<BaseTexture>);
  55307. private _projectionTextureViewLightDirty;
  55308. private _projectionTextureProjectionLightDirty;
  55309. private _projectionTextureDirty;
  55310. private _projectionTextureViewTargetVector;
  55311. private _projectionTextureViewLightMatrix;
  55312. private _projectionTextureProjectionLightMatrix;
  55313. private _projectionTextureScalingMatrix;
  55314. /**
  55315. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  55316. * It can cast shadows.
  55317. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55318. * @param name The light friendly name
  55319. * @param position The position of the spot light in the scene
  55320. * @param direction The direction of the light in the scene
  55321. * @param angle The cone angle of the light in Radians
  55322. * @param exponent The light decay speed with the distance from the emission spot
  55323. * @param scene The scene the lights belongs to
  55324. */
  55325. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  55326. /**
  55327. * Returns the string "SpotLight".
  55328. * @returns the class name
  55329. */
  55330. getClassName(): string;
  55331. /**
  55332. * Returns the integer 2.
  55333. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55334. */
  55335. getTypeID(): number;
  55336. /**
  55337. * Overrides the direction setter to recompute the projection texture view light Matrix.
  55338. */
  55339. protected _setDirection(value: Vector3): void;
  55340. /**
  55341. * Overrides the position setter to recompute the projection texture view light Matrix.
  55342. */
  55343. protected _setPosition(value: Vector3): void;
  55344. /**
  55345. * 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.
  55346. * Returns the SpotLight.
  55347. */
  55348. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55349. protected _computeProjectionTextureViewLightMatrix(): void;
  55350. protected _computeProjectionTextureProjectionLightMatrix(): void;
  55351. /**
  55352. * Main function for light texture projection matrix computing.
  55353. */
  55354. protected _computeProjectionTextureMatrix(): void;
  55355. protected _buildUniformLayout(): void;
  55356. private _computeAngleValues;
  55357. /**
  55358. * Sets the passed Effect "effect" with the Light textures.
  55359. * @param effect The effect to update
  55360. * @param lightIndex The index of the light in the effect to update
  55361. * @returns The light
  55362. */
  55363. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  55364. /**
  55365. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  55366. * @param effect The effect to update
  55367. * @param lightIndex The index of the light in the effect to update
  55368. * @returns The spot light
  55369. */
  55370. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  55371. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55372. /**
  55373. * Disposes the light and the associated resources.
  55374. */
  55375. dispose(): void;
  55376. /**
  55377. * Prepares the list of defines specific to the light type.
  55378. * @param defines the list of defines
  55379. * @param lightIndex defines the index of the light for the effect
  55380. */
  55381. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55382. }
  55383. }
  55384. declare module "babylonjs/Gizmos/lightGizmo" {
  55385. import { Nullable } from "babylonjs/types";
  55386. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55387. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55388. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55389. import { Light } from "babylonjs/Lights/light";
  55390. /**
  55391. * Gizmo that enables viewing a light
  55392. */
  55393. export class LightGizmo extends Gizmo {
  55394. private _lightMesh;
  55395. private _material;
  55396. private _cachedPosition;
  55397. private _cachedForward;
  55398. private _attachedMeshParent;
  55399. /**
  55400. * Creates a LightGizmo
  55401. * @param gizmoLayer The utility layer the gizmo will be added to
  55402. */
  55403. constructor(gizmoLayer?: UtilityLayerRenderer);
  55404. private _light;
  55405. /**
  55406. * The light that the gizmo is attached to
  55407. */
  55408. set light(light: Nullable<Light>);
  55409. get light(): Nullable<Light>;
  55410. /**
  55411. * Gets the material used to render the light gizmo
  55412. */
  55413. get material(): StandardMaterial;
  55414. /**
  55415. * @hidden
  55416. * Updates the gizmo to match the attached mesh's position/rotation
  55417. */
  55418. protected _update(): void;
  55419. private static _Scale;
  55420. /**
  55421. * Creates the lines for a light mesh
  55422. */
  55423. private static _CreateLightLines;
  55424. /**
  55425. * Disposes of the light gizmo
  55426. */
  55427. dispose(): void;
  55428. private static _CreateHemisphericLightMesh;
  55429. private static _CreatePointLightMesh;
  55430. private static _CreateSpotLightMesh;
  55431. private static _CreateDirectionalLightMesh;
  55432. }
  55433. }
  55434. declare module "babylonjs/Gizmos/index" {
  55435. export * from "babylonjs/Gizmos/axisDragGizmo";
  55436. export * from "babylonjs/Gizmos/axisScaleGizmo";
  55437. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  55438. export * from "babylonjs/Gizmos/gizmo";
  55439. export * from "babylonjs/Gizmos/gizmoManager";
  55440. export * from "babylonjs/Gizmos/planeRotationGizmo";
  55441. export * from "babylonjs/Gizmos/positionGizmo";
  55442. export * from "babylonjs/Gizmos/rotationGizmo";
  55443. export * from "babylonjs/Gizmos/scaleGizmo";
  55444. export * from "babylonjs/Gizmos/lightGizmo";
  55445. export * from "babylonjs/Gizmos/planeDragGizmo";
  55446. }
  55447. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  55448. /** @hidden */
  55449. export var backgroundFragmentDeclaration: {
  55450. name: string;
  55451. shader: string;
  55452. };
  55453. }
  55454. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  55455. /** @hidden */
  55456. export var backgroundUboDeclaration: {
  55457. name: string;
  55458. shader: string;
  55459. };
  55460. }
  55461. declare module "babylonjs/Shaders/background.fragment" {
  55462. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  55463. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  55464. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55465. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  55466. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  55467. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  55468. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55469. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  55470. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  55471. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  55472. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  55473. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  55474. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  55475. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  55476. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  55477. /** @hidden */
  55478. export var backgroundPixelShader: {
  55479. name: string;
  55480. shader: string;
  55481. };
  55482. }
  55483. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  55484. /** @hidden */
  55485. export var backgroundVertexDeclaration: {
  55486. name: string;
  55487. shader: string;
  55488. };
  55489. }
  55490. declare module "babylonjs/Shaders/background.vertex" {
  55491. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  55492. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  55493. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55494. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55495. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55496. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  55497. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  55498. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  55499. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  55500. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55501. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55502. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  55503. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  55504. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  55505. /** @hidden */
  55506. export var backgroundVertexShader: {
  55507. name: string;
  55508. shader: string;
  55509. };
  55510. }
  55511. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  55512. import { Nullable, int, float } from "babylonjs/types";
  55513. import { Scene } from "babylonjs/scene";
  55514. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55515. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55517. import { Mesh } from "babylonjs/Meshes/mesh";
  55518. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55519. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  55520. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  55521. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55522. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  55523. import { Color3 } from "babylonjs/Maths/math.color";
  55524. import "babylonjs/Shaders/background.fragment";
  55525. import "babylonjs/Shaders/background.vertex";
  55526. /**
  55527. * Background material used to create an efficient environement around your scene.
  55528. */
  55529. export class BackgroundMaterial extends PushMaterial {
  55530. /**
  55531. * Standard reflectance value at parallel view angle.
  55532. */
  55533. static StandardReflectance0: number;
  55534. /**
  55535. * Standard reflectance value at grazing angle.
  55536. */
  55537. static StandardReflectance90: number;
  55538. protected _primaryColor: Color3;
  55539. /**
  55540. * Key light Color (multiply against the environement texture)
  55541. */
  55542. primaryColor: Color3;
  55543. protected __perceptualColor: Nullable<Color3>;
  55544. /**
  55545. * Experimental Internal Use Only.
  55546. *
  55547. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  55548. * This acts as a helper to set the primary color to a more "human friendly" value.
  55549. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  55550. * output color as close as possible from the chosen value.
  55551. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  55552. * part of lighting setup.)
  55553. */
  55554. get _perceptualColor(): Nullable<Color3>;
  55555. set _perceptualColor(value: Nullable<Color3>);
  55556. protected _primaryColorShadowLevel: float;
  55557. /**
  55558. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  55559. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  55560. */
  55561. get primaryColorShadowLevel(): float;
  55562. set primaryColorShadowLevel(value: float);
  55563. protected _primaryColorHighlightLevel: float;
  55564. /**
  55565. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  55566. * The primary color is used at the level chosen to define what the white area would look.
  55567. */
  55568. get primaryColorHighlightLevel(): float;
  55569. set primaryColorHighlightLevel(value: float);
  55570. protected _reflectionTexture: Nullable<BaseTexture>;
  55571. /**
  55572. * Reflection Texture used in the material.
  55573. * Should be author in a specific way for the best result (refer to the documentation).
  55574. */
  55575. reflectionTexture: Nullable<BaseTexture>;
  55576. protected _reflectionBlur: float;
  55577. /**
  55578. * Reflection Texture level of blur.
  55579. *
  55580. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  55581. * texture twice.
  55582. */
  55583. reflectionBlur: float;
  55584. protected _diffuseTexture: Nullable<BaseTexture>;
  55585. /**
  55586. * Diffuse Texture used in the material.
  55587. * Should be author in a specific way for the best result (refer to the documentation).
  55588. */
  55589. diffuseTexture: Nullable<BaseTexture>;
  55590. protected _shadowLights: Nullable<IShadowLight[]>;
  55591. /**
  55592. * Specify the list of lights casting shadow on the material.
  55593. * All scene shadow lights will be included if null.
  55594. */
  55595. shadowLights: Nullable<IShadowLight[]>;
  55596. protected _shadowLevel: float;
  55597. /**
  55598. * Helps adjusting the shadow to a softer level if required.
  55599. * 0 means black shadows and 1 means no shadows.
  55600. */
  55601. shadowLevel: float;
  55602. protected _sceneCenter: Vector3;
  55603. /**
  55604. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  55605. * It is usually zero but might be interesting to modify according to your setup.
  55606. */
  55607. sceneCenter: Vector3;
  55608. protected _opacityFresnel: boolean;
  55609. /**
  55610. * This helps specifying that the material is falling off to the sky box at grazing angle.
  55611. * This helps ensuring a nice transition when the camera goes under the ground.
  55612. */
  55613. opacityFresnel: boolean;
  55614. protected _reflectionFresnel: boolean;
  55615. /**
  55616. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  55617. * This helps adding a mirror texture on the ground.
  55618. */
  55619. reflectionFresnel: boolean;
  55620. protected _reflectionFalloffDistance: number;
  55621. /**
  55622. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  55623. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  55624. */
  55625. reflectionFalloffDistance: number;
  55626. protected _reflectionAmount: number;
  55627. /**
  55628. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  55629. */
  55630. reflectionAmount: number;
  55631. protected _reflectionReflectance0: number;
  55632. /**
  55633. * This specifies the weight of the reflection at grazing angle.
  55634. */
  55635. reflectionReflectance0: number;
  55636. protected _reflectionReflectance90: number;
  55637. /**
  55638. * This specifies the weight of the reflection at a perpendicular point of view.
  55639. */
  55640. reflectionReflectance90: number;
  55641. /**
  55642. * Sets the reflection reflectance fresnel values according to the default standard
  55643. * empirically know to work well :-)
  55644. */
  55645. set reflectionStandardFresnelWeight(value: number);
  55646. protected _useRGBColor: boolean;
  55647. /**
  55648. * Helps to directly use the maps channels instead of their level.
  55649. */
  55650. useRGBColor: boolean;
  55651. protected _enableNoise: boolean;
  55652. /**
  55653. * This helps reducing the banding effect that could occur on the background.
  55654. */
  55655. enableNoise: boolean;
  55656. /**
  55657. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55658. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  55659. * Recommended to be keep at 1.0 except for special cases.
  55660. */
  55661. get fovMultiplier(): number;
  55662. set fovMultiplier(value: number);
  55663. private _fovMultiplier;
  55664. /**
  55665. * Enable the FOV adjustment feature controlled by fovMultiplier.
  55666. */
  55667. useEquirectangularFOV: boolean;
  55668. private _maxSimultaneousLights;
  55669. /**
  55670. * Number of Simultaneous lights allowed on the material.
  55671. */
  55672. maxSimultaneousLights: int;
  55673. private _shadowOnly;
  55674. /**
  55675. * Make the material only render shadows
  55676. */
  55677. shadowOnly: boolean;
  55678. /**
  55679. * Default configuration related to image processing available in the Background Material.
  55680. */
  55681. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55682. /**
  55683. * Keep track of the image processing observer to allow dispose and replace.
  55684. */
  55685. private _imageProcessingObserver;
  55686. /**
  55687. * Attaches a new image processing configuration to the PBR Material.
  55688. * @param configuration (if null the scene configuration will be use)
  55689. */
  55690. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55691. /**
  55692. * Gets the image processing configuration used either in this material.
  55693. */
  55694. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  55695. /**
  55696. * Sets the Default image processing configuration used either in the this material.
  55697. *
  55698. * If sets to null, the scene one is in use.
  55699. */
  55700. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  55701. /**
  55702. * Gets wether the color curves effect is enabled.
  55703. */
  55704. get cameraColorCurvesEnabled(): boolean;
  55705. /**
  55706. * Sets wether the color curves effect is enabled.
  55707. */
  55708. set cameraColorCurvesEnabled(value: boolean);
  55709. /**
  55710. * Gets wether the color grading effect is enabled.
  55711. */
  55712. get cameraColorGradingEnabled(): boolean;
  55713. /**
  55714. * Gets wether the color grading effect is enabled.
  55715. */
  55716. set cameraColorGradingEnabled(value: boolean);
  55717. /**
  55718. * Gets wether tonemapping is enabled or not.
  55719. */
  55720. get cameraToneMappingEnabled(): boolean;
  55721. /**
  55722. * Sets wether tonemapping is enabled or not
  55723. */
  55724. set cameraToneMappingEnabled(value: boolean);
  55725. /**
  55726. * The camera exposure used on this material.
  55727. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55728. * This corresponds to a photographic exposure.
  55729. */
  55730. get cameraExposure(): float;
  55731. /**
  55732. * The camera exposure used on this material.
  55733. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55734. * This corresponds to a photographic exposure.
  55735. */
  55736. set cameraExposure(value: float);
  55737. /**
  55738. * Gets The camera contrast used on this material.
  55739. */
  55740. get cameraContrast(): float;
  55741. /**
  55742. * Sets The camera contrast used on this material.
  55743. */
  55744. set cameraContrast(value: float);
  55745. /**
  55746. * Gets the Color Grading 2D Lookup Texture.
  55747. */
  55748. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55749. /**
  55750. * Sets the Color Grading 2D Lookup Texture.
  55751. */
  55752. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55753. /**
  55754. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55755. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55756. * 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;
  55757. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55758. */
  55759. get cameraColorCurves(): Nullable<ColorCurves>;
  55760. /**
  55761. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55762. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55763. * 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;
  55764. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55765. */
  55766. set cameraColorCurves(value: Nullable<ColorCurves>);
  55767. /**
  55768. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  55769. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  55770. */
  55771. switchToBGR: boolean;
  55772. private _renderTargets;
  55773. private _reflectionControls;
  55774. private _white;
  55775. private _primaryShadowColor;
  55776. private _primaryHighlightColor;
  55777. /**
  55778. * Instantiates a Background Material in the given scene
  55779. * @param name The friendly name of the material
  55780. * @param scene The scene to add the material to
  55781. */
  55782. constructor(name: string, scene: Scene);
  55783. /**
  55784. * Gets a boolean indicating that current material needs to register RTT
  55785. */
  55786. get hasRenderTargetTextures(): boolean;
  55787. /**
  55788. * The entire material has been created in order to prevent overdraw.
  55789. * @returns false
  55790. */
  55791. needAlphaTesting(): boolean;
  55792. /**
  55793. * The entire material has been created in order to prevent overdraw.
  55794. * @returns true if blending is enable
  55795. */
  55796. needAlphaBlending(): boolean;
  55797. /**
  55798. * Checks wether the material is ready to be rendered for a given mesh.
  55799. * @param mesh The mesh to render
  55800. * @param subMesh The submesh to check against
  55801. * @param useInstances Specify wether or not the material is used with instances
  55802. * @returns true if all the dependencies are ready (Textures, Effects...)
  55803. */
  55804. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55805. /**
  55806. * Compute the primary color according to the chosen perceptual color.
  55807. */
  55808. private _computePrimaryColorFromPerceptualColor;
  55809. /**
  55810. * Compute the highlights and shadow colors according to their chosen levels.
  55811. */
  55812. private _computePrimaryColors;
  55813. /**
  55814. * Build the uniform buffer used in the material.
  55815. */
  55816. buildUniformLayout(): void;
  55817. /**
  55818. * Unbind the material.
  55819. */
  55820. unbind(): void;
  55821. /**
  55822. * Bind only the world matrix to the material.
  55823. * @param world The world matrix to bind.
  55824. */
  55825. bindOnlyWorldMatrix(world: Matrix): void;
  55826. /**
  55827. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  55828. * @param world The world matrix to bind.
  55829. * @param subMesh The submesh to bind for.
  55830. */
  55831. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55832. /**
  55833. * Checks to see if a texture is used in the material.
  55834. * @param texture - Base texture to use.
  55835. * @returns - Boolean specifying if a texture is used in the material.
  55836. */
  55837. hasTexture(texture: BaseTexture): boolean;
  55838. /**
  55839. * Dispose the material.
  55840. * @param forceDisposeEffect Force disposal of the associated effect.
  55841. * @param forceDisposeTextures Force disposal of the associated textures.
  55842. */
  55843. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55844. /**
  55845. * Clones the material.
  55846. * @param name The cloned name.
  55847. * @returns The cloned material.
  55848. */
  55849. clone(name: string): BackgroundMaterial;
  55850. /**
  55851. * Serializes the current material to its JSON representation.
  55852. * @returns The JSON representation.
  55853. */
  55854. serialize(): any;
  55855. /**
  55856. * Gets the class name of the material
  55857. * @returns "BackgroundMaterial"
  55858. */
  55859. getClassName(): string;
  55860. /**
  55861. * Parse a JSON input to create back a background material.
  55862. * @param source The JSON data to parse
  55863. * @param scene The scene to create the parsed material in
  55864. * @param rootUrl The root url of the assets the material depends upon
  55865. * @returns the instantiated BackgroundMaterial.
  55866. */
  55867. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  55868. }
  55869. }
  55870. declare module "babylonjs/Helpers/environmentHelper" {
  55871. import { Observable } from "babylonjs/Misc/observable";
  55872. import { Nullable } from "babylonjs/types";
  55873. import { Scene } from "babylonjs/scene";
  55874. import { Vector3 } from "babylonjs/Maths/math.vector";
  55875. import { Color3 } from "babylonjs/Maths/math.color";
  55876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55877. import { Mesh } from "babylonjs/Meshes/mesh";
  55878. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55879. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  55880. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55881. import "babylonjs/Meshes/Builders/planeBuilder";
  55882. import "babylonjs/Meshes/Builders/boxBuilder";
  55883. /**
  55884. * Represents the different options available during the creation of
  55885. * a Environment helper.
  55886. *
  55887. * This can control the default ground, skybox and image processing setup of your scene.
  55888. */
  55889. export interface IEnvironmentHelperOptions {
  55890. /**
  55891. * Specifies whether or not to create a ground.
  55892. * True by default.
  55893. */
  55894. createGround: boolean;
  55895. /**
  55896. * Specifies the ground size.
  55897. * 15 by default.
  55898. */
  55899. groundSize: number;
  55900. /**
  55901. * The texture used on the ground for the main color.
  55902. * Comes from the BabylonJS CDN by default.
  55903. *
  55904. * Remarks: Can be either a texture or a url.
  55905. */
  55906. groundTexture: string | BaseTexture;
  55907. /**
  55908. * The color mixed in the ground texture by default.
  55909. * BabylonJS clearColor by default.
  55910. */
  55911. groundColor: Color3;
  55912. /**
  55913. * Specifies the ground opacity.
  55914. * 1 by default.
  55915. */
  55916. groundOpacity: number;
  55917. /**
  55918. * Enables the ground to receive shadows.
  55919. * True by default.
  55920. */
  55921. enableGroundShadow: boolean;
  55922. /**
  55923. * Helps preventing the shadow to be fully black on the ground.
  55924. * 0.5 by default.
  55925. */
  55926. groundShadowLevel: number;
  55927. /**
  55928. * Creates a mirror texture attach to the ground.
  55929. * false by default.
  55930. */
  55931. enableGroundMirror: boolean;
  55932. /**
  55933. * Specifies the ground mirror size ratio.
  55934. * 0.3 by default as the default kernel is 64.
  55935. */
  55936. groundMirrorSizeRatio: number;
  55937. /**
  55938. * Specifies the ground mirror blur kernel size.
  55939. * 64 by default.
  55940. */
  55941. groundMirrorBlurKernel: number;
  55942. /**
  55943. * Specifies the ground mirror visibility amount.
  55944. * 1 by default
  55945. */
  55946. groundMirrorAmount: number;
  55947. /**
  55948. * Specifies the ground mirror reflectance weight.
  55949. * This uses the standard weight of the background material to setup the fresnel effect
  55950. * of the mirror.
  55951. * 1 by default.
  55952. */
  55953. groundMirrorFresnelWeight: number;
  55954. /**
  55955. * Specifies the ground mirror Falloff distance.
  55956. * This can helps reducing the size of the reflection.
  55957. * 0 by Default.
  55958. */
  55959. groundMirrorFallOffDistance: number;
  55960. /**
  55961. * Specifies the ground mirror texture type.
  55962. * Unsigned Int by Default.
  55963. */
  55964. groundMirrorTextureType: number;
  55965. /**
  55966. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  55967. * the shown objects.
  55968. */
  55969. groundYBias: number;
  55970. /**
  55971. * Specifies whether or not to create a skybox.
  55972. * True by default.
  55973. */
  55974. createSkybox: boolean;
  55975. /**
  55976. * Specifies the skybox size.
  55977. * 20 by default.
  55978. */
  55979. skyboxSize: number;
  55980. /**
  55981. * The texture used on the skybox for the main color.
  55982. * Comes from the BabylonJS CDN by default.
  55983. *
  55984. * Remarks: Can be either a texture or a url.
  55985. */
  55986. skyboxTexture: string | BaseTexture;
  55987. /**
  55988. * The color mixed in the skybox texture by default.
  55989. * BabylonJS clearColor by default.
  55990. */
  55991. skyboxColor: Color3;
  55992. /**
  55993. * The background rotation around the Y axis of the scene.
  55994. * This helps aligning the key lights of your scene with the background.
  55995. * 0 by default.
  55996. */
  55997. backgroundYRotation: number;
  55998. /**
  55999. * Compute automatically the size of the elements to best fit with the scene.
  56000. */
  56001. sizeAuto: boolean;
  56002. /**
  56003. * Default position of the rootMesh if autoSize is not true.
  56004. */
  56005. rootPosition: Vector3;
  56006. /**
  56007. * Sets up the image processing in the scene.
  56008. * true by default.
  56009. */
  56010. setupImageProcessing: boolean;
  56011. /**
  56012. * The texture used as your environment texture in the scene.
  56013. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  56014. *
  56015. * Remarks: Can be either a texture or a url.
  56016. */
  56017. environmentTexture: string | BaseTexture;
  56018. /**
  56019. * The value of the exposure to apply to the scene.
  56020. * 0.6 by default if setupImageProcessing is true.
  56021. */
  56022. cameraExposure: number;
  56023. /**
  56024. * The value of the contrast to apply to the scene.
  56025. * 1.6 by default if setupImageProcessing is true.
  56026. */
  56027. cameraContrast: number;
  56028. /**
  56029. * Specifies whether or not tonemapping should be enabled in the scene.
  56030. * true by default if setupImageProcessing is true.
  56031. */
  56032. toneMappingEnabled: boolean;
  56033. }
  56034. /**
  56035. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  56036. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  56037. * It also helps with the default setup of your imageProcessing configuration.
  56038. */
  56039. export class EnvironmentHelper {
  56040. /**
  56041. * Default ground texture URL.
  56042. */
  56043. private static _groundTextureCDNUrl;
  56044. /**
  56045. * Default skybox texture URL.
  56046. */
  56047. private static _skyboxTextureCDNUrl;
  56048. /**
  56049. * Default environment texture URL.
  56050. */
  56051. private static _environmentTextureCDNUrl;
  56052. /**
  56053. * Creates the default options for the helper.
  56054. */
  56055. private static _getDefaultOptions;
  56056. private _rootMesh;
  56057. /**
  56058. * Gets the root mesh created by the helper.
  56059. */
  56060. get rootMesh(): Mesh;
  56061. private _skybox;
  56062. /**
  56063. * Gets the skybox created by the helper.
  56064. */
  56065. get skybox(): Nullable<Mesh>;
  56066. private _skyboxTexture;
  56067. /**
  56068. * Gets the skybox texture created by the helper.
  56069. */
  56070. get skyboxTexture(): Nullable<BaseTexture>;
  56071. private _skyboxMaterial;
  56072. /**
  56073. * Gets the skybox material created by the helper.
  56074. */
  56075. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  56076. private _ground;
  56077. /**
  56078. * Gets the ground mesh created by the helper.
  56079. */
  56080. get ground(): Nullable<Mesh>;
  56081. private _groundTexture;
  56082. /**
  56083. * Gets the ground texture created by the helper.
  56084. */
  56085. get groundTexture(): Nullable<BaseTexture>;
  56086. private _groundMirror;
  56087. /**
  56088. * Gets the ground mirror created by the helper.
  56089. */
  56090. get groundMirror(): Nullable<MirrorTexture>;
  56091. /**
  56092. * Gets the ground mirror render list to helps pushing the meshes
  56093. * you wish in the ground reflection.
  56094. */
  56095. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  56096. private _groundMaterial;
  56097. /**
  56098. * Gets the ground material created by the helper.
  56099. */
  56100. get groundMaterial(): Nullable<BackgroundMaterial>;
  56101. /**
  56102. * Stores the creation options.
  56103. */
  56104. private readonly _scene;
  56105. private _options;
  56106. /**
  56107. * This observable will be notified with any error during the creation of the environment,
  56108. * mainly texture creation errors.
  56109. */
  56110. onErrorObservable: Observable<{
  56111. message?: string;
  56112. exception?: any;
  56113. }>;
  56114. /**
  56115. * constructor
  56116. * @param options Defines the options we want to customize the helper
  56117. * @param scene The scene to add the material to
  56118. */
  56119. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  56120. /**
  56121. * Updates the background according to the new options
  56122. * @param options
  56123. */
  56124. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  56125. /**
  56126. * Sets the primary color of all the available elements.
  56127. * @param color the main color to affect to the ground and the background
  56128. */
  56129. setMainColor(color: Color3): void;
  56130. /**
  56131. * Setup the image processing according to the specified options.
  56132. */
  56133. private _setupImageProcessing;
  56134. /**
  56135. * Setup the environment texture according to the specified options.
  56136. */
  56137. private _setupEnvironmentTexture;
  56138. /**
  56139. * Setup the background according to the specified options.
  56140. */
  56141. private _setupBackground;
  56142. /**
  56143. * Get the scene sizes according to the setup.
  56144. */
  56145. private _getSceneSize;
  56146. /**
  56147. * Setup the ground according to the specified options.
  56148. */
  56149. private _setupGround;
  56150. /**
  56151. * Setup the ground material according to the specified options.
  56152. */
  56153. private _setupGroundMaterial;
  56154. /**
  56155. * Setup the ground diffuse texture according to the specified options.
  56156. */
  56157. private _setupGroundDiffuseTexture;
  56158. /**
  56159. * Setup the ground mirror texture according to the specified options.
  56160. */
  56161. private _setupGroundMirrorTexture;
  56162. /**
  56163. * Setup the ground to receive the mirror texture.
  56164. */
  56165. private _setupMirrorInGroundMaterial;
  56166. /**
  56167. * Setup the skybox according to the specified options.
  56168. */
  56169. private _setupSkybox;
  56170. /**
  56171. * Setup the skybox material according to the specified options.
  56172. */
  56173. private _setupSkyboxMaterial;
  56174. /**
  56175. * Setup the skybox reflection texture according to the specified options.
  56176. */
  56177. private _setupSkyboxReflectionTexture;
  56178. private _errorHandler;
  56179. /**
  56180. * Dispose all the elements created by the Helper.
  56181. */
  56182. dispose(): void;
  56183. }
  56184. }
  56185. declare module "babylonjs/Helpers/photoDome" {
  56186. import { Observable } from "babylonjs/Misc/observable";
  56187. import { Nullable } from "babylonjs/types";
  56188. import { Scene } from "babylonjs/scene";
  56189. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56190. import { Mesh } from "babylonjs/Meshes/mesh";
  56191. import { Texture } from "babylonjs/Materials/Textures/texture";
  56192. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  56193. import "babylonjs/Meshes/Builders/sphereBuilder";
  56194. /**
  56195. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  56196. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  56197. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  56198. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56199. */
  56200. export class PhotoDome extends TransformNode {
  56201. /**
  56202. * Define the image as a Monoscopic panoramic 360 image.
  56203. */
  56204. static readonly MODE_MONOSCOPIC: number;
  56205. /**
  56206. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  56207. */
  56208. static readonly MODE_TOPBOTTOM: number;
  56209. /**
  56210. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  56211. */
  56212. static readonly MODE_SIDEBYSIDE: number;
  56213. private _useDirectMapping;
  56214. /**
  56215. * The texture being displayed on the sphere
  56216. */
  56217. protected _photoTexture: Texture;
  56218. /**
  56219. * Gets or sets the texture being displayed on the sphere
  56220. */
  56221. get photoTexture(): Texture;
  56222. set photoTexture(value: Texture);
  56223. /**
  56224. * Observable raised when an error occured while loading the 360 image
  56225. */
  56226. onLoadErrorObservable: Observable<string>;
  56227. /**
  56228. * The skybox material
  56229. */
  56230. protected _material: BackgroundMaterial;
  56231. /**
  56232. * The surface used for the skybox
  56233. */
  56234. protected _mesh: Mesh;
  56235. /**
  56236. * Gets the mesh used for the skybox.
  56237. */
  56238. get mesh(): Mesh;
  56239. /**
  56240. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56241. * Also see the options.resolution property.
  56242. */
  56243. get fovMultiplier(): number;
  56244. set fovMultiplier(value: number);
  56245. private _imageMode;
  56246. /**
  56247. * Gets or set the current video mode for the video. It can be:
  56248. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  56249. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  56250. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  56251. */
  56252. get imageMode(): number;
  56253. set imageMode(value: number);
  56254. /**
  56255. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  56256. * @param name Element's name, child elements will append suffixes for their own names.
  56257. * @param urlsOfPhoto defines the url of the photo to display
  56258. * @param options defines an object containing optional or exposed sub element properties
  56259. * @param onError defines a callback called when an error occured while loading the texture
  56260. */
  56261. constructor(name: string, urlOfPhoto: string, options: {
  56262. resolution?: number;
  56263. size?: number;
  56264. useDirectMapping?: boolean;
  56265. faceForward?: boolean;
  56266. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  56267. private _onBeforeCameraRenderObserver;
  56268. private _changeImageMode;
  56269. /**
  56270. * Releases resources associated with this node.
  56271. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56272. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56273. */
  56274. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56275. }
  56276. }
  56277. declare module "babylonjs/Misc/rgbdTextureTools" {
  56278. import "babylonjs/Shaders/rgbdDecode.fragment";
  56279. import "babylonjs/Engines/Extensions/engine.renderTarget";
  56280. import { Texture } from "babylonjs/Materials/Textures/texture";
  56281. /**
  56282. * Class used to host RGBD texture specific utilities
  56283. */
  56284. export class RGBDTextureTools {
  56285. /**
  56286. * Expand the RGBD Texture from RGBD to Half Float if possible.
  56287. * @param texture the texture to expand.
  56288. */
  56289. static ExpandRGBDTexture(texture: Texture): void;
  56290. }
  56291. }
  56292. declare module "babylonjs/Misc/brdfTextureTools" {
  56293. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56294. import { Scene } from "babylonjs/scene";
  56295. /**
  56296. * Class used to host texture specific utilities
  56297. */
  56298. export class BRDFTextureTools {
  56299. /**
  56300. * Prevents texture cache collision
  56301. */
  56302. private static _instanceNumber;
  56303. /**
  56304. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  56305. * @param scene defines the hosting scene
  56306. * @returns the environment BRDF texture
  56307. */
  56308. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  56309. private static _environmentBRDFBase64Texture;
  56310. }
  56311. }
  56312. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  56313. import { Nullable } from "babylonjs/types";
  56314. import { Color3 } from "babylonjs/Maths/math.color";
  56315. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56316. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56317. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56318. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56319. import { Engine } from "babylonjs/Engines/engine";
  56320. import { Scene } from "babylonjs/scene";
  56321. /**
  56322. * @hidden
  56323. */
  56324. export interface IMaterialClearCoatDefines {
  56325. CLEARCOAT: boolean;
  56326. CLEARCOAT_DEFAULTIOR: boolean;
  56327. CLEARCOAT_TEXTURE: boolean;
  56328. CLEARCOAT_TEXTUREDIRECTUV: number;
  56329. CLEARCOAT_BUMP: boolean;
  56330. CLEARCOAT_BUMPDIRECTUV: number;
  56331. CLEARCOAT_TINT: boolean;
  56332. CLEARCOAT_TINT_TEXTURE: boolean;
  56333. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56334. /** @hidden */
  56335. _areTexturesDirty: boolean;
  56336. }
  56337. /**
  56338. * Define the code related to the clear coat parameters of the pbr material.
  56339. */
  56340. export class PBRClearCoatConfiguration {
  56341. /**
  56342. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  56343. * The default fits with a polyurethane material.
  56344. */
  56345. private static readonly _DefaultIndexOfRefraction;
  56346. private _isEnabled;
  56347. /**
  56348. * Defines if the clear coat is enabled in the material.
  56349. */
  56350. isEnabled: boolean;
  56351. /**
  56352. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  56353. */
  56354. intensity: number;
  56355. /**
  56356. * Defines the clear coat layer roughness.
  56357. */
  56358. roughness: number;
  56359. private _indexOfRefraction;
  56360. /**
  56361. * Defines the index of refraction of the clear coat.
  56362. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  56363. * The default fits with a polyurethane material.
  56364. * Changing the default value is more performance intensive.
  56365. */
  56366. indexOfRefraction: number;
  56367. private _texture;
  56368. /**
  56369. * Stores the clear coat values in a texture.
  56370. */
  56371. texture: Nullable<BaseTexture>;
  56372. private _bumpTexture;
  56373. /**
  56374. * Define the clear coat specific bump texture.
  56375. */
  56376. bumpTexture: Nullable<BaseTexture>;
  56377. private _isTintEnabled;
  56378. /**
  56379. * Defines if the clear coat tint is enabled in the material.
  56380. */
  56381. isTintEnabled: boolean;
  56382. /**
  56383. * Defines the clear coat tint of the material.
  56384. * This is only use if tint is enabled
  56385. */
  56386. tintColor: Color3;
  56387. /**
  56388. * Defines the distance at which the tint color should be found in the
  56389. * clear coat media.
  56390. * This is only use if tint is enabled
  56391. */
  56392. tintColorAtDistance: number;
  56393. /**
  56394. * Defines the clear coat layer thickness.
  56395. * This is only use if tint is enabled
  56396. */
  56397. tintThickness: number;
  56398. private _tintTexture;
  56399. /**
  56400. * Stores the clear tint values in a texture.
  56401. * rgb is tint
  56402. * a is a thickness factor
  56403. */
  56404. tintTexture: Nullable<BaseTexture>;
  56405. /** @hidden */
  56406. private _internalMarkAllSubMeshesAsTexturesDirty;
  56407. /** @hidden */
  56408. _markAllSubMeshesAsTexturesDirty(): void;
  56409. /**
  56410. * Instantiate a new istance of clear coat configuration.
  56411. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56412. */
  56413. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56414. /**
  56415. * Gets wehter the submesh is ready to be used or not.
  56416. * @param defines the list of "defines" to update.
  56417. * @param scene defines the scene the material belongs to.
  56418. * @param engine defines the engine the material belongs to.
  56419. * @param disableBumpMap defines wether the material disables bump or not.
  56420. * @returns - boolean indicating that the submesh is ready or not.
  56421. */
  56422. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  56423. /**
  56424. * Checks to see if a texture is used in the material.
  56425. * @param defines the list of "defines" to update.
  56426. * @param scene defines the scene to the material belongs to.
  56427. */
  56428. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  56429. /**
  56430. * Binds the material data.
  56431. * @param uniformBuffer defines the Uniform buffer to fill in.
  56432. * @param scene defines the scene the material belongs to.
  56433. * @param engine defines the engine the material belongs to.
  56434. * @param disableBumpMap defines wether the material disables bump or not.
  56435. * @param isFrozen defines wether the material is frozen or not.
  56436. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56437. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56438. */
  56439. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  56440. /**
  56441. * Checks to see if a texture is used in the material.
  56442. * @param texture - Base texture to use.
  56443. * @returns - Boolean specifying if a texture is used in the material.
  56444. */
  56445. hasTexture(texture: BaseTexture): boolean;
  56446. /**
  56447. * Returns an array of the actively used textures.
  56448. * @param activeTextures Array of BaseTextures
  56449. */
  56450. getActiveTextures(activeTextures: BaseTexture[]): void;
  56451. /**
  56452. * Returns the animatable textures.
  56453. * @param animatables Array of animatable textures.
  56454. */
  56455. getAnimatables(animatables: IAnimatable[]): void;
  56456. /**
  56457. * Disposes the resources of the material.
  56458. * @param forceDisposeTextures - Forces the disposal of all textures.
  56459. */
  56460. dispose(forceDisposeTextures?: boolean): void;
  56461. /**
  56462. * Get the current class name of the texture useful for serialization or dynamic coding.
  56463. * @returns "PBRClearCoatConfiguration"
  56464. */
  56465. getClassName(): string;
  56466. /**
  56467. * Add fallbacks to the effect fallbacks list.
  56468. * @param defines defines the Base texture to use.
  56469. * @param fallbacks defines the current fallback list.
  56470. * @param currentRank defines the current fallback rank.
  56471. * @returns the new fallback rank.
  56472. */
  56473. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56474. /**
  56475. * Add the required uniforms to the current list.
  56476. * @param uniforms defines the current uniform list.
  56477. */
  56478. static AddUniforms(uniforms: string[]): void;
  56479. /**
  56480. * Add the required samplers to the current list.
  56481. * @param samplers defines the current sampler list.
  56482. */
  56483. static AddSamplers(samplers: string[]): void;
  56484. /**
  56485. * Add the required uniforms to the current buffer.
  56486. * @param uniformBuffer defines the current uniform buffer.
  56487. */
  56488. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56489. /**
  56490. * Makes a duplicate of the current configuration into another one.
  56491. * @param clearCoatConfiguration define the config where to copy the info
  56492. */
  56493. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  56494. /**
  56495. * Serializes this clear coat configuration.
  56496. * @returns - An object with the serialized config.
  56497. */
  56498. serialize(): any;
  56499. /**
  56500. * Parses a anisotropy Configuration from a serialized object.
  56501. * @param source - Serialized object.
  56502. * @param scene Defines the scene we are parsing for
  56503. * @param rootUrl Defines the rootUrl to load from
  56504. */
  56505. parse(source: any, scene: Scene, rootUrl: string): void;
  56506. }
  56507. }
  56508. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  56509. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56511. import { Vector2 } from "babylonjs/Maths/math.vector";
  56512. import { Scene } from "babylonjs/scene";
  56513. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56514. import { Nullable } from "babylonjs/types";
  56515. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56516. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56517. /**
  56518. * @hidden
  56519. */
  56520. export interface IMaterialAnisotropicDefines {
  56521. ANISOTROPIC: boolean;
  56522. ANISOTROPIC_TEXTURE: boolean;
  56523. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56524. MAINUV1: boolean;
  56525. _areTexturesDirty: boolean;
  56526. _needUVs: boolean;
  56527. }
  56528. /**
  56529. * Define the code related to the anisotropic parameters of the pbr material.
  56530. */
  56531. export class PBRAnisotropicConfiguration {
  56532. private _isEnabled;
  56533. /**
  56534. * Defines if the anisotropy is enabled in the material.
  56535. */
  56536. isEnabled: boolean;
  56537. /**
  56538. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  56539. */
  56540. intensity: number;
  56541. /**
  56542. * Defines if the effect is along the tangents, bitangents or in between.
  56543. * By default, the effect is "strectching" the highlights along the tangents.
  56544. */
  56545. direction: Vector2;
  56546. private _texture;
  56547. /**
  56548. * Stores the anisotropy values in a texture.
  56549. * rg is direction (like normal from -1 to 1)
  56550. * b is a intensity
  56551. */
  56552. texture: Nullable<BaseTexture>;
  56553. /** @hidden */
  56554. private _internalMarkAllSubMeshesAsTexturesDirty;
  56555. /** @hidden */
  56556. _markAllSubMeshesAsTexturesDirty(): void;
  56557. /**
  56558. * Instantiate a new istance of anisotropy configuration.
  56559. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56560. */
  56561. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56562. /**
  56563. * Specifies that the submesh is ready to be used.
  56564. * @param defines the list of "defines" to update.
  56565. * @param scene defines the scene the material belongs to.
  56566. * @returns - boolean indicating that the submesh is ready or not.
  56567. */
  56568. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  56569. /**
  56570. * Checks to see if a texture is used in the material.
  56571. * @param defines the list of "defines" to update.
  56572. * @param mesh the mesh we are preparing the defines for.
  56573. * @param scene defines the scene the material belongs to.
  56574. */
  56575. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  56576. /**
  56577. * Binds the material data.
  56578. * @param uniformBuffer defines the Uniform buffer to fill in.
  56579. * @param scene defines the scene the material belongs to.
  56580. * @param isFrozen defines wether the material is frozen or not.
  56581. */
  56582. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56583. /**
  56584. * Checks to see if a texture is used in the material.
  56585. * @param texture - Base texture to use.
  56586. * @returns - Boolean specifying if a texture is used in the material.
  56587. */
  56588. hasTexture(texture: BaseTexture): boolean;
  56589. /**
  56590. * Returns an array of the actively used textures.
  56591. * @param activeTextures Array of BaseTextures
  56592. */
  56593. getActiveTextures(activeTextures: BaseTexture[]): void;
  56594. /**
  56595. * Returns the animatable textures.
  56596. * @param animatables Array of animatable textures.
  56597. */
  56598. getAnimatables(animatables: IAnimatable[]): void;
  56599. /**
  56600. * Disposes the resources of the material.
  56601. * @param forceDisposeTextures - Forces the disposal of all textures.
  56602. */
  56603. dispose(forceDisposeTextures?: boolean): void;
  56604. /**
  56605. * Get the current class name of the texture useful for serialization or dynamic coding.
  56606. * @returns "PBRAnisotropicConfiguration"
  56607. */
  56608. getClassName(): string;
  56609. /**
  56610. * Add fallbacks to the effect fallbacks list.
  56611. * @param defines defines the Base texture to use.
  56612. * @param fallbacks defines the current fallback list.
  56613. * @param currentRank defines the current fallback rank.
  56614. * @returns the new fallback rank.
  56615. */
  56616. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56617. /**
  56618. * Add the required uniforms to the current list.
  56619. * @param uniforms defines the current uniform list.
  56620. */
  56621. static AddUniforms(uniforms: string[]): void;
  56622. /**
  56623. * Add the required uniforms to the current buffer.
  56624. * @param uniformBuffer defines the current uniform buffer.
  56625. */
  56626. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56627. /**
  56628. * Add the required samplers to the current list.
  56629. * @param samplers defines the current sampler list.
  56630. */
  56631. static AddSamplers(samplers: string[]): void;
  56632. /**
  56633. * Makes a duplicate of the current configuration into another one.
  56634. * @param anisotropicConfiguration define the config where to copy the info
  56635. */
  56636. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  56637. /**
  56638. * Serializes this anisotropy configuration.
  56639. * @returns - An object with the serialized config.
  56640. */
  56641. serialize(): any;
  56642. /**
  56643. * Parses a anisotropy Configuration from a serialized object.
  56644. * @param source - Serialized object.
  56645. * @param scene Defines the scene we are parsing for
  56646. * @param rootUrl Defines the rootUrl to load from
  56647. */
  56648. parse(source: any, scene: Scene, rootUrl: string): void;
  56649. }
  56650. }
  56651. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  56652. import { Scene } from "babylonjs/scene";
  56653. /**
  56654. * @hidden
  56655. */
  56656. export interface IMaterialBRDFDefines {
  56657. BRDF_V_HEIGHT_CORRELATED: boolean;
  56658. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56659. SPHERICAL_HARMONICS: boolean;
  56660. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56661. /** @hidden */
  56662. _areMiscDirty: boolean;
  56663. }
  56664. /**
  56665. * Define the code related to the BRDF parameters of the pbr material.
  56666. */
  56667. export class PBRBRDFConfiguration {
  56668. /**
  56669. * Default value used for the energy conservation.
  56670. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56671. */
  56672. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  56673. /**
  56674. * Default value used for the Smith Visibility Height Correlated mode.
  56675. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56676. */
  56677. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  56678. /**
  56679. * Default value used for the IBL diffuse part.
  56680. * This can help switching back to the polynomials mode globally which is a tiny bit
  56681. * less GPU intensive at the drawback of a lower quality.
  56682. */
  56683. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  56684. /**
  56685. * Default value used for activating energy conservation for the specular workflow.
  56686. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56687. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56688. */
  56689. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  56690. private _useEnergyConservation;
  56691. /**
  56692. * Defines if the material uses energy conservation.
  56693. */
  56694. useEnergyConservation: boolean;
  56695. private _useSmithVisibilityHeightCorrelated;
  56696. /**
  56697. * LEGACY Mode set to false
  56698. * Defines if the material uses height smith correlated visibility term.
  56699. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  56700. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  56701. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  56702. * Not relying on height correlated will also disable energy conservation.
  56703. */
  56704. useSmithVisibilityHeightCorrelated: boolean;
  56705. private _useSphericalHarmonics;
  56706. /**
  56707. * LEGACY Mode set to false
  56708. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  56709. * diffuse part of the IBL.
  56710. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  56711. * to the ground truth.
  56712. */
  56713. useSphericalHarmonics: boolean;
  56714. private _useSpecularGlossinessInputEnergyConservation;
  56715. /**
  56716. * Defines if the material uses energy conservation, when the specular workflow is active.
  56717. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56718. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56719. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  56720. */
  56721. useSpecularGlossinessInputEnergyConservation: boolean;
  56722. /** @hidden */
  56723. private _internalMarkAllSubMeshesAsMiscDirty;
  56724. /** @hidden */
  56725. _markAllSubMeshesAsMiscDirty(): void;
  56726. /**
  56727. * Instantiate a new istance of clear coat configuration.
  56728. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  56729. */
  56730. constructor(markAllSubMeshesAsMiscDirty: () => void);
  56731. /**
  56732. * Checks to see if a texture is used in the material.
  56733. * @param defines the list of "defines" to update.
  56734. */
  56735. prepareDefines(defines: IMaterialBRDFDefines): void;
  56736. /**
  56737. * Get the current class name of the texture useful for serialization or dynamic coding.
  56738. * @returns "PBRClearCoatConfiguration"
  56739. */
  56740. getClassName(): string;
  56741. /**
  56742. * Makes a duplicate of the current configuration into another one.
  56743. * @param brdfConfiguration define the config where to copy the info
  56744. */
  56745. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  56746. /**
  56747. * Serializes this BRDF configuration.
  56748. * @returns - An object with the serialized config.
  56749. */
  56750. serialize(): any;
  56751. /**
  56752. * Parses a anisotropy Configuration from a serialized object.
  56753. * @param source - Serialized object.
  56754. * @param scene Defines the scene we are parsing for
  56755. * @param rootUrl Defines the rootUrl to load from
  56756. */
  56757. parse(source: any, scene: Scene, rootUrl: string): void;
  56758. }
  56759. }
  56760. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  56761. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56762. import { Color3 } from "babylonjs/Maths/math.color";
  56763. import { Scene } from "babylonjs/scene";
  56764. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56765. import { Nullable } from "babylonjs/types";
  56766. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56767. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56768. /**
  56769. * @hidden
  56770. */
  56771. export interface IMaterialSheenDefines {
  56772. SHEEN: boolean;
  56773. SHEEN_TEXTURE: boolean;
  56774. SHEEN_TEXTUREDIRECTUV: number;
  56775. SHEEN_LINKWITHALBEDO: boolean;
  56776. SHEEN_ROUGHNESS: boolean;
  56777. SHEEN_ALBEDOSCALING: boolean;
  56778. /** @hidden */
  56779. _areTexturesDirty: boolean;
  56780. }
  56781. /**
  56782. * Define the code related to the Sheen parameters of the pbr material.
  56783. */
  56784. export class PBRSheenConfiguration {
  56785. private _isEnabled;
  56786. /**
  56787. * Defines if the material uses sheen.
  56788. */
  56789. isEnabled: boolean;
  56790. private _linkSheenWithAlbedo;
  56791. /**
  56792. * Defines if the sheen is linked to the sheen color.
  56793. */
  56794. linkSheenWithAlbedo: boolean;
  56795. /**
  56796. * Defines the sheen intensity.
  56797. */
  56798. intensity: number;
  56799. /**
  56800. * Defines the sheen color.
  56801. */
  56802. color: Color3;
  56803. private _texture;
  56804. /**
  56805. * Stores the sheen tint values in a texture.
  56806. * rgb is tint
  56807. * a is a intensity or roughness if roughness has been defined
  56808. */
  56809. texture: Nullable<BaseTexture>;
  56810. private _roughness;
  56811. /**
  56812. * Defines the sheen roughness.
  56813. * It is not taken into account if linkSheenWithAlbedo is true.
  56814. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  56815. */
  56816. roughness: Nullable<number>;
  56817. private _albedoScaling;
  56818. /**
  56819. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  56820. * It allows the strength of the sheen effect to not depend on the base color of the material,
  56821. * making it easier to setup and tweak the effect
  56822. */
  56823. albedoScaling: boolean;
  56824. /** @hidden */
  56825. private _internalMarkAllSubMeshesAsTexturesDirty;
  56826. /** @hidden */
  56827. _markAllSubMeshesAsTexturesDirty(): void;
  56828. /**
  56829. * Instantiate a new istance of clear coat configuration.
  56830. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56831. */
  56832. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56833. /**
  56834. * Specifies that the submesh is ready to be used.
  56835. * @param defines the list of "defines" to update.
  56836. * @param scene defines the scene the material belongs to.
  56837. * @returns - boolean indicating that the submesh is ready or not.
  56838. */
  56839. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  56840. /**
  56841. * Checks to see if a texture is used in the material.
  56842. * @param defines the list of "defines" to update.
  56843. * @param scene defines the scene the material belongs to.
  56844. */
  56845. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  56846. /**
  56847. * Binds the material data.
  56848. * @param uniformBuffer defines the Uniform buffer to fill in.
  56849. * @param scene defines the scene the material belongs to.
  56850. * @param isFrozen defines wether the material is frozen or not.
  56851. */
  56852. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56853. /**
  56854. * Checks to see if a texture is used in the material.
  56855. * @param texture - Base texture to use.
  56856. * @returns - Boolean specifying if a texture is used in the material.
  56857. */
  56858. hasTexture(texture: BaseTexture): boolean;
  56859. /**
  56860. * Returns an array of the actively used textures.
  56861. * @param activeTextures Array of BaseTextures
  56862. */
  56863. getActiveTextures(activeTextures: BaseTexture[]): void;
  56864. /**
  56865. * Returns the animatable textures.
  56866. * @param animatables Array of animatable textures.
  56867. */
  56868. getAnimatables(animatables: IAnimatable[]): void;
  56869. /**
  56870. * Disposes the resources of the material.
  56871. * @param forceDisposeTextures - Forces the disposal of all textures.
  56872. */
  56873. dispose(forceDisposeTextures?: boolean): void;
  56874. /**
  56875. * Get the current class name of the texture useful for serialization or dynamic coding.
  56876. * @returns "PBRSheenConfiguration"
  56877. */
  56878. getClassName(): string;
  56879. /**
  56880. * Add fallbacks to the effect fallbacks list.
  56881. * @param defines defines the Base texture to use.
  56882. * @param fallbacks defines the current fallback list.
  56883. * @param currentRank defines the current fallback rank.
  56884. * @returns the new fallback rank.
  56885. */
  56886. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56887. /**
  56888. * Add the required uniforms to the current list.
  56889. * @param uniforms defines the current uniform list.
  56890. */
  56891. static AddUniforms(uniforms: string[]): void;
  56892. /**
  56893. * Add the required uniforms to the current buffer.
  56894. * @param uniformBuffer defines the current uniform buffer.
  56895. */
  56896. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56897. /**
  56898. * Add the required samplers to the current list.
  56899. * @param samplers defines the current sampler list.
  56900. */
  56901. static AddSamplers(samplers: string[]): void;
  56902. /**
  56903. * Makes a duplicate of the current configuration into another one.
  56904. * @param sheenConfiguration define the config where to copy the info
  56905. */
  56906. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  56907. /**
  56908. * Serializes this BRDF configuration.
  56909. * @returns - An object with the serialized config.
  56910. */
  56911. serialize(): any;
  56912. /**
  56913. * Parses a anisotropy Configuration from a serialized object.
  56914. * @param source - Serialized object.
  56915. * @param scene Defines the scene we are parsing for
  56916. * @param rootUrl Defines the rootUrl to load from
  56917. */
  56918. parse(source: any, scene: Scene, rootUrl: string): void;
  56919. }
  56920. }
  56921. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  56922. import { Nullable } from "babylonjs/types";
  56923. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56924. import { Color3 } from "babylonjs/Maths/math.color";
  56925. import { SmartArray } from "babylonjs/Misc/smartArray";
  56926. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56927. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56928. import { Effect } from "babylonjs/Materials/effect";
  56929. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56930. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56931. import { Engine } from "babylonjs/Engines/engine";
  56932. import { Scene } from "babylonjs/scene";
  56933. /**
  56934. * @hidden
  56935. */
  56936. export interface IMaterialSubSurfaceDefines {
  56937. SUBSURFACE: boolean;
  56938. SS_REFRACTION: boolean;
  56939. SS_TRANSLUCENCY: boolean;
  56940. SS_SCATTERING: boolean;
  56941. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56942. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56943. SS_REFRACTIONMAP_3D: boolean;
  56944. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56945. SS_LODINREFRACTIONALPHA: boolean;
  56946. SS_GAMMAREFRACTION: boolean;
  56947. SS_RGBDREFRACTION: boolean;
  56948. SS_LINEARSPECULARREFRACTION: boolean;
  56949. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56950. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56951. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56952. /** @hidden */
  56953. _areTexturesDirty: boolean;
  56954. }
  56955. /**
  56956. * Define the code related to the sub surface parameters of the pbr material.
  56957. */
  56958. export class PBRSubSurfaceConfiguration {
  56959. private _isRefractionEnabled;
  56960. /**
  56961. * Defines if the refraction is enabled in the material.
  56962. */
  56963. isRefractionEnabled: boolean;
  56964. private _isTranslucencyEnabled;
  56965. /**
  56966. * Defines if the translucency is enabled in the material.
  56967. */
  56968. isTranslucencyEnabled: boolean;
  56969. private _isScatteringEnabled;
  56970. /**
  56971. * Defines if the sub surface scattering is enabled in the material.
  56972. */
  56973. isScatteringEnabled: boolean;
  56974. private _scatteringDiffusionProfileIndex;
  56975. /**
  56976. * Diffusion profile for subsurface scattering.
  56977. * Useful for better scattering in the skins or foliages.
  56978. */
  56979. get scatteringDiffusionProfile(): Nullable<Color3>;
  56980. set scatteringDiffusionProfile(c: Nullable<Color3>);
  56981. /**
  56982. * Defines the refraction intensity of the material.
  56983. * The refraction when enabled replaces the Diffuse part of the material.
  56984. * The intensity helps transitionning between diffuse and refraction.
  56985. */
  56986. refractionIntensity: number;
  56987. /**
  56988. * Defines the translucency intensity of the material.
  56989. * When translucency has been enabled, this defines how much of the "translucency"
  56990. * is addded to the diffuse part of the material.
  56991. */
  56992. translucencyIntensity: number;
  56993. /**
  56994. * Defines the scattering intensity of the material.
  56995. * When scattering has been enabled, this defines how much of the "scattered light"
  56996. * is addded to the diffuse part of the material.
  56997. */
  56998. scatteringIntensity: number;
  56999. /**
  57000. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  57001. */
  57002. useAlbedoToTintRefraction: boolean;
  57003. private _thicknessTexture;
  57004. /**
  57005. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  57006. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  57007. * 0 would mean minimumThickness
  57008. * 1 would mean maximumThickness
  57009. * The other channels might be use as a mask to vary the different effects intensity.
  57010. */
  57011. thicknessTexture: Nullable<BaseTexture>;
  57012. private _refractionTexture;
  57013. /**
  57014. * Defines the texture to use for refraction.
  57015. */
  57016. refractionTexture: Nullable<BaseTexture>;
  57017. private _indexOfRefraction;
  57018. /**
  57019. * Index of refraction of the material base layer.
  57020. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57021. *
  57022. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57023. *
  57024. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57025. */
  57026. indexOfRefraction: number;
  57027. private _volumeIndexOfRefraction;
  57028. /**
  57029. * Index of refraction of the material's volume.
  57030. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57031. *
  57032. * This ONLY impacts refraction. If not provided or given a non-valid value,
  57033. * the volume will use the same IOR as the surface.
  57034. */
  57035. get volumeIndexOfRefraction(): number;
  57036. set volumeIndexOfRefraction(value: number);
  57037. private _invertRefractionY;
  57038. /**
  57039. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57040. */
  57041. invertRefractionY: boolean;
  57042. private _linkRefractionWithTransparency;
  57043. /**
  57044. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57045. * Materials half opaque for instance using refraction could benefit from this control.
  57046. */
  57047. linkRefractionWithTransparency: boolean;
  57048. /**
  57049. * Defines the minimum thickness stored in the thickness map.
  57050. * If no thickness map is defined, this value will be used to simulate thickness.
  57051. */
  57052. minimumThickness: number;
  57053. /**
  57054. * Defines the maximum thickness stored in the thickness map.
  57055. */
  57056. maximumThickness: number;
  57057. /**
  57058. * Defines the volume tint of the material.
  57059. * This is used for both translucency and scattering.
  57060. */
  57061. tintColor: Color3;
  57062. /**
  57063. * Defines the distance at which the tint color should be found in the media.
  57064. * This is used for refraction only.
  57065. */
  57066. tintColorAtDistance: number;
  57067. /**
  57068. * Defines how far each channel transmit through the media.
  57069. * It is defined as a color to simplify it selection.
  57070. */
  57071. diffusionDistance: Color3;
  57072. private _useMaskFromThicknessTexture;
  57073. /**
  57074. * Stores the intensity of the different subsurface effects in the thickness texture.
  57075. * * the green channel is the translucency intensity.
  57076. * * the blue channel is the scattering intensity.
  57077. * * the alpha channel is the refraction intensity.
  57078. */
  57079. useMaskFromThicknessTexture: boolean;
  57080. private _scene;
  57081. /** @hidden */
  57082. private _internalMarkAllSubMeshesAsTexturesDirty;
  57083. private _internalMarkScenePrePassDirty;
  57084. /** @hidden */
  57085. _markAllSubMeshesAsTexturesDirty(): void;
  57086. /** @hidden */
  57087. _markScenePrePassDirty(): void;
  57088. /**
  57089. * Instantiate a new istance of sub surface configuration.
  57090. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57091. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  57092. * @param scene The scene
  57093. */
  57094. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  57095. /**
  57096. * Gets wehter the submesh is ready to be used or not.
  57097. * @param defines the list of "defines" to update.
  57098. * @param scene defines the scene the material belongs to.
  57099. * @returns - boolean indicating that the submesh is ready or not.
  57100. */
  57101. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  57102. /**
  57103. * Checks to see if a texture is used in the material.
  57104. * @param defines the list of "defines" to update.
  57105. * @param scene defines the scene to the material belongs to.
  57106. */
  57107. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  57108. /**
  57109. * Binds the material data.
  57110. * @param uniformBuffer defines the Uniform buffer to fill in.
  57111. * @param scene defines the scene the material belongs to.
  57112. * @param engine defines the engine the material belongs to.
  57113. * @param isFrozen defines whether the material is frozen or not.
  57114. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  57115. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  57116. */
  57117. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  57118. /**
  57119. * Unbinds the material from the mesh.
  57120. * @param activeEffect defines the effect that should be unbound from.
  57121. * @returns true if unbound, otherwise false
  57122. */
  57123. unbind(activeEffect: Effect): boolean;
  57124. /**
  57125. * Returns the texture used for refraction or null if none is used.
  57126. * @param scene defines the scene the material belongs to.
  57127. * @returns - Refraction texture if present. If no refraction texture and refraction
  57128. * is linked with transparency, returns environment texture. Otherwise, returns null.
  57129. */
  57130. private _getRefractionTexture;
  57131. /**
  57132. * Returns true if alpha blending should be disabled.
  57133. */
  57134. get disableAlphaBlending(): boolean;
  57135. /**
  57136. * Fills the list of render target textures.
  57137. * @param renderTargets the list of render targets to update
  57138. */
  57139. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  57140. /**
  57141. * Checks to see if a texture is used in the material.
  57142. * @param texture - Base texture to use.
  57143. * @returns - Boolean specifying if a texture is used in the material.
  57144. */
  57145. hasTexture(texture: BaseTexture): boolean;
  57146. /**
  57147. * Gets a boolean indicating that current material needs to register RTT
  57148. * @returns true if this uses a render target otherwise false.
  57149. */
  57150. hasRenderTargetTextures(): boolean;
  57151. /**
  57152. * Returns an array of the actively used textures.
  57153. * @param activeTextures Array of BaseTextures
  57154. */
  57155. getActiveTextures(activeTextures: BaseTexture[]): void;
  57156. /**
  57157. * Returns the animatable textures.
  57158. * @param animatables Array of animatable textures.
  57159. */
  57160. getAnimatables(animatables: IAnimatable[]): void;
  57161. /**
  57162. * Disposes the resources of the material.
  57163. * @param forceDisposeTextures - Forces the disposal of all textures.
  57164. */
  57165. dispose(forceDisposeTextures?: boolean): void;
  57166. /**
  57167. * Get the current class name of the texture useful for serialization or dynamic coding.
  57168. * @returns "PBRSubSurfaceConfiguration"
  57169. */
  57170. getClassName(): string;
  57171. /**
  57172. * Add fallbacks to the effect fallbacks list.
  57173. * @param defines defines the Base texture to use.
  57174. * @param fallbacks defines the current fallback list.
  57175. * @param currentRank defines the current fallback rank.
  57176. * @returns the new fallback rank.
  57177. */
  57178. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57179. /**
  57180. * Add the required uniforms to the current list.
  57181. * @param uniforms defines the current uniform list.
  57182. */
  57183. static AddUniforms(uniforms: string[]): void;
  57184. /**
  57185. * Add the required samplers to the current list.
  57186. * @param samplers defines the current sampler list.
  57187. */
  57188. static AddSamplers(samplers: string[]): void;
  57189. /**
  57190. * Add the required uniforms to the current buffer.
  57191. * @param uniformBuffer defines the current uniform buffer.
  57192. */
  57193. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57194. /**
  57195. * Makes a duplicate of the current configuration into another one.
  57196. * @param configuration define the config where to copy the info
  57197. */
  57198. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  57199. /**
  57200. * Serializes this Sub Surface configuration.
  57201. * @returns - An object with the serialized config.
  57202. */
  57203. serialize(): any;
  57204. /**
  57205. * Parses a anisotropy Configuration from a serialized object.
  57206. * @param source - Serialized object.
  57207. * @param scene Defines the scene we are parsing for
  57208. * @param rootUrl Defines the rootUrl to load from
  57209. */
  57210. parse(source: any, scene: Scene, rootUrl: string): void;
  57211. }
  57212. }
  57213. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  57214. /** @hidden */
  57215. export var prePassDeclaration: {
  57216. name: string;
  57217. shader: string;
  57218. };
  57219. }
  57220. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  57221. /** @hidden */
  57222. export var pbrFragmentDeclaration: {
  57223. name: string;
  57224. shader: string;
  57225. };
  57226. }
  57227. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  57228. /** @hidden */
  57229. export var pbrUboDeclaration: {
  57230. name: string;
  57231. shader: string;
  57232. };
  57233. }
  57234. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  57235. /** @hidden */
  57236. export var pbrFragmentExtraDeclaration: {
  57237. name: string;
  57238. shader: string;
  57239. };
  57240. }
  57241. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  57242. /** @hidden */
  57243. export var pbrFragmentSamplersDeclaration: {
  57244. name: string;
  57245. shader: string;
  57246. };
  57247. }
  57248. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  57249. /** @hidden */
  57250. export var subSurfaceScatteringFunctions: {
  57251. name: string;
  57252. shader: string;
  57253. };
  57254. }
  57255. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  57256. /** @hidden */
  57257. export var importanceSampling: {
  57258. name: string;
  57259. shader: string;
  57260. };
  57261. }
  57262. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  57263. /** @hidden */
  57264. export var pbrHelperFunctions: {
  57265. name: string;
  57266. shader: string;
  57267. };
  57268. }
  57269. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  57270. /** @hidden */
  57271. export var harmonicsFunctions: {
  57272. name: string;
  57273. shader: string;
  57274. };
  57275. }
  57276. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  57277. /** @hidden */
  57278. export var pbrDirectLightingSetupFunctions: {
  57279. name: string;
  57280. shader: string;
  57281. };
  57282. }
  57283. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  57284. /** @hidden */
  57285. export var pbrDirectLightingFalloffFunctions: {
  57286. name: string;
  57287. shader: string;
  57288. };
  57289. }
  57290. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  57291. /** @hidden */
  57292. export var pbrBRDFFunctions: {
  57293. name: string;
  57294. shader: string;
  57295. };
  57296. }
  57297. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  57298. /** @hidden */
  57299. export var hdrFilteringFunctions: {
  57300. name: string;
  57301. shader: string;
  57302. };
  57303. }
  57304. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  57305. /** @hidden */
  57306. export var pbrDirectLightingFunctions: {
  57307. name: string;
  57308. shader: string;
  57309. };
  57310. }
  57311. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  57312. /** @hidden */
  57313. export var pbrIBLFunctions: {
  57314. name: string;
  57315. shader: string;
  57316. };
  57317. }
  57318. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  57319. /** @hidden */
  57320. export var pbrBlockAlbedoOpacity: {
  57321. name: string;
  57322. shader: string;
  57323. };
  57324. }
  57325. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  57326. /** @hidden */
  57327. export var pbrBlockReflectivity: {
  57328. name: string;
  57329. shader: string;
  57330. };
  57331. }
  57332. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  57333. /** @hidden */
  57334. export var pbrBlockAmbientOcclusion: {
  57335. name: string;
  57336. shader: string;
  57337. };
  57338. }
  57339. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  57340. /** @hidden */
  57341. export var pbrBlockAlphaFresnel: {
  57342. name: string;
  57343. shader: string;
  57344. };
  57345. }
  57346. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  57347. /** @hidden */
  57348. export var pbrBlockAnisotropic: {
  57349. name: string;
  57350. shader: string;
  57351. };
  57352. }
  57353. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  57354. /** @hidden */
  57355. export var pbrBlockReflection: {
  57356. name: string;
  57357. shader: string;
  57358. };
  57359. }
  57360. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  57361. /** @hidden */
  57362. export var pbrBlockSheen: {
  57363. name: string;
  57364. shader: string;
  57365. };
  57366. }
  57367. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  57368. /** @hidden */
  57369. export var pbrBlockClearcoat: {
  57370. name: string;
  57371. shader: string;
  57372. };
  57373. }
  57374. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  57375. /** @hidden */
  57376. export var pbrBlockSubSurface: {
  57377. name: string;
  57378. shader: string;
  57379. };
  57380. }
  57381. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  57382. /** @hidden */
  57383. export var pbrBlockNormalGeometric: {
  57384. name: string;
  57385. shader: string;
  57386. };
  57387. }
  57388. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  57389. /** @hidden */
  57390. export var pbrBlockNormalFinal: {
  57391. name: string;
  57392. shader: string;
  57393. };
  57394. }
  57395. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  57396. /** @hidden */
  57397. export var pbrBlockGeometryInfo: {
  57398. name: string;
  57399. shader: string;
  57400. };
  57401. }
  57402. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  57403. /** @hidden */
  57404. export var pbrBlockReflectance0: {
  57405. name: string;
  57406. shader: string;
  57407. };
  57408. }
  57409. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  57410. /** @hidden */
  57411. export var pbrBlockReflectance: {
  57412. name: string;
  57413. shader: string;
  57414. };
  57415. }
  57416. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  57417. /** @hidden */
  57418. export var pbrBlockDirectLighting: {
  57419. name: string;
  57420. shader: string;
  57421. };
  57422. }
  57423. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  57424. /** @hidden */
  57425. export var pbrBlockFinalLitComponents: {
  57426. name: string;
  57427. shader: string;
  57428. };
  57429. }
  57430. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  57431. /** @hidden */
  57432. export var pbrBlockFinalUnlitComponents: {
  57433. name: string;
  57434. shader: string;
  57435. };
  57436. }
  57437. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  57438. /** @hidden */
  57439. export var pbrBlockFinalColorComposition: {
  57440. name: string;
  57441. shader: string;
  57442. };
  57443. }
  57444. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  57445. /** @hidden */
  57446. export var pbrBlockImageProcessing: {
  57447. name: string;
  57448. shader: string;
  57449. };
  57450. }
  57451. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  57452. /** @hidden */
  57453. export var pbrDebug: {
  57454. name: string;
  57455. shader: string;
  57456. };
  57457. }
  57458. declare module "babylonjs/Shaders/pbr.fragment" {
  57459. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  57460. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  57461. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  57462. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  57463. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57464. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57465. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  57466. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57467. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  57468. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57469. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57470. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57471. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  57472. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  57473. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  57474. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57475. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57476. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  57477. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  57478. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  57479. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  57480. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  57481. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  57482. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  57483. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  57484. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  57485. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  57486. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  57487. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  57488. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  57489. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  57490. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  57491. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  57492. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  57493. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  57494. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  57495. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  57496. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  57497. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  57498. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  57499. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  57500. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  57501. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  57502. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  57503. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  57504. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57505. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  57506. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  57507. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  57508. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57509. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  57510. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  57511. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  57512. /** @hidden */
  57513. export var pbrPixelShader: {
  57514. name: string;
  57515. shader: string;
  57516. };
  57517. }
  57518. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  57519. /** @hidden */
  57520. export var pbrVertexDeclaration: {
  57521. name: string;
  57522. shader: string;
  57523. };
  57524. }
  57525. declare module "babylonjs/Shaders/pbr.vertex" {
  57526. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  57527. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  57528. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57529. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57530. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57531. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  57532. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  57533. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  57534. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  57535. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57536. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57537. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57538. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57539. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57540. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  57541. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57542. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57543. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  57544. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  57545. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  57546. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57547. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57548. /** @hidden */
  57549. export var pbrVertexShader: {
  57550. name: string;
  57551. shader: string;
  57552. };
  57553. }
  57554. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  57555. import { Nullable } from "babylonjs/types";
  57556. import { Scene } from "babylonjs/scene";
  57557. import { Matrix } from "babylonjs/Maths/math.vector";
  57558. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57560. import { Mesh } from "babylonjs/Meshes/mesh";
  57561. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  57562. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  57563. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  57564. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  57565. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  57566. import { Color3 } from "babylonjs/Maths/math.color";
  57567. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  57568. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  57569. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  57570. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  57571. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57572. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57573. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57574. import "babylonjs/Shaders/pbr.fragment";
  57575. import "babylonjs/Shaders/pbr.vertex";
  57576. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  57577. /**
  57578. * Manages the defines for the PBR Material.
  57579. * @hidden
  57580. */
  57581. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  57582. PBR: boolean;
  57583. NUM_SAMPLES: string;
  57584. REALTIME_FILTERING: boolean;
  57585. MAINUV1: boolean;
  57586. MAINUV2: boolean;
  57587. UV1: boolean;
  57588. UV2: boolean;
  57589. ALBEDO: boolean;
  57590. GAMMAALBEDO: boolean;
  57591. ALBEDODIRECTUV: number;
  57592. VERTEXCOLOR: boolean;
  57593. DETAIL: boolean;
  57594. DETAILDIRECTUV: number;
  57595. DETAIL_NORMALBLENDMETHOD: number;
  57596. AMBIENT: boolean;
  57597. AMBIENTDIRECTUV: number;
  57598. AMBIENTINGRAYSCALE: boolean;
  57599. OPACITY: boolean;
  57600. VERTEXALPHA: boolean;
  57601. OPACITYDIRECTUV: number;
  57602. OPACITYRGB: boolean;
  57603. ALPHATEST: boolean;
  57604. DEPTHPREPASS: boolean;
  57605. ALPHABLEND: boolean;
  57606. ALPHAFROMALBEDO: boolean;
  57607. ALPHATESTVALUE: string;
  57608. SPECULAROVERALPHA: boolean;
  57609. RADIANCEOVERALPHA: boolean;
  57610. ALPHAFRESNEL: boolean;
  57611. LINEARALPHAFRESNEL: boolean;
  57612. PREMULTIPLYALPHA: boolean;
  57613. EMISSIVE: boolean;
  57614. EMISSIVEDIRECTUV: number;
  57615. REFLECTIVITY: boolean;
  57616. REFLECTIVITYDIRECTUV: number;
  57617. SPECULARTERM: boolean;
  57618. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  57619. MICROSURFACEAUTOMATIC: boolean;
  57620. LODBASEDMICROSFURACE: boolean;
  57621. MICROSURFACEMAP: boolean;
  57622. MICROSURFACEMAPDIRECTUV: number;
  57623. METALLICWORKFLOW: boolean;
  57624. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  57625. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  57626. METALLNESSSTOREINMETALMAPBLUE: boolean;
  57627. AOSTOREINMETALMAPRED: boolean;
  57628. METALLIC_REFLECTANCE: boolean;
  57629. METALLIC_REFLECTANCEDIRECTUV: number;
  57630. ENVIRONMENTBRDF: boolean;
  57631. ENVIRONMENTBRDF_RGBD: boolean;
  57632. NORMAL: boolean;
  57633. TANGENT: boolean;
  57634. BUMP: boolean;
  57635. BUMPDIRECTUV: number;
  57636. OBJECTSPACE_NORMALMAP: boolean;
  57637. PARALLAX: boolean;
  57638. PARALLAXOCCLUSION: boolean;
  57639. NORMALXYSCALE: boolean;
  57640. LIGHTMAP: boolean;
  57641. LIGHTMAPDIRECTUV: number;
  57642. USELIGHTMAPASSHADOWMAP: boolean;
  57643. GAMMALIGHTMAP: boolean;
  57644. RGBDLIGHTMAP: boolean;
  57645. REFLECTION: boolean;
  57646. REFLECTIONMAP_3D: boolean;
  57647. REFLECTIONMAP_SPHERICAL: boolean;
  57648. REFLECTIONMAP_PLANAR: boolean;
  57649. REFLECTIONMAP_CUBIC: boolean;
  57650. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  57651. REFLECTIONMAP_PROJECTION: boolean;
  57652. REFLECTIONMAP_SKYBOX: boolean;
  57653. REFLECTIONMAP_EXPLICIT: boolean;
  57654. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  57655. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  57656. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  57657. INVERTCUBICMAP: boolean;
  57658. USESPHERICALFROMREFLECTIONMAP: boolean;
  57659. USEIRRADIANCEMAP: boolean;
  57660. SPHERICAL_HARMONICS: boolean;
  57661. USESPHERICALINVERTEX: boolean;
  57662. REFLECTIONMAP_OPPOSITEZ: boolean;
  57663. LODINREFLECTIONALPHA: boolean;
  57664. GAMMAREFLECTION: boolean;
  57665. RGBDREFLECTION: boolean;
  57666. LINEARSPECULARREFLECTION: boolean;
  57667. RADIANCEOCCLUSION: boolean;
  57668. HORIZONOCCLUSION: boolean;
  57669. INSTANCES: boolean;
  57670. THIN_INSTANCES: boolean;
  57671. PREPASS: boolean;
  57672. SCENE_MRT_COUNT: number;
  57673. NUM_BONE_INFLUENCERS: number;
  57674. BonesPerMesh: number;
  57675. BONETEXTURE: boolean;
  57676. NONUNIFORMSCALING: boolean;
  57677. MORPHTARGETS: boolean;
  57678. MORPHTARGETS_NORMAL: boolean;
  57679. MORPHTARGETS_TANGENT: boolean;
  57680. MORPHTARGETS_UV: boolean;
  57681. NUM_MORPH_INFLUENCERS: number;
  57682. IMAGEPROCESSING: boolean;
  57683. VIGNETTE: boolean;
  57684. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57685. VIGNETTEBLENDMODEOPAQUE: boolean;
  57686. TONEMAPPING: boolean;
  57687. TONEMAPPING_ACES: boolean;
  57688. CONTRAST: boolean;
  57689. COLORCURVES: boolean;
  57690. COLORGRADING: boolean;
  57691. COLORGRADING3D: boolean;
  57692. SAMPLER3DGREENDEPTH: boolean;
  57693. SAMPLER3DBGRMAP: boolean;
  57694. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57695. EXPOSURE: boolean;
  57696. MULTIVIEW: boolean;
  57697. USEPHYSICALLIGHTFALLOFF: boolean;
  57698. USEGLTFLIGHTFALLOFF: boolean;
  57699. TWOSIDEDLIGHTING: boolean;
  57700. SHADOWFLOAT: boolean;
  57701. CLIPPLANE: boolean;
  57702. CLIPPLANE2: boolean;
  57703. CLIPPLANE3: boolean;
  57704. CLIPPLANE4: boolean;
  57705. CLIPPLANE5: boolean;
  57706. CLIPPLANE6: boolean;
  57707. POINTSIZE: boolean;
  57708. FOG: boolean;
  57709. LOGARITHMICDEPTH: boolean;
  57710. FORCENORMALFORWARD: boolean;
  57711. SPECULARAA: boolean;
  57712. CLEARCOAT: boolean;
  57713. CLEARCOAT_DEFAULTIOR: boolean;
  57714. CLEARCOAT_TEXTURE: boolean;
  57715. CLEARCOAT_TEXTUREDIRECTUV: number;
  57716. CLEARCOAT_BUMP: boolean;
  57717. CLEARCOAT_BUMPDIRECTUV: number;
  57718. CLEARCOAT_TINT: boolean;
  57719. CLEARCOAT_TINT_TEXTURE: boolean;
  57720. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57721. ANISOTROPIC: boolean;
  57722. ANISOTROPIC_TEXTURE: boolean;
  57723. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57724. BRDF_V_HEIGHT_CORRELATED: boolean;
  57725. MS_BRDF_ENERGY_CONSERVATION: boolean;
  57726. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  57727. SHEEN: boolean;
  57728. SHEEN_TEXTURE: boolean;
  57729. SHEEN_TEXTUREDIRECTUV: number;
  57730. SHEEN_LINKWITHALBEDO: boolean;
  57731. SHEEN_ROUGHNESS: boolean;
  57732. SHEEN_ALBEDOSCALING: boolean;
  57733. SUBSURFACE: boolean;
  57734. SS_REFRACTION: boolean;
  57735. SS_TRANSLUCENCY: boolean;
  57736. SS_SCATTERING: boolean;
  57737. SS_THICKNESSANDMASK_TEXTURE: boolean;
  57738. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  57739. SS_REFRACTIONMAP_3D: boolean;
  57740. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  57741. SS_LODINREFRACTIONALPHA: boolean;
  57742. SS_GAMMAREFRACTION: boolean;
  57743. SS_RGBDREFRACTION: boolean;
  57744. SS_LINEARSPECULARREFRACTION: boolean;
  57745. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  57746. SS_ALBEDOFORREFRACTIONTINT: boolean;
  57747. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  57748. UNLIT: boolean;
  57749. DEBUGMODE: number;
  57750. /**
  57751. * Initializes the PBR Material defines.
  57752. */
  57753. constructor();
  57754. /**
  57755. * Resets the PBR Material defines.
  57756. */
  57757. reset(): void;
  57758. }
  57759. /**
  57760. * The Physically based material base class of BJS.
  57761. *
  57762. * This offers the main features of a standard PBR material.
  57763. * For more information, please refer to the documentation :
  57764. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57765. */
  57766. export abstract class PBRBaseMaterial extends PushMaterial {
  57767. /**
  57768. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57769. */
  57770. static readonly PBRMATERIAL_OPAQUE: number;
  57771. /**
  57772. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57773. */
  57774. static readonly PBRMATERIAL_ALPHATEST: number;
  57775. /**
  57776. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57777. */
  57778. static readonly PBRMATERIAL_ALPHABLEND: number;
  57779. /**
  57780. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57781. * They are also discarded below the alpha cutoff threshold to improve performances.
  57782. */
  57783. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57784. /**
  57785. * Defines the default value of how much AO map is occluding the analytical lights
  57786. * (point spot...).
  57787. */
  57788. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57789. /**
  57790. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  57791. */
  57792. static readonly LIGHTFALLOFF_PHYSICAL: number;
  57793. /**
  57794. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  57795. * to enhance interoperability with other engines.
  57796. */
  57797. static readonly LIGHTFALLOFF_GLTF: number;
  57798. /**
  57799. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  57800. * to enhance interoperability with other materials.
  57801. */
  57802. static readonly LIGHTFALLOFF_STANDARD: number;
  57803. /**
  57804. * Intensity of the direct lights e.g. the four lights available in your scene.
  57805. * This impacts both the direct diffuse and specular highlights.
  57806. */
  57807. protected _directIntensity: number;
  57808. /**
  57809. * Intensity of the emissive part of the material.
  57810. * This helps controlling the emissive effect without modifying the emissive color.
  57811. */
  57812. protected _emissiveIntensity: number;
  57813. /**
  57814. * Intensity of the environment e.g. how much the environment will light the object
  57815. * either through harmonics for rough material or through the refelction for shiny ones.
  57816. */
  57817. protected _environmentIntensity: number;
  57818. /**
  57819. * This is a special control allowing the reduction of the specular highlights coming from the
  57820. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57821. */
  57822. protected _specularIntensity: number;
  57823. /**
  57824. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  57825. */
  57826. private _lightingInfos;
  57827. /**
  57828. * Debug Control allowing disabling the bump map on this material.
  57829. */
  57830. protected _disableBumpMap: boolean;
  57831. /**
  57832. * AKA Diffuse Texture in standard nomenclature.
  57833. */
  57834. protected _albedoTexture: Nullable<BaseTexture>;
  57835. /**
  57836. * AKA Occlusion Texture in other nomenclature.
  57837. */
  57838. protected _ambientTexture: Nullable<BaseTexture>;
  57839. /**
  57840. * AKA Occlusion Texture Intensity in other nomenclature.
  57841. */
  57842. protected _ambientTextureStrength: number;
  57843. /**
  57844. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57845. * 1 means it completely occludes it
  57846. * 0 mean it has no impact
  57847. */
  57848. protected _ambientTextureImpactOnAnalyticalLights: number;
  57849. /**
  57850. * Stores the alpha values in a texture.
  57851. */
  57852. protected _opacityTexture: Nullable<BaseTexture>;
  57853. /**
  57854. * Stores the reflection values in a texture.
  57855. */
  57856. protected _reflectionTexture: Nullable<BaseTexture>;
  57857. /**
  57858. * Stores the emissive values in a texture.
  57859. */
  57860. protected _emissiveTexture: Nullable<BaseTexture>;
  57861. /**
  57862. * AKA Specular texture in other nomenclature.
  57863. */
  57864. protected _reflectivityTexture: Nullable<BaseTexture>;
  57865. /**
  57866. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57867. */
  57868. protected _metallicTexture: Nullable<BaseTexture>;
  57869. /**
  57870. * Specifies the metallic scalar of the metallic/roughness workflow.
  57871. * Can also be used to scale the metalness values of the metallic texture.
  57872. */
  57873. protected _metallic: Nullable<number>;
  57874. /**
  57875. * Specifies the roughness scalar of the metallic/roughness workflow.
  57876. * Can also be used to scale the roughness values of the metallic texture.
  57877. */
  57878. protected _roughness: Nullable<number>;
  57879. /**
  57880. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57881. * By default the indexOfrefraction is used to compute F0;
  57882. *
  57883. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57884. *
  57885. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57886. * F90 = metallicReflectanceColor;
  57887. */
  57888. protected _metallicF0Factor: number;
  57889. /**
  57890. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57891. * By default the F90 is always 1;
  57892. *
  57893. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57894. *
  57895. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57896. * F90 = metallicReflectanceColor;
  57897. */
  57898. protected _metallicReflectanceColor: Color3;
  57899. /**
  57900. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57901. * This is multiply against the scalar values defined in the material.
  57902. */
  57903. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  57904. /**
  57905. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57906. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57907. */
  57908. protected _microSurfaceTexture: Nullable<BaseTexture>;
  57909. /**
  57910. * Stores surface normal data used to displace a mesh in a texture.
  57911. */
  57912. protected _bumpTexture: Nullable<BaseTexture>;
  57913. /**
  57914. * Stores the pre-calculated light information of a mesh in a texture.
  57915. */
  57916. protected _lightmapTexture: Nullable<BaseTexture>;
  57917. /**
  57918. * The color of a material in ambient lighting.
  57919. */
  57920. protected _ambientColor: Color3;
  57921. /**
  57922. * AKA Diffuse Color in other nomenclature.
  57923. */
  57924. protected _albedoColor: Color3;
  57925. /**
  57926. * AKA Specular Color in other nomenclature.
  57927. */
  57928. protected _reflectivityColor: Color3;
  57929. /**
  57930. * The color applied when light is reflected from a material.
  57931. */
  57932. protected _reflectionColor: Color3;
  57933. /**
  57934. * The color applied when light is emitted from a material.
  57935. */
  57936. protected _emissiveColor: Color3;
  57937. /**
  57938. * AKA Glossiness in other nomenclature.
  57939. */
  57940. protected _microSurface: number;
  57941. /**
  57942. * Specifies that the material will use the light map as a show map.
  57943. */
  57944. protected _useLightmapAsShadowmap: boolean;
  57945. /**
  57946. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57947. * makes the reflect vector face the model (under horizon).
  57948. */
  57949. protected _useHorizonOcclusion: boolean;
  57950. /**
  57951. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57952. * too much the area relying on ambient texture to define their ambient occlusion.
  57953. */
  57954. protected _useRadianceOcclusion: boolean;
  57955. /**
  57956. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57957. */
  57958. protected _useAlphaFromAlbedoTexture: boolean;
  57959. /**
  57960. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  57961. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57962. */
  57963. protected _useSpecularOverAlpha: boolean;
  57964. /**
  57965. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57966. */
  57967. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57968. /**
  57969. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57970. */
  57971. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  57972. /**
  57973. * Specifies if the metallic texture contains the roughness information in its green channel.
  57974. */
  57975. protected _useRoughnessFromMetallicTextureGreen: boolean;
  57976. /**
  57977. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57978. */
  57979. protected _useMetallnessFromMetallicTextureBlue: boolean;
  57980. /**
  57981. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57982. */
  57983. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  57984. /**
  57985. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57986. */
  57987. protected _useAmbientInGrayScale: boolean;
  57988. /**
  57989. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57990. * The material will try to infer what glossiness each pixel should be.
  57991. */
  57992. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  57993. /**
  57994. * Defines the falloff type used in this material.
  57995. * It by default is Physical.
  57996. */
  57997. protected _lightFalloff: number;
  57998. /**
  57999. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  58000. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  58001. */
  58002. protected _useRadianceOverAlpha: boolean;
  58003. /**
  58004. * Allows using an object space normal map (instead of tangent space).
  58005. */
  58006. protected _useObjectSpaceNormalMap: boolean;
  58007. /**
  58008. * Allows using the bump map in parallax mode.
  58009. */
  58010. protected _useParallax: boolean;
  58011. /**
  58012. * Allows using the bump map in parallax occlusion mode.
  58013. */
  58014. protected _useParallaxOcclusion: boolean;
  58015. /**
  58016. * Controls the scale bias of the parallax mode.
  58017. */
  58018. protected _parallaxScaleBias: number;
  58019. /**
  58020. * If sets to true, disables all the lights affecting the material.
  58021. */
  58022. protected _disableLighting: boolean;
  58023. /**
  58024. * Number of Simultaneous lights allowed on the material.
  58025. */
  58026. protected _maxSimultaneousLights: number;
  58027. /**
  58028. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  58029. */
  58030. protected _invertNormalMapX: boolean;
  58031. /**
  58032. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  58033. */
  58034. protected _invertNormalMapY: boolean;
  58035. /**
  58036. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58037. */
  58038. protected _twoSidedLighting: boolean;
  58039. /**
  58040. * Defines the alpha limits in alpha test mode.
  58041. */
  58042. protected _alphaCutOff: number;
  58043. /**
  58044. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  58045. */
  58046. protected _forceAlphaTest: boolean;
  58047. /**
  58048. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58049. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  58050. */
  58051. protected _useAlphaFresnel: boolean;
  58052. /**
  58053. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58054. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  58055. */
  58056. protected _useLinearAlphaFresnel: boolean;
  58057. /**
  58058. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  58059. * from cos thetav and roughness:
  58060. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  58061. */
  58062. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  58063. /**
  58064. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  58065. */
  58066. protected _forceIrradianceInFragment: boolean;
  58067. private _realTimeFiltering;
  58068. /**
  58069. * Enables realtime filtering on the texture.
  58070. */
  58071. get realTimeFiltering(): boolean;
  58072. set realTimeFiltering(b: boolean);
  58073. private _realTimeFilteringQuality;
  58074. /**
  58075. * Quality switch for realtime filtering
  58076. */
  58077. get realTimeFilteringQuality(): number;
  58078. set realTimeFilteringQuality(n: number);
  58079. /**
  58080. * Should this material render to several textures at once
  58081. */
  58082. get shouldRenderToMRT(): boolean;
  58083. /**
  58084. * Force normal to face away from face.
  58085. */
  58086. protected _forceNormalForward: boolean;
  58087. /**
  58088. * Enables specular anti aliasing in the PBR shader.
  58089. * It will both interacts on the Geometry for analytical and IBL lighting.
  58090. * It also prefilter the roughness map based on the bump values.
  58091. */
  58092. protected _enableSpecularAntiAliasing: boolean;
  58093. /**
  58094. * Default configuration related to image processing available in the PBR Material.
  58095. */
  58096. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58097. /**
  58098. * Keep track of the image processing observer to allow dispose and replace.
  58099. */
  58100. private _imageProcessingObserver;
  58101. /**
  58102. * Attaches a new image processing configuration to the PBR Material.
  58103. * @param configuration
  58104. */
  58105. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58106. /**
  58107. * Stores the available render targets.
  58108. */
  58109. private _renderTargets;
  58110. /**
  58111. * Sets the global ambient color for the material used in lighting calculations.
  58112. */
  58113. private _globalAmbientColor;
  58114. /**
  58115. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  58116. */
  58117. private _useLogarithmicDepth;
  58118. /**
  58119. * If set to true, no lighting calculations will be applied.
  58120. */
  58121. private _unlit;
  58122. private _debugMode;
  58123. /**
  58124. * @hidden
  58125. * This is reserved for the inspector.
  58126. * Defines the material debug mode.
  58127. * It helps seeing only some components of the material while troubleshooting.
  58128. */
  58129. debugMode: number;
  58130. /**
  58131. * @hidden
  58132. * This is reserved for the inspector.
  58133. * Specify from where on screen the debug mode should start.
  58134. * The value goes from -1 (full screen) to 1 (not visible)
  58135. * It helps with side by side comparison against the final render
  58136. * This defaults to -1
  58137. */
  58138. private debugLimit;
  58139. /**
  58140. * @hidden
  58141. * This is reserved for the inspector.
  58142. * As the default viewing range might not be enough (if the ambient is really small for instance)
  58143. * You can use the factor to better multiply the final value.
  58144. */
  58145. private debugFactor;
  58146. /**
  58147. * Defines the clear coat layer parameters for the material.
  58148. */
  58149. readonly clearCoat: PBRClearCoatConfiguration;
  58150. /**
  58151. * Defines the anisotropic parameters for the material.
  58152. */
  58153. readonly anisotropy: PBRAnisotropicConfiguration;
  58154. /**
  58155. * Defines the BRDF parameters for the material.
  58156. */
  58157. readonly brdf: PBRBRDFConfiguration;
  58158. /**
  58159. * Defines the Sheen parameters for the material.
  58160. */
  58161. readonly sheen: PBRSheenConfiguration;
  58162. /**
  58163. * Defines the SubSurface parameters for the material.
  58164. */
  58165. readonly subSurface: PBRSubSurfaceConfiguration;
  58166. /**
  58167. * Defines the detail map parameters for the material.
  58168. */
  58169. readonly detailMap: DetailMapConfiguration;
  58170. protected _rebuildInParallel: boolean;
  58171. /**
  58172. * Instantiates a new PBRMaterial instance.
  58173. *
  58174. * @param name The material name
  58175. * @param scene The scene the material will be use in.
  58176. */
  58177. constructor(name: string, scene: Scene);
  58178. /**
  58179. * Gets a boolean indicating that current material needs to register RTT
  58180. */
  58181. get hasRenderTargetTextures(): boolean;
  58182. /**
  58183. * Gets the name of the material class.
  58184. */
  58185. getClassName(): string;
  58186. /**
  58187. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  58188. */
  58189. get useLogarithmicDepth(): boolean;
  58190. /**
  58191. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  58192. */
  58193. set useLogarithmicDepth(value: boolean);
  58194. /**
  58195. * Returns true if alpha blending should be disabled.
  58196. */
  58197. protected get _disableAlphaBlending(): boolean;
  58198. /**
  58199. * Specifies whether or not this material should be rendered in alpha blend mode.
  58200. */
  58201. needAlphaBlending(): boolean;
  58202. /**
  58203. * Specifies whether or not this material should be rendered in alpha test mode.
  58204. */
  58205. needAlphaTesting(): boolean;
  58206. /**
  58207. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  58208. */
  58209. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  58210. /**
  58211. * Gets the texture used for the alpha test.
  58212. */
  58213. getAlphaTestTexture(): Nullable<BaseTexture>;
  58214. /**
  58215. * Specifies that the submesh is ready to be used.
  58216. * @param mesh - BJS mesh.
  58217. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  58218. * @param useInstances - Specifies that instances should be used.
  58219. * @returns - boolean indicating that the submesh is ready or not.
  58220. */
  58221. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58222. /**
  58223. * Specifies if the material uses metallic roughness workflow.
  58224. * @returns boolean specifiying if the material uses metallic roughness workflow.
  58225. */
  58226. isMetallicWorkflow(): boolean;
  58227. private _prepareEffect;
  58228. private _prepareDefines;
  58229. /**
  58230. * Force shader compilation
  58231. */
  58232. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  58233. /**
  58234. * Initializes the uniform buffer layout for the shader.
  58235. */
  58236. buildUniformLayout(): void;
  58237. /**
  58238. * Unbinds the material from the mesh
  58239. */
  58240. unbind(): void;
  58241. /**
  58242. * Binds the submesh data.
  58243. * @param world - The world matrix.
  58244. * @param mesh - The BJS mesh.
  58245. * @param subMesh - A submesh of the BJS mesh.
  58246. */
  58247. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58248. /**
  58249. * Returns the animatable textures.
  58250. * @returns - Array of animatable textures.
  58251. */
  58252. getAnimatables(): IAnimatable[];
  58253. /**
  58254. * Returns the texture used for reflections.
  58255. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  58256. */
  58257. private _getReflectionTexture;
  58258. /**
  58259. * Returns an array of the actively used textures.
  58260. * @returns - Array of BaseTextures
  58261. */
  58262. getActiveTextures(): BaseTexture[];
  58263. /**
  58264. * Checks to see if a texture is used in the material.
  58265. * @param texture - Base texture to use.
  58266. * @returns - Boolean specifying if a texture is used in the material.
  58267. */
  58268. hasTexture(texture: BaseTexture): boolean;
  58269. /**
  58270. * Disposes the resources of the material.
  58271. * @param forceDisposeEffect - Forces the disposal of effects.
  58272. * @param forceDisposeTextures - Forces the disposal of all textures.
  58273. */
  58274. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  58275. }
  58276. }
  58277. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  58278. import { Nullable } from "babylonjs/types";
  58279. import { Scene } from "babylonjs/scene";
  58280. import { Color3 } from "babylonjs/Maths/math.color";
  58281. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  58282. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  58283. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58284. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58285. /**
  58286. * The Physically based material of BJS.
  58287. *
  58288. * This offers the main features of a standard PBR material.
  58289. * For more information, please refer to the documentation :
  58290. * https://doc.babylonjs.com/how_to/physically_based_rendering
  58291. */
  58292. export class PBRMaterial extends PBRBaseMaterial {
  58293. /**
  58294. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  58295. */
  58296. static readonly PBRMATERIAL_OPAQUE: number;
  58297. /**
  58298. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  58299. */
  58300. static readonly PBRMATERIAL_ALPHATEST: number;
  58301. /**
  58302. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58303. */
  58304. static readonly PBRMATERIAL_ALPHABLEND: number;
  58305. /**
  58306. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58307. * They are also discarded below the alpha cutoff threshold to improve performances.
  58308. */
  58309. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  58310. /**
  58311. * Defines the default value of how much AO map is occluding the analytical lights
  58312. * (point spot...).
  58313. */
  58314. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  58315. /**
  58316. * Intensity of the direct lights e.g. the four lights available in your scene.
  58317. * This impacts both the direct diffuse and specular highlights.
  58318. */
  58319. directIntensity: number;
  58320. /**
  58321. * Intensity of the emissive part of the material.
  58322. * This helps controlling the emissive effect without modifying the emissive color.
  58323. */
  58324. emissiveIntensity: number;
  58325. /**
  58326. * Intensity of the environment e.g. how much the environment will light the object
  58327. * either through harmonics for rough material or through the refelction for shiny ones.
  58328. */
  58329. environmentIntensity: number;
  58330. /**
  58331. * This is a special control allowing the reduction of the specular highlights coming from the
  58332. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  58333. */
  58334. specularIntensity: number;
  58335. /**
  58336. * Debug Control allowing disabling the bump map on this material.
  58337. */
  58338. disableBumpMap: boolean;
  58339. /**
  58340. * AKA Diffuse Texture in standard nomenclature.
  58341. */
  58342. albedoTexture: BaseTexture;
  58343. /**
  58344. * AKA Occlusion Texture in other nomenclature.
  58345. */
  58346. ambientTexture: BaseTexture;
  58347. /**
  58348. * AKA Occlusion Texture Intensity in other nomenclature.
  58349. */
  58350. ambientTextureStrength: number;
  58351. /**
  58352. * Defines how much the AO map is occluding the analytical lights (point spot...).
  58353. * 1 means it completely occludes it
  58354. * 0 mean it has no impact
  58355. */
  58356. ambientTextureImpactOnAnalyticalLights: number;
  58357. /**
  58358. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  58359. */
  58360. opacityTexture: BaseTexture;
  58361. /**
  58362. * Stores the reflection values in a texture.
  58363. */
  58364. reflectionTexture: Nullable<BaseTexture>;
  58365. /**
  58366. * Stores the emissive values in a texture.
  58367. */
  58368. emissiveTexture: BaseTexture;
  58369. /**
  58370. * AKA Specular texture in other nomenclature.
  58371. */
  58372. reflectivityTexture: BaseTexture;
  58373. /**
  58374. * Used to switch from specular/glossiness to metallic/roughness workflow.
  58375. */
  58376. metallicTexture: BaseTexture;
  58377. /**
  58378. * Specifies the metallic scalar of the metallic/roughness workflow.
  58379. * Can also be used to scale the metalness values of the metallic texture.
  58380. */
  58381. metallic: Nullable<number>;
  58382. /**
  58383. * Specifies the roughness scalar of the metallic/roughness workflow.
  58384. * Can also be used to scale the roughness values of the metallic texture.
  58385. */
  58386. roughness: Nullable<number>;
  58387. /**
  58388. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  58389. * By default the indexOfrefraction is used to compute F0;
  58390. *
  58391. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  58392. *
  58393. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  58394. * F90 = metallicReflectanceColor;
  58395. */
  58396. metallicF0Factor: number;
  58397. /**
  58398. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  58399. * By default the F90 is always 1;
  58400. *
  58401. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  58402. *
  58403. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  58404. * F90 = metallicReflectanceColor;
  58405. */
  58406. metallicReflectanceColor: Color3;
  58407. /**
  58408. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  58409. * This is multiply against the scalar values defined in the material.
  58410. */
  58411. metallicReflectanceTexture: Nullable<BaseTexture>;
  58412. /**
  58413. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  58414. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  58415. */
  58416. microSurfaceTexture: BaseTexture;
  58417. /**
  58418. * Stores surface normal data used to displace a mesh in a texture.
  58419. */
  58420. bumpTexture: BaseTexture;
  58421. /**
  58422. * Stores the pre-calculated light information of a mesh in a texture.
  58423. */
  58424. lightmapTexture: BaseTexture;
  58425. /**
  58426. * Stores the refracted light information in a texture.
  58427. */
  58428. get refractionTexture(): Nullable<BaseTexture>;
  58429. set refractionTexture(value: Nullable<BaseTexture>);
  58430. /**
  58431. * The color of a material in ambient lighting.
  58432. */
  58433. ambientColor: Color3;
  58434. /**
  58435. * AKA Diffuse Color in other nomenclature.
  58436. */
  58437. albedoColor: Color3;
  58438. /**
  58439. * AKA Specular Color in other nomenclature.
  58440. */
  58441. reflectivityColor: Color3;
  58442. /**
  58443. * The color reflected from the material.
  58444. */
  58445. reflectionColor: Color3;
  58446. /**
  58447. * The color emitted from the material.
  58448. */
  58449. emissiveColor: Color3;
  58450. /**
  58451. * AKA Glossiness in other nomenclature.
  58452. */
  58453. microSurface: number;
  58454. /**
  58455. * Index of refraction of the material base layer.
  58456. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58457. *
  58458. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  58459. *
  58460. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  58461. */
  58462. get indexOfRefraction(): number;
  58463. set indexOfRefraction(value: number);
  58464. /**
  58465. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58466. */
  58467. get invertRefractionY(): boolean;
  58468. set invertRefractionY(value: boolean);
  58469. /**
  58470. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58471. * Materials half opaque for instance using refraction could benefit from this control.
  58472. */
  58473. get linkRefractionWithTransparency(): boolean;
  58474. set linkRefractionWithTransparency(value: boolean);
  58475. /**
  58476. * If true, the light map contains occlusion information instead of lighting info.
  58477. */
  58478. useLightmapAsShadowmap: boolean;
  58479. /**
  58480. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  58481. */
  58482. useAlphaFromAlbedoTexture: boolean;
  58483. /**
  58484. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  58485. */
  58486. forceAlphaTest: boolean;
  58487. /**
  58488. * Defines the alpha limits in alpha test mode.
  58489. */
  58490. alphaCutOff: number;
  58491. /**
  58492. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  58493. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  58494. */
  58495. useSpecularOverAlpha: boolean;
  58496. /**
  58497. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  58498. */
  58499. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  58500. /**
  58501. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  58502. */
  58503. useRoughnessFromMetallicTextureAlpha: boolean;
  58504. /**
  58505. * Specifies if the metallic texture contains the roughness information in its green channel.
  58506. */
  58507. useRoughnessFromMetallicTextureGreen: boolean;
  58508. /**
  58509. * Specifies if the metallic texture contains the metallness information in its blue channel.
  58510. */
  58511. useMetallnessFromMetallicTextureBlue: boolean;
  58512. /**
  58513. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  58514. */
  58515. useAmbientOcclusionFromMetallicTextureRed: boolean;
  58516. /**
  58517. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  58518. */
  58519. useAmbientInGrayScale: boolean;
  58520. /**
  58521. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  58522. * The material will try to infer what glossiness each pixel should be.
  58523. */
  58524. useAutoMicroSurfaceFromReflectivityMap: boolean;
  58525. /**
  58526. * BJS is using an harcoded light falloff based on a manually sets up range.
  58527. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  58528. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  58529. */
  58530. get usePhysicalLightFalloff(): boolean;
  58531. /**
  58532. * BJS is using an harcoded light falloff based on a manually sets up range.
  58533. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  58534. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  58535. */
  58536. set usePhysicalLightFalloff(value: boolean);
  58537. /**
  58538. * In order to support the falloff compatibility with gltf, a special mode has been added
  58539. * to reproduce the gltf light falloff.
  58540. */
  58541. get useGLTFLightFalloff(): boolean;
  58542. /**
  58543. * In order to support the falloff compatibility with gltf, a special mode has been added
  58544. * to reproduce the gltf light falloff.
  58545. */
  58546. set useGLTFLightFalloff(value: boolean);
  58547. /**
  58548. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  58549. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  58550. */
  58551. useRadianceOverAlpha: boolean;
  58552. /**
  58553. * Allows using an object space normal map (instead of tangent space).
  58554. */
  58555. useObjectSpaceNormalMap: boolean;
  58556. /**
  58557. * Allows using the bump map in parallax mode.
  58558. */
  58559. useParallax: boolean;
  58560. /**
  58561. * Allows using the bump map in parallax occlusion mode.
  58562. */
  58563. useParallaxOcclusion: boolean;
  58564. /**
  58565. * Controls the scale bias of the parallax mode.
  58566. */
  58567. parallaxScaleBias: number;
  58568. /**
  58569. * If sets to true, disables all the lights affecting the material.
  58570. */
  58571. disableLighting: boolean;
  58572. /**
  58573. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  58574. */
  58575. forceIrradianceInFragment: boolean;
  58576. /**
  58577. * Number of Simultaneous lights allowed on the material.
  58578. */
  58579. maxSimultaneousLights: number;
  58580. /**
  58581. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58582. */
  58583. invertNormalMapX: boolean;
  58584. /**
  58585. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58586. */
  58587. invertNormalMapY: boolean;
  58588. /**
  58589. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58590. */
  58591. twoSidedLighting: boolean;
  58592. /**
  58593. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58594. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  58595. */
  58596. useAlphaFresnel: boolean;
  58597. /**
  58598. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58599. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  58600. */
  58601. useLinearAlphaFresnel: boolean;
  58602. /**
  58603. * Let user defines the brdf lookup texture used for IBL.
  58604. * A default 8bit version is embedded but you could point at :
  58605. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  58606. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  58607. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  58608. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  58609. */
  58610. environmentBRDFTexture: Nullable<BaseTexture>;
  58611. /**
  58612. * Force normal to face away from face.
  58613. */
  58614. forceNormalForward: boolean;
  58615. /**
  58616. * Enables specular anti aliasing in the PBR shader.
  58617. * It will both interacts on the Geometry for analytical and IBL lighting.
  58618. * It also prefilter the roughness map based on the bump values.
  58619. */
  58620. enableSpecularAntiAliasing: boolean;
  58621. /**
  58622. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  58623. * makes the reflect vector face the model (under horizon).
  58624. */
  58625. useHorizonOcclusion: boolean;
  58626. /**
  58627. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  58628. * too much the area relying on ambient texture to define their ambient occlusion.
  58629. */
  58630. useRadianceOcclusion: boolean;
  58631. /**
  58632. * If set to true, no lighting calculations will be applied.
  58633. */
  58634. unlit: boolean;
  58635. /**
  58636. * Gets the image processing configuration used either in this material.
  58637. */
  58638. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  58639. /**
  58640. * Sets the Default image processing configuration used either in the this material.
  58641. *
  58642. * If sets to null, the scene one is in use.
  58643. */
  58644. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  58645. /**
  58646. * Gets wether the color curves effect is enabled.
  58647. */
  58648. get cameraColorCurvesEnabled(): boolean;
  58649. /**
  58650. * Sets wether the color curves effect is enabled.
  58651. */
  58652. set cameraColorCurvesEnabled(value: boolean);
  58653. /**
  58654. * Gets wether the color grading effect is enabled.
  58655. */
  58656. get cameraColorGradingEnabled(): boolean;
  58657. /**
  58658. * Gets wether the color grading effect is enabled.
  58659. */
  58660. set cameraColorGradingEnabled(value: boolean);
  58661. /**
  58662. * Gets wether tonemapping is enabled or not.
  58663. */
  58664. get cameraToneMappingEnabled(): boolean;
  58665. /**
  58666. * Sets wether tonemapping is enabled or not
  58667. */
  58668. set cameraToneMappingEnabled(value: boolean);
  58669. /**
  58670. * The camera exposure used on this material.
  58671. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58672. * This corresponds to a photographic exposure.
  58673. */
  58674. get cameraExposure(): number;
  58675. /**
  58676. * The camera exposure used on this material.
  58677. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58678. * This corresponds to a photographic exposure.
  58679. */
  58680. set cameraExposure(value: number);
  58681. /**
  58682. * Gets The camera contrast used on this material.
  58683. */
  58684. get cameraContrast(): number;
  58685. /**
  58686. * Sets The camera contrast used on this material.
  58687. */
  58688. set cameraContrast(value: number);
  58689. /**
  58690. * Gets the Color Grading 2D Lookup Texture.
  58691. */
  58692. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  58693. /**
  58694. * Sets the Color Grading 2D Lookup Texture.
  58695. */
  58696. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  58697. /**
  58698. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58699. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58700. * 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;
  58701. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58702. */
  58703. get cameraColorCurves(): Nullable<ColorCurves>;
  58704. /**
  58705. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58706. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58707. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  58708. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58709. */
  58710. set cameraColorCurves(value: Nullable<ColorCurves>);
  58711. /**
  58712. * Instantiates a new PBRMaterial instance.
  58713. *
  58714. * @param name The material name
  58715. * @param scene The scene the material will be use in.
  58716. */
  58717. constructor(name: string, scene: Scene);
  58718. /**
  58719. * Returns the name of this material class.
  58720. */
  58721. getClassName(): string;
  58722. /**
  58723. * Makes a duplicate of the current material.
  58724. * @param name - name to use for the new material.
  58725. */
  58726. clone(name: string): PBRMaterial;
  58727. /**
  58728. * Serializes this PBR Material.
  58729. * @returns - An object with the serialized material.
  58730. */
  58731. serialize(): any;
  58732. /**
  58733. * Parses a PBR Material from a serialized object.
  58734. * @param source - Serialized object.
  58735. * @param scene - BJS scene instance.
  58736. * @param rootUrl - url for the scene object
  58737. * @returns - PBRMaterial
  58738. */
  58739. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  58740. }
  58741. }
  58742. declare module "babylonjs/Misc/dds" {
  58743. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58744. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58745. import { Nullable } from "babylonjs/types";
  58746. import { Scene } from "babylonjs/scene";
  58747. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  58748. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58749. /**
  58750. * Direct draw surface info
  58751. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58752. */
  58753. export interface DDSInfo {
  58754. /**
  58755. * Width of the texture
  58756. */
  58757. width: number;
  58758. /**
  58759. * Width of the texture
  58760. */
  58761. height: number;
  58762. /**
  58763. * Number of Mipmaps for the texture
  58764. * @see https://en.wikipedia.org/wiki/Mipmap
  58765. */
  58766. mipmapCount: number;
  58767. /**
  58768. * If the textures format is a known fourCC format
  58769. * @see https://www.fourcc.org/
  58770. */
  58771. isFourCC: boolean;
  58772. /**
  58773. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58774. */
  58775. isRGB: boolean;
  58776. /**
  58777. * If the texture is a lumincance format
  58778. */
  58779. isLuminance: boolean;
  58780. /**
  58781. * If this is a cube texture
  58782. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58783. */
  58784. isCube: boolean;
  58785. /**
  58786. * If the texture is a compressed format eg. FOURCC_DXT1
  58787. */
  58788. isCompressed: boolean;
  58789. /**
  58790. * The dxgiFormat of the texture
  58791. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58792. */
  58793. dxgiFormat: number;
  58794. /**
  58795. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58796. */
  58797. textureType: number;
  58798. /**
  58799. * Sphericle polynomial created for the dds texture
  58800. */
  58801. sphericalPolynomial?: SphericalPolynomial;
  58802. }
  58803. /**
  58804. * Class used to provide DDS decompression tools
  58805. */
  58806. export class DDSTools {
  58807. /**
  58808. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58809. */
  58810. static StoreLODInAlphaChannel: boolean;
  58811. /**
  58812. * Gets DDS information from an array buffer
  58813. * @param data defines the array buffer view to read data from
  58814. * @returns the DDS information
  58815. */
  58816. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58817. private static _FloatView;
  58818. private static _Int32View;
  58819. private static _ToHalfFloat;
  58820. private static _FromHalfFloat;
  58821. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58822. private static _GetHalfFloatRGBAArrayBuffer;
  58823. private static _GetFloatRGBAArrayBuffer;
  58824. private static _GetFloatAsUIntRGBAArrayBuffer;
  58825. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58826. private static _GetRGBAArrayBuffer;
  58827. private static _ExtractLongWordOrder;
  58828. private static _GetRGBArrayBuffer;
  58829. private static _GetLuminanceArrayBuffer;
  58830. /**
  58831. * Uploads DDS Levels to a Babylon Texture
  58832. * @hidden
  58833. */
  58834. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58835. }
  58836. module "babylonjs/Engines/thinEngine" {
  58837. interface ThinEngine {
  58838. /**
  58839. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58840. * @param rootUrl defines the url where the file to load is located
  58841. * @param scene defines the current scene
  58842. * @param lodScale defines scale to apply to the mip map selection
  58843. * @param lodOffset defines offset to apply to the mip map selection
  58844. * @param onLoad defines an optional callback raised when the texture is loaded
  58845. * @param onError defines an optional callback raised if there is an issue to load the texture
  58846. * @param format defines the format of the data
  58847. * @param forcedExtension defines the extension to use to pick the right loader
  58848. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58849. * @returns the cube texture as an InternalTexture
  58850. */
  58851. 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;
  58852. }
  58853. }
  58854. }
  58855. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  58856. import { Nullable } from "babylonjs/types";
  58857. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58858. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58859. /**
  58860. * Implementation of the DDS Texture Loader.
  58861. * @hidden
  58862. */
  58863. export class _DDSTextureLoader implements IInternalTextureLoader {
  58864. /**
  58865. * Defines wether the loader supports cascade loading the different faces.
  58866. */
  58867. readonly supportCascades: boolean;
  58868. /**
  58869. * This returns if the loader support the current file information.
  58870. * @param extension defines the file extension of the file being loaded
  58871. * @returns true if the loader can load the specified file
  58872. */
  58873. canLoad(extension: string): boolean;
  58874. /**
  58875. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58876. * @param data contains the texture data
  58877. * @param texture defines the BabylonJS internal texture
  58878. * @param createPolynomials will be true if polynomials have been requested
  58879. * @param onLoad defines the callback to trigger once the texture is ready
  58880. * @param onError defines the callback to trigger in case of error
  58881. */
  58882. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58883. /**
  58884. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58885. * @param data contains the texture data
  58886. * @param texture defines the BabylonJS internal texture
  58887. * @param callback defines the method to call once ready to upload
  58888. */
  58889. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58890. }
  58891. }
  58892. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  58893. import { Nullable } from "babylonjs/types";
  58894. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58895. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58896. /**
  58897. * Implementation of the ENV Texture Loader.
  58898. * @hidden
  58899. */
  58900. export class _ENVTextureLoader implements IInternalTextureLoader {
  58901. /**
  58902. * Defines wether the loader supports cascade loading the different faces.
  58903. */
  58904. readonly supportCascades: boolean;
  58905. /**
  58906. * This returns if the loader support the current file information.
  58907. * @param extension defines the file extension of the file being loaded
  58908. * @returns true if the loader can load the specified file
  58909. */
  58910. canLoad(extension: string): boolean;
  58911. /**
  58912. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58913. * @param data contains the texture data
  58914. * @param texture defines the BabylonJS internal texture
  58915. * @param createPolynomials will be true if polynomials have been requested
  58916. * @param onLoad defines the callback to trigger once the texture is ready
  58917. * @param onError defines the callback to trigger in case of error
  58918. */
  58919. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58920. /**
  58921. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58922. * @param data contains the texture data
  58923. * @param texture defines the BabylonJS internal texture
  58924. * @param callback defines the method to call once ready to upload
  58925. */
  58926. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58927. }
  58928. }
  58929. declare module "babylonjs/Misc/khronosTextureContainer" {
  58930. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58931. /**
  58932. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58933. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58934. */
  58935. export class KhronosTextureContainer {
  58936. /** contents of the KTX container file */
  58937. data: ArrayBufferView;
  58938. private static HEADER_LEN;
  58939. private static COMPRESSED_2D;
  58940. private static COMPRESSED_3D;
  58941. private static TEX_2D;
  58942. private static TEX_3D;
  58943. /**
  58944. * Gets the openGL type
  58945. */
  58946. glType: number;
  58947. /**
  58948. * Gets the openGL type size
  58949. */
  58950. glTypeSize: number;
  58951. /**
  58952. * Gets the openGL format
  58953. */
  58954. glFormat: number;
  58955. /**
  58956. * Gets the openGL internal format
  58957. */
  58958. glInternalFormat: number;
  58959. /**
  58960. * Gets the base internal format
  58961. */
  58962. glBaseInternalFormat: number;
  58963. /**
  58964. * Gets image width in pixel
  58965. */
  58966. pixelWidth: number;
  58967. /**
  58968. * Gets image height in pixel
  58969. */
  58970. pixelHeight: number;
  58971. /**
  58972. * Gets image depth in pixels
  58973. */
  58974. pixelDepth: number;
  58975. /**
  58976. * Gets the number of array elements
  58977. */
  58978. numberOfArrayElements: number;
  58979. /**
  58980. * Gets the number of faces
  58981. */
  58982. numberOfFaces: number;
  58983. /**
  58984. * Gets the number of mipmap levels
  58985. */
  58986. numberOfMipmapLevels: number;
  58987. /**
  58988. * Gets the bytes of key value data
  58989. */
  58990. bytesOfKeyValueData: number;
  58991. /**
  58992. * Gets the load type
  58993. */
  58994. loadType: number;
  58995. /**
  58996. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  58997. */
  58998. isInvalid: boolean;
  58999. /**
  59000. * Creates a new KhronosTextureContainer
  59001. * @param data contents of the KTX container file
  59002. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  59003. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  59004. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  59005. */
  59006. constructor(
  59007. /** contents of the KTX container file */
  59008. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  59009. /**
  59010. * Uploads KTX content to a Babylon Texture.
  59011. * It is assumed that the texture has already been created & is currently bound
  59012. * @hidden
  59013. */
  59014. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  59015. private _upload2DCompressedLevels;
  59016. /**
  59017. * Checks if the given data starts with a KTX file identifier.
  59018. * @param data the data to check
  59019. * @returns true if the data is a KTX file or false otherwise
  59020. */
  59021. static IsValid(data: ArrayBufferView): boolean;
  59022. }
  59023. }
  59024. declare module "babylonjs/Misc/khronosTextureContainer2" {
  59025. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59026. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59027. /**
  59028. * Class for loading KTX2 files
  59029. * !!! Experimental Extension Subject to Changes !!!
  59030. * @hidden
  59031. */
  59032. export class KhronosTextureContainer2 {
  59033. private static _ModulePromise;
  59034. private static _TranscodeFormat;
  59035. constructor(engine: ThinEngine);
  59036. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  59037. private _determineTranscodeFormat;
  59038. /**
  59039. * Checks if the given data starts with a KTX2 file identifier.
  59040. * @param data the data to check
  59041. * @returns true if the data is a KTX2 file or false otherwise
  59042. */
  59043. static IsValid(data: ArrayBufferView): boolean;
  59044. }
  59045. }
  59046. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  59047. import { Nullable } from "babylonjs/types";
  59048. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59049. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59050. /**
  59051. * Implementation of the KTX Texture Loader.
  59052. * @hidden
  59053. */
  59054. export class _KTXTextureLoader implements IInternalTextureLoader {
  59055. /**
  59056. * Defines wether the loader supports cascade loading the different faces.
  59057. */
  59058. readonly supportCascades: boolean;
  59059. /**
  59060. * This returns if the loader support the current file information.
  59061. * @param extension defines the file extension of the file being loaded
  59062. * @param mimeType defines the optional mime type of the file being loaded
  59063. * @returns true if the loader can load the specified file
  59064. */
  59065. canLoad(extension: string, mimeType?: string): boolean;
  59066. /**
  59067. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59068. * @param data contains the texture data
  59069. * @param texture defines the BabylonJS internal texture
  59070. * @param createPolynomials will be true if polynomials have been requested
  59071. * @param onLoad defines the callback to trigger once the texture is ready
  59072. * @param onError defines the callback to trigger in case of error
  59073. */
  59074. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59075. /**
  59076. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59077. * @param data contains the texture data
  59078. * @param texture defines the BabylonJS internal texture
  59079. * @param callback defines the method to call once ready to upload
  59080. */
  59081. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  59082. }
  59083. }
  59084. declare module "babylonjs/Helpers/sceneHelpers" {
  59085. import { Nullable } from "babylonjs/types";
  59086. import { Mesh } from "babylonjs/Meshes/mesh";
  59087. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59088. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  59089. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  59090. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  59091. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  59092. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  59093. import "babylonjs/Meshes/Builders/boxBuilder";
  59094. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  59095. /** @hidden */
  59096. export var _forceSceneHelpersToBundle: boolean;
  59097. module "babylonjs/scene" {
  59098. interface Scene {
  59099. /**
  59100. * Creates a default light for the scene.
  59101. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  59102. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  59103. */
  59104. createDefaultLight(replace?: boolean): void;
  59105. /**
  59106. * Creates a default camera for the scene.
  59107. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  59108. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59109. * @param replace has default false, when true replaces the active camera in the scene
  59110. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  59111. */
  59112. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59113. /**
  59114. * Creates a default camera and a default light.
  59115. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  59116. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59117. * @param replace has the default false, when true replaces the active camera/light in the scene
  59118. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  59119. */
  59120. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59121. /**
  59122. * Creates a new sky box
  59123. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  59124. * @param environmentTexture defines the texture to use as environment texture
  59125. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  59126. * @param scale defines the overall scale of the skybox
  59127. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  59128. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  59129. * @returns a new mesh holding the sky box
  59130. */
  59131. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  59132. /**
  59133. * Creates a new environment
  59134. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  59135. * @param options defines the options you can use to configure the environment
  59136. * @returns the new EnvironmentHelper
  59137. */
  59138. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  59139. /**
  59140. * Creates a new VREXperienceHelper
  59141. * @see https://doc.babylonjs.com/how_to/webvr_helper
  59142. * @param webVROptions defines the options used to create the new VREXperienceHelper
  59143. * @returns a new VREXperienceHelper
  59144. */
  59145. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  59146. /**
  59147. * Creates a new WebXRDefaultExperience
  59148. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  59149. * @param options experience options
  59150. * @returns a promise for a new WebXRDefaultExperience
  59151. */
  59152. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  59153. }
  59154. }
  59155. }
  59156. declare module "babylonjs/Helpers/videoDome" {
  59157. import { Scene } from "babylonjs/scene";
  59158. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59159. import { Mesh } from "babylonjs/Meshes/mesh";
  59160. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  59161. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  59162. import "babylonjs/Meshes/Builders/sphereBuilder";
  59163. /**
  59164. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  59165. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  59166. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  59167. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59168. */
  59169. export class VideoDome extends TransformNode {
  59170. /**
  59171. * Define the video source as a Monoscopic panoramic 360 video.
  59172. */
  59173. static readonly MODE_MONOSCOPIC: number;
  59174. /**
  59175. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59176. */
  59177. static readonly MODE_TOPBOTTOM: number;
  59178. /**
  59179. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59180. */
  59181. static readonly MODE_SIDEBYSIDE: number;
  59182. private _halfDome;
  59183. private _useDirectMapping;
  59184. /**
  59185. * The video texture being displayed on the sphere
  59186. */
  59187. protected _videoTexture: VideoTexture;
  59188. /**
  59189. * Gets the video texture being displayed on the sphere
  59190. */
  59191. get videoTexture(): VideoTexture;
  59192. /**
  59193. * The skybox material
  59194. */
  59195. protected _material: BackgroundMaterial;
  59196. /**
  59197. * The surface used for the skybox
  59198. */
  59199. protected _mesh: Mesh;
  59200. /**
  59201. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  59202. */
  59203. private _halfDomeMask;
  59204. /**
  59205. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  59206. * Also see the options.resolution property.
  59207. */
  59208. get fovMultiplier(): number;
  59209. set fovMultiplier(value: number);
  59210. private _videoMode;
  59211. /**
  59212. * Gets or set the current video mode for the video. It can be:
  59213. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  59214. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59215. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59216. */
  59217. get videoMode(): number;
  59218. set videoMode(value: number);
  59219. /**
  59220. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  59221. *
  59222. */
  59223. get halfDome(): boolean;
  59224. /**
  59225. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  59226. */
  59227. set halfDome(enabled: boolean);
  59228. /**
  59229. * Oberserver used in Stereoscopic VR Mode.
  59230. */
  59231. private _onBeforeCameraRenderObserver;
  59232. /**
  59233. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  59234. * @param name Element's name, child elements will append suffixes for their own names.
  59235. * @param urlsOrVideo defines the url(s) or the video element to use
  59236. * @param options An object containing optional or exposed sub element properties
  59237. */
  59238. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  59239. resolution?: number;
  59240. clickToPlay?: boolean;
  59241. autoPlay?: boolean;
  59242. loop?: boolean;
  59243. size?: number;
  59244. poster?: string;
  59245. faceForward?: boolean;
  59246. useDirectMapping?: boolean;
  59247. halfDomeMode?: boolean;
  59248. }, scene: Scene);
  59249. private _changeVideoMode;
  59250. /**
  59251. * Releases resources associated with this node.
  59252. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  59253. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  59254. */
  59255. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  59256. }
  59257. }
  59258. declare module "babylonjs/Helpers/index" {
  59259. export * from "babylonjs/Helpers/environmentHelper";
  59260. export * from "babylonjs/Helpers/photoDome";
  59261. export * from "babylonjs/Helpers/sceneHelpers";
  59262. export * from "babylonjs/Helpers/videoDome";
  59263. }
  59264. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  59265. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  59266. import { IDisposable } from "babylonjs/scene";
  59267. import { Engine } from "babylonjs/Engines/engine";
  59268. /**
  59269. * This class can be used to get instrumentation data from a Babylon engine
  59270. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59271. */
  59272. export class EngineInstrumentation implements IDisposable {
  59273. /**
  59274. * Define the instrumented engine.
  59275. */
  59276. engine: Engine;
  59277. private _captureGPUFrameTime;
  59278. private _gpuFrameTimeToken;
  59279. private _gpuFrameTime;
  59280. private _captureShaderCompilationTime;
  59281. private _shaderCompilationTime;
  59282. private _onBeginFrameObserver;
  59283. private _onEndFrameObserver;
  59284. private _onBeforeShaderCompilationObserver;
  59285. private _onAfterShaderCompilationObserver;
  59286. /**
  59287. * Gets the perf counter used for GPU frame time
  59288. */
  59289. get gpuFrameTimeCounter(): PerfCounter;
  59290. /**
  59291. * Gets the GPU frame time capture status
  59292. */
  59293. get captureGPUFrameTime(): boolean;
  59294. /**
  59295. * Enable or disable the GPU frame time capture
  59296. */
  59297. set captureGPUFrameTime(value: boolean);
  59298. /**
  59299. * Gets the perf counter used for shader compilation time
  59300. */
  59301. get shaderCompilationTimeCounter(): PerfCounter;
  59302. /**
  59303. * Gets the shader compilation time capture status
  59304. */
  59305. get captureShaderCompilationTime(): boolean;
  59306. /**
  59307. * Enable or disable the shader compilation time capture
  59308. */
  59309. set captureShaderCompilationTime(value: boolean);
  59310. /**
  59311. * Instantiates a new engine instrumentation.
  59312. * This class can be used to get instrumentation data from a Babylon engine
  59313. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59314. * @param engine Defines the engine to instrument
  59315. */
  59316. constructor(
  59317. /**
  59318. * Define the instrumented engine.
  59319. */
  59320. engine: Engine);
  59321. /**
  59322. * Dispose and release associated resources.
  59323. */
  59324. dispose(): void;
  59325. }
  59326. }
  59327. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  59328. import { Scene, IDisposable } from "babylonjs/scene";
  59329. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  59330. /**
  59331. * This class can be used to get instrumentation data from a Babylon engine
  59332. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59333. */
  59334. export class SceneInstrumentation implements IDisposable {
  59335. /**
  59336. * Defines the scene to instrument
  59337. */
  59338. scene: Scene;
  59339. private _captureActiveMeshesEvaluationTime;
  59340. private _activeMeshesEvaluationTime;
  59341. private _captureRenderTargetsRenderTime;
  59342. private _renderTargetsRenderTime;
  59343. private _captureFrameTime;
  59344. private _frameTime;
  59345. private _captureRenderTime;
  59346. private _renderTime;
  59347. private _captureInterFrameTime;
  59348. private _interFrameTime;
  59349. private _captureParticlesRenderTime;
  59350. private _particlesRenderTime;
  59351. private _captureSpritesRenderTime;
  59352. private _spritesRenderTime;
  59353. private _capturePhysicsTime;
  59354. private _physicsTime;
  59355. private _captureAnimationsTime;
  59356. private _animationsTime;
  59357. private _captureCameraRenderTime;
  59358. private _cameraRenderTime;
  59359. private _onBeforeActiveMeshesEvaluationObserver;
  59360. private _onAfterActiveMeshesEvaluationObserver;
  59361. private _onBeforeRenderTargetsRenderObserver;
  59362. private _onAfterRenderTargetsRenderObserver;
  59363. private _onAfterRenderObserver;
  59364. private _onBeforeDrawPhaseObserver;
  59365. private _onAfterDrawPhaseObserver;
  59366. private _onBeforeAnimationsObserver;
  59367. private _onBeforeParticlesRenderingObserver;
  59368. private _onAfterParticlesRenderingObserver;
  59369. private _onBeforeSpritesRenderingObserver;
  59370. private _onAfterSpritesRenderingObserver;
  59371. private _onBeforePhysicsObserver;
  59372. private _onAfterPhysicsObserver;
  59373. private _onAfterAnimationsObserver;
  59374. private _onBeforeCameraRenderObserver;
  59375. private _onAfterCameraRenderObserver;
  59376. /**
  59377. * Gets the perf counter used for active meshes evaluation time
  59378. */
  59379. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59380. /**
  59381. * Gets the active meshes evaluation time capture status
  59382. */
  59383. get captureActiveMeshesEvaluationTime(): boolean;
  59384. /**
  59385. * Enable or disable the active meshes evaluation time capture
  59386. */
  59387. set captureActiveMeshesEvaluationTime(value: boolean);
  59388. /**
  59389. * Gets the perf counter used for render targets render time
  59390. */
  59391. get renderTargetsRenderTimeCounter(): PerfCounter;
  59392. /**
  59393. * Gets the render targets render time capture status
  59394. */
  59395. get captureRenderTargetsRenderTime(): boolean;
  59396. /**
  59397. * Enable or disable the render targets render time capture
  59398. */
  59399. set captureRenderTargetsRenderTime(value: boolean);
  59400. /**
  59401. * Gets the perf counter used for particles render time
  59402. */
  59403. get particlesRenderTimeCounter(): PerfCounter;
  59404. /**
  59405. * Gets the particles render time capture status
  59406. */
  59407. get captureParticlesRenderTime(): boolean;
  59408. /**
  59409. * Enable or disable the particles render time capture
  59410. */
  59411. set captureParticlesRenderTime(value: boolean);
  59412. /**
  59413. * Gets the perf counter used for sprites render time
  59414. */
  59415. get spritesRenderTimeCounter(): PerfCounter;
  59416. /**
  59417. * Gets the sprites render time capture status
  59418. */
  59419. get captureSpritesRenderTime(): boolean;
  59420. /**
  59421. * Enable or disable the sprites render time capture
  59422. */
  59423. set captureSpritesRenderTime(value: boolean);
  59424. /**
  59425. * Gets the perf counter used for physics time
  59426. */
  59427. get physicsTimeCounter(): PerfCounter;
  59428. /**
  59429. * Gets the physics time capture status
  59430. */
  59431. get capturePhysicsTime(): boolean;
  59432. /**
  59433. * Enable or disable the physics time capture
  59434. */
  59435. set capturePhysicsTime(value: boolean);
  59436. /**
  59437. * Gets the perf counter used for animations time
  59438. */
  59439. get animationsTimeCounter(): PerfCounter;
  59440. /**
  59441. * Gets the animations time capture status
  59442. */
  59443. get captureAnimationsTime(): boolean;
  59444. /**
  59445. * Enable or disable the animations time capture
  59446. */
  59447. set captureAnimationsTime(value: boolean);
  59448. /**
  59449. * Gets the perf counter used for frame time capture
  59450. */
  59451. get frameTimeCounter(): PerfCounter;
  59452. /**
  59453. * Gets the frame time capture status
  59454. */
  59455. get captureFrameTime(): boolean;
  59456. /**
  59457. * Enable or disable the frame time capture
  59458. */
  59459. set captureFrameTime(value: boolean);
  59460. /**
  59461. * Gets the perf counter used for inter-frames time capture
  59462. */
  59463. get interFrameTimeCounter(): PerfCounter;
  59464. /**
  59465. * Gets the inter-frames time capture status
  59466. */
  59467. get captureInterFrameTime(): boolean;
  59468. /**
  59469. * Enable or disable the inter-frames time capture
  59470. */
  59471. set captureInterFrameTime(value: boolean);
  59472. /**
  59473. * Gets the perf counter used for render time capture
  59474. */
  59475. get renderTimeCounter(): PerfCounter;
  59476. /**
  59477. * Gets the render time capture status
  59478. */
  59479. get captureRenderTime(): boolean;
  59480. /**
  59481. * Enable or disable the render time capture
  59482. */
  59483. set captureRenderTime(value: boolean);
  59484. /**
  59485. * Gets the perf counter used for camera render time capture
  59486. */
  59487. get cameraRenderTimeCounter(): PerfCounter;
  59488. /**
  59489. * Gets the camera render time capture status
  59490. */
  59491. get captureCameraRenderTime(): boolean;
  59492. /**
  59493. * Enable or disable the camera render time capture
  59494. */
  59495. set captureCameraRenderTime(value: boolean);
  59496. /**
  59497. * Gets the perf counter used for draw calls
  59498. */
  59499. get drawCallsCounter(): PerfCounter;
  59500. /**
  59501. * Instantiates a new scene instrumentation.
  59502. * This class can be used to get instrumentation data from a Babylon engine
  59503. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59504. * @param scene Defines the scene to instrument
  59505. */
  59506. constructor(
  59507. /**
  59508. * Defines the scene to instrument
  59509. */
  59510. scene: Scene);
  59511. /**
  59512. * Dispose and release associated resources.
  59513. */
  59514. dispose(): void;
  59515. }
  59516. }
  59517. declare module "babylonjs/Instrumentation/index" {
  59518. export * from "babylonjs/Instrumentation/engineInstrumentation";
  59519. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  59520. export * from "babylonjs/Instrumentation/timeToken";
  59521. }
  59522. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  59523. /** @hidden */
  59524. export var glowMapGenerationPixelShader: {
  59525. name: string;
  59526. shader: string;
  59527. };
  59528. }
  59529. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  59530. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59531. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59532. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59533. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59534. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59535. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59536. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59537. /** @hidden */
  59538. export var glowMapGenerationVertexShader: {
  59539. name: string;
  59540. shader: string;
  59541. };
  59542. }
  59543. declare module "babylonjs/Layers/effectLayer" {
  59544. import { Observable } from "babylonjs/Misc/observable";
  59545. import { Nullable } from "babylonjs/types";
  59546. import { Camera } from "babylonjs/Cameras/camera";
  59547. import { Scene } from "babylonjs/scene";
  59548. import { ISize } from "babylonjs/Maths/math.size";
  59549. import { Color4 } from "babylonjs/Maths/math.color";
  59550. import { Engine } from "babylonjs/Engines/engine";
  59551. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59553. import { Mesh } from "babylonjs/Meshes/mesh";
  59554. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59555. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59556. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59557. import { Effect } from "babylonjs/Materials/effect";
  59558. import { Material } from "babylonjs/Materials/material";
  59559. import "babylonjs/Shaders/glowMapGeneration.fragment";
  59560. import "babylonjs/Shaders/glowMapGeneration.vertex";
  59561. /**
  59562. * Effect layer options. This helps customizing the behaviour
  59563. * of the effect layer.
  59564. */
  59565. export interface IEffectLayerOptions {
  59566. /**
  59567. * Multiplication factor apply to the canvas size to compute the render target size
  59568. * used to generated the objects (the smaller the faster).
  59569. */
  59570. mainTextureRatio: number;
  59571. /**
  59572. * Enforces a fixed size texture to ensure effect stability across devices.
  59573. */
  59574. mainTextureFixedSize?: number;
  59575. /**
  59576. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59577. */
  59578. alphaBlendingMode: number;
  59579. /**
  59580. * The camera attached to the layer.
  59581. */
  59582. camera: Nullable<Camera>;
  59583. /**
  59584. * The rendering group to draw the layer in.
  59585. */
  59586. renderingGroupId: number;
  59587. }
  59588. /**
  59589. * The effect layer Helps adding post process effect blended with the main pass.
  59590. *
  59591. * This can be for instance use to generate glow or higlight effects on the scene.
  59592. *
  59593. * The effect layer class can not be used directly and is intented to inherited from to be
  59594. * customized per effects.
  59595. */
  59596. export abstract class EffectLayer {
  59597. private _vertexBuffers;
  59598. private _indexBuffer;
  59599. private _cachedDefines;
  59600. private _effectLayerMapGenerationEffect;
  59601. private _effectLayerOptions;
  59602. private _mergeEffect;
  59603. protected _scene: Scene;
  59604. protected _engine: Engine;
  59605. protected _maxSize: number;
  59606. protected _mainTextureDesiredSize: ISize;
  59607. protected _mainTexture: RenderTargetTexture;
  59608. protected _shouldRender: boolean;
  59609. protected _postProcesses: PostProcess[];
  59610. protected _textures: BaseTexture[];
  59611. protected _emissiveTextureAndColor: {
  59612. texture: Nullable<BaseTexture>;
  59613. color: Color4;
  59614. };
  59615. /**
  59616. * The name of the layer
  59617. */
  59618. name: string;
  59619. /**
  59620. * The clear color of the texture used to generate the glow map.
  59621. */
  59622. neutralColor: Color4;
  59623. /**
  59624. * Specifies whether the highlight layer is enabled or not.
  59625. */
  59626. isEnabled: boolean;
  59627. /**
  59628. * Gets the camera attached to the layer.
  59629. */
  59630. get camera(): Nullable<Camera>;
  59631. /**
  59632. * Gets the rendering group id the layer should render in.
  59633. */
  59634. get renderingGroupId(): number;
  59635. set renderingGroupId(renderingGroupId: number);
  59636. /**
  59637. * An event triggered when the effect layer has been disposed.
  59638. */
  59639. onDisposeObservable: Observable<EffectLayer>;
  59640. /**
  59641. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59642. */
  59643. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59644. /**
  59645. * An event triggered when the generated texture is being merged in the scene.
  59646. */
  59647. onBeforeComposeObservable: Observable<EffectLayer>;
  59648. /**
  59649. * An event triggered when the mesh is rendered into the effect render target.
  59650. */
  59651. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59652. /**
  59653. * An event triggered after the mesh has been rendered into the effect render target.
  59654. */
  59655. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59656. /**
  59657. * An event triggered when the generated texture has been merged in the scene.
  59658. */
  59659. onAfterComposeObservable: Observable<EffectLayer>;
  59660. /**
  59661. * An event triggered when the efffect layer changes its size.
  59662. */
  59663. onSizeChangedObservable: Observable<EffectLayer>;
  59664. /** @hidden */
  59665. static _SceneComponentInitialization: (scene: Scene) => void;
  59666. /**
  59667. * Instantiates a new effect Layer and references it in the scene.
  59668. * @param name The name of the layer
  59669. * @param scene The scene to use the layer in
  59670. */
  59671. constructor(
  59672. /** The Friendly of the effect in the scene */
  59673. name: string, scene: Scene);
  59674. /**
  59675. * Get the effect name of the layer.
  59676. * @return The effect name
  59677. */
  59678. abstract getEffectName(): string;
  59679. /**
  59680. * Checks for the readiness of the element composing the layer.
  59681. * @param subMesh the mesh to check for
  59682. * @param useInstances specify whether or not to use instances to render the mesh
  59683. * @return true if ready otherwise, false
  59684. */
  59685. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59686. /**
  59687. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59688. * @returns true if the effect requires stencil during the main canvas render pass.
  59689. */
  59690. abstract needStencil(): boolean;
  59691. /**
  59692. * Create the merge effect. This is the shader use to blit the information back
  59693. * to the main canvas at the end of the scene rendering.
  59694. * @returns The effect containing the shader used to merge the effect on the main canvas
  59695. */
  59696. protected abstract _createMergeEffect(): Effect;
  59697. /**
  59698. * Creates the render target textures and post processes used in the effect layer.
  59699. */
  59700. protected abstract _createTextureAndPostProcesses(): void;
  59701. /**
  59702. * Implementation specific of rendering the generating effect on the main canvas.
  59703. * @param effect The effect used to render through
  59704. */
  59705. protected abstract _internalRender(effect: Effect): void;
  59706. /**
  59707. * Sets the required values for both the emissive texture and and the main color.
  59708. */
  59709. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59710. /**
  59711. * Free any resources and references associated to a mesh.
  59712. * Internal use
  59713. * @param mesh The mesh to free.
  59714. */
  59715. abstract _disposeMesh(mesh: Mesh): void;
  59716. /**
  59717. * Serializes this layer (Glow or Highlight for example)
  59718. * @returns a serialized layer object
  59719. */
  59720. abstract serialize?(): any;
  59721. /**
  59722. * Initializes the effect layer with the required options.
  59723. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59724. */
  59725. protected _init(options: Partial<IEffectLayerOptions>): void;
  59726. /**
  59727. * Generates the index buffer of the full screen quad blending to the main canvas.
  59728. */
  59729. private _generateIndexBuffer;
  59730. /**
  59731. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59732. */
  59733. private _generateVertexBuffer;
  59734. /**
  59735. * Sets the main texture desired size which is the closest power of two
  59736. * of the engine canvas size.
  59737. */
  59738. private _setMainTextureSize;
  59739. /**
  59740. * Creates the main texture for the effect layer.
  59741. */
  59742. protected _createMainTexture(): void;
  59743. /**
  59744. * Adds specific effects defines.
  59745. * @param defines The defines to add specifics to.
  59746. */
  59747. protected _addCustomEffectDefines(defines: string[]): void;
  59748. /**
  59749. * Checks for the readiness of the element composing the layer.
  59750. * @param subMesh the mesh to check for
  59751. * @param useInstances specify whether or not to use instances to render the mesh
  59752. * @param emissiveTexture the associated emissive texture used to generate the glow
  59753. * @return true if ready otherwise, false
  59754. */
  59755. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59756. /**
  59757. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59758. */
  59759. render(): void;
  59760. /**
  59761. * Determine if a given mesh will be used in the current effect.
  59762. * @param mesh mesh to test
  59763. * @returns true if the mesh will be used
  59764. */
  59765. hasMesh(mesh: AbstractMesh): boolean;
  59766. /**
  59767. * Returns true if the layer contains information to display, otherwise false.
  59768. * @returns true if the glow layer should be rendered
  59769. */
  59770. shouldRender(): boolean;
  59771. /**
  59772. * Returns true if the mesh should render, otherwise false.
  59773. * @param mesh The mesh to render
  59774. * @returns true if it should render otherwise false
  59775. */
  59776. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59777. /**
  59778. * Returns true if the mesh can be rendered, otherwise false.
  59779. * @param mesh The mesh to render
  59780. * @param material The material used on the mesh
  59781. * @returns true if it can be rendered otherwise false
  59782. */
  59783. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59784. /**
  59785. * Returns true if the mesh should render, otherwise false.
  59786. * @param mesh The mesh to render
  59787. * @returns true if it should render otherwise false
  59788. */
  59789. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59790. /**
  59791. * Renders the submesh passed in parameter to the generation map.
  59792. */
  59793. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59794. /**
  59795. * Defines whether the current material of the mesh should be use to render the effect.
  59796. * @param mesh defines the current mesh to render
  59797. */
  59798. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59799. /**
  59800. * Rebuild the required buffers.
  59801. * @hidden Internal use only.
  59802. */
  59803. _rebuild(): void;
  59804. /**
  59805. * Dispose only the render target textures and post process.
  59806. */
  59807. private _disposeTextureAndPostProcesses;
  59808. /**
  59809. * Dispose the highlight layer and free resources.
  59810. */
  59811. dispose(): void;
  59812. /**
  59813. * Gets the class name of the effect layer
  59814. * @returns the string with the class name of the effect layer
  59815. */
  59816. getClassName(): string;
  59817. /**
  59818. * Creates an effect layer from parsed effect layer data
  59819. * @param parsedEffectLayer defines effect layer data
  59820. * @param scene defines the current scene
  59821. * @param rootUrl defines the root URL containing the effect layer information
  59822. * @returns a parsed effect Layer
  59823. */
  59824. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59825. }
  59826. }
  59827. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  59828. import { Scene } from "babylonjs/scene";
  59829. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  59830. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59831. import { AbstractScene } from "babylonjs/abstractScene";
  59832. module "babylonjs/abstractScene" {
  59833. interface AbstractScene {
  59834. /**
  59835. * The list of effect layers (highlights/glow) added to the scene
  59836. * @see https://doc.babylonjs.com/how_to/highlight_layer
  59837. * @see https://doc.babylonjs.com/how_to/glow_layer
  59838. */
  59839. effectLayers: Array<EffectLayer>;
  59840. /**
  59841. * Removes the given effect layer from this scene.
  59842. * @param toRemove defines the effect layer to remove
  59843. * @returns the index of the removed effect layer
  59844. */
  59845. removeEffectLayer(toRemove: EffectLayer): number;
  59846. /**
  59847. * Adds the given effect layer to this scene
  59848. * @param newEffectLayer defines the effect layer to add
  59849. */
  59850. addEffectLayer(newEffectLayer: EffectLayer): void;
  59851. }
  59852. }
  59853. /**
  59854. * Defines the layer scene component responsible to manage any effect layers
  59855. * in a given scene.
  59856. */
  59857. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59858. /**
  59859. * The component name helpfull to identify the component in the list of scene components.
  59860. */
  59861. readonly name: string;
  59862. /**
  59863. * The scene the component belongs to.
  59864. */
  59865. scene: Scene;
  59866. private _engine;
  59867. private _renderEffects;
  59868. private _needStencil;
  59869. private _previousStencilState;
  59870. /**
  59871. * Creates a new instance of the component for the given scene
  59872. * @param scene Defines the scene to register the component in
  59873. */
  59874. constructor(scene: Scene);
  59875. /**
  59876. * Registers the component in a given scene
  59877. */
  59878. register(): void;
  59879. /**
  59880. * Rebuilds the elements related to this component in case of
  59881. * context lost for instance.
  59882. */
  59883. rebuild(): void;
  59884. /**
  59885. * Serializes the component data to the specified json object
  59886. * @param serializationObject The object to serialize to
  59887. */
  59888. serialize(serializationObject: any): void;
  59889. /**
  59890. * Adds all the elements from the container to the scene
  59891. * @param container the container holding the elements
  59892. */
  59893. addFromContainer(container: AbstractScene): void;
  59894. /**
  59895. * Removes all the elements in the container from the scene
  59896. * @param container contains the elements to remove
  59897. * @param dispose if the removed element should be disposed (default: false)
  59898. */
  59899. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59900. /**
  59901. * Disposes the component and the associated ressources.
  59902. */
  59903. dispose(): void;
  59904. private _isReadyForMesh;
  59905. private _renderMainTexture;
  59906. private _setStencil;
  59907. private _setStencilBack;
  59908. private _draw;
  59909. private _drawCamera;
  59910. private _drawRenderingGroup;
  59911. }
  59912. }
  59913. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  59914. /** @hidden */
  59915. export var glowMapMergePixelShader: {
  59916. name: string;
  59917. shader: string;
  59918. };
  59919. }
  59920. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  59921. /** @hidden */
  59922. export var glowMapMergeVertexShader: {
  59923. name: string;
  59924. shader: string;
  59925. };
  59926. }
  59927. declare module "babylonjs/Layers/glowLayer" {
  59928. import { Nullable } from "babylonjs/types";
  59929. import { Camera } from "babylonjs/Cameras/camera";
  59930. import { Scene } from "babylonjs/scene";
  59931. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59932. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59933. import { Mesh } from "babylonjs/Meshes/mesh";
  59934. import { Texture } from "babylonjs/Materials/Textures/texture";
  59935. import { Effect } from "babylonjs/Materials/effect";
  59936. import { Material } from "babylonjs/Materials/material";
  59937. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59938. import { Color4 } from "babylonjs/Maths/math.color";
  59939. import "babylonjs/Shaders/glowMapMerge.fragment";
  59940. import "babylonjs/Shaders/glowMapMerge.vertex";
  59941. import "babylonjs/Layers/effectLayerSceneComponent";
  59942. module "babylonjs/abstractScene" {
  59943. interface AbstractScene {
  59944. /**
  59945. * Return a the first highlight layer of the scene with a given name.
  59946. * @param name The name of the highlight layer to look for.
  59947. * @return The highlight layer if found otherwise null.
  59948. */
  59949. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  59950. }
  59951. }
  59952. /**
  59953. * Glow layer options. This helps customizing the behaviour
  59954. * of the glow layer.
  59955. */
  59956. export interface IGlowLayerOptions {
  59957. /**
  59958. * Multiplication factor apply to the canvas size to compute the render target size
  59959. * used to generated the glowing objects (the smaller the faster).
  59960. */
  59961. mainTextureRatio: number;
  59962. /**
  59963. * Enforces a fixed size texture to ensure resize independant blur.
  59964. */
  59965. mainTextureFixedSize?: number;
  59966. /**
  59967. * How big is the kernel of the blur texture.
  59968. */
  59969. blurKernelSize: number;
  59970. /**
  59971. * The camera attached to the layer.
  59972. */
  59973. camera: Nullable<Camera>;
  59974. /**
  59975. * Enable MSAA by chosing the number of samples.
  59976. */
  59977. mainTextureSamples?: number;
  59978. /**
  59979. * The rendering group to draw the layer in.
  59980. */
  59981. renderingGroupId: number;
  59982. }
  59983. /**
  59984. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  59985. *
  59986. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  59987. *
  59988. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  59989. */
  59990. export class GlowLayer extends EffectLayer {
  59991. /**
  59992. * Effect Name of the layer.
  59993. */
  59994. static readonly EffectName: string;
  59995. /**
  59996. * The default blur kernel size used for the glow.
  59997. */
  59998. static DefaultBlurKernelSize: number;
  59999. /**
  60000. * The default texture size ratio used for the glow.
  60001. */
  60002. static DefaultTextureRatio: number;
  60003. /**
  60004. * Sets the kernel size of the blur.
  60005. */
  60006. set blurKernelSize(value: number);
  60007. /**
  60008. * Gets the kernel size of the blur.
  60009. */
  60010. get blurKernelSize(): number;
  60011. /**
  60012. * Sets the glow intensity.
  60013. */
  60014. set intensity(value: number);
  60015. /**
  60016. * Gets the glow intensity.
  60017. */
  60018. get intensity(): number;
  60019. private _options;
  60020. private _intensity;
  60021. private _horizontalBlurPostprocess1;
  60022. private _verticalBlurPostprocess1;
  60023. private _horizontalBlurPostprocess2;
  60024. private _verticalBlurPostprocess2;
  60025. private _blurTexture1;
  60026. private _blurTexture2;
  60027. private _postProcesses1;
  60028. private _postProcesses2;
  60029. private _includedOnlyMeshes;
  60030. private _excludedMeshes;
  60031. private _meshesUsingTheirOwnMaterials;
  60032. /**
  60033. * Callback used to let the user override the color selection on a per mesh basis
  60034. */
  60035. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  60036. /**
  60037. * Callback used to let the user override the texture selection on a per mesh basis
  60038. */
  60039. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  60040. /**
  60041. * Instantiates a new glow Layer and references it to the scene.
  60042. * @param name The name of the layer
  60043. * @param scene The scene to use the layer in
  60044. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  60045. */
  60046. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  60047. /**
  60048. * Get the effect name of the layer.
  60049. * @return The effect name
  60050. */
  60051. getEffectName(): string;
  60052. /**
  60053. * Create the merge effect. This is the shader use to blit the information back
  60054. * to the main canvas at the end of the scene rendering.
  60055. */
  60056. protected _createMergeEffect(): Effect;
  60057. /**
  60058. * Creates the render target textures and post processes used in the glow layer.
  60059. */
  60060. protected _createTextureAndPostProcesses(): void;
  60061. /**
  60062. * Checks for the readiness of the element composing the layer.
  60063. * @param subMesh the mesh to check for
  60064. * @param useInstances specify wether or not to use instances to render the mesh
  60065. * @param emissiveTexture the associated emissive texture used to generate the glow
  60066. * @return true if ready otherwise, false
  60067. */
  60068. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60069. /**
  60070. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60071. */
  60072. needStencil(): boolean;
  60073. /**
  60074. * Returns true if the mesh can be rendered, otherwise false.
  60075. * @param mesh The mesh to render
  60076. * @param material The material used on the mesh
  60077. * @returns true if it can be rendered otherwise false
  60078. */
  60079. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60080. /**
  60081. * Implementation specific of rendering the generating effect on the main canvas.
  60082. * @param effect The effect used to render through
  60083. */
  60084. protected _internalRender(effect: Effect): void;
  60085. /**
  60086. * Sets the required values for both the emissive texture and and the main color.
  60087. */
  60088. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60089. /**
  60090. * Returns true if the mesh should render, otherwise false.
  60091. * @param mesh The mesh to render
  60092. * @returns true if it should render otherwise false
  60093. */
  60094. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60095. /**
  60096. * Adds specific effects defines.
  60097. * @param defines The defines to add specifics to.
  60098. */
  60099. protected _addCustomEffectDefines(defines: string[]): void;
  60100. /**
  60101. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  60102. * @param mesh The mesh to exclude from the glow layer
  60103. */
  60104. addExcludedMesh(mesh: Mesh): void;
  60105. /**
  60106. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  60107. * @param mesh The mesh to remove
  60108. */
  60109. removeExcludedMesh(mesh: Mesh): void;
  60110. /**
  60111. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  60112. * @param mesh The mesh to include in the glow layer
  60113. */
  60114. addIncludedOnlyMesh(mesh: Mesh): void;
  60115. /**
  60116. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  60117. * @param mesh The mesh to remove
  60118. */
  60119. removeIncludedOnlyMesh(mesh: Mesh): void;
  60120. /**
  60121. * Determine if a given mesh will be used in the glow layer
  60122. * @param mesh The mesh to test
  60123. * @returns true if the mesh will be highlighted by the current glow layer
  60124. */
  60125. hasMesh(mesh: AbstractMesh): boolean;
  60126. /**
  60127. * Defines whether the current material of the mesh should be use to render the effect.
  60128. * @param mesh defines the current mesh to render
  60129. */
  60130. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60131. /**
  60132. * Add a mesh to be rendered through its own material and not with emissive only.
  60133. * @param mesh The mesh for which we need to use its material
  60134. */
  60135. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  60136. /**
  60137. * Remove a mesh from being rendered through its own material and not with emissive only.
  60138. * @param mesh The mesh for which we need to not use its material
  60139. */
  60140. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  60141. /**
  60142. * Free any resources and references associated to a mesh.
  60143. * Internal use
  60144. * @param mesh The mesh to free.
  60145. * @hidden
  60146. */
  60147. _disposeMesh(mesh: Mesh): void;
  60148. /**
  60149. * Gets the class name of the effect layer
  60150. * @returns the string with the class name of the effect layer
  60151. */
  60152. getClassName(): string;
  60153. /**
  60154. * Serializes this glow layer
  60155. * @returns a serialized glow layer object
  60156. */
  60157. serialize(): any;
  60158. /**
  60159. * Creates a Glow Layer from parsed glow layer data
  60160. * @param parsedGlowLayer defines glow layer data
  60161. * @param scene defines the current scene
  60162. * @param rootUrl defines the root URL containing the glow layer information
  60163. * @returns a parsed Glow Layer
  60164. */
  60165. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  60166. }
  60167. }
  60168. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  60169. /** @hidden */
  60170. export var glowBlurPostProcessPixelShader: {
  60171. name: string;
  60172. shader: string;
  60173. };
  60174. }
  60175. declare module "babylonjs/Layers/highlightLayer" {
  60176. import { Observable } from "babylonjs/Misc/observable";
  60177. import { Nullable } from "babylonjs/types";
  60178. import { Camera } from "babylonjs/Cameras/camera";
  60179. import { Scene } from "babylonjs/scene";
  60180. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60182. import { Mesh } from "babylonjs/Meshes/mesh";
  60183. import { Effect } from "babylonjs/Materials/effect";
  60184. import { Material } from "babylonjs/Materials/material";
  60185. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60186. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60187. import "babylonjs/Shaders/glowMapMerge.fragment";
  60188. import "babylonjs/Shaders/glowMapMerge.vertex";
  60189. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  60190. module "babylonjs/abstractScene" {
  60191. interface AbstractScene {
  60192. /**
  60193. * Return a the first highlight layer of the scene with a given name.
  60194. * @param name The name of the highlight layer to look for.
  60195. * @return The highlight layer if found otherwise null.
  60196. */
  60197. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  60198. }
  60199. }
  60200. /**
  60201. * Highlight layer options. This helps customizing the behaviour
  60202. * of the highlight layer.
  60203. */
  60204. export interface IHighlightLayerOptions {
  60205. /**
  60206. * Multiplication factor apply to the canvas size to compute the render target size
  60207. * used to generated the glowing objects (the smaller the faster).
  60208. */
  60209. mainTextureRatio: number;
  60210. /**
  60211. * Enforces a fixed size texture to ensure resize independant blur.
  60212. */
  60213. mainTextureFixedSize?: number;
  60214. /**
  60215. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  60216. * of the picture to blur (the smaller the faster).
  60217. */
  60218. blurTextureSizeRatio: number;
  60219. /**
  60220. * How big in texel of the blur texture is the vertical blur.
  60221. */
  60222. blurVerticalSize: number;
  60223. /**
  60224. * How big in texel of the blur texture is the horizontal blur.
  60225. */
  60226. blurHorizontalSize: number;
  60227. /**
  60228. * Alpha blending mode used to apply the blur. Default is combine.
  60229. */
  60230. alphaBlendingMode: number;
  60231. /**
  60232. * The camera attached to the layer.
  60233. */
  60234. camera: Nullable<Camera>;
  60235. /**
  60236. * Should we display highlight as a solid stroke?
  60237. */
  60238. isStroke?: boolean;
  60239. /**
  60240. * The rendering group to draw the layer in.
  60241. */
  60242. renderingGroupId: number;
  60243. }
  60244. /**
  60245. * The highlight layer Helps adding a glow effect around a mesh.
  60246. *
  60247. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  60248. * glowy meshes to your scene.
  60249. *
  60250. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  60251. */
  60252. export class HighlightLayer extends EffectLayer {
  60253. name: string;
  60254. /**
  60255. * Effect Name of the highlight layer.
  60256. */
  60257. static readonly EffectName: string;
  60258. /**
  60259. * The neutral color used during the preparation of the glow effect.
  60260. * This is black by default as the blend operation is a blend operation.
  60261. */
  60262. static NeutralColor: Color4;
  60263. /**
  60264. * Stencil value used for glowing meshes.
  60265. */
  60266. static GlowingMeshStencilReference: number;
  60267. /**
  60268. * Stencil value used for the other meshes in the scene.
  60269. */
  60270. static NormalMeshStencilReference: number;
  60271. /**
  60272. * Specifies whether or not the inner glow is ACTIVE in the layer.
  60273. */
  60274. innerGlow: boolean;
  60275. /**
  60276. * Specifies whether or not the outer glow is ACTIVE in the layer.
  60277. */
  60278. outerGlow: boolean;
  60279. /**
  60280. * Specifies the horizontal size of the blur.
  60281. */
  60282. set blurHorizontalSize(value: number);
  60283. /**
  60284. * Specifies the vertical size of the blur.
  60285. */
  60286. set blurVerticalSize(value: number);
  60287. /**
  60288. * Gets the horizontal size of the blur.
  60289. */
  60290. get blurHorizontalSize(): number;
  60291. /**
  60292. * Gets the vertical size of the blur.
  60293. */
  60294. get blurVerticalSize(): number;
  60295. /**
  60296. * An event triggered when the highlight layer is being blurred.
  60297. */
  60298. onBeforeBlurObservable: Observable<HighlightLayer>;
  60299. /**
  60300. * An event triggered when the highlight layer has been blurred.
  60301. */
  60302. onAfterBlurObservable: Observable<HighlightLayer>;
  60303. private _instanceGlowingMeshStencilReference;
  60304. private _options;
  60305. private _downSamplePostprocess;
  60306. private _horizontalBlurPostprocess;
  60307. private _verticalBlurPostprocess;
  60308. private _blurTexture;
  60309. private _meshes;
  60310. private _excludedMeshes;
  60311. /**
  60312. * Instantiates a new highlight Layer and references it to the scene..
  60313. * @param name The name of the layer
  60314. * @param scene The scene to use the layer in
  60315. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  60316. */
  60317. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  60318. /**
  60319. * Get the effect name of the layer.
  60320. * @return The effect name
  60321. */
  60322. getEffectName(): string;
  60323. /**
  60324. * Create the merge effect. This is the shader use to blit the information back
  60325. * to the main canvas at the end of the scene rendering.
  60326. */
  60327. protected _createMergeEffect(): Effect;
  60328. /**
  60329. * Creates the render target textures and post processes used in the highlight layer.
  60330. */
  60331. protected _createTextureAndPostProcesses(): void;
  60332. /**
  60333. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  60334. */
  60335. needStencil(): boolean;
  60336. /**
  60337. * Checks for the readiness of the element composing the layer.
  60338. * @param subMesh the mesh to check for
  60339. * @param useInstances specify wether or not to use instances to render the mesh
  60340. * @param emissiveTexture the associated emissive texture used to generate the glow
  60341. * @return true if ready otherwise, false
  60342. */
  60343. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60344. /**
  60345. * Implementation specific of rendering the generating effect on the main canvas.
  60346. * @param effect The effect used to render through
  60347. */
  60348. protected _internalRender(effect: Effect): void;
  60349. /**
  60350. * Returns true if the layer contains information to display, otherwise false.
  60351. */
  60352. shouldRender(): boolean;
  60353. /**
  60354. * Returns true if the mesh should render, otherwise false.
  60355. * @param mesh The mesh to render
  60356. * @returns true if it should render otherwise false
  60357. */
  60358. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60359. /**
  60360. * Returns true if the mesh can be rendered, otherwise false.
  60361. * @param mesh The mesh to render
  60362. * @param material The material used on the mesh
  60363. * @returns true if it can be rendered otherwise false
  60364. */
  60365. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60366. /**
  60367. * Adds specific effects defines.
  60368. * @param defines The defines to add specifics to.
  60369. */
  60370. protected _addCustomEffectDefines(defines: string[]): void;
  60371. /**
  60372. * Sets the required values for both the emissive texture and and the main color.
  60373. */
  60374. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60375. /**
  60376. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  60377. * @param mesh The mesh to exclude from the highlight layer
  60378. */
  60379. addExcludedMesh(mesh: Mesh): void;
  60380. /**
  60381. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  60382. * @param mesh The mesh to highlight
  60383. */
  60384. removeExcludedMesh(mesh: Mesh): void;
  60385. /**
  60386. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60387. * @param mesh mesh to test
  60388. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60389. */
  60390. hasMesh(mesh: AbstractMesh): boolean;
  60391. /**
  60392. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60393. * @param mesh The mesh to highlight
  60394. * @param color The color of the highlight
  60395. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60396. */
  60397. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60398. /**
  60399. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60400. * @param mesh The mesh to highlight
  60401. */
  60402. removeMesh(mesh: Mesh): void;
  60403. /**
  60404. * Remove all the meshes currently referenced in the highlight layer
  60405. */
  60406. removeAllMeshes(): void;
  60407. /**
  60408. * Force the stencil to the normal expected value for none glowing parts
  60409. */
  60410. private _defaultStencilReference;
  60411. /**
  60412. * Free any resources and references associated to a mesh.
  60413. * Internal use
  60414. * @param mesh The mesh to free.
  60415. * @hidden
  60416. */
  60417. _disposeMesh(mesh: Mesh): void;
  60418. /**
  60419. * Dispose the highlight layer and free resources.
  60420. */
  60421. dispose(): void;
  60422. /**
  60423. * Gets the class name of the effect layer
  60424. * @returns the string with the class name of the effect layer
  60425. */
  60426. getClassName(): string;
  60427. /**
  60428. * Serializes this Highlight layer
  60429. * @returns a serialized Highlight layer object
  60430. */
  60431. serialize(): any;
  60432. /**
  60433. * Creates a Highlight layer from parsed Highlight layer data
  60434. * @param parsedHightlightLayer defines the Highlight layer data
  60435. * @param scene defines the current scene
  60436. * @param rootUrl defines the root URL containing the Highlight layer information
  60437. * @returns a parsed Highlight layer
  60438. */
  60439. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  60440. }
  60441. }
  60442. declare module "babylonjs/Layers/layerSceneComponent" {
  60443. import { Scene } from "babylonjs/scene";
  60444. import { ISceneComponent } from "babylonjs/sceneComponent";
  60445. import { Layer } from "babylonjs/Layers/layer";
  60446. import { AbstractScene } from "babylonjs/abstractScene";
  60447. module "babylonjs/abstractScene" {
  60448. interface AbstractScene {
  60449. /**
  60450. * The list of layers (background and foreground) of the scene
  60451. */
  60452. layers: Array<Layer>;
  60453. }
  60454. }
  60455. /**
  60456. * Defines the layer scene component responsible to manage any layers
  60457. * in a given scene.
  60458. */
  60459. export class LayerSceneComponent implements ISceneComponent {
  60460. /**
  60461. * The component name helpfull to identify the component in the list of scene components.
  60462. */
  60463. readonly name: string;
  60464. /**
  60465. * The scene the component belongs to.
  60466. */
  60467. scene: Scene;
  60468. private _engine;
  60469. /**
  60470. * Creates a new instance of the component for the given scene
  60471. * @param scene Defines the scene to register the component in
  60472. */
  60473. constructor(scene: Scene);
  60474. /**
  60475. * Registers the component in a given scene
  60476. */
  60477. register(): void;
  60478. /**
  60479. * Rebuilds the elements related to this component in case of
  60480. * context lost for instance.
  60481. */
  60482. rebuild(): void;
  60483. /**
  60484. * Disposes the component and the associated ressources.
  60485. */
  60486. dispose(): void;
  60487. private _draw;
  60488. private _drawCameraPredicate;
  60489. private _drawCameraBackground;
  60490. private _drawCameraForeground;
  60491. private _drawRenderTargetPredicate;
  60492. private _drawRenderTargetBackground;
  60493. private _drawRenderTargetForeground;
  60494. /**
  60495. * Adds all the elements from the container to the scene
  60496. * @param container the container holding the elements
  60497. */
  60498. addFromContainer(container: AbstractScene): void;
  60499. /**
  60500. * Removes all the elements in the container from the scene
  60501. * @param container contains the elements to remove
  60502. * @param dispose if the removed element should be disposed (default: false)
  60503. */
  60504. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60505. }
  60506. }
  60507. declare module "babylonjs/Shaders/layer.fragment" {
  60508. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60509. /** @hidden */
  60510. export var layerPixelShader: {
  60511. name: string;
  60512. shader: string;
  60513. };
  60514. }
  60515. declare module "babylonjs/Shaders/layer.vertex" {
  60516. /** @hidden */
  60517. export var layerVertexShader: {
  60518. name: string;
  60519. shader: string;
  60520. };
  60521. }
  60522. declare module "babylonjs/Layers/layer" {
  60523. import { Observable } from "babylonjs/Misc/observable";
  60524. import { Nullable } from "babylonjs/types";
  60525. import { Scene } from "babylonjs/scene";
  60526. import { Vector2 } from "babylonjs/Maths/math.vector";
  60527. import { Color4 } from "babylonjs/Maths/math.color";
  60528. import { Texture } from "babylonjs/Materials/Textures/texture";
  60529. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60530. import "babylonjs/Shaders/layer.fragment";
  60531. import "babylonjs/Shaders/layer.vertex";
  60532. /**
  60533. * This represents a full screen 2d layer.
  60534. * This can be useful to display a picture in the background of your scene for instance.
  60535. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60536. */
  60537. export class Layer {
  60538. /**
  60539. * Define the name of the layer.
  60540. */
  60541. name: string;
  60542. /**
  60543. * Define the texture the layer should display.
  60544. */
  60545. texture: Nullable<Texture>;
  60546. /**
  60547. * Is the layer in background or foreground.
  60548. */
  60549. isBackground: boolean;
  60550. /**
  60551. * Define the color of the layer (instead of texture).
  60552. */
  60553. color: Color4;
  60554. /**
  60555. * Define the scale of the layer in order to zoom in out of the texture.
  60556. */
  60557. scale: Vector2;
  60558. /**
  60559. * Define an offset for the layer in order to shift the texture.
  60560. */
  60561. offset: Vector2;
  60562. /**
  60563. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  60564. */
  60565. alphaBlendingMode: number;
  60566. /**
  60567. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  60568. * Alpha test will not mix with the background color in case of transparency.
  60569. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  60570. */
  60571. alphaTest: boolean;
  60572. /**
  60573. * Define a mask to restrict the layer to only some of the scene cameras.
  60574. */
  60575. layerMask: number;
  60576. /**
  60577. * Define the list of render target the layer is visible into.
  60578. */
  60579. renderTargetTextures: RenderTargetTexture[];
  60580. /**
  60581. * Define if the layer is only used in renderTarget or if it also
  60582. * renders in the main frame buffer of the canvas.
  60583. */
  60584. renderOnlyInRenderTargetTextures: boolean;
  60585. private _scene;
  60586. private _vertexBuffers;
  60587. private _indexBuffer;
  60588. private _effect;
  60589. private _previousDefines;
  60590. /**
  60591. * An event triggered when the layer is disposed.
  60592. */
  60593. onDisposeObservable: Observable<Layer>;
  60594. private _onDisposeObserver;
  60595. /**
  60596. * Back compatibility with callback before the onDisposeObservable existed.
  60597. * The set callback will be triggered when the layer has been disposed.
  60598. */
  60599. set onDispose(callback: () => void);
  60600. /**
  60601. * An event triggered before rendering the scene
  60602. */
  60603. onBeforeRenderObservable: Observable<Layer>;
  60604. private _onBeforeRenderObserver;
  60605. /**
  60606. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60607. * The set callback will be triggered just before rendering the layer.
  60608. */
  60609. set onBeforeRender(callback: () => void);
  60610. /**
  60611. * An event triggered after rendering the scene
  60612. */
  60613. onAfterRenderObservable: Observable<Layer>;
  60614. private _onAfterRenderObserver;
  60615. /**
  60616. * Back compatibility with callback before the onAfterRenderObservable existed.
  60617. * The set callback will be triggered just after rendering the layer.
  60618. */
  60619. set onAfterRender(callback: () => void);
  60620. /**
  60621. * Instantiates a new layer.
  60622. * This represents a full screen 2d layer.
  60623. * This can be useful to display a picture in the background of your scene for instance.
  60624. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60625. * @param name Define the name of the layer in the scene
  60626. * @param imgUrl Define the url of the texture to display in the layer
  60627. * @param scene Define the scene the layer belongs to
  60628. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60629. * @param color Defines a color for the layer
  60630. */
  60631. constructor(
  60632. /**
  60633. * Define the name of the layer.
  60634. */
  60635. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60636. private _createIndexBuffer;
  60637. /** @hidden */
  60638. _rebuild(): void;
  60639. /**
  60640. * Renders the layer in the scene.
  60641. */
  60642. render(): void;
  60643. /**
  60644. * Disposes and releases the associated ressources.
  60645. */
  60646. dispose(): void;
  60647. }
  60648. }
  60649. declare module "babylonjs/Layers/index" {
  60650. export * from "babylonjs/Layers/effectLayer";
  60651. export * from "babylonjs/Layers/effectLayerSceneComponent";
  60652. export * from "babylonjs/Layers/glowLayer";
  60653. export * from "babylonjs/Layers/highlightLayer";
  60654. export * from "babylonjs/Layers/layer";
  60655. export * from "babylonjs/Layers/layerSceneComponent";
  60656. }
  60657. declare module "babylonjs/Shaders/lensFlare.fragment" {
  60658. /** @hidden */
  60659. export var lensFlarePixelShader: {
  60660. name: string;
  60661. shader: string;
  60662. };
  60663. }
  60664. declare module "babylonjs/Shaders/lensFlare.vertex" {
  60665. /** @hidden */
  60666. export var lensFlareVertexShader: {
  60667. name: string;
  60668. shader: string;
  60669. };
  60670. }
  60671. declare module "babylonjs/LensFlares/lensFlareSystem" {
  60672. import { Scene } from "babylonjs/scene";
  60673. import { Vector3 } from "babylonjs/Maths/math.vector";
  60674. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60675. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  60676. import "babylonjs/Shaders/lensFlare.fragment";
  60677. import "babylonjs/Shaders/lensFlare.vertex";
  60678. import { Viewport } from "babylonjs/Maths/math.viewport";
  60679. /**
  60680. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60681. * It is usually composed of several `lensFlare`.
  60682. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60683. */
  60684. export class LensFlareSystem {
  60685. /**
  60686. * Define the name of the lens flare system
  60687. */
  60688. name: string;
  60689. /**
  60690. * List of lens flares used in this system.
  60691. */
  60692. lensFlares: LensFlare[];
  60693. /**
  60694. * Define a limit from the border the lens flare can be visible.
  60695. */
  60696. borderLimit: number;
  60697. /**
  60698. * Define a viewport border we do not want to see the lens flare in.
  60699. */
  60700. viewportBorder: number;
  60701. /**
  60702. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60703. */
  60704. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60705. /**
  60706. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60707. */
  60708. layerMask: number;
  60709. /**
  60710. * Define the id of the lens flare system in the scene.
  60711. * (equal to name by default)
  60712. */
  60713. id: string;
  60714. private _scene;
  60715. private _emitter;
  60716. private _vertexBuffers;
  60717. private _indexBuffer;
  60718. private _effect;
  60719. private _positionX;
  60720. private _positionY;
  60721. private _isEnabled;
  60722. /** @hidden */
  60723. static _SceneComponentInitialization: (scene: Scene) => void;
  60724. /**
  60725. * Instantiates a lens flare system.
  60726. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60727. * It is usually composed of several `lensFlare`.
  60728. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60729. * @param name Define the name of the lens flare system in the scene
  60730. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60731. * @param scene Define the scene the lens flare system belongs to
  60732. */
  60733. constructor(
  60734. /**
  60735. * Define the name of the lens flare system
  60736. */
  60737. name: string, emitter: any, scene: Scene);
  60738. /**
  60739. * Define if the lens flare system is enabled.
  60740. */
  60741. get isEnabled(): boolean;
  60742. set isEnabled(value: boolean);
  60743. /**
  60744. * Get the scene the effects belongs to.
  60745. * @returns the scene holding the lens flare system
  60746. */
  60747. getScene(): Scene;
  60748. /**
  60749. * Get the emitter of the lens flare system.
  60750. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60751. * @returns the emitter of the lens flare system
  60752. */
  60753. getEmitter(): any;
  60754. /**
  60755. * Set the emitter of the lens flare system.
  60756. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60757. * @param newEmitter Define the new emitter of the system
  60758. */
  60759. setEmitter(newEmitter: any): void;
  60760. /**
  60761. * Get the lens flare system emitter position.
  60762. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60763. * @returns the position
  60764. */
  60765. getEmitterPosition(): Vector3;
  60766. /**
  60767. * @hidden
  60768. */
  60769. computeEffectivePosition(globalViewport: Viewport): boolean;
  60770. /** @hidden */
  60771. _isVisible(): boolean;
  60772. /**
  60773. * @hidden
  60774. */
  60775. render(): boolean;
  60776. /**
  60777. * Dispose and release the lens flare with its associated resources.
  60778. */
  60779. dispose(): void;
  60780. /**
  60781. * Parse a lens flare system from a JSON repressentation
  60782. * @param parsedLensFlareSystem Define the JSON to parse
  60783. * @param scene Define the scene the parsed system should be instantiated in
  60784. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60785. * @returns the parsed system
  60786. */
  60787. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60788. /**
  60789. * Serialize the current Lens Flare System into a JSON representation.
  60790. * @returns the serialized JSON
  60791. */
  60792. serialize(): any;
  60793. }
  60794. }
  60795. declare module "babylonjs/LensFlares/lensFlare" {
  60796. import { Nullable } from "babylonjs/types";
  60797. import { Color3 } from "babylonjs/Maths/math.color";
  60798. import { Texture } from "babylonjs/Materials/Textures/texture";
  60799. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60800. /**
  60801. * This represents one of the lens effect in a `lensFlareSystem`.
  60802. * It controls one of the indiviual texture used in the effect.
  60803. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60804. */
  60805. export class LensFlare {
  60806. /**
  60807. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60808. */
  60809. size: number;
  60810. /**
  60811. * 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.
  60812. */
  60813. position: number;
  60814. /**
  60815. * Define the lens color.
  60816. */
  60817. color: Color3;
  60818. /**
  60819. * Define the lens texture.
  60820. */
  60821. texture: Nullable<Texture>;
  60822. /**
  60823. * Define the alpha mode to render this particular lens.
  60824. */
  60825. alphaMode: number;
  60826. private _system;
  60827. /**
  60828. * Creates a new Lens Flare.
  60829. * This represents one of the lens effect in a `lensFlareSystem`.
  60830. * It controls one of the indiviual texture used in the effect.
  60831. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60832. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60833. * @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.
  60834. * @param color Define the lens color
  60835. * @param imgUrl Define the lens texture url
  60836. * @param system Define the `lensFlareSystem` this flare is part of
  60837. * @returns The newly created Lens Flare
  60838. */
  60839. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60840. /**
  60841. * Instantiates a new Lens Flare.
  60842. * This represents one of the lens effect in a `lensFlareSystem`.
  60843. * It controls one of the indiviual texture used in the effect.
  60844. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60845. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60846. * @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.
  60847. * @param color Define the lens color
  60848. * @param imgUrl Define the lens texture url
  60849. * @param system Define the `lensFlareSystem` this flare is part of
  60850. */
  60851. constructor(
  60852. /**
  60853. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60854. */
  60855. size: number,
  60856. /**
  60857. * 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.
  60858. */
  60859. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60860. /**
  60861. * Dispose and release the lens flare with its associated resources.
  60862. */
  60863. dispose(): void;
  60864. }
  60865. }
  60866. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  60867. import { Nullable } from "babylonjs/types";
  60868. import { Scene } from "babylonjs/scene";
  60869. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60870. import { AbstractScene } from "babylonjs/abstractScene";
  60871. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60872. module "babylonjs/abstractScene" {
  60873. interface AbstractScene {
  60874. /**
  60875. * The list of lens flare system added to the scene
  60876. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60877. */
  60878. lensFlareSystems: Array<LensFlareSystem>;
  60879. /**
  60880. * Removes the given lens flare system from this scene.
  60881. * @param toRemove The lens flare system to remove
  60882. * @returns The index of the removed lens flare system
  60883. */
  60884. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60885. /**
  60886. * Adds the given lens flare system to this scene
  60887. * @param newLensFlareSystem The lens flare system to add
  60888. */
  60889. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60890. /**
  60891. * Gets a lens flare system using its name
  60892. * @param name defines the name to look for
  60893. * @returns the lens flare system or null if not found
  60894. */
  60895. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60896. /**
  60897. * Gets a lens flare system using its id
  60898. * @param id defines the id to look for
  60899. * @returns the lens flare system or null if not found
  60900. */
  60901. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60902. }
  60903. }
  60904. /**
  60905. * Defines the lens flare scene component responsible to manage any lens flares
  60906. * in a given scene.
  60907. */
  60908. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60909. /**
  60910. * The component name helpfull to identify the component in the list of scene components.
  60911. */
  60912. readonly name: string;
  60913. /**
  60914. * The scene the component belongs to.
  60915. */
  60916. scene: Scene;
  60917. /**
  60918. * Creates a new instance of the component for the given scene
  60919. * @param scene Defines the scene to register the component in
  60920. */
  60921. constructor(scene: Scene);
  60922. /**
  60923. * Registers the component in a given scene
  60924. */
  60925. register(): void;
  60926. /**
  60927. * Rebuilds the elements related to this component in case of
  60928. * context lost for instance.
  60929. */
  60930. rebuild(): void;
  60931. /**
  60932. * Adds all the elements from the container to the scene
  60933. * @param container the container holding the elements
  60934. */
  60935. addFromContainer(container: AbstractScene): void;
  60936. /**
  60937. * Removes all the elements in the container from the scene
  60938. * @param container contains the elements to remove
  60939. * @param dispose if the removed element should be disposed (default: false)
  60940. */
  60941. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60942. /**
  60943. * Serializes the component data to the specified json object
  60944. * @param serializationObject The object to serialize to
  60945. */
  60946. serialize(serializationObject: any): void;
  60947. /**
  60948. * Disposes the component and the associated ressources.
  60949. */
  60950. dispose(): void;
  60951. private _draw;
  60952. }
  60953. }
  60954. declare module "babylonjs/LensFlares/index" {
  60955. export * from "babylonjs/LensFlares/lensFlare";
  60956. export * from "babylonjs/LensFlares/lensFlareSystem";
  60957. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  60958. }
  60959. declare module "babylonjs/Shaders/depth.fragment" {
  60960. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  60961. /** @hidden */
  60962. export var depthPixelShader: {
  60963. name: string;
  60964. shader: string;
  60965. };
  60966. }
  60967. declare module "babylonjs/Shaders/depth.vertex" {
  60968. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60969. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60970. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60971. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60972. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60973. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60974. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60975. /** @hidden */
  60976. export var depthVertexShader: {
  60977. name: string;
  60978. shader: string;
  60979. };
  60980. }
  60981. declare module "babylonjs/Rendering/depthRenderer" {
  60982. import { Nullable } from "babylonjs/types";
  60983. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60984. import { Scene } from "babylonjs/scene";
  60985. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60986. import { Camera } from "babylonjs/Cameras/camera";
  60987. import "babylonjs/Shaders/depth.fragment";
  60988. import "babylonjs/Shaders/depth.vertex";
  60989. /**
  60990. * This represents a depth renderer in Babylon.
  60991. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60992. */
  60993. export class DepthRenderer {
  60994. private _scene;
  60995. private _depthMap;
  60996. private _effect;
  60997. private readonly _storeNonLinearDepth;
  60998. private readonly _clearColor;
  60999. /** Get if the depth renderer is using packed depth or not */
  61000. readonly isPacked: boolean;
  61001. private _cachedDefines;
  61002. private _camera;
  61003. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  61004. enabled: boolean;
  61005. /**
  61006. * Specifiess that the depth renderer will only be used within
  61007. * the camera it is created for.
  61008. * This can help forcing its rendering during the camera processing.
  61009. */
  61010. useOnlyInActiveCamera: boolean;
  61011. /** @hidden */
  61012. static _SceneComponentInitialization: (scene: Scene) => void;
  61013. /**
  61014. * Instantiates a depth renderer
  61015. * @param scene The scene the renderer belongs to
  61016. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61017. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61018. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61019. */
  61020. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61021. /**
  61022. * Creates the depth rendering effect and checks if the effect is ready.
  61023. * @param subMesh The submesh to be used to render the depth map of
  61024. * @param useInstances If multiple world instances should be used
  61025. * @returns if the depth renderer is ready to render the depth map
  61026. */
  61027. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61028. /**
  61029. * Gets the texture which the depth map will be written to.
  61030. * @returns The depth map texture
  61031. */
  61032. getDepthMap(): RenderTargetTexture;
  61033. /**
  61034. * Disposes of the depth renderer.
  61035. */
  61036. dispose(): void;
  61037. }
  61038. }
  61039. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  61040. /** @hidden */
  61041. export var minmaxReduxPixelShader: {
  61042. name: string;
  61043. shader: string;
  61044. };
  61045. }
  61046. declare module "babylonjs/Misc/minMaxReducer" {
  61047. import { Nullable } from "babylonjs/types";
  61048. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61049. import { Camera } from "babylonjs/Cameras/camera";
  61050. import { Observer } from "babylonjs/Misc/observable";
  61051. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61052. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  61053. import { Observable } from "babylonjs/Misc/observable";
  61054. import "babylonjs/Shaders/minmaxRedux.fragment";
  61055. /**
  61056. * This class computes a min/max reduction from a texture: it means it computes the minimum
  61057. * and maximum values from all values of the texture.
  61058. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  61059. * The source values are read from the red channel of the texture.
  61060. */
  61061. export class MinMaxReducer {
  61062. /**
  61063. * Observable triggered when the computation has been performed
  61064. */
  61065. onAfterReductionPerformed: Observable<{
  61066. min: number;
  61067. max: number;
  61068. }>;
  61069. protected _camera: Camera;
  61070. protected _sourceTexture: Nullable<RenderTargetTexture>;
  61071. protected _reductionSteps: Nullable<Array<PostProcess>>;
  61072. protected _postProcessManager: PostProcessManager;
  61073. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  61074. protected _forceFullscreenViewport: boolean;
  61075. /**
  61076. * Creates a min/max reducer
  61077. * @param camera The camera to use for the post processes
  61078. */
  61079. constructor(camera: Camera);
  61080. /**
  61081. * Gets the texture used to read the values from.
  61082. */
  61083. get sourceTexture(): Nullable<RenderTargetTexture>;
  61084. /**
  61085. * Sets the source texture to read the values from.
  61086. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  61087. * because in such textures '1' value must not be taken into account to compute the maximum
  61088. * as this value is used to clear the texture.
  61089. * Note that the computation is not activated by calling this function, you must call activate() for that!
  61090. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  61091. * @param depthRedux Indicates if the texture is a depth texture or not
  61092. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  61093. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61094. */
  61095. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61096. /**
  61097. * Defines the refresh rate of the computation.
  61098. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61099. */
  61100. get refreshRate(): number;
  61101. set refreshRate(value: number);
  61102. protected _activated: boolean;
  61103. /**
  61104. * Gets the activation status of the reducer
  61105. */
  61106. get activated(): boolean;
  61107. /**
  61108. * Activates the reduction computation.
  61109. * When activated, the observers registered in onAfterReductionPerformed are
  61110. * called after the compuation is performed
  61111. */
  61112. activate(): void;
  61113. /**
  61114. * Deactivates the reduction computation.
  61115. */
  61116. deactivate(): void;
  61117. /**
  61118. * Disposes the min/max reducer
  61119. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  61120. */
  61121. dispose(disposeAll?: boolean): void;
  61122. }
  61123. }
  61124. declare module "babylonjs/Misc/depthReducer" {
  61125. import { Nullable } from "babylonjs/types";
  61126. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61127. import { Camera } from "babylonjs/Cameras/camera";
  61128. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61129. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  61130. /**
  61131. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  61132. */
  61133. export class DepthReducer extends MinMaxReducer {
  61134. private _depthRenderer;
  61135. private _depthRendererId;
  61136. /**
  61137. * Gets the depth renderer used for the computation.
  61138. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  61139. */
  61140. get depthRenderer(): Nullable<DepthRenderer>;
  61141. /**
  61142. * Creates a depth reducer
  61143. * @param camera The camera used to render the depth texture
  61144. */
  61145. constructor(camera: Camera);
  61146. /**
  61147. * Sets the depth renderer to use to generate the depth map
  61148. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  61149. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  61150. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61151. */
  61152. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  61153. /** @hidden */
  61154. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61155. /**
  61156. * Activates the reduction computation.
  61157. * When activated, the observers registered in onAfterReductionPerformed are
  61158. * called after the compuation is performed
  61159. */
  61160. activate(): void;
  61161. /**
  61162. * Deactivates the reduction computation.
  61163. */
  61164. deactivate(): void;
  61165. /**
  61166. * Disposes the depth reducer
  61167. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  61168. */
  61169. dispose(disposeAll?: boolean): void;
  61170. }
  61171. }
  61172. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  61173. import { Nullable } from "babylonjs/types";
  61174. import { Scene } from "babylonjs/scene";
  61175. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61176. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61178. import { Effect } from "babylonjs/Materials/effect";
  61179. import "babylonjs/Shaders/shadowMap.fragment";
  61180. import "babylonjs/Shaders/shadowMap.vertex";
  61181. import "babylonjs/Shaders/depthBoxBlur.fragment";
  61182. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  61183. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  61184. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  61185. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61186. /**
  61187. * A CSM implementation allowing casting shadows on large scenes.
  61188. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61189. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  61190. */
  61191. export class CascadedShadowGenerator extends ShadowGenerator {
  61192. private static readonly frustumCornersNDCSpace;
  61193. /**
  61194. * Name of the CSM class
  61195. */
  61196. static CLASSNAME: string;
  61197. /**
  61198. * Defines the default number of cascades used by the CSM.
  61199. */
  61200. static readonly DEFAULT_CASCADES_COUNT: number;
  61201. /**
  61202. * Defines the minimum number of cascades used by the CSM.
  61203. */
  61204. static readonly MIN_CASCADES_COUNT: number;
  61205. /**
  61206. * Defines the maximum number of cascades used by the CSM.
  61207. */
  61208. static readonly MAX_CASCADES_COUNT: number;
  61209. protected _validateFilter(filter: number): number;
  61210. /**
  61211. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  61212. */
  61213. penumbraDarkness: number;
  61214. private _numCascades;
  61215. /**
  61216. * Gets or set the number of cascades used by the CSM.
  61217. */
  61218. get numCascades(): number;
  61219. set numCascades(value: number);
  61220. /**
  61221. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  61222. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  61223. */
  61224. stabilizeCascades: boolean;
  61225. private _freezeShadowCastersBoundingInfo;
  61226. private _freezeShadowCastersBoundingInfoObservable;
  61227. /**
  61228. * Enables or disables the shadow casters bounding info computation.
  61229. * If your shadow casters don't move, you can disable this feature.
  61230. * If it is enabled, the bounding box computation is done every frame.
  61231. */
  61232. get freezeShadowCastersBoundingInfo(): boolean;
  61233. set freezeShadowCastersBoundingInfo(freeze: boolean);
  61234. private _scbiMin;
  61235. private _scbiMax;
  61236. protected _computeShadowCastersBoundingInfo(): void;
  61237. protected _shadowCastersBoundingInfo: BoundingInfo;
  61238. /**
  61239. * Gets or sets the shadow casters bounding info.
  61240. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  61241. * so that the system won't overwrite the bounds you provide
  61242. */
  61243. get shadowCastersBoundingInfo(): BoundingInfo;
  61244. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  61245. protected _breaksAreDirty: boolean;
  61246. protected _minDistance: number;
  61247. protected _maxDistance: number;
  61248. /**
  61249. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  61250. *
  61251. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  61252. * If you don't know these values, simply leave them to their defaults and don't call this function.
  61253. * @param min minimal distance for the breaks (default to 0.)
  61254. * @param max maximal distance for the breaks (default to 1.)
  61255. */
  61256. setMinMaxDistance(min: number, max: number): void;
  61257. /** Gets the minimal distance used in the cascade break computation */
  61258. get minDistance(): number;
  61259. /** Gets the maximal distance used in the cascade break computation */
  61260. get maxDistance(): number;
  61261. /**
  61262. * Gets the class name of that object
  61263. * @returns "CascadedShadowGenerator"
  61264. */
  61265. getClassName(): string;
  61266. private _cascadeMinExtents;
  61267. private _cascadeMaxExtents;
  61268. /**
  61269. * Gets a cascade minimum extents
  61270. * @param cascadeIndex index of the cascade
  61271. * @returns the minimum cascade extents
  61272. */
  61273. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  61274. /**
  61275. * Gets a cascade maximum extents
  61276. * @param cascadeIndex index of the cascade
  61277. * @returns the maximum cascade extents
  61278. */
  61279. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  61280. private _cascades;
  61281. private _currentLayer;
  61282. private _viewSpaceFrustumsZ;
  61283. private _viewMatrices;
  61284. private _projectionMatrices;
  61285. private _transformMatrices;
  61286. private _transformMatricesAsArray;
  61287. private _frustumLengths;
  61288. private _lightSizeUVCorrection;
  61289. private _depthCorrection;
  61290. private _frustumCornersWorldSpace;
  61291. private _frustumCenter;
  61292. private _shadowCameraPos;
  61293. private _shadowMaxZ;
  61294. /**
  61295. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  61296. * It defaults to camera.maxZ
  61297. */
  61298. get shadowMaxZ(): number;
  61299. /**
  61300. * Sets the shadow max z distance.
  61301. */
  61302. set shadowMaxZ(value: number);
  61303. protected _debug: boolean;
  61304. /**
  61305. * Gets or sets the debug flag.
  61306. * When enabled, the cascades are materialized by different colors on the screen.
  61307. */
  61308. get debug(): boolean;
  61309. set debug(dbg: boolean);
  61310. private _depthClamp;
  61311. /**
  61312. * Gets or sets the depth clamping value.
  61313. *
  61314. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  61315. * to account for the shadow casters far away.
  61316. *
  61317. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  61318. */
  61319. get depthClamp(): boolean;
  61320. set depthClamp(value: boolean);
  61321. private _cascadeBlendPercentage;
  61322. /**
  61323. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  61324. * It defaults to 0.1 (10% blending).
  61325. */
  61326. get cascadeBlendPercentage(): number;
  61327. set cascadeBlendPercentage(value: number);
  61328. private _lambda;
  61329. /**
  61330. * Gets or set the lambda parameter.
  61331. * This parameter is used to split the camera frustum and create the cascades.
  61332. * It's a value between 0. and 1.: If 0, the split is a uniform split of the frustum, if 1 it is a logarithmic split.
  61333. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  61334. */
  61335. get lambda(): number;
  61336. set lambda(value: number);
  61337. /**
  61338. * Gets the view matrix corresponding to a given cascade
  61339. * @param cascadeNum cascade to retrieve the view matrix from
  61340. * @returns the cascade view matrix
  61341. */
  61342. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  61343. /**
  61344. * Gets the projection matrix corresponding to a given cascade
  61345. * @param cascadeNum cascade to retrieve the projection matrix from
  61346. * @returns the cascade projection matrix
  61347. */
  61348. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  61349. /**
  61350. * Gets the transformation matrix corresponding to a given cascade
  61351. * @param cascadeNum cascade to retrieve the transformation matrix from
  61352. * @returns the cascade transformation matrix
  61353. */
  61354. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  61355. private _depthRenderer;
  61356. /**
  61357. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  61358. *
  61359. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  61360. *
  61361. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  61362. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  61363. * @param depthRenderer The depth renderer to use when autoCalcDepthBounds is enabled. If you pass null or don't call this function at all, a depth renderer will be automatically created
  61364. */
  61365. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  61366. private _depthReducer;
  61367. private _autoCalcDepthBounds;
  61368. /**
  61369. * Gets or sets the autoCalcDepthBounds property.
  61370. *
  61371. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  61372. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  61373. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  61374. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  61375. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  61376. */
  61377. get autoCalcDepthBounds(): boolean;
  61378. set autoCalcDepthBounds(value: boolean);
  61379. /**
  61380. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  61381. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61382. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  61383. * for setting the refresh rate on the renderer yourself!
  61384. */
  61385. get autoCalcDepthBoundsRefreshRate(): number;
  61386. set autoCalcDepthBoundsRefreshRate(value: number);
  61387. /**
  61388. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  61389. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  61390. * you change the camera near/far planes!
  61391. */
  61392. splitFrustum(): void;
  61393. private _splitFrustum;
  61394. private _computeMatrices;
  61395. private _computeFrustumInWorldSpace;
  61396. private _computeCascadeFrustum;
  61397. /**
  61398. * Support test.
  61399. */
  61400. static get IsSupported(): boolean;
  61401. /** @hidden */
  61402. static _SceneComponentInitialization: (scene: Scene) => void;
  61403. /**
  61404. * Creates a Cascaded Shadow Generator object.
  61405. * A ShadowGenerator is the required tool to use the shadows.
  61406. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61407. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61408. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61409. * @param light The directional light object generating the shadows.
  61410. * @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.
  61411. */
  61412. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61413. protected _initializeGenerator(): void;
  61414. protected _createTargetRenderTexture(): void;
  61415. protected _initializeShadowMap(): void;
  61416. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61417. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61418. /**
  61419. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61420. * @param defines Defines of the material we want to update
  61421. * @param lightIndex Index of the light in the enabled light list of the material
  61422. */
  61423. prepareDefines(defines: any, lightIndex: number): void;
  61424. /**
  61425. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61426. * defined in the generator but impacting the effect).
  61427. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61428. * @param effect The effect we are binfing the information for
  61429. */
  61430. bindShadowLight(lightIndex: string, effect: Effect): void;
  61431. /**
  61432. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  61433. * (eq to view projection * shadow projection matrices)
  61434. * @returns The transform matrix used to create the shadow map
  61435. */
  61436. getTransformMatrix(): Matrix;
  61437. /**
  61438. * Disposes the ShadowGenerator.
  61439. * Returns nothing.
  61440. */
  61441. dispose(): void;
  61442. /**
  61443. * Serializes the shadow generator setup to a json object.
  61444. * @returns The serialized JSON object
  61445. */
  61446. serialize(): any;
  61447. /**
  61448. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  61449. * @param parsedShadowGenerator The JSON object to parse
  61450. * @param scene The scene to create the shadow map for
  61451. * @returns The parsed shadow generator
  61452. */
  61453. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  61454. }
  61455. }
  61456. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  61457. import { Scene } from "babylonjs/scene";
  61458. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61459. import { AbstractScene } from "babylonjs/abstractScene";
  61460. /**
  61461. * Defines the shadow generator component responsible to manage any shadow generators
  61462. * in a given scene.
  61463. */
  61464. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  61465. /**
  61466. * The component name helpfull to identify the component in the list of scene components.
  61467. */
  61468. readonly name: string;
  61469. /**
  61470. * The scene the component belongs to.
  61471. */
  61472. scene: Scene;
  61473. /**
  61474. * Creates a new instance of the component for the given scene
  61475. * @param scene Defines the scene to register the component in
  61476. */
  61477. constructor(scene: Scene);
  61478. /**
  61479. * Registers the component in a given scene
  61480. */
  61481. register(): void;
  61482. /**
  61483. * Rebuilds the elements related to this component in case of
  61484. * context lost for instance.
  61485. */
  61486. rebuild(): void;
  61487. /**
  61488. * Serializes the component data to the specified json object
  61489. * @param serializationObject The object to serialize to
  61490. */
  61491. serialize(serializationObject: any): void;
  61492. /**
  61493. * Adds all the elements from the container to the scene
  61494. * @param container the container holding the elements
  61495. */
  61496. addFromContainer(container: AbstractScene): void;
  61497. /**
  61498. * Removes all the elements in the container from the scene
  61499. * @param container contains the elements to remove
  61500. * @param dispose if the removed element should be disposed (default: false)
  61501. */
  61502. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61503. /**
  61504. * Rebuilds the elements related to this component in case of
  61505. * context lost for instance.
  61506. */
  61507. dispose(): void;
  61508. private _gatherRenderTargets;
  61509. }
  61510. }
  61511. declare module "babylonjs/Lights/Shadows/index" {
  61512. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  61513. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  61514. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  61515. }
  61516. declare module "babylonjs/Lights/pointLight" {
  61517. import { Scene } from "babylonjs/scene";
  61518. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61520. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  61521. import { Effect } from "babylonjs/Materials/effect";
  61522. /**
  61523. * A point light is a light defined by an unique point in world space.
  61524. * The light is emitted in every direction from this point.
  61525. * A good example of a point light is a standard light bulb.
  61526. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61527. */
  61528. export class PointLight extends ShadowLight {
  61529. private _shadowAngle;
  61530. /**
  61531. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61532. * This specifies what angle the shadow will use to be created.
  61533. *
  61534. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61535. */
  61536. get shadowAngle(): number;
  61537. /**
  61538. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61539. * This specifies what angle the shadow will use to be created.
  61540. *
  61541. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61542. */
  61543. set shadowAngle(value: number);
  61544. /**
  61545. * Gets the direction if it has been set.
  61546. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61547. */
  61548. get direction(): Vector3;
  61549. /**
  61550. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61551. */
  61552. set direction(value: Vector3);
  61553. /**
  61554. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  61555. * A PointLight emits the light in every direction.
  61556. * It can cast shadows.
  61557. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  61558. * ```javascript
  61559. * var pointLight = new PointLight("pl", camera.position, scene);
  61560. * ```
  61561. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61562. * @param name The light friendly name
  61563. * @param position The position of the point light in the scene
  61564. * @param scene The scene the lights belongs to
  61565. */
  61566. constructor(name: string, position: Vector3, scene: Scene);
  61567. /**
  61568. * Returns the string "PointLight"
  61569. * @returns the class name
  61570. */
  61571. getClassName(): string;
  61572. /**
  61573. * Returns the integer 0.
  61574. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61575. */
  61576. getTypeID(): number;
  61577. /**
  61578. * Specifies wether or not the shadowmap should be a cube texture.
  61579. * @returns true if the shadowmap needs to be a cube texture.
  61580. */
  61581. needCube(): boolean;
  61582. /**
  61583. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  61584. * @param faceIndex The index of the face we are computed the direction to generate shadow
  61585. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  61586. */
  61587. getShadowDirection(faceIndex?: number): Vector3;
  61588. /**
  61589. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  61590. * - fov = PI / 2
  61591. * - aspect ratio : 1.0
  61592. * - z-near and far equal to the active camera minZ and maxZ.
  61593. * Returns the PointLight.
  61594. */
  61595. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61596. protected _buildUniformLayout(): void;
  61597. /**
  61598. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  61599. * @param effect The effect to update
  61600. * @param lightIndex The index of the light in the effect to update
  61601. * @returns The point light
  61602. */
  61603. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  61604. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61605. /**
  61606. * Prepares the list of defines specific to the light type.
  61607. * @param defines the list of defines
  61608. * @param lightIndex defines the index of the light for the effect
  61609. */
  61610. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61611. }
  61612. }
  61613. declare module "babylonjs/Lights/index" {
  61614. export * from "babylonjs/Lights/light";
  61615. export * from "babylonjs/Lights/shadowLight";
  61616. export * from "babylonjs/Lights/Shadows/index";
  61617. export * from "babylonjs/Lights/directionalLight";
  61618. export * from "babylonjs/Lights/hemisphericLight";
  61619. export * from "babylonjs/Lights/pointLight";
  61620. export * from "babylonjs/Lights/spotLight";
  61621. }
  61622. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  61623. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  61624. /**
  61625. * Header information of HDR texture files.
  61626. */
  61627. export interface HDRInfo {
  61628. /**
  61629. * The height of the texture in pixels.
  61630. */
  61631. height: number;
  61632. /**
  61633. * The width of the texture in pixels.
  61634. */
  61635. width: number;
  61636. /**
  61637. * The index of the beginning of the data in the binary file.
  61638. */
  61639. dataPosition: number;
  61640. }
  61641. /**
  61642. * This groups tools to convert HDR texture to native colors array.
  61643. */
  61644. export class HDRTools {
  61645. private static Ldexp;
  61646. private static Rgbe2float;
  61647. private static readStringLine;
  61648. /**
  61649. * Reads header information from an RGBE texture stored in a native array.
  61650. * More information on this format are available here:
  61651. * https://en.wikipedia.org/wiki/RGBE_image_format
  61652. *
  61653. * @param uint8array The binary file stored in native array.
  61654. * @return The header information.
  61655. */
  61656. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61657. /**
  61658. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61659. * This RGBE texture needs to store the information as a panorama.
  61660. *
  61661. * More information on this format are available here:
  61662. * https://en.wikipedia.org/wiki/RGBE_image_format
  61663. *
  61664. * @param buffer The binary file stored in an array buffer.
  61665. * @param size The expected size of the extracted cubemap.
  61666. * @return The Cube Map information.
  61667. */
  61668. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61669. /**
  61670. * Returns the pixels data extracted from an RGBE texture.
  61671. * This pixels will be stored left to right up to down in the R G B order in one array.
  61672. *
  61673. * More information on this format are available here:
  61674. * https://en.wikipedia.org/wiki/RGBE_image_format
  61675. *
  61676. * @param uint8array The binary file stored in an array buffer.
  61677. * @param hdrInfo The header information of the file.
  61678. * @return The pixels data in RGB right to left up to down order.
  61679. */
  61680. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61681. private static RGBE_ReadPixels_RLE;
  61682. }
  61683. }
  61684. declare module "babylonjs/Materials/effectRenderer" {
  61685. import { Nullable } from "babylonjs/types";
  61686. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61687. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61688. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61689. import { Viewport } from "babylonjs/Maths/math.viewport";
  61690. import { Observable } from "babylonjs/Misc/observable";
  61691. import { Effect } from "babylonjs/Materials/effect";
  61692. import "babylonjs/Shaders/postprocess.vertex";
  61693. /**
  61694. * Effect Render Options
  61695. */
  61696. export interface IEffectRendererOptions {
  61697. /**
  61698. * Defines the vertices positions.
  61699. */
  61700. positions?: number[];
  61701. /**
  61702. * Defines the indices.
  61703. */
  61704. indices?: number[];
  61705. }
  61706. /**
  61707. * Helper class to render one or more effects.
  61708. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61709. */
  61710. export class EffectRenderer {
  61711. private engine;
  61712. private static _DefaultOptions;
  61713. private _vertexBuffers;
  61714. private _indexBuffer;
  61715. private _fullscreenViewport;
  61716. /**
  61717. * Creates an effect renderer
  61718. * @param engine the engine to use for rendering
  61719. * @param options defines the options of the effect renderer
  61720. */
  61721. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61722. /**
  61723. * Sets the current viewport in normalized coordinates 0-1
  61724. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61725. */
  61726. setViewport(viewport?: Viewport): void;
  61727. /**
  61728. * Binds the embedded attributes buffer to the effect.
  61729. * @param effect Defines the effect to bind the attributes for
  61730. */
  61731. bindBuffers(effect: Effect): void;
  61732. /**
  61733. * Sets the current effect wrapper to use during draw.
  61734. * The effect needs to be ready before calling this api.
  61735. * This also sets the default full screen position attribute.
  61736. * @param effectWrapper Defines the effect to draw with
  61737. */
  61738. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61739. /**
  61740. * Restores engine states
  61741. */
  61742. restoreStates(): void;
  61743. /**
  61744. * Draws a full screen quad.
  61745. */
  61746. draw(): void;
  61747. private isRenderTargetTexture;
  61748. /**
  61749. * renders one or more effects to a specified texture
  61750. * @param effectWrapper the effect to renderer
  61751. * @param outputTexture texture to draw to, if null it will render to the screen.
  61752. */
  61753. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61754. /**
  61755. * Disposes of the effect renderer
  61756. */
  61757. dispose(): void;
  61758. }
  61759. /**
  61760. * Options to create an EffectWrapper
  61761. */
  61762. interface EffectWrapperCreationOptions {
  61763. /**
  61764. * Engine to use to create the effect
  61765. */
  61766. engine: ThinEngine;
  61767. /**
  61768. * Fragment shader for the effect
  61769. */
  61770. fragmentShader: string;
  61771. /**
  61772. * Use the shader store instead of direct source code
  61773. */
  61774. useShaderStore?: boolean;
  61775. /**
  61776. * Vertex shader for the effect
  61777. */
  61778. vertexShader?: string;
  61779. /**
  61780. * Attributes to use in the shader
  61781. */
  61782. attributeNames?: Array<string>;
  61783. /**
  61784. * Uniforms to use in the shader
  61785. */
  61786. uniformNames?: Array<string>;
  61787. /**
  61788. * Texture sampler names to use in the shader
  61789. */
  61790. samplerNames?: Array<string>;
  61791. /**
  61792. * Defines to use in the shader
  61793. */
  61794. defines?: Array<string>;
  61795. /**
  61796. * Callback when effect is compiled
  61797. */
  61798. onCompiled?: Nullable<(effect: Effect) => void>;
  61799. /**
  61800. * The friendly name of the effect displayed in Spector.
  61801. */
  61802. name?: string;
  61803. }
  61804. /**
  61805. * Wraps an effect to be used for rendering
  61806. */
  61807. export class EffectWrapper {
  61808. /**
  61809. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61810. */
  61811. onApplyObservable: Observable<{}>;
  61812. /**
  61813. * The underlying effect
  61814. */
  61815. effect: Effect;
  61816. /**
  61817. * Creates an effect to be renderer
  61818. * @param creationOptions options to create the effect
  61819. */
  61820. constructor(creationOptions: EffectWrapperCreationOptions);
  61821. /**
  61822. * Disposes of the effect wrapper
  61823. */
  61824. dispose(): void;
  61825. }
  61826. }
  61827. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  61828. /** @hidden */
  61829. export var hdrFilteringVertexShader: {
  61830. name: string;
  61831. shader: string;
  61832. };
  61833. }
  61834. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  61835. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61836. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  61837. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  61838. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  61839. /** @hidden */
  61840. export var hdrFilteringPixelShader: {
  61841. name: string;
  61842. shader: string;
  61843. };
  61844. }
  61845. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  61846. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61847. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61848. import { Nullable } from "babylonjs/types";
  61849. import "babylonjs/Shaders/hdrFiltering.vertex";
  61850. import "babylonjs/Shaders/hdrFiltering.fragment";
  61851. /**
  61852. * Options for texture filtering
  61853. */
  61854. interface IHDRFilteringOptions {
  61855. /**
  61856. * Scales pixel intensity for the input HDR map.
  61857. */
  61858. hdrScale?: number;
  61859. /**
  61860. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61861. */
  61862. quality?: number;
  61863. }
  61864. /**
  61865. * Filters HDR maps to get correct renderings of PBR reflections
  61866. */
  61867. export class HDRFiltering {
  61868. private _engine;
  61869. private _effectRenderer;
  61870. private _effectWrapper;
  61871. private _lodGenerationOffset;
  61872. private _lodGenerationScale;
  61873. /**
  61874. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61875. * you care about baking speed.
  61876. */
  61877. quality: number;
  61878. /**
  61879. * Scales pixel intensity for the input HDR map.
  61880. */
  61881. hdrScale: number;
  61882. /**
  61883. * Instantiates HDR filter for reflection maps
  61884. *
  61885. * @param engine Thin engine
  61886. * @param options Options
  61887. */
  61888. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61889. private _createRenderTarget;
  61890. private _prefilterInternal;
  61891. private _createEffect;
  61892. /**
  61893. * Get a value indicating if the filter is ready to be used
  61894. * @param texture Texture to filter
  61895. * @returns true if the filter is ready
  61896. */
  61897. isReady(texture: BaseTexture): boolean;
  61898. /**
  61899. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61900. * Prefiltering will be invoked at the end of next rendering pass.
  61901. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61902. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61903. * @param texture Texture to filter
  61904. * @param onFinished Callback when filtering is done
  61905. * @return Promise called when prefiltering is done
  61906. */
  61907. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61908. }
  61909. }
  61910. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  61911. import { Nullable } from "babylonjs/types";
  61912. import { Scene } from "babylonjs/scene";
  61913. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61914. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61915. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61916. import "babylonjs/Engines/Extensions/engine.rawTexture";
  61917. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  61918. /**
  61919. * This represents a texture coming from an HDR input.
  61920. *
  61921. * The only supported format is currently panorama picture stored in RGBE format.
  61922. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61923. */
  61924. export class HDRCubeTexture extends BaseTexture {
  61925. private static _facesMapping;
  61926. private _generateHarmonics;
  61927. private _noMipmap;
  61928. private _prefilterOnLoad;
  61929. private _textureMatrix;
  61930. private _size;
  61931. private _onLoad;
  61932. private _onError;
  61933. /**
  61934. * The texture URL.
  61935. */
  61936. url: string;
  61937. /**
  61938. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  61939. */
  61940. coordinatesMode: number;
  61941. protected _isBlocking: boolean;
  61942. /**
  61943. * Sets wether or not the texture is blocking during loading.
  61944. */
  61945. set isBlocking(value: boolean);
  61946. /**
  61947. * Gets wether or not the texture is blocking during loading.
  61948. */
  61949. get isBlocking(): boolean;
  61950. protected _rotationY: number;
  61951. /**
  61952. * Sets texture matrix rotation angle around Y axis in radians.
  61953. */
  61954. set rotationY(value: number);
  61955. /**
  61956. * Gets texture matrix rotation angle around Y axis radians.
  61957. */
  61958. get rotationY(): number;
  61959. /**
  61960. * Gets or sets the center of the bounding box associated with the cube texture
  61961. * It must define where the camera used to render the texture was set
  61962. */
  61963. boundingBoxPosition: Vector3;
  61964. private _boundingBoxSize;
  61965. /**
  61966. * Gets or sets the size of the bounding box associated with the cube texture
  61967. * When defined, the cubemap will switch to local mode
  61968. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61969. * @example https://www.babylonjs-playground.com/#RNASML
  61970. */
  61971. set boundingBoxSize(value: Vector3);
  61972. get boundingBoxSize(): Vector3;
  61973. /**
  61974. * Instantiates an HDRTexture from the following parameters.
  61975. *
  61976. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61977. * @param sceneOrEngine The scene or engine the texture will be used in
  61978. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61979. * @param noMipmap Forces to not generate the mipmap if true
  61980. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61981. * @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)
  61982. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61983. */
  61984. constructor(url: string, sceneOrEngine: Scene | ThinEngine, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, prefilterOnLoad?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  61985. /**
  61986. * Get the current class name of the texture useful for serialization or dynamic coding.
  61987. * @returns "HDRCubeTexture"
  61988. */
  61989. getClassName(): string;
  61990. /**
  61991. * Occurs when the file is raw .hdr file.
  61992. */
  61993. private loadTexture;
  61994. clone(): HDRCubeTexture;
  61995. delayLoad(): void;
  61996. /**
  61997. * Get the texture reflection matrix used to rotate/transform the reflection.
  61998. * @returns the reflection matrix
  61999. */
  62000. getReflectionTextureMatrix(): Matrix;
  62001. /**
  62002. * Set the texture reflection matrix used to rotate/transform the reflection.
  62003. * @param value Define the reflection matrix to set
  62004. */
  62005. setReflectionTextureMatrix(value: Matrix): void;
  62006. /**
  62007. * Parses a JSON representation of an HDR Texture in order to create the texture
  62008. * @param parsedTexture Define the JSON representation
  62009. * @param scene Define the scene the texture should be created in
  62010. * @param rootUrl Define the root url in case we need to load relative dependencies
  62011. * @returns the newly created texture after parsing
  62012. */
  62013. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  62014. serialize(): any;
  62015. }
  62016. }
  62017. declare module "babylonjs/Physics/physicsEngine" {
  62018. import { Nullable } from "babylonjs/types";
  62019. import { Vector3 } from "babylonjs/Maths/math.vector";
  62020. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  62021. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  62022. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  62023. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62024. /**
  62025. * Class used to control physics engine
  62026. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62027. */
  62028. export class PhysicsEngine implements IPhysicsEngine {
  62029. private _physicsPlugin;
  62030. /**
  62031. * Global value used to control the smallest number supported by the simulation
  62032. */
  62033. static Epsilon: number;
  62034. private _impostors;
  62035. private _joints;
  62036. private _subTimeStep;
  62037. /**
  62038. * Gets the gravity vector used by the simulation
  62039. */
  62040. gravity: Vector3;
  62041. /**
  62042. * Factory used to create the default physics plugin.
  62043. * @returns The default physics plugin
  62044. */
  62045. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  62046. /**
  62047. * Creates a new Physics Engine
  62048. * @param gravity defines the gravity vector used by the simulation
  62049. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  62050. */
  62051. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  62052. /**
  62053. * Sets the gravity vector used by the simulation
  62054. * @param gravity defines the gravity vector to use
  62055. */
  62056. setGravity(gravity: Vector3): void;
  62057. /**
  62058. * Set the time step of the physics engine.
  62059. * Default is 1/60.
  62060. * To slow it down, enter 1/600 for example.
  62061. * To speed it up, 1/30
  62062. * @param newTimeStep defines the new timestep to apply to this world.
  62063. */
  62064. setTimeStep(newTimeStep?: number): void;
  62065. /**
  62066. * Get the time step of the physics engine.
  62067. * @returns the current time step
  62068. */
  62069. getTimeStep(): number;
  62070. /**
  62071. * Set the sub time step of the physics engine.
  62072. * Default is 0 meaning there is no sub steps
  62073. * To increase physics resolution precision, set a small value (like 1 ms)
  62074. * @param subTimeStep defines the new sub timestep used for physics resolution.
  62075. */
  62076. setSubTimeStep(subTimeStep?: number): void;
  62077. /**
  62078. * Get the sub time step of the physics engine.
  62079. * @returns the current sub time step
  62080. */
  62081. getSubTimeStep(): number;
  62082. /**
  62083. * Release all resources
  62084. */
  62085. dispose(): void;
  62086. /**
  62087. * Gets the name of the current physics plugin
  62088. * @returns the name of the plugin
  62089. */
  62090. getPhysicsPluginName(): string;
  62091. /**
  62092. * Adding a new impostor for the impostor tracking.
  62093. * This will be done by the impostor itself.
  62094. * @param impostor the impostor to add
  62095. */
  62096. addImpostor(impostor: PhysicsImpostor): void;
  62097. /**
  62098. * Remove an impostor from the engine.
  62099. * This impostor and its mesh will not longer be updated by the physics engine.
  62100. * @param impostor the impostor to remove
  62101. */
  62102. removeImpostor(impostor: PhysicsImpostor): void;
  62103. /**
  62104. * Add a joint to the physics engine
  62105. * @param mainImpostor defines the main impostor to which the joint is added.
  62106. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  62107. * @param joint defines the joint that will connect both impostors.
  62108. */
  62109. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62110. /**
  62111. * Removes a joint from the simulation
  62112. * @param mainImpostor defines the impostor used with the joint
  62113. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  62114. * @param joint defines the joint to remove
  62115. */
  62116. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62117. /**
  62118. * Called by the scene. No need to call it.
  62119. * @param delta defines the timespam between frames
  62120. */
  62121. _step(delta: number): void;
  62122. /**
  62123. * Gets the current plugin used to run the simulation
  62124. * @returns current plugin
  62125. */
  62126. getPhysicsPlugin(): IPhysicsEnginePlugin;
  62127. /**
  62128. * Gets the list of physic impostors
  62129. * @returns an array of PhysicsImpostor
  62130. */
  62131. getImpostors(): Array<PhysicsImpostor>;
  62132. /**
  62133. * Gets the impostor for a physics enabled object
  62134. * @param object defines the object impersonated by the impostor
  62135. * @returns the PhysicsImpostor or null if not found
  62136. */
  62137. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  62138. /**
  62139. * Gets the impostor for a physics body object
  62140. * @param body defines physics body used by the impostor
  62141. * @returns the PhysicsImpostor or null if not found
  62142. */
  62143. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  62144. /**
  62145. * Does a raycast in the physics world
  62146. * @param from when should the ray start?
  62147. * @param to when should the ray end?
  62148. * @returns PhysicsRaycastResult
  62149. */
  62150. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62151. }
  62152. }
  62153. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  62154. import { Nullable } from "babylonjs/types";
  62155. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  62156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62157. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62158. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62159. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62160. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62161. /** @hidden */
  62162. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  62163. private _useDeltaForWorldStep;
  62164. world: any;
  62165. name: string;
  62166. private _physicsMaterials;
  62167. private _fixedTimeStep;
  62168. private _cannonRaycastResult;
  62169. private _raycastResult;
  62170. private _physicsBodysToRemoveAfterStep;
  62171. private _firstFrame;
  62172. BJSCANNON: any;
  62173. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  62174. setGravity(gravity: Vector3): void;
  62175. setTimeStep(timeStep: number): void;
  62176. getTimeStep(): number;
  62177. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62178. private _removeMarkedPhysicsBodiesFromWorld;
  62179. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62180. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62181. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62182. private _processChildMeshes;
  62183. removePhysicsBody(impostor: PhysicsImpostor): void;
  62184. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62185. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62186. private _addMaterial;
  62187. private _checkWithEpsilon;
  62188. private _createShape;
  62189. private _createHeightmap;
  62190. private _minus90X;
  62191. private _plus90X;
  62192. private _tmpPosition;
  62193. private _tmpDeltaPosition;
  62194. private _tmpUnityRotation;
  62195. private _updatePhysicsBodyTransformation;
  62196. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62197. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62198. isSupported(): boolean;
  62199. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62200. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62201. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62202. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62203. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62204. getBodyMass(impostor: PhysicsImpostor): number;
  62205. getBodyFriction(impostor: PhysicsImpostor): number;
  62206. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62207. getBodyRestitution(impostor: PhysicsImpostor): number;
  62208. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62209. sleepBody(impostor: PhysicsImpostor): void;
  62210. wakeUpBody(impostor: PhysicsImpostor): void;
  62211. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  62212. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62213. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62214. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62215. getRadius(impostor: PhysicsImpostor): number;
  62216. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62217. dispose(): void;
  62218. private _extendNamespace;
  62219. /**
  62220. * Does a raycast in the physics world
  62221. * @param from when should the ray start?
  62222. * @param to when should the ray end?
  62223. * @returns PhysicsRaycastResult
  62224. */
  62225. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62226. }
  62227. }
  62228. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  62229. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62230. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62231. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62232. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62233. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  62234. import { Nullable } from "babylonjs/types";
  62235. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62236. /** @hidden */
  62237. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  62238. private _useDeltaForWorldStep;
  62239. world: any;
  62240. name: string;
  62241. BJSOIMO: any;
  62242. private _raycastResult;
  62243. private _fixedTimeStep;
  62244. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  62245. setGravity(gravity: Vector3): void;
  62246. setTimeStep(timeStep: number): void;
  62247. getTimeStep(): number;
  62248. private _tmpImpostorsArray;
  62249. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62250. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62251. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62252. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62253. private _tmpPositionVector;
  62254. removePhysicsBody(impostor: PhysicsImpostor): void;
  62255. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62256. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62257. isSupported(): boolean;
  62258. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62259. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62260. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62261. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62262. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62263. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62264. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62265. getBodyMass(impostor: PhysicsImpostor): number;
  62266. getBodyFriction(impostor: PhysicsImpostor): number;
  62267. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62268. getBodyRestitution(impostor: PhysicsImpostor): number;
  62269. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62270. sleepBody(impostor: PhysicsImpostor): void;
  62271. wakeUpBody(impostor: PhysicsImpostor): void;
  62272. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62273. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  62274. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  62275. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62276. getRadius(impostor: PhysicsImpostor): number;
  62277. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62278. dispose(): void;
  62279. /**
  62280. * Does a raycast in the physics world
  62281. * @param from when should the ray start?
  62282. * @param to when should the ray end?
  62283. * @returns PhysicsRaycastResult
  62284. */
  62285. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62286. }
  62287. }
  62288. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  62289. import { Nullable } from "babylonjs/types";
  62290. import { Scene } from "babylonjs/scene";
  62291. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  62292. import { Color4 } from "babylonjs/Maths/math.color";
  62293. import { Mesh } from "babylonjs/Meshes/mesh";
  62294. /**
  62295. * Class containing static functions to help procedurally build meshes
  62296. */
  62297. export class RibbonBuilder {
  62298. /**
  62299. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62300. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  62301. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  62302. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  62303. * * 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
  62304. * * 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
  62305. * * 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
  62306. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62307. * * 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
  62308. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62309. * * 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
  62310. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  62311. * * 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
  62312. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  62313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62314. * @param name defines the name of the mesh
  62315. * @param options defines the options used to create the mesh
  62316. * @param scene defines the hosting scene
  62317. * @returns the ribbon mesh
  62318. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  62319. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62320. */
  62321. static CreateRibbon(name: string, options: {
  62322. pathArray: Vector3[][];
  62323. closeArray?: boolean;
  62324. closePath?: boolean;
  62325. offset?: number;
  62326. updatable?: boolean;
  62327. sideOrientation?: number;
  62328. frontUVs?: Vector4;
  62329. backUVs?: Vector4;
  62330. instance?: Mesh;
  62331. invertUV?: boolean;
  62332. uvs?: Vector2[];
  62333. colors?: Color4[];
  62334. }, scene?: Nullable<Scene>): Mesh;
  62335. }
  62336. }
  62337. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  62338. import { Nullable } from "babylonjs/types";
  62339. import { Scene } from "babylonjs/scene";
  62340. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62341. import { Mesh } from "babylonjs/Meshes/mesh";
  62342. /**
  62343. * Class containing static functions to help procedurally build meshes
  62344. */
  62345. export class ShapeBuilder {
  62346. /**
  62347. * 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.
  62348. * * 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.
  62349. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62350. * * 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.
  62351. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  62352. * * 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
  62353. * * 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
  62354. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  62355. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62356. * * 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
  62357. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  62358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62359. * @param name defines the name of the mesh
  62360. * @param options defines the options used to create the mesh
  62361. * @param scene defines the hosting scene
  62362. * @returns the extruded shape mesh
  62363. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62364. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62365. */
  62366. static ExtrudeShape(name: string, options: {
  62367. shape: Vector3[];
  62368. path: Vector3[];
  62369. scale?: number;
  62370. rotation?: number;
  62371. cap?: number;
  62372. updatable?: boolean;
  62373. sideOrientation?: number;
  62374. frontUVs?: Vector4;
  62375. backUVs?: Vector4;
  62376. instance?: Mesh;
  62377. invertUV?: boolean;
  62378. }, scene?: Nullable<Scene>): Mesh;
  62379. /**
  62380. * Creates an custom extruded shape mesh.
  62381. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  62382. * * 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.
  62383. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62384. * * 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
  62385. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  62386. * * 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
  62387. * * It must returns a float value that will be the scale value applied to the shape on each path point
  62388. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  62389. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  62390. * * 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
  62391. * * 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
  62392. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  62393. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62394. * * 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
  62395. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62397. * @param name defines the name of the mesh
  62398. * @param options defines the options used to create the mesh
  62399. * @param scene defines the hosting scene
  62400. * @returns the custom extruded shape mesh
  62401. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  62402. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62403. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62404. */
  62405. static ExtrudeShapeCustom(name: string, options: {
  62406. shape: Vector3[];
  62407. path: Vector3[];
  62408. scaleFunction?: any;
  62409. rotationFunction?: any;
  62410. ribbonCloseArray?: boolean;
  62411. ribbonClosePath?: boolean;
  62412. cap?: number;
  62413. updatable?: boolean;
  62414. sideOrientation?: number;
  62415. frontUVs?: Vector4;
  62416. backUVs?: Vector4;
  62417. instance?: Mesh;
  62418. invertUV?: boolean;
  62419. }, scene?: Nullable<Scene>): Mesh;
  62420. private static _ExtrudeShapeGeneric;
  62421. }
  62422. }
  62423. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  62424. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  62425. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62426. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62427. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62428. import { Nullable } from "babylonjs/types";
  62429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62430. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62431. /**
  62432. * AmmoJS Physics plugin
  62433. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62434. * @see https://github.com/kripken/ammo.js/
  62435. */
  62436. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  62437. private _useDeltaForWorldStep;
  62438. /**
  62439. * Reference to the Ammo library
  62440. */
  62441. bjsAMMO: any;
  62442. /**
  62443. * Created ammoJS world which physics bodies are added to
  62444. */
  62445. world: any;
  62446. /**
  62447. * Name of the plugin
  62448. */
  62449. name: string;
  62450. private _timeStep;
  62451. private _fixedTimeStep;
  62452. private _maxSteps;
  62453. private _tmpQuaternion;
  62454. private _tmpAmmoTransform;
  62455. private _tmpAmmoQuaternion;
  62456. private _tmpAmmoConcreteContactResultCallback;
  62457. private _collisionConfiguration;
  62458. private _dispatcher;
  62459. private _overlappingPairCache;
  62460. private _solver;
  62461. private _softBodySolver;
  62462. private _tmpAmmoVectorA;
  62463. private _tmpAmmoVectorB;
  62464. private _tmpAmmoVectorC;
  62465. private _tmpAmmoVectorD;
  62466. private _tmpContactCallbackResult;
  62467. private _tmpAmmoVectorRCA;
  62468. private _tmpAmmoVectorRCB;
  62469. private _raycastResult;
  62470. private static readonly DISABLE_COLLISION_FLAG;
  62471. private static readonly KINEMATIC_FLAG;
  62472. private static readonly DISABLE_DEACTIVATION_FLAG;
  62473. /**
  62474. * Initializes the ammoJS plugin
  62475. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  62476. * @param ammoInjection can be used to inject your own ammo reference
  62477. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  62478. */
  62479. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  62480. /**
  62481. * Sets the gravity of the physics world (m/(s^2))
  62482. * @param gravity Gravity to set
  62483. */
  62484. setGravity(gravity: Vector3): void;
  62485. /**
  62486. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  62487. * @param timeStep timestep to use in seconds
  62488. */
  62489. setTimeStep(timeStep: number): void;
  62490. /**
  62491. * 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)
  62492. * @param fixedTimeStep fixedTimeStep to use in seconds
  62493. */
  62494. setFixedTimeStep(fixedTimeStep: number): void;
  62495. /**
  62496. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  62497. * @param maxSteps the maximum number of steps by the physics engine per frame
  62498. */
  62499. setMaxSteps(maxSteps: number): void;
  62500. /**
  62501. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  62502. * @returns the current timestep in seconds
  62503. */
  62504. getTimeStep(): number;
  62505. /**
  62506. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  62507. */
  62508. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  62509. private _isImpostorInContact;
  62510. private _isImpostorPairInContact;
  62511. private _stepSimulation;
  62512. /**
  62513. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  62514. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  62515. * After the step the babylon meshes are set to the position of the physics imposters
  62516. * @param delta amount of time to step forward
  62517. * @param impostors array of imposters to update before/after the step
  62518. */
  62519. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62520. /**
  62521. * Update babylon mesh to match physics world object
  62522. * @param impostor imposter to match
  62523. */
  62524. private _afterSoftStep;
  62525. /**
  62526. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62527. * @param impostor imposter to match
  62528. */
  62529. private _ropeStep;
  62530. /**
  62531. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62532. * @param impostor imposter to match
  62533. */
  62534. private _softbodyOrClothStep;
  62535. private _tmpMatrix;
  62536. /**
  62537. * Applies an impulse on the imposter
  62538. * @param impostor imposter to apply impulse to
  62539. * @param force amount of force to be applied to the imposter
  62540. * @param contactPoint the location to apply the impulse on the imposter
  62541. */
  62542. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62543. /**
  62544. * Applies a force on the imposter
  62545. * @param impostor imposter to apply force
  62546. * @param force amount of force to be applied to the imposter
  62547. * @param contactPoint the location to apply the force on the imposter
  62548. */
  62549. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62550. /**
  62551. * Creates a physics body using the plugin
  62552. * @param impostor the imposter to create the physics body on
  62553. */
  62554. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62555. /**
  62556. * Removes the physics body from the imposter and disposes of the body's memory
  62557. * @param impostor imposter to remove the physics body from
  62558. */
  62559. removePhysicsBody(impostor: PhysicsImpostor): void;
  62560. /**
  62561. * Generates a joint
  62562. * @param impostorJoint the imposter joint to create the joint with
  62563. */
  62564. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62565. /**
  62566. * Removes a joint
  62567. * @param impostorJoint the imposter joint to remove the joint from
  62568. */
  62569. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62570. private _addMeshVerts;
  62571. /**
  62572. * Initialise the soft body vertices to match its object's (mesh) vertices
  62573. * Softbody vertices (nodes) are in world space and to match this
  62574. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  62575. * @param impostor to create the softbody for
  62576. */
  62577. private _softVertexData;
  62578. /**
  62579. * Create an impostor's soft body
  62580. * @param impostor to create the softbody for
  62581. */
  62582. private _createSoftbody;
  62583. /**
  62584. * Create cloth for an impostor
  62585. * @param impostor to create the softbody for
  62586. */
  62587. private _createCloth;
  62588. /**
  62589. * Create rope for an impostor
  62590. * @param impostor to create the softbody for
  62591. */
  62592. private _createRope;
  62593. /**
  62594. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  62595. * @param impostor to create the custom physics shape for
  62596. */
  62597. private _createCustom;
  62598. private _addHullVerts;
  62599. private _createShape;
  62600. /**
  62601. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  62602. * @param impostor imposter containing the physics body and babylon object
  62603. */
  62604. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62605. /**
  62606. * Sets the babylon object's position/rotation from the physics body's position/rotation
  62607. * @param impostor imposter containing the physics body and babylon object
  62608. * @param newPosition new position
  62609. * @param newRotation new rotation
  62610. */
  62611. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62612. /**
  62613. * If this plugin is supported
  62614. * @returns true if its supported
  62615. */
  62616. isSupported(): boolean;
  62617. /**
  62618. * Sets the linear velocity of the physics body
  62619. * @param impostor imposter to set the velocity on
  62620. * @param velocity velocity to set
  62621. */
  62622. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62623. /**
  62624. * Sets the angular velocity of the physics body
  62625. * @param impostor imposter to set the velocity on
  62626. * @param velocity velocity to set
  62627. */
  62628. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62629. /**
  62630. * gets the linear velocity
  62631. * @param impostor imposter to get linear velocity from
  62632. * @returns linear velocity
  62633. */
  62634. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62635. /**
  62636. * gets the angular velocity
  62637. * @param impostor imposter to get angular velocity from
  62638. * @returns angular velocity
  62639. */
  62640. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62641. /**
  62642. * Sets the mass of physics body
  62643. * @param impostor imposter to set the mass on
  62644. * @param mass mass to set
  62645. */
  62646. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62647. /**
  62648. * Gets the mass of the physics body
  62649. * @param impostor imposter to get the mass from
  62650. * @returns mass
  62651. */
  62652. getBodyMass(impostor: PhysicsImpostor): number;
  62653. /**
  62654. * Gets friction of the impostor
  62655. * @param impostor impostor to get friction from
  62656. * @returns friction value
  62657. */
  62658. getBodyFriction(impostor: PhysicsImpostor): number;
  62659. /**
  62660. * Sets friction of the impostor
  62661. * @param impostor impostor to set friction on
  62662. * @param friction friction value
  62663. */
  62664. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62665. /**
  62666. * Gets restitution of the impostor
  62667. * @param impostor impostor to get restitution from
  62668. * @returns restitution value
  62669. */
  62670. getBodyRestitution(impostor: PhysicsImpostor): number;
  62671. /**
  62672. * Sets resitution of the impostor
  62673. * @param impostor impostor to set resitution on
  62674. * @param restitution resitution value
  62675. */
  62676. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62677. /**
  62678. * Gets pressure inside the impostor
  62679. * @param impostor impostor to get pressure from
  62680. * @returns pressure value
  62681. */
  62682. getBodyPressure(impostor: PhysicsImpostor): number;
  62683. /**
  62684. * Sets pressure inside a soft body impostor
  62685. * Cloth and rope must remain 0 pressure
  62686. * @param impostor impostor to set pressure on
  62687. * @param pressure pressure value
  62688. */
  62689. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62690. /**
  62691. * Gets stiffness of the impostor
  62692. * @param impostor impostor to get stiffness from
  62693. * @returns pressure value
  62694. */
  62695. getBodyStiffness(impostor: PhysicsImpostor): number;
  62696. /**
  62697. * Sets stiffness of the impostor
  62698. * @param impostor impostor to set stiffness on
  62699. * @param stiffness stiffness value from 0 to 1
  62700. */
  62701. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62702. /**
  62703. * Gets velocityIterations of the impostor
  62704. * @param impostor impostor to get velocity iterations from
  62705. * @returns velocityIterations value
  62706. */
  62707. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62708. /**
  62709. * Sets velocityIterations of the impostor
  62710. * @param impostor impostor to set velocity iterations on
  62711. * @param velocityIterations velocityIterations value
  62712. */
  62713. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62714. /**
  62715. * Gets positionIterations of the impostor
  62716. * @param impostor impostor to get position iterations from
  62717. * @returns positionIterations value
  62718. */
  62719. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62720. /**
  62721. * Sets positionIterations of the impostor
  62722. * @param impostor impostor to set position on
  62723. * @param positionIterations positionIterations value
  62724. */
  62725. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62726. /**
  62727. * Append an anchor to a cloth object
  62728. * @param impostor is the cloth impostor to add anchor to
  62729. * @param otherImpostor is the rigid impostor to anchor to
  62730. * @param width ratio across width from 0 to 1
  62731. * @param height ratio up height from 0 to 1
  62732. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62733. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62734. */
  62735. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62736. /**
  62737. * Append an hook to a rope object
  62738. * @param impostor is the rope impostor to add hook to
  62739. * @param otherImpostor is the rigid impostor to hook to
  62740. * @param length ratio along the rope from 0 to 1
  62741. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62742. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62743. */
  62744. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62745. /**
  62746. * Sleeps the physics body and stops it from being active
  62747. * @param impostor impostor to sleep
  62748. */
  62749. sleepBody(impostor: PhysicsImpostor): void;
  62750. /**
  62751. * Activates the physics body
  62752. * @param impostor impostor to activate
  62753. */
  62754. wakeUpBody(impostor: PhysicsImpostor): void;
  62755. /**
  62756. * Updates the distance parameters of the joint
  62757. * @param joint joint to update
  62758. * @param maxDistance maximum distance of the joint
  62759. * @param minDistance minimum distance of the joint
  62760. */
  62761. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62762. /**
  62763. * Sets a motor on the joint
  62764. * @param joint joint to set motor on
  62765. * @param speed speed of the motor
  62766. * @param maxForce maximum force of the motor
  62767. * @param motorIndex index of the motor
  62768. */
  62769. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62770. /**
  62771. * Sets the motors limit
  62772. * @param joint joint to set limit on
  62773. * @param upperLimit upper limit
  62774. * @param lowerLimit lower limit
  62775. */
  62776. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62777. /**
  62778. * Syncs the position and rotation of a mesh with the impostor
  62779. * @param mesh mesh to sync
  62780. * @param impostor impostor to update the mesh with
  62781. */
  62782. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62783. /**
  62784. * Gets the radius of the impostor
  62785. * @param impostor impostor to get radius from
  62786. * @returns the radius
  62787. */
  62788. getRadius(impostor: PhysicsImpostor): number;
  62789. /**
  62790. * Gets the box size of the impostor
  62791. * @param impostor impostor to get box size from
  62792. * @param result the resulting box size
  62793. */
  62794. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62795. /**
  62796. * Disposes of the impostor
  62797. */
  62798. dispose(): void;
  62799. /**
  62800. * Does a raycast in the physics world
  62801. * @param from when should the ray start?
  62802. * @param to when should the ray end?
  62803. * @returns PhysicsRaycastResult
  62804. */
  62805. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62806. }
  62807. }
  62808. declare module "babylonjs/Probes/reflectionProbe" {
  62809. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62810. import { Vector3 } from "babylonjs/Maths/math.vector";
  62811. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62812. import { Nullable } from "babylonjs/types";
  62813. import { Scene } from "babylonjs/scene";
  62814. module "babylonjs/abstractScene" {
  62815. interface AbstractScene {
  62816. /**
  62817. * The list of reflection probes added to the scene
  62818. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62819. */
  62820. reflectionProbes: Array<ReflectionProbe>;
  62821. /**
  62822. * Removes the given reflection probe from this scene.
  62823. * @param toRemove The reflection probe to remove
  62824. * @returns The index of the removed reflection probe
  62825. */
  62826. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62827. /**
  62828. * Adds the given reflection probe to this scene.
  62829. * @param newReflectionProbe The reflection probe to add
  62830. */
  62831. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62832. }
  62833. }
  62834. /**
  62835. * Class used to generate realtime reflection / refraction cube textures
  62836. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62837. */
  62838. export class ReflectionProbe {
  62839. /** defines the name of the probe */
  62840. name: string;
  62841. private _scene;
  62842. private _renderTargetTexture;
  62843. private _projectionMatrix;
  62844. private _viewMatrix;
  62845. private _target;
  62846. private _add;
  62847. private _attachedMesh;
  62848. private _invertYAxis;
  62849. /** Gets or sets probe position (center of the cube map) */
  62850. position: Vector3;
  62851. /**
  62852. * Creates a new reflection probe
  62853. * @param name defines the name of the probe
  62854. * @param size defines the texture resolution (for each face)
  62855. * @param scene defines the hosting scene
  62856. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62857. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62858. */
  62859. constructor(
  62860. /** defines the name of the probe */
  62861. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62862. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62863. get samples(): number;
  62864. set samples(value: number);
  62865. /** Gets or sets the refresh rate to use (on every frame by default) */
  62866. get refreshRate(): number;
  62867. set refreshRate(value: number);
  62868. /**
  62869. * Gets the hosting scene
  62870. * @returns a Scene
  62871. */
  62872. getScene(): Scene;
  62873. /** Gets the internal CubeTexture used to render to */
  62874. get cubeTexture(): RenderTargetTexture;
  62875. /** Gets the list of meshes to render */
  62876. get renderList(): Nullable<AbstractMesh[]>;
  62877. /**
  62878. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62879. * @param mesh defines the mesh to attach to
  62880. */
  62881. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62882. /**
  62883. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62884. * @param renderingGroupId The rendering group id corresponding to its index
  62885. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62886. */
  62887. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62888. /**
  62889. * Clean all associated resources
  62890. */
  62891. dispose(): void;
  62892. /**
  62893. * Converts the reflection probe information to a readable string for debug purpose.
  62894. * @param fullDetails Supports for multiple levels of logging within scene loading
  62895. * @returns the human readable reflection probe info
  62896. */
  62897. toString(fullDetails?: boolean): string;
  62898. /**
  62899. * Get the class name of the relfection probe.
  62900. * @returns "ReflectionProbe"
  62901. */
  62902. getClassName(): string;
  62903. /**
  62904. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62905. * @returns The JSON representation of the texture
  62906. */
  62907. serialize(): any;
  62908. /**
  62909. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62910. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62911. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62912. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62913. * @returns The parsed reflection probe if successful
  62914. */
  62915. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62916. }
  62917. }
  62918. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  62919. /** @hidden */
  62920. export var _BabylonLoaderRegistered: boolean;
  62921. /**
  62922. * Helps setting up some configuration for the babylon file loader.
  62923. */
  62924. export class BabylonFileLoaderConfiguration {
  62925. /**
  62926. * The loader does not allow injecting custom physix engine into the plugins.
  62927. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62928. * So you could set this variable to your engine import to make it work.
  62929. */
  62930. static LoaderInjectedPhysicsEngine: any;
  62931. }
  62932. }
  62933. declare module "babylonjs/Loading/Plugins/index" {
  62934. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  62935. }
  62936. declare module "babylonjs/Loading/index" {
  62937. export * from "babylonjs/Loading/loadingScreen";
  62938. export * from "babylonjs/Loading/Plugins/index";
  62939. export * from "babylonjs/Loading/sceneLoader";
  62940. export * from "babylonjs/Loading/sceneLoaderFlags";
  62941. }
  62942. declare module "babylonjs/Materials/Background/index" {
  62943. export * from "babylonjs/Materials/Background/backgroundMaterial";
  62944. }
  62945. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  62946. import { Scene } from "babylonjs/scene";
  62947. import { Color3 } from "babylonjs/Maths/math.color";
  62948. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  62949. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62950. /**
  62951. * The Physically based simple base material of BJS.
  62952. *
  62953. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62954. * It is used as the base class for both the specGloss and metalRough conventions.
  62955. */
  62956. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62957. /**
  62958. * Number of Simultaneous lights allowed on the material.
  62959. */
  62960. maxSimultaneousLights: number;
  62961. /**
  62962. * If sets to true, disables all the lights affecting the material.
  62963. */
  62964. disableLighting: boolean;
  62965. /**
  62966. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62967. */
  62968. environmentTexture: BaseTexture;
  62969. /**
  62970. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62971. */
  62972. invertNormalMapX: boolean;
  62973. /**
  62974. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62975. */
  62976. invertNormalMapY: boolean;
  62977. /**
  62978. * Normal map used in the model.
  62979. */
  62980. normalTexture: BaseTexture;
  62981. /**
  62982. * Emissivie color used to self-illuminate the model.
  62983. */
  62984. emissiveColor: Color3;
  62985. /**
  62986. * Emissivie texture used to self-illuminate the model.
  62987. */
  62988. emissiveTexture: BaseTexture;
  62989. /**
  62990. * Occlusion Channel Strenght.
  62991. */
  62992. occlusionStrength: number;
  62993. /**
  62994. * Occlusion Texture of the material (adding extra occlusion effects).
  62995. */
  62996. occlusionTexture: BaseTexture;
  62997. /**
  62998. * Defines the alpha limits in alpha test mode.
  62999. */
  63000. alphaCutOff: number;
  63001. /**
  63002. * Gets the current double sided mode.
  63003. */
  63004. get doubleSided(): boolean;
  63005. /**
  63006. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  63007. */
  63008. set doubleSided(value: boolean);
  63009. /**
  63010. * Stores the pre-calculated light information of a mesh in a texture.
  63011. */
  63012. lightmapTexture: BaseTexture;
  63013. /**
  63014. * If true, the light map contains occlusion information instead of lighting info.
  63015. */
  63016. useLightmapAsShadowmap: boolean;
  63017. /**
  63018. * Instantiates a new PBRMaterial instance.
  63019. *
  63020. * @param name The material name
  63021. * @param scene The scene the material will be use in.
  63022. */
  63023. constructor(name: string, scene: Scene);
  63024. getClassName(): string;
  63025. }
  63026. }
  63027. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  63028. import { Scene } from "babylonjs/scene";
  63029. import { Color3 } from "babylonjs/Maths/math.color";
  63030. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63031. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63032. /**
  63033. * The PBR material of BJS following the metal roughness convention.
  63034. *
  63035. * This fits to the PBR convention in the GLTF definition:
  63036. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  63037. */
  63038. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  63039. /**
  63040. * The base color has two different interpretations depending on the value of metalness.
  63041. * When the material is a metal, the base color is the specific measured reflectance value
  63042. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  63043. * of the material.
  63044. */
  63045. baseColor: Color3;
  63046. /**
  63047. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  63048. * well as opacity information in the alpha channel.
  63049. */
  63050. baseTexture: BaseTexture;
  63051. /**
  63052. * Specifies the metallic scalar value of the material.
  63053. * Can also be used to scale the metalness values of the metallic texture.
  63054. */
  63055. metallic: number;
  63056. /**
  63057. * Specifies the roughness scalar value of the material.
  63058. * Can also be used to scale the roughness values of the metallic texture.
  63059. */
  63060. roughness: number;
  63061. /**
  63062. * Texture containing both the metallic value in the B channel and the
  63063. * roughness value in the G channel to keep better precision.
  63064. */
  63065. metallicRoughnessTexture: BaseTexture;
  63066. /**
  63067. * Instantiates a new PBRMetalRoughnessMaterial instance.
  63068. *
  63069. * @param name The material name
  63070. * @param scene The scene the material will be use in.
  63071. */
  63072. constructor(name: string, scene: Scene);
  63073. /**
  63074. * Return the currrent class name of the material.
  63075. */
  63076. getClassName(): string;
  63077. /**
  63078. * Makes a duplicate of the current material.
  63079. * @param name - name to use for the new material.
  63080. */
  63081. clone(name: string): PBRMetallicRoughnessMaterial;
  63082. /**
  63083. * Serialize the material to a parsable JSON object.
  63084. */
  63085. serialize(): any;
  63086. /**
  63087. * Parses a JSON object correponding to the serialize function.
  63088. */
  63089. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  63090. }
  63091. }
  63092. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  63093. import { Scene } from "babylonjs/scene";
  63094. import { Color3 } from "babylonjs/Maths/math.color";
  63095. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63096. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63097. /**
  63098. * The PBR material of BJS following the specular glossiness convention.
  63099. *
  63100. * This fits to the PBR convention in the GLTF definition:
  63101. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  63102. */
  63103. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  63104. /**
  63105. * Specifies the diffuse color of the material.
  63106. */
  63107. diffuseColor: Color3;
  63108. /**
  63109. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  63110. * channel.
  63111. */
  63112. diffuseTexture: BaseTexture;
  63113. /**
  63114. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  63115. */
  63116. specularColor: Color3;
  63117. /**
  63118. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  63119. */
  63120. glossiness: number;
  63121. /**
  63122. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  63123. */
  63124. specularGlossinessTexture: BaseTexture;
  63125. /**
  63126. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  63127. *
  63128. * @param name The material name
  63129. * @param scene The scene the material will be use in.
  63130. */
  63131. constructor(name: string, scene: Scene);
  63132. /**
  63133. * Return the currrent class name of the material.
  63134. */
  63135. getClassName(): string;
  63136. /**
  63137. * Makes a duplicate of the current material.
  63138. * @param name - name to use for the new material.
  63139. */
  63140. clone(name: string): PBRSpecularGlossinessMaterial;
  63141. /**
  63142. * Serialize the material to a parsable JSON object.
  63143. */
  63144. serialize(): any;
  63145. /**
  63146. * Parses a JSON object correponding to the serialize function.
  63147. */
  63148. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  63149. }
  63150. }
  63151. declare module "babylonjs/Materials/PBR/index" {
  63152. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  63153. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63154. export * from "babylonjs/Materials/PBR/pbrMaterial";
  63155. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  63156. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  63157. }
  63158. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  63159. import { Nullable } from "babylonjs/types";
  63160. import { Scene } from "babylonjs/scene";
  63161. import { Matrix } from "babylonjs/Maths/math.vector";
  63162. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63163. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63164. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63165. /**
  63166. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  63167. * It can help converting any input color in a desired output one. This can then be used to create effects
  63168. * from sepia, black and white to sixties or futuristic rendering...
  63169. *
  63170. * The only supported format is currently 3dl.
  63171. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  63172. */
  63173. export class ColorGradingTexture extends BaseTexture {
  63174. /**
  63175. * The texture URL.
  63176. */
  63177. url: string;
  63178. /**
  63179. * Empty line regex stored for GC.
  63180. */
  63181. private static _noneEmptyLineRegex;
  63182. private _textureMatrix;
  63183. private _onLoad;
  63184. /**
  63185. * Instantiates a ColorGradingTexture from the following parameters.
  63186. *
  63187. * @param url The location of the color gradind data (currently only supporting 3dl)
  63188. * @param sceneOrEngine The scene or engine the texture will be used in
  63189. * @param onLoad defines a callback triggered when the texture has been loaded
  63190. */
  63191. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  63192. /**
  63193. * Fires the onload event from the constructor if requested.
  63194. */
  63195. private _triggerOnLoad;
  63196. /**
  63197. * Returns the texture matrix used in most of the material.
  63198. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  63199. */
  63200. getTextureMatrix(): Matrix;
  63201. /**
  63202. * Occurs when the file being loaded is a .3dl LUT file.
  63203. */
  63204. private load3dlTexture;
  63205. /**
  63206. * Starts the loading process of the texture.
  63207. */
  63208. private loadTexture;
  63209. /**
  63210. * Clones the color gradind texture.
  63211. */
  63212. clone(): ColorGradingTexture;
  63213. /**
  63214. * Called during delayed load for textures.
  63215. */
  63216. delayLoad(): void;
  63217. /**
  63218. * Parses a color grading texture serialized by Babylon.
  63219. * @param parsedTexture The texture information being parsedTexture
  63220. * @param scene The scene to load the texture in
  63221. * @param rootUrl The root url of the data assets to load
  63222. * @return A color gradind texture
  63223. */
  63224. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  63225. /**
  63226. * Serializes the LUT texture to json format.
  63227. */
  63228. serialize(): any;
  63229. }
  63230. }
  63231. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  63232. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63233. import { Scene } from "babylonjs/scene";
  63234. import { Nullable } from "babylonjs/types";
  63235. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63236. /**
  63237. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  63238. */
  63239. export class EquiRectangularCubeTexture extends BaseTexture {
  63240. /** The six faces of the cube. */
  63241. private static _FacesMapping;
  63242. private _noMipmap;
  63243. private _onLoad;
  63244. private _onError;
  63245. /** The size of the cubemap. */
  63246. private _size;
  63247. /** The buffer of the image. */
  63248. private _buffer;
  63249. /** The width of the input image. */
  63250. private _width;
  63251. /** The height of the input image. */
  63252. private _height;
  63253. /** The URL to the image. */
  63254. url: string;
  63255. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  63256. coordinatesMode: number;
  63257. /**
  63258. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  63259. * @param url The location of the image
  63260. * @param scene The scene the texture will be used in
  63261. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63262. * @param noMipmap Forces to not generate the mipmap if true
  63263. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63264. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63265. * @param onLoad — defines a callback called when texture is loaded
  63266. * @param onError — defines a callback called if there is an error
  63267. */
  63268. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  63269. /**
  63270. * Load the image data, by putting the image on a canvas and extracting its buffer.
  63271. */
  63272. private loadImage;
  63273. /**
  63274. * Convert the image buffer into a cubemap and create a CubeTexture.
  63275. */
  63276. private loadTexture;
  63277. /**
  63278. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  63279. * @param buffer The ArrayBuffer that should be converted.
  63280. * @returns The buffer as Float32Array.
  63281. */
  63282. private getFloat32ArrayFromArrayBuffer;
  63283. /**
  63284. * Get the current class name of the texture useful for serialization or dynamic coding.
  63285. * @returns "EquiRectangularCubeTexture"
  63286. */
  63287. getClassName(): string;
  63288. /**
  63289. * Create a clone of the current EquiRectangularCubeTexture and return it.
  63290. * @returns A clone of the current EquiRectangularCubeTexture.
  63291. */
  63292. clone(): EquiRectangularCubeTexture;
  63293. }
  63294. }
  63295. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  63296. import { Nullable } from "babylonjs/types";
  63297. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63298. import { Matrix } from "babylonjs/Maths/math.vector";
  63299. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  63300. import "babylonjs/Engines/Extensions/engine.videoTexture";
  63301. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63302. import { Scene } from "babylonjs/scene";
  63303. /**
  63304. * Defines the options related to the creation of an HtmlElementTexture
  63305. */
  63306. export interface IHtmlElementTextureOptions {
  63307. /**
  63308. * Defines wether mip maps should be created or not.
  63309. */
  63310. generateMipMaps?: boolean;
  63311. /**
  63312. * Defines the sampling mode of the texture.
  63313. */
  63314. samplingMode?: number;
  63315. /**
  63316. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  63317. */
  63318. engine: Nullable<ThinEngine>;
  63319. /**
  63320. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  63321. */
  63322. scene: Nullable<Scene>;
  63323. }
  63324. /**
  63325. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  63326. * To be as efficient as possible depending on your constraints nothing aside the first upload
  63327. * is automatically managed.
  63328. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  63329. * in your application.
  63330. *
  63331. * As the update is not automatic, you need to call them manually.
  63332. */
  63333. export class HtmlElementTexture extends BaseTexture {
  63334. /**
  63335. * The texture URL.
  63336. */
  63337. element: HTMLVideoElement | HTMLCanvasElement;
  63338. private static readonly DefaultOptions;
  63339. private _textureMatrix;
  63340. private _isVideo;
  63341. private _generateMipMaps;
  63342. private _samplingMode;
  63343. /**
  63344. * Instantiates a HtmlElementTexture from the following parameters.
  63345. *
  63346. * @param name Defines the name of the texture
  63347. * @param element Defines the video or canvas the texture is filled with
  63348. * @param options Defines the other none mandatory texture creation options
  63349. */
  63350. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  63351. private _createInternalTexture;
  63352. /**
  63353. * Returns the texture matrix used in most of the material.
  63354. */
  63355. getTextureMatrix(): Matrix;
  63356. /**
  63357. * Updates the content of the texture.
  63358. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  63359. */
  63360. update(invertY?: Nullable<boolean>): void;
  63361. }
  63362. }
  63363. declare module "babylonjs/Misc/tga" {
  63364. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63365. /**
  63366. * Based on jsTGALoader - Javascript loader for TGA file
  63367. * By Vincent Thibault
  63368. * @see http://blog.robrowser.com/javascript-tga-loader.html
  63369. */
  63370. export class TGATools {
  63371. private static _TYPE_INDEXED;
  63372. private static _TYPE_RGB;
  63373. private static _TYPE_GREY;
  63374. private static _TYPE_RLE_INDEXED;
  63375. private static _TYPE_RLE_RGB;
  63376. private static _TYPE_RLE_GREY;
  63377. private static _ORIGIN_MASK;
  63378. private static _ORIGIN_SHIFT;
  63379. private static _ORIGIN_BL;
  63380. private static _ORIGIN_BR;
  63381. private static _ORIGIN_UL;
  63382. private static _ORIGIN_UR;
  63383. /**
  63384. * Gets the header of a TGA file
  63385. * @param data defines the TGA data
  63386. * @returns the header
  63387. */
  63388. static GetTGAHeader(data: Uint8Array): any;
  63389. /**
  63390. * Uploads TGA content to a Babylon Texture
  63391. * @hidden
  63392. */
  63393. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  63394. /** @hidden */
  63395. 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;
  63396. /** @hidden */
  63397. 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;
  63398. /** @hidden */
  63399. 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;
  63400. /** @hidden */
  63401. 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;
  63402. /** @hidden */
  63403. 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;
  63404. /** @hidden */
  63405. 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;
  63406. }
  63407. }
  63408. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  63409. import { Nullable } from "babylonjs/types";
  63410. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63411. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  63412. /**
  63413. * Implementation of the TGA Texture Loader.
  63414. * @hidden
  63415. */
  63416. export class _TGATextureLoader implements IInternalTextureLoader {
  63417. /**
  63418. * Defines wether the loader supports cascade loading the different faces.
  63419. */
  63420. readonly supportCascades: boolean;
  63421. /**
  63422. * This returns if the loader support the current file information.
  63423. * @param extension defines the file extension of the file being loaded
  63424. * @returns true if the loader can load the specified file
  63425. */
  63426. canLoad(extension: string): boolean;
  63427. /**
  63428. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63429. * @param data contains the texture data
  63430. * @param texture defines the BabylonJS internal texture
  63431. * @param createPolynomials will be true if polynomials have been requested
  63432. * @param onLoad defines the callback to trigger once the texture is ready
  63433. * @param onError defines the callback to trigger in case of error
  63434. */
  63435. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63436. /**
  63437. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63438. * @param data contains the texture data
  63439. * @param texture defines the BabylonJS internal texture
  63440. * @param callback defines the method to call once ready to upload
  63441. */
  63442. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63443. }
  63444. }
  63445. declare module "babylonjs/Misc/basis" {
  63446. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63447. /**
  63448. * Info about the .basis files
  63449. */
  63450. class BasisFileInfo {
  63451. /**
  63452. * If the file has alpha
  63453. */
  63454. hasAlpha: boolean;
  63455. /**
  63456. * Info about each image of the basis file
  63457. */
  63458. images: Array<{
  63459. levels: Array<{
  63460. width: number;
  63461. height: number;
  63462. transcodedPixels: ArrayBufferView;
  63463. }>;
  63464. }>;
  63465. }
  63466. /**
  63467. * Result of transcoding a basis file
  63468. */
  63469. class TranscodeResult {
  63470. /**
  63471. * Info about the .basis file
  63472. */
  63473. fileInfo: BasisFileInfo;
  63474. /**
  63475. * Format to use when loading the file
  63476. */
  63477. format: number;
  63478. }
  63479. /**
  63480. * Configuration options for the Basis transcoder
  63481. */
  63482. export class BasisTranscodeConfiguration {
  63483. /**
  63484. * Supported compression formats used to determine the supported output format of the transcoder
  63485. */
  63486. supportedCompressionFormats?: {
  63487. /**
  63488. * etc1 compression format
  63489. */
  63490. etc1?: boolean;
  63491. /**
  63492. * s3tc compression format
  63493. */
  63494. s3tc?: boolean;
  63495. /**
  63496. * pvrtc compression format
  63497. */
  63498. pvrtc?: boolean;
  63499. /**
  63500. * etc2 compression format
  63501. */
  63502. etc2?: boolean;
  63503. };
  63504. /**
  63505. * If mipmap levels should be loaded for transcoded images (Default: true)
  63506. */
  63507. loadMipmapLevels?: boolean;
  63508. /**
  63509. * Index of a single image to load (Default: all images)
  63510. */
  63511. loadSingleImage?: number;
  63512. }
  63513. /**
  63514. * Used to load .Basis files
  63515. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  63516. */
  63517. export class BasisTools {
  63518. private static _IgnoreSupportedFormats;
  63519. /**
  63520. * URL to use when loading the basis transcoder
  63521. */
  63522. static JSModuleURL: string;
  63523. /**
  63524. * URL to use when loading the wasm module for the transcoder
  63525. */
  63526. static WasmModuleURL: string;
  63527. /**
  63528. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  63529. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  63530. * @returns internal format corresponding to the Basis format
  63531. */
  63532. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  63533. private static _WorkerPromise;
  63534. private static _Worker;
  63535. private static _actionId;
  63536. private static _CreateWorkerAsync;
  63537. /**
  63538. * Transcodes a loaded image file to compressed pixel data
  63539. * @param data image data to transcode
  63540. * @param config configuration options for the transcoding
  63541. * @returns a promise resulting in the transcoded image
  63542. */
  63543. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  63544. /**
  63545. * Loads a texture from the transcode result
  63546. * @param texture texture load to
  63547. * @param transcodeResult the result of transcoding the basis file to load from
  63548. */
  63549. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  63550. }
  63551. }
  63552. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  63553. import { Nullable } from "babylonjs/types";
  63554. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63555. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  63556. /**
  63557. * Loader for .basis file format
  63558. */
  63559. export class _BasisTextureLoader implements IInternalTextureLoader {
  63560. /**
  63561. * Defines whether the loader supports cascade loading the different faces.
  63562. */
  63563. readonly supportCascades: boolean;
  63564. /**
  63565. * This returns if the loader support the current file information.
  63566. * @param extension defines the file extension of the file being loaded
  63567. * @returns true if the loader can load the specified file
  63568. */
  63569. canLoad(extension: string): boolean;
  63570. /**
  63571. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63572. * @param data contains the texture data
  63573. * @param texture defines the BabylonJS internal texture
  63574. * @param createPolynomials will be true if polynomials have been requested
  63575. * @param onLoad defines the callback to trigger once the texture is ready
  63576. * @param onError defines the callback to trigger in case of error
  63577. */
  63578. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63579. /**
  63580. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63581. * @param data contains the texture data
  63582. * @param texture defines the BabylonJS internal texture
  63583. * @param callback defines the method to call once ready to upload
  63584. */
  63585. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63586. }
  63587. }
  63588. declare module "babylonjs/Materials/Textures/Loaders/index" {
  63589. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  63590. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  63591. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  63592. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  63593. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  63594. }
  63595. declare module "babylonjs/Materials/Textures/Packer/frame" {
  63596. import { Vector2 } from "babylonjs/Maths/math.vector";
  63597. /**
  63598. * Defines the basic options interface of a TexturePacker Frame
  63599. */
  63600. export interface ITexturePackerFrame {
  63601. /**
  63602. * The frame ID
  63603. */
  63604. id: number;
  63605. /**
  63606. * The frames Scale
  63607. */
  63608. scale: Vector2;
  63609. /**
  63610. * The Frames offset
  63611. */
  63612. offset: Vector2;
  63613. }
  63614. /**
  63615. * This is a support class for frame Data on texture packer sets.
  63616. */
  63617. export class TexturePackerFrame implements ITexturePackerFrame {
  63618. /**
  63619. * The frame ID
  63620. */
  63621. id: number;
  63622. /**
  63623. * The frames Scale
  63624. */
  63625. scale: Vector2;
  63626. /**
  63627. * The Frames offset
  63628. */
  63629. offset: Vector2;
  63630. /**
  63631. * Initializes a texture package frame.
  63632. * @param id The numerical frame identifier
  63633. * @param scale Scalar Vector2 for UV frame
  63634. * @param offset Vector2 for the frame position in UV units.
  63635. * @returns TexturePackerFrame
  63636. */
  63637. constructor(id: number, scale: Vector2, offset: Vector2);
  63638. }
  63639. }
  63640. declare module "babylonjs/Materials/Textures/Packer/packer" {
  63641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63642. import { Scene } from "babylonjs/scene";
  63643. import { Nullable } from "babylonjs/types";
  63644. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  63645. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  63646. /**
  63647. * Defines the basic options interface of a TexturePacker
  63648. */
  63649. export interface ITexturePackerOptions {
  63650. /**
  63651. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  63652. */
  63653. map?: string[];
  63654. /**
  63655. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63656. */
  63657. uvsIn?: string;
  63658. /**
  63659. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63660. */
  63661. uvsOut?: string;
  63662. /**
  63663. * number representing the layout style. Defaults to LAYOUT_STRIP
  63664. */
  63665. layout?: number;
  63666. /**
  63667. * number of columns if using custom column count layout(2). This defaults to 4.
  63668. */
  63669. colnum?: number;
  63670. /**
  63671. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63672. */
  63673. updateInputMeshes?: boolean;
  63674. /**
  63675. * boolean flag to dispose all the source textures. Defaults to true.
  63676. */
  63677. disposeSources?: boolean;
  63678. /**
  63679. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63680. */
  63681. fillBlanks?: boolean;
  63682. /**
  63683. * string value representing the context fill style color. Defaults to 'black'.
  63684. */
  63685. customFillColor?: string;
  63686. /**
  63687. * Width and Height Value of each Frame in the TexturePacker Sets
  63688. */
  63689. frameSize?: number;
  63690. /**
  63691. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63692. */
  63693. paddingRatio?: number;
  63694. /**
  63695. * Number that declares the fill method for the padding gutter.
  63696. */
  63697. paddingMode?: number;
  63698. /**
  63699. * If in SUBUV_COLOR padding mode what color to use.
  63700. */
  63701. paddingColor?: Color3 | Color4;
  63702. }
  63703. /**
  63704. * Defines the basic interface of a TexturePacker JSON File
  63705. */
  63706. export interface ITexturePackerJSON {
  63707. /**
  63708. * The frame ID
  63709. */
  63710. name: string;
  63711. /**
  63712. * The base64 channel data
  63713. */
  63714. sets: any;
  63715. /**
  63716. * The options of the Packer
  63717. */
  63718. options: ITexturePackerOptions;
  63719. /**
  63720. * The frame data of the Packer
  63721. */
  63722. frames: Array<number>;
  63723. }
  63724. /**
  63725. * This is a support class that generates a series of packed texture sets.
  63726. * @see https://doc.babylonjs.com/babylon101/materials
  63727. */
  63728. export class TexturePacker {
  63729. /** Packer Layout Constant 0 */
  63730. static readonly LAYOUT_STRIP: number;
  63731. /** Packer Layout Constant 1 */
  63732. static readonly LAYOUT_POWER2: number;
  63733. /** Packer Layout Constant 2 */
  63734. static readonly LAYOUT_COLNUM: number;
  63735. /** Packer Layout Constant 0 */
  63736. static readonly SUBUV_WRAP: number;
  63737. /** Packer Layout Constant 1 */
  63738. static readonly SUBUV_EXTEND: number;
  63739. /** Packer Layout Constant 2 */
  63740. static readonly SUBUV_COLOR: number;
  63741. /** The Name of the Texture Package */
  63742. name: string;
  63743. /** The scene scope of the TexturePacker */
  63744. scene: Scene;
  63745. /** The Meshes to target */
  63746. meshes: AbstractMesh[];
  63747. /** Arguments passed with the Constructor */
  63748. options: ITexturePackerOptions;
  63749. /** The promise that is started upon initialization */
  63750. promise: Nullable<Promise<TexturePacker | string>>;
  63751. /** The Container object for the channel sets that are generated */
  63752. sets: object;
  63753. /** The Container array for the frames that are generated */
  63754. frames: TexturePackerFrame[];
  63755. /** The expected number of textures the system is parsing. */
  63756. private _expecting;
  63757. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63758. private _paddingValue;
  63759. /**
  63760. * Initializes a texture package series from an array of meshes or a single mesh.
  63761. * @param name The name of the package
  63762. * @param meshes The target meshes to compose the package from
  63763. * @param options The arguments that texture packer should follow while building.
  63764. * @param scene The scene which the textures are scoped to.
  63765. * @returns TexturePacker
  63766. */
  63767. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63768. /**
  63769. * Starts the package process
  63770. * @param resolve The promises resolution function
  63771. * @returns TexturePacker
  63772. */
  63773. private _createFrames;
  63774. /**
  63775. * Calculates the Size of the Channel Sets
  63776. * @returns Vector2
  63777. */
  63778. private _calculateSize;
  63779. /**
  63780. * Calculates the UV data for the frames.
  63781. * @param baseSize the base frameSize
  63782. * @param padding the base frame padding
  63783. * @param dtSize size of the Dynamic Texture for that channel
  63784. * @param dtUnits is 1/dtSize
  63785. * @param update flag to update the input meshes
  63786. */
  63787. private _calculateMeshUVFrames;
  63788. /**
  63789. * Calculates the frames Offset.
  63790. * @param index of the frame
  63791. * @returns Vector2
  63792. */
  63793. private _getFrameOffset;
  63794. /**
  63795. * Updates a Mesh to the frame data
  63796. * @param mesh that is the target
  63797. * @param frameID or the frame index
  63798. */
  63799. private _updateMeshUV;
  63800. /**
  63801. * Updates a Meshes materials to use the texture packer channels
  63802. * @param m is the mesh to target
  63803. * @param force all channels on the packer to be set.
  63804. */
  63805. private _updateTextureReferences;
  63806. /**
  63807. * Public method to set a Mesh to a frame
  63808. * @param m that is the target
  63809. * @param frameID or the frame index
  63810. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63811. */
  63812. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63813. /**
  63814. * Starts the async promise to compile the texture packer.
  63815. * @returns Promise<void>
  63816. */
  63817. processAsync(): Promise<void>;
  63818. /**
  63819. * Disposes all textures associated with this packer
  63820. */
  63821. dispose(): void;
  63822. /**
  63823. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63824. * @param imageType is the image type to use.
  63825. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63826. */
  63827. download(imageType?: string, quality?: number): void;
  63828. /**
  63829. * Public method to load a texturePacker JSON file.
  63830. * @param data of the JSON file in string format.
  63831. */
  63832. updateFromJSON(data: string): void;
  63833. }
  63834. }
  63835. declare module "babylonjs/Materials/Textures/Packer/index" {
  63836. export * from "babylonjs/Materials/Textures/Packer/packer";
  63837. export * from "babylonjs/Materials/Textures/Packer/frame";
  63838. }
  63839. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  63840. import { Scene } from "babylonjs/scene";
  63841. import { Texture } from "babylonjs/Materials/Textures/texture";
  63842. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63843. /**
  63844. * 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.
  63845. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63846. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63847. */
  63848. export class CustomProceduralTexture extends ProceduralTexture {
  63849. private _animate;
  63850. private _time;
  63851. private _config;
  63852. private _texturePath;
  63853. /**
  63854. * Instantiates a new Custom Procedural Texture.
  63855. * 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.
  63856. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63857. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63858. * @param name Define the name of the texture
  63859. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63860. * @param size Define the size of the texture to create
  63861. * @param scene Define the scene the texture belongs to
  63862. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63863. * @param generateMipMaps Define if the texture should creates mip maps or not
  63864. */
  63865. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63866. private _loadJson;
  63867. /**
  63868. * Is the texture ready to be used ? (rendered at least once)
  63869. * @returns true if ready, otherwise, false.
  63870. */
  63871. isReady(): boolean;
  63872. /**
  63873. * Render the texture to its associated render target.
  63874. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63875. */
  63876. render(useCameraPostProcess?: boolean): void;
  63877. /**
  63878. * Update the list of dependant textures samplers in the shader.
  63879. */
  63880. updateTextures(): void;
  63881. /**
  63882. * Update the uniform values of the procedural texture in the shader.
  63883. */
  63884. updateShaderUniforms(): void;
  63885. /**
  63886. * Define if the texture animates or not.
  63887. */
  63888. get animate(): boolean;
  63889. set animate(value: boolean);
  63890. }
  63891. }
  63892. declare module "babylonjs/Shaders/noise.fragment" {
  63893. /** @hidden */
  63894. export var noisePixelShader: {
  63895. name: string;
  63896. shader: string;
  63897. };
  63898. }
  63899. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  63900. import { Nullable } from "babylonjs/types";
  63901. import { Scene } from "babylonjs/scene";
  63902. import { Texture } from "babylonjs/Materials/Textures/texture";
  63903. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63904. import "babylonjs/Shaders/noise.fragment";
  63905. /**
  63906. * Class used to generate noise procedural textures
  63907. */
  63908. export class NoiseProceduralTexture extends ProceduralTexture {
  63909. private _time;
  63910. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63911. brightness: number;
  63912. /** Defines the number of octaves to process */
  63913. octaves: number;
  63914. /** Defines the level of persistence (0.8 by default) */
  63915. persistence: number;
  63916. /** Gets or sets animation speed factor (default is 1) */
  63917. animationSpeedFactor: number;
  63918. /**
  63919. * Creates a new NoiseProceduralTexture
  63920. * @param name defines the name fo the texture
  63921. * @param size defines the size of the texture (default is 256)
  63922. * @param scene defines the hosting scene
  63923. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63924. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63925. */
  63926. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63927. private _updateShaderUniforms;
  63928. protected _getDefines(): string;
  63929. /** Generate the current state of the procedural texture */
  63930. render(useCameraPostProcess?: boolean): void;
  63931. /**
  63932. * Serializes this noise procedural texture
  63933. * @returns a serialized noise procedural texture object
  63934. */
  63935. serialize(): any;
  63936. /**
  63937. * Clone the texture.
  63938. * @returns the cloned texture
  63939. */
  63940. clone(): NoiseProceduralTexture;
  63941. /**
  63942. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63943. * @param parsedTexture defines parsed texture data
  63944. * @param scene defines the current scene
  63945. * @param rootUrl defines the root URL containing noise procedural texture information
  63946. * @returns a parsed NoiseProceduralTexture
  63947. */
  63948. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63949. }
  63950. }
  63951. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  63952. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  63953. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  63954. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63955. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  63956. }
  63957. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  63958. import { Nullable } from "babylonjs/types";
  63959. import { Scene } from "babylonjs/scene";
  63960. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  63961. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63962. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  63963. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63964. /**
  63965. * Raw cube texture where the raw buffers are passed in
  63966. */
  63967. export class RawCubeTexture extends CubeTexture {
  63968. /**
  63969. * Creates a cube texture where the raw buffers are passed in.
  63970. * @param scene defines the scene the texture is attached to
  63971. * @param data defines the array of data to use to create each face
  63972. * @param size defines the size of the textures
  63973. * @param format defines the format of the data
  63974. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63975. * @param generateMipMaps defines if the engine should generate the mip levels
  63976. * @param invertY defines if data must be stored with Y axis inverted
  63977. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63978. * @param compression defines the compression used (null by default)
  63979. */
  63980. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63981. /**
  63982. * Updates the raw cube texture.
  63983. * @param data defines the data to store
  63984. * @param format defines the data format
  63985. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63986. * @param invertY defines if data must be stored with Y axis inverted
  63987. * @param compression defines the compression used (null by default)
  63988. * @param level defines which level of the texture to update
  63989. */
  63990. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63991. /**
  63992. * Updates a raw cube texture with RGBD encoded data.
  63993. * @param data defines the array of data [mipmap][face] to use to create each face
  63994. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63995. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63996. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63997. * @returns a promsie that resolves when the operation is complete
  63998. */
  63999. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  64000. /**
  64001. * Clones the raw cube texture.
  64002. * @return a new cube texture
  64003. */
  64004. clone(): CubeTexture;
  64005. /** @hidden */
  64006. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  64007. }
  64008. }
  64009. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  64010. import { Scene } from "babylonjs/scene";
  64011. import { Texture } from "babylonjs/Materials/Textures/texture";
  64012. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64013. /**
  64014. * Class used to store 2D array textures containing user data
  64015. */
  64016. export class RawTexture2DArray extends Texture {
  64017. /** Gets or sets the texture format to use */
  64018. format: number;
  64019. /**
  64020. * Create a new RawTexture2DArray
  64021. * @param data defines the data of the texture
  64022. * @param width defines the width of the texture
  64023. * @param height defines the height of the texture
  64024. * @param depth defines the number of layers of the texture
  64025. * @param format defines the texture format to use
  64026. * @param scene defines the hosting scene
  64027. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64028. * @param invertY defines if texture must be stored with Y axis inverted
  64029. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64030. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64031. */
  64032. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64033. /** Gets or sets the texture format to use */
  64034. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64035. /**
  64036. * Update the texture with new data
  64037. * @param data defines the data to store in the texture
  64038. */
  64039. update(data: ArrayBufferView): void;
  64040. }
  64041. }
  64042. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  64043. import { Scene } from "babylonjs/scene";
  64044. import { Texture } from "babylonjs/Materials/Textures/texture";
  64045. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64046. /**
  64047. * Class used to store 3D textures containing user data
  64048. */
  64049. export class RawTexture3D extends Texture {
  64050. /** Gets or sets the texture format to use */
  64051. format: number;
  64052. /**
  64053. * Create a new RawTexture3D
  64054. * @param data defines the data of the texture
  64055. * @param width defines the width of the texture
  64056. * @param height defines the height of the texture
  64057. * @param depth defines the depth of the texture
  64058. * @param format defines the texture format to use
  64059. * @param scene defines the hosting scene
  64060. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64061. * @param invertY defines if texture must be stored with Y axis inverted
  64062. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64063. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64064. */
  64065. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64066. /** Gets or sets the texture format to use */
  64067. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64068. /**
  64069. * Update the texture with new data
  64070. * @param data defines the data to store in the texture
  64071. */
  64072. update(data: ArrayBufferView): void;
  64073. }
  64074. }
  64075. declare module "babylonjs/Materials/Textures/refractionTexture" {
  64076. import { Scene } from "babylonjs/scene";
  64077. import { Plane } from "babylonjs/Maths/math.plane";
  64078. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64079. /**
  64080. * Creates a refraction texture used by refraction channel of the standard material.
  64081. * It is like a mirror but to see through a material.
  64082. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64083. */
  64084. export class RefractionTexture extends RenderTargetTexture {
  64085. /**
  64086. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  64087. * 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.
  64088. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64089. */
  64090. refractionPlane: Plane;
  64091. /**
  64092. * Define how deep under the surface we should see.
  64093. */
  64094. depth: number;
  64095. /**
  64096. * Creates a refraction texture used by refraction channel of the standard material.
  64097. * It is like a mirror but to see through a material.
  64098. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64099. * @param name Define the texture name
  64100. * @param size Define the size of the underlying texture
  64101. * @param scene Define the scene the refraction belongs to
  64102. * @param generateMipMaps Define if we need to generate mips level for the refraction
  64103. */
  64104. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  64105. /**
  64106. * Clone the refraction texture.
  64107. * @returns the cloned texture
  64108. */
  64109. clone(): RefractionTexture;
  64110. /**
  64111. * Serialize the texture to a JSON representation you could use in Parse later on
  64112. * @returns the serialized JSON representation
  64113. */
  64114. serialize(): any;
  64115. }
  64116. }
  64117. declare module "babylonjs/Materials/Textures/index" {
  64118. export * from "babylonjs/Materials/Textures/baseTexture";
  64119. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  64120. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  64121. export * from "babylonjs/Materials/Textures/cubeTexture";
  64122. export * from "babylonjs/Materials/Textures/dynamicTexture";
  64123. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64124. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  64125. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  64126. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  64127. export * from "babylonjs/Materials/Textures/internalTexture";
  64128. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  64129. export * from "babylonjs/Materials/Textures/Loaders/index";
  64130. export * from "babylonjs/Materials/Textures/mirrorTexture";
  64131. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  64132. export * from "babylonjs/Materials/Textures/Packer/index";
  64133. export * from "babylonjs/Materials/Textures/Procedurals/index";
  64134. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  64135. export * from "babylonjs/Materials/Textures/rawTexture";
  64136. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  64137. export * from "babylonjs/Materials/Textures/rawTexture3D";
  64138. export * from "babylonjs/Materials/Textures/refractionTexture";
  64139. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  64140. export * from "babylonjs/Materials/Textures/texture";
  64141. export * from "babylonjs/Materials/Textures/videoTexture";
  64142. }
  64143. declare module "babylonjs/Materials/Node/Enums/index" {
  64144. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  64145. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  64146. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  64147. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  64148. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  64149. }
  64150. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  64151. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64152. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64153. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64154. import { Mesh } from "babylonjs/Meshes/mesh";
  64155. import { Effect } from "babylonjs/Materials/effect";
  64156. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64157. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64158. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64159. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64160. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  64161. /**
  64162. * Block used to add support for vertex skinning (bones)
  64163. */
  64164. export class BonesBlock extends NodeMaterialBlock {
  64165. /**
  64166. * Creates a new BonesBlock
  64167. * @param name defines the block name
  64168. */
  64169. constructor(name: string);
  64170. /**
  64171. * Initialize the block and prepare the context for build
  64172. * @param state defines the state that will be used for the build
  64173. */
  64174. initialize(state: NodeMaterialBuildState): void;
  64175. /**
  64176. * Gets the current class name
  64177. * @returns the class name
  64178. */
  64179. getClassName(): string;
  64180. /**
  64181. * Gets the matrix indices input component
  64182. */
  64183. get matricesIndices(): NodeMaterialConnectionPoint;
  64184. /**
  64185. * Gets the matrix weights input component
  64186. */
  64187. get matricesWeights(): NodeMaterialConnectionPoint;
  64188. /**
  64189. * Gets the extra matrix indices input component
  64190. */
  64191. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  64192. /**
  64193. * Gets the extra matrix weights input component
  64194. */
  64195. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  64196. /**
  64197. * Gets the world input component
  64198. */
  64199. get world(): NodeMaterialConnectionPoint;
  64200. /**
  64201. * Gets the output component
  64202. */
  64203. get output(): NodeMaterialConnectionPoint;
  64204. autoConfigure(material: NodeMaterial): void;
  64205. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  64206. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64207. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64208. protected _buildBlock(state: NodeMaterialBuildState): this;
  64209. }
  64210. }
  64211. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  64212. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64213. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64214. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64215. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64216. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64217. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64218. /**
  64219. * Block used to add support for instances
  64220. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  64221. */
  64222. export class InstancesBlock extends NodeMaterialBlock {
  64223. /**
  64224. * Creates a new InstancesBlock
  64225. * @param name defines the block name
  64226. */
  64227. constructor(name: string);
  64228. /**
  64229. * Gets the current class name
  64230. * @returns the class name
  64231. */
  64232. getClassName(): string;
  64233. /**
  64234. * Gets the first world row input component
  64235. */
  64236. get world0(): NodeMaterialConnectionPoint;
  64237. /**
  64238. * Gets the second world row input component
  64239. */
  64240. get world1(): NodeMaterialConnectionPoint;
  64241. /**
  64242. * Gets the third world row input component
  64243. */
  64244. get world2(): NodeMaterialConnectionPoint;
  64245. /**
  64246. * Gets the forth world row input component
  64247. */
  64248. get world3(): NodeMaterialConnectionPoint;
  64249. /**
  64250. * Gets the world input component
  64251. */
  64252. get world(): NodeMaterialConnectionPoint;
  64253. /**
  64254. * Gets the output component
  64255. */
  64256. get output(): NodeMaterialConnectionPoint;
  64257. /**
  64258. * Gets the isntanceID component
  64259. */
  64260. get instanceID(): NodeMaterialConnectionPoint;
  64261. autoConfigure(material: NodeMaterial): void;
  64262. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  64263. protected _buildBlock(state: NodeMaterialBuildState): this;
  64264. }
  64265. }
  64266. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  64267. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64268. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64269. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64270. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64271. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64272. import { Effect } from "babylonjs/Materials/effect";
  64273. import { Mesh } from "babylonjs/Meshes/mesh";
  64274. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64275. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64276. /**
  64277. * Block used to add morph targets support to vertex shader
  64278. */
  64279. export class MorphTargetsBlock extends NodeMaterialBlock {
  64280. private _repeatableContentAnchor;
  64281. /**
  64282. * Create a new MorphTargetsBlock
  64283. * @param name defines the block name
  64284. */
  64285. constructor(name: string);
  64286. /**
  64287. * Gets the current class name
  64288. * @returns the class name
  64289. */
  64290. getClassName(): string;
  64291. /**
  64292. * Gets the position input component
  64293. */
  64294. get position(): NodeMaterialConnectionPoint;
  64295. /**
  64296. * Gets the normal input component
  64297. */
  64298. get normal(): NodeMaterialConnectionPoint;
  64299. /**
  64300. * Gets the tangent input component
  64301. */
  64302. get tangent(): NodeMaterialConnectionPoint;
  64303. /**
  64304. * Gets the tangent input component
  64305. */
  64306. get uv(): NodeMaterialConnectionPoint;
  64307. /**
  64308. * Gets the position output component
  64309. */
  64310. get positionOutput(): NodeMaterialConnectionPoint;
  64311. /**
  64312. * Gets the normal output component
  64313. */
  64314. get normalOutput(): NodeMaterialConnectionPoint;
  64315. /**
  64316. * Gets the tangent output component
  64317. */
  64318. get tangentOutput(): NodeMaterialConnectionPoint;
  64319. /**
  64320. * Gets the tangent output component
  64321. */
  64322. get uvOutput(): NodeMaterialConnectionPoint;
  64323. initialize(state: NodeMaterialBuildState): void;
  64324. autoConfigure(material: NodeMaterial): void;
  64325. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64326. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64327. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  64328. protected _buildBlock(state: NodeMaterialBuildState): this;
  64329. }
  64330. }
  64331. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  64332. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64333. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64334. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64335. import { Nullable } from "babylonjs/types";
  64336. import { Scene } from "babylonjs/scene";
  64337. import { Effect } from "babylonjs/Materials/effect";
  64338. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64339. import { Mesh } from "babylonjs/Meshes/mesh";
  64340. import { Light } from "babylonjs/Lights/light";
  64341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64342. /**
  64343. * Block used to get data information from a light
  64344. */
  64345. export class LightInformationBlock extends NodeMaterialBlock {
  64346. private _lightDataUniformName;
  64347. private _lightColorUniformName;
  64348. private _lightTypeDefineName;
  64349. /**
  64350. * Gets or sets the light associated with this block
  64351. */
  64352. light: Nullable<Light>;
  64353. /**
  64354. * Creates a new LightInformationBlock
  64355. * @param name defines the block name
  64356. */
  64357. constructor(name: string);
  64358. /**
  64359. * Gets the current class name
  64360. * @returns the class name
  64361. */
  64362. getClassName(): string;
  64363. /**
  64364. * Gets the world position input component
  64365. */
  64366. get worldPosition(): NodeMaterialConnectionPoint;
  64367. /**
  64368. * Gets the direction output component
  64369. */
  64370. get direction(): NodeMaterialConnectionPoint;
  64371. /**
  64372. * Gets the direction output component
  64373. */
  64374. get color(): NodeMaterialConnectionPoint;
  64375. /**
  64376. * Gets the direction output component
  64377. */
  64378. get intensity(): NodeMaterialConnectionPoint;
  64379. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64380. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64381. protected _buildBlock(state: NodeMaterialBuildState): this;
  64382. serialize(): any;
  64383. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64384. }
  64385. }
  64386. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  64387. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  64388. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  64389. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  64390. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  64391. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  64392. }
  64393. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  64394. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64395. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64396. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64397. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64398. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64399. import { Effect } from "babylonjs/Materials/effect";
  64400. import { Mesh } from "babylonjs/Meshes/mesh";
  64401. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64402. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  64403. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  64404. /**
  64405. * Block used to add image processing support to fragment shader
  64406. */
  64407. export class ImageProcessingBlock extends NodeMaterialBlock {
  64408. /**
  64409. * Create a new ImageProcessingBlock
  64410. * @param name defines the block name
  64411. */
  64412. constructor(name: string);
  64413. /**
  64414. * Gets the current class name
  64415. * @returns the class name
  64416. */
  64417. getClassName(): string;
  64418. /**
  64419. * Gets the color input component
  64420. */
  64421. get color(): NodeMaterialConnectionPoint;
  64422. /**
  64423. * Gets the output component
  64424. */
  64425. get output(): NodeMaterialConnectionPoint;
  64426. /**
  64427. * Initialize the block and prepare the context for build
  64428. * @param state defines the state that will be used for the build
  64429. */
  64430. initialize(state: NodeMaterialBuildState): void;
  64431. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  64432. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64433. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64434. protected _buildBlock(state: NodeMaterialBuildState): this;
  64435. }
  64436. }
  64437. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  64438. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64439. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64440. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64441. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64442. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64443. import { Effect } from "babylonjs/Materials/effect";
  64444. import { Mesh } from "babylonjs/Meshes/mesh";
  64445. import { Scene } from "babylonjs/scene";
  64446. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  64447. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  64448. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  64449. /**
  64450. * Block used to pertub normals based on a normal map
  64451. */
  64452. export class PerturbNormalBlock extends NodeMaterialBlock {
  64453. private _tangentSpaceParameterName;
  64454. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64455. invertX: boolean;
  64456. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  64457. invertY: boolean;
  64458. /**
  64459. * Create a new PerturbNormalBlock
  64460. * @param name defines the block name
  64461. */
  64462. constructor(name: string);
  64463. /**
  64464. * Gets the current class name
  64465. * @returns the class name
  64466. */
  64467. getClassName(): string;
  64468. /**
  64469. * Gets the world position input component
  64470. */
  64471. get worldPosition(): NodeMaterialConnectionPoint;
  64472. /**
  64473. * Gets the world normal input component
  64474. */
  64475. get worldNormal(): NodeMaterialConnectionPoint;
  64476. /**
  64477. * Gets the world tangent input component
  64478. */
  64479. get worldTangent(): NodeMaterialConnectionPoint;
  64480. /**
  64481. * Gets the uv input component
  64482. */
  64483. get uv(): NodeMaterialConnectionPoint;
  64484. /**
  64485. * Gets the normal map color input component
  64486. */
  64487. get normalMapColor(): NodeMaterialConnectionPoint;
  64488. /**
  64489. * Gets the strength input component
  64490. */
  64491. get strength(): NodeMaterialConnectionPoint;
  64492. /**
  64493. * Gets the output component
  64494. */
  64495. get output(): NodeMaterialConnectionPoint;
  64496. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64497. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64498. autoConfigure(material: NodeMaterial): void;
  64499. protected _buildBlock(state: NodeMaterialBuildState): this;
  64500. protected _dumpPropertiesCode(): string;
  64501. serialize(): any;
  64502. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64503. }
  64504. }
  64505. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  64506. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64507. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64508. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64509. /**
  64510. * Block used to discard a pixel if a value is smaller than a cutoff
  64511. */
  64512. export class DiscardBlock extends NodeMaterialBlock {
  64513. /**
  64514. * Create a new DiscardBlock
  64515. * @param name defines the block name
  64516. */
  64517. constructor(name: string);
  64518. /**
  64519. * Gets the current class name
  64520. * @returns the class name
  64521. */
  64522. getClassName(): string;
  64523. /**
  64524. * Gets the color input component
  64525. */
  64526. get value(): NodeMaterialConnectionPoint;
  64527. /**
  64528. * Gets the cutoff input component
  64529. */
  64530. get cutoff(): NodeMaterialConnectionPoint;
  64531. protected _buildBlock(state: NodeMaterialBuildState): this;
  64532. }
  64533. }
  64534. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  64535. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64536. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64537. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64538. /**
  64539. * Block used to test if the fragment shader is front facing
  64540. */
  64541. export class FrontFacingBlock extends NodeMaterialBlock {
  64542. /**
  64543. * Creates a new FrontFacingBlock
  64544. * @param name defines the block name
  64545. */
  64546. constructor(name: string);
  64547. /**
  64548. * Gets the current class name
  64549. * @returns the class name
  64550. */
  64551. getClassName(): string;
  64552. /**
  64553. * Gets the output component
  64554. */
  64555. get output(): NodeMaterialConnectionPoint;
  64556. protected _buildBlock(state: NodeMaterialBuildState): this;
  64557. }
  64558. }
  64559. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  64560. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64561. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64562. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64563. /**
  64564. * Block used to get the derivative value on x and y of a given input
  64565. */
  64566. export class DerivativeBlock extends NodeMaterialBlock {
  64567. /**
  64568. * Create a new DerivativeBlock
  64569. * @param name defines the block name
  64570. */
  64571. constructor(name: string);
  64572. /**
  64573. * Gets the current class name
  64574. * @returns the class name
  64575. */
  64576. getClassName(): string;
  64577. /**
  64578. * Gets the input component
  64579. */
  64580. get input(): NodeMaterialConnectionPoint;
  64581. /**
  64582. * Gets the derivative output on x
  64583. */
  64584. get dx(): NodeMaterialConnectionPoint;
  64585. /**
  64586. * Gets the derivative output on y
  64587. */
  64588. get dy(): NodeMaterialConnectionPoint;
  64589. protected _buildBlock(state: NodeMaterialBuildState): this;
  64590. }
  64591. }
  64592. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  64593. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64594. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64595. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64596. /**
  64597. * Block used to make gl_FragCoord available
  64598. */
  64599. export class FragCoordBlock extends NodeMaterialBlock {
  64600. /**
  64601. * Creates a new FragCoordBlock
  64602. * @param name defines the block name
  64603. */
  64604. constructor(name: string);
  64605. /**
  64606. * Gets the current class name
  64607. * @returns the class name
  64608. */
  64609. getClassName(): string;
  64610. /**
  64611. * Gets the xy component
  64612. */
  64613. get xy(): NodeMaterialConnectionPoint;
  64614. /**
  64615. * Gets the xyz component
  64616. */
  64617. get xyz(): NodeMaterialConnectionPoint;
  64618. /**
  64619. * Gets the xyzw component
  64620. */
  64621. get xyzw(): NodeMaterialConnectionPoint;
  64622. /**
  64623. * Gets the x component
  64624. */
  64625. get x(): NodeMaterialConnectionPoint;
  64626. /**
  64627. * Gets the y component
  64628. */
  64629. get y(): NodeMaterialConnectionPoint;
  64630. /**
  64631. * Gets the z component
  64632. */
  64633. get z(): NodeMaterialConnectionPoint;
  64634. /**
  64635. * Gets the w component
  64636. */
  64637. get output(): NodeMaterialConnectionPoint;
  64638. protected writeOutputs(state: NodeMaterialBuildState): string;
  64639. protected _buildBlock(state: NodeMaterialBuildState): this;
  64640. }
  64641. }
  64642. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  64643. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64644. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64645. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64646. import { Effect } from "babylonjs/Materials/effect";
  64647. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64648. import { Mesh } from "babylonjs/Meshes/mesh";
  64649. /**
  64650. * Block used to get the screen sizes
  64651. */
  64652. export class ScreenSizeBlock extends NodeMaterialBlock {
  64653. private _varName;
  64654. private _scene;
  64655. /**
  64656. * Creates a new ScreenSizeBlock
  64657. * @param name defines the block name
  64658. */
  64659. constructor(name: string);
  64660. /**
  64661. * Gets the current class name
  64662. * @returns the class name
  64663. */
  64664. getClassName(): string;
  64665. /**
  64666. * Gets the xy component
  64667. */
  64668. get xy(): NodeMaterialConnectionPoint;
  64669. /**
  64670. * Gets the x component
  64671. */
  64672. get x(): NodeMaterialConnectionPoint;
  64673. /**
  64674. * Gets the y component
  64675. */
  64676. get y(): NodeMaterialConnectionPoint;
  64677. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64678. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  64679. protected _buildBlock(state: NodeMaterialBuildState): this;
  64680. }
  64681. }
  64682. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  64683. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  64684. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  64685. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  64686. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  64687. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  64688. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  64689. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  64690. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  64691. }
  64692. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  64693. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64694. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64695. import { Mesh } from "babylonjs/Meshes/mesh";
  64696. import { Effect } from "babylonjs/Materials/effect";
  64697. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64698. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64699. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64700. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  64701. /**
  64702. * Block used to add support for scene fog
  64703. */
  64704. export class FogBlock extends NodeMaterialBlock {
  64705. private _fogDistanceName;
  64706. private _fogParameters;
  64707. /**
  64708. * Create a new FogBlock
  64709. * @param name defines the block name
  64710. */
  64711. constructor(name: string);
  64712. /**
  64713. * Gets the current class name
  64714. * @returns the class name
  64715. */
  64716. getClassName(): string;
  64717. /**
  64718. * Gets the world position input component
  64719. */
  64720. get worldPosition(): NodeMaterialConnectionPoint;
  64721. /**
  64722. * Gets the view input component
  64723. */
  64724. get view(): NodeMaterialConnectionPoint;
  64725. /**
  64726. * Gets the color input component
  64727. */
  64728. get input(): NodeMaterialConnectionPoint;
  64729. /**
  64730. * Gets the fog color input component
  64731. */
  64732. get fogColor(): NodeMaterialConnectionPoint;
  64733. /**
  64734. * Gets the output component
  64735. */
  64736. get output(): NodeMaterialConnectionPoint;
  64737. autoConfigure(material: NodeMaterial): void;
  64738. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64739. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64740. protected _buildBlock(state: NodeMaterialBuildState): this;
  64741. }
  64742. }
  64743. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  64744. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64745. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64746. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64747. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64748. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64749. import { Effect } from "babylonjs/Materials/effect";
  64750. import { Mesh } from "babylonjs/Meshes/mesh";
  64751. import { Light } from "babylonjs/Lights/light";
  64752. import { Nullable } from "babylonjs/types";
  64753. import { Scene } from "babylonjs/scene";
  64754. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  64755. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  64756. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  64757. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64758. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  64759. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  64760. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  64761. /**
  64762. * Block used to add light in the fragment shader
  64763. */
  64764. export class LightBlock extends NodeMaterialBlock {
  64765. private _lightId;
  64766. /**
  64767. * Gets or sets the light associated with this block
  64768. */
  64769. light: Nullable<Light>;
  64770. /**
  64771. * Create a new LightBlock
  64772. * @param name defines the block name
  64773. */
  64774. constructor(name: string);
  64775. /**
  64776. * Gets the current class name
  64777. * @returns the class name
  64778. */
  64779. getClassName(): string;
  64780. /**
  64781. * Gets the world position input component
  64782. */
  64783. get worldPosition(): NodeMaterialConnectionPoint;
  64784. /**
  64785. * Gets the world normal input component
  64786. */
  64787. get worldNormal(): NodeMaterialConnectionPoint;
  64788. /**
  64789. * Gets the camera (or eye) position component
  64790. */
  64791. get cameraPosition(): NodeMaterialConnectionPoint;
  64792. /**
  64793. * Gets the glossiness component
  64794. */
  64795. get glossiness(): NodeMaterialConnectionPoint;
  64796. /**
  64797. * Gets the glossinness power component
  64798. */
  64799. get glossPower(): NodeMaterialConnectionPoint;
  64800. /**
  64801. * Gets the diffuse color component
  64802. */
  64803. get diffuseColor(): NodeMaterialConnectionPoint;
  64804. /**
  64805. * Gets the specular color component
  64806. */
  64807. get specularColor(): NodeMaterialConnectionPoint;
  64808. /**
  64809. * Gets the diffuse output component
  64810. */
  64811. get diffuseOutput(): NodeMaterialConnectionPoint;
  64812. /**
  64813. * Gets the specular output component
  64814. */
  64815. get specularOutput(): NodeMaterialConnectionPoint;
  64816. /**
  64817. * Gets the shadow output component
  64818. */
  64819. get shadow(): NodeMaterialConnectionPoint;
  64820. autoConfigure(material: NodeMaterial): void;
  64821. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64822. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64823. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64824. private _injectVertexCode;
  64825. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64826. serialize(): any;
  64827. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64828. }
  64829. }
  64830. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  64831. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64832. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64833. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64834. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  64835. /**
  64836. * Block used to read a reflection texture from a sampler
  64837. */
  64838. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64839. /**
  64840. * Create a new ReflectionTextureBlock
  64841. * @param name defines the block name
  64842. */
  64843. constructor(name: string);
  64844. /**
  64845. * Gets the current class name
  64846. * @returns the class name
  64847. */
  64848. getClassName(): string;
  64849. /**
  64850. * Gets the world position input component
  64851. */
  64852. get position(): NodeMaterialConnectionPoint;
  64853. /**
  64854. * Gets the world position input component
  64855. */
  64856. get worldPosition(): NodeMaterialConnectionPoint;
  64857. /**
  64858. * Gets the world normal input component
  64859. */
  64860. get worldNormal(): NodeMaterialConnectionPoint;
  64861. /**
  64862. * Gets the world input component
  64863. */
  64864. get world(): NodeMaterialConnectionPoint;
  64865. /**
  64866. * Gets the camera (or eye) position component
  64867. */
  64868. get cameraPosition(): NodeMaterialConnectionPoint;
  64869. /**
  64870. * Gets the view input component
  64871. */
  64872. get view(): NodeMaterialConnectionPoint;
  64873. /**
  64874. * Gets the rgb output component
  64875. */
  64876. get rgb(): NodeMaterialConnectionPoint;
  64877. /**
  64878. * Gets the rgba output component
  64879. */
  64880. get rgba(): NodeMaterialConnectionPoint;
  64881. /**
  64882. * Gets the r output component
  64883. */
  64884. get r(): NodeMaterialConnectionPoint;
  64885. /**
  64886. * Gets the g output component
  64887. */
  64888. get g(): NodeMaterialConnectionPoint;
  64889. /**
  64890. * Gets the b output component
  64891. */
  64892. get b(): NodeMaterialConnectionPoint;
  64893. /**
  64894. * Gets the a output component
  64895. */
  64896. get a(): NodeMaterialConnectionPoint;
  64897. autoConfigure(material: NodeMaterial): void;
  64898. protected _buildBlock(state: NodeMaterialBuildState): this;
  64899. }
  64900. }
  64901. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  64902. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  64903. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  64904. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  64905. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  64906. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  64907. }
  64908. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  64909. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  64910. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  64911. }
  64912. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  64913. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64914. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64915. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64916. /**
  64917. * Block used to add 2 vectors
  64918. */
  64919. export class AddBlock extends NodeMaterialBlock {
  64920. /**
  64921. * Creates a new AddBlock
  64922. * @param name defines the block name
  64923. */
  64924. constructor(name: string);
  64925. /**
  64926. * Gets the current class name
  64927. * @returns the class name
  64928. */
  64929. getClassName(): string;
  64930. /**
  64931. * Gets the left operand input component
  64932. */
  64933. get left(): NodeMaterialConnectionPoint;
  64934. /**
  64935. * Gets the right operand input component
  64936. */
  64937. get right(): NodeMaterialConnectionPoint;
  64938. /**
  64939. * Gets the output component
  64940. */
  64941. get output(): NodeMaterialConnectionPoint;
  64942. protected _buildBlock(state: NodeMaterialBuildState): this;
  64943. }
  64944. }
  64945. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  64946. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64947. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64948. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64949. /**
  64950. * Block used to scale a vector by a float
  64951. */
  64952. export class ScaleBlock extends NodeMaterialBlock {
  64953. /**
  64954. * Creates a new ScaleBlock
  64955. * @param name defines the block name
  64956. */
  64957. constructor(name: string);
  64958. /**
  64959. * Gets the current class name
  64960. * @returns the class name
  64961. */
  64962. getClassName(): string;
  64963. /**
  64964. * Gets the input component
  64965. */
  64966. get input(): NodeMaterialConnectionPoint;
  64967. /**
  64968. * Gets the factor input component
  64969. */
  64970. get factor(): NodeMaterialConnectionPoint;
  64971. /**
  64972. * Gets the output component
  64973. */
  64974. get output(): NodeMaterialConnectionPoint;
  64975. protected _buildBlock(state: NodeMaterialBuildState): this;
  64976. }
  64977. }
  64978. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  64979. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64980. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64981. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64982. import { Scene } from "babylonjs/scene";
  64983. /**
  64984. * Block used to clamp a float
  64985. */
  64986. export class ClampBlock extends NodeMaterialBlock {
  64987. /** Gets or sets the minimum range */
  64988. minimum: number;
  64989. /** Gets or sets the maximum range */
  64990. maximum: number;
  64991. /**
  64992. * Creates a new ClampBlock
  64993. * @param name defines the block name
  64994. */
  64995. constructor(name: string);
  64996. /**
  64997. * Gets the current class name
  64998. * @returns the class name
  64999. */
  65000. getClassName(): string;
  65001. /**
  65002. * Gets the value input component
  65003. */
  65004. get value(): NodeMaterialConnectionPoint;
  65005. /**
  65006. * Gets the output component
  65007. */
  65008. get output(): NodeMaterialConnectionPoint;
  65009. protected _buildBlock(state: NodeMaterialBuildState): this;
  65010. protected _dumpPropertiesCode(): string;
  65011. serialize(): any;
  65012. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65013. }
  65014. }
  65015. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  65016. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65017. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65018. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65019. /**
  65020. * Block used to apply a cross product between 2 vectors
  65021. */
  65022. export class CrossBlock extends NodeMaterialBlock {
  65023. /**
  65024. * Creates a new CrossBlock
  65025. * @param name defines the block name
  65026. */
  65027. constructor(name: string);
  65028. /**
  65029. * Gets the current class name
  65030. * @returns the class name
  65031. */
  65032. getClassName(): string;
  65033. /**
  65034. * Gets the left operand input component
  65035. */
  65036. get left(): NodeMaterialConnectionPoint;
  65037. /**
  65038. * Gets the right operand input component
  65039. */
  65040. get right(): NodeMaterialConnectionPoint;
  65041. /**
  65042. * Gets the output component
  65043. */
  65044. get output(): NodeMaterialConnectionPoint;
  65045. protected _buildBlock(state: NodeMaterialBuildState): this;
  65046. }
  65047. }
  65048. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  65049. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65050. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65051. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65052. /**
  65053. * Block used to apply a dot product between 2 vectors
  65054. */
  65055. export class DotBlock extends NodeMaterialBlock {
  65056. /**
  65057. * Creates a new DotBlock
  65058. * @param name defines the block name
  65059. */
  65060. constructor(name: string);
  65061. /**
  65062. * Gets the current class name
  65063. * @returns the class name
  65064. */
  65065. getClassName(): string;
  65066. /**
  65067. * Gets the left operand input component
  65068. */
  65069. get left(): NodeMaterialConnectionPoint;
  65070. /**
  65071. * Gets the right operand input component
  65072. */
  65073. get right(): NodeMaterialConnectionPoint;
  65074. /**
  65075. * Gets the output component
  65076. */
  65077. get output(): NodeMaterialConnectionPoint;
  65078. protected _buildBlock(state: NodeMaterialBuildState): this;
  65079. }
  65080. }
  65081. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  65082. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65083. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65084. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65085. /**
  65086. * Block used to normalize a vector
  65087. */
  65088. export class NormalizeBlock extends NodeMaterialBlock {
  65089. /**
  65090. * Creates a new NormalizeBlock
  65091. * @param name defines the block name
  65092. */
  65093. constructor(name: string);
  65094. /**
  65095. * Gets the current class name
  65096. * @returns the class name
  65097. */
  65098. getClassName(): string;
  65099. /**
  65100. * Gets the input component
  65101. */
  65102. get input(): NodeMaterialConnectionPoint;
  65103. /**
  65104. * Gets the output component
  65105. */
  65106. get output(): NodeMaterialConnectionPoint;
  65107. protected _buildBlock(state: NodeMaterialBuildState): this;
  65108. }
  65109. }
  65110. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  65111. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65112. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65113. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65114. import { Scene } from "babylonjs/scene";
  65115. /**
  65116. * Operations supported by the Trigonometry block
  65117. */
  65118. export enum TrigonometryBlockOperations {
  65119. /** Cos */
  65120. Cos = 0,
  65121. /** Sin */
  65122. Sin = 1,
  65123. /** Abs */
  65124. Abs = 2,
  65125. /** Exp */
  65126. Exp = 3,
  65127. /** Exp2 */
  65128. Exp2 = 4,
  65129. /** Round */
  65130. Round = 5,
  65131. /** Floor */
  65132. Floor = 6,
  65133. /** Ceiling */
  65134. Ceiling = 7,
  65135. /** Square root */
  65136. Sqrt = 8,
  65137. /** Log */
  65138. Log = 9,
  65139. /** Tangent */
  65140. Tan = 10,
  65141. /** Arc tangent */
  65142. ArcTan = 11,
  65143. /** Arc cosinus */
  65144. ArcCos = 12,
  65145. /** Arc sinus */
  65146. ArcSin = 13,
  65147. /** Fraction */
  65148. Fract = 14,
  65149. /** Sign */
  65150. Sign = 15,
  65151. /** To radians (from degrees) */
  65152. Radians = 16,
  65153. /** To degrees (from radians) */
  65154. Degrees = 17
  65155. }
  65156. /**
  65157. * Block used to apply trigonometry operation to floats
  65158. */
  65159. export class TrigonometryBlock extends NodeMaterialBlock {
  65160. /**
  65161. * Gets or sets the operation applied by the block
  65162. */
  65163. operation: TrigonometryBlockOperations;
  65164. /**
  65165. * Creates a new TrigonometryBlock
  65166. * @param name defines the block name
  65167. */
  65168. constructor(name: string);
  65169. /**
  65170. * Gets the current class name
  65171. * @returns the class name
  65172. */
  65173. getClassName(): string;
  65174. /**
  65175. * Gets the input component
  65176. */
  65177. get input(): NodeMaterialConnectionPoint;
  65178. /**
  65179. * Gets the output component
  65180. */
  65181. get output(): NodeMaterialConnectionPoint;
  65182. protected _buildBlock(state: NodeMaterialBuildState): this;
  65183. serialize(): any;
  65184. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65185. protected _dumpPropertiesCode(): string;
  65186. }
  65187. }
  65188. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  65189. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65190. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65191. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65192. /**
  65193. * Block used to create a Color3/4 out of individual inputs (one for each component)
  65194. */
  65195. export class ColorMergerBlock extends NodeMaterialBlock {
  65196. /**
  65197. * Create a new ColorMergerBlock
  65198. * @param name defines the block name
  65199. */
  65200. constructor(name: string);
  65201. /**
  65202. * Gets the current class name
  65203. * @returns the class name
  65204. */
  65205. getClassName(): string;
  65206. /**
  65207. * Gets the rgb component (input)
  65208. */
  65209. get rgbIn(): NodeMaterialConnectionPoint;
  65210. /**
  65211. * Gets the r component (input)
  65212. */
  65213. get r(): NodeMaterialConnectionPoint;
  65214. /**
  65215. * Gets the g component (input)
  65216. */
  65217. get g(): NodeMaterialConnectionPoint;
  65218. /**
  65219. * Gets the b component (input)
  65220. */
  65221. get b(): NodeMaterialConnectionPoint;
  65222. /**
  65223. * Gets the a component (input)
  65224. */
  65225. get a(): NodeMaterialConnectionPoint;
  65226. /**
  65227. * Gets the rgba component (output)
  65228. */
  65229. get rgba(): NodeMaterialConnectionPoint;
  65230. /**
  65231. * Gets the rgb component (output)
  65232. */
  65233. get rgbOut(): NodeMaterialConnectionPoint;
  65234. /**
  65235. * Gets the rgb component (output)
  65236. * @deprecated Please use rgbOut instead.
  65237. */
  65238. get rgb(): NodeMaterialConnectionPoint;
  65239. protected _buildBlock(state: NodeMaterialBuildState): this;
  65240. }
  65241. }
  65242. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  65243. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65244. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65245. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65246. /**
  65247. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  65248. */
  65249. export class VectorSplitterBlock extends NodeMaterialBlock {
  65250. /**
  65251. * Create a new VectorSplitterBlock
  65252. * @param name defines the block name
  65253. */
  65254. constructor(name: string);
  65255. /**
  65256. * Gets the current class name
  65257. * @returns the class name
  65258. */
  65259. getClassName(): string;
  65260. /**
  65261. * Gets the xyzw component (input)
  65262. */
  65263. get xyzw(): NodeMaterialConnectionPoint;
  65264. /**
  65265. * Gets the xyz component (input)
  65266. */
  65267. get xyzIn(): NodeMaterialConnectionPoint;
  65268. /**
  65269. * Gets the xy component (input)
  65270. */
  65271. get xyIn(): NodeMaterialConnectionPoint;
  65272. /**
  65273. * Gets the xyz component (output)
  65274. */
  65275. get xyzOut(): NodeMaterialConnectionPoint;
  65276. /**
  65277. * Gets the xy component (output)
  65278. */
  65279. get xyOut(): NodeMaterialConnectionPoint;
  65280. /**
  65281. * Gets the x component (output)
  65282. */
  65283. get x(): NodeMaterialConnectionPoint;
  65284. /**
  65285. * Gets the y component (output)
  65286. */
  65287. get y(): NodeMaterialConnectionPoint;
  65288. /**
  65289. * Gets the z component (output)
  65290. */
  65291. get z(): NodeMaterialConnectionPoint;
  65292. /**
  65293. * Gets the w component (output)
  65294. */
  65295. get w(): NodeMaterialConnectionPoint;
  65296. protected _inputRename(name: string): string;
  65297. protected _outputRename(name: string): string;
  65298. protected _buildBlock(state: NodeMaterialBuildState): this;
  65299. }
  65300. }
  65301. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  65302. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65303. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65304. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65305. /**
  65306. * Block used to lerp between 2 values
  65307. */
  65308. export class LerpBlock extends NodeMaterialBlock {
  65309. /**
  65310. * Creates a new LerpBlock
  65311. * @param name defines the block name
  65312. */
  65313. constructor(name: string);
  65314. /**
  65315. * Gets the current class name
  65316. * @returns the class name
  65317. */
  65318. getClassName(): string;
  65319. /**
  65320. * Gets the left operand input component
  65321. */
  65322. get left(): NodeMaterialConnectionPoint;
  65323. /**
  65324. * Gets the right operand input component
  65325. */
  65326. get right(): NodeMaterialConnectionPoint;
  65327. /**
  65328. * Gets the gradient operand input component
  65329. */
  65330. get gradient(): NodeMaterialConnectionPoint;
  65331. /**
  65332. * Gets the output component
  65333. */
  65334. get output(): NodeMaterialConnectionPoint;
  65335. protected _buildBlock(state: NodeMaterialBuildState): this;
  65336. }
  65337. }
  65338. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  65339. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65340. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65341. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65342. /**
  65343. * Block used to divide 2 vectors
  65344. */
  65345. export class DivideBlock extends NodeMaterialBlock {
  65346. /**
  65347. * Creates a new DivideBlock
  65348. * @param name defines the block name
  65349. */
  65350. constructor(name: string);
  65351. /**
  65352. * Gets the current class name
  65353. * @returns the class name
  65354. */
  65355. getClassName(): string;
  65356. /**
  65357. * Gets the left operand input component
  65358. */
  65359. get left(): NodeMaterialConnectionPoint;
  65360. /**
  65361. * Gets the right operand input component
  65362. */
  65363. get right(): NodeMaterialConnectionPoint;
  65364. /**
  65365. * Gets the output component
  65366. */
  65367. get output(): NodeMaterialConnectionPoint;
  65368. protected _buildBlock(state: NodeMaterialBuildState): this;
  65369. }
  65370. }
  65371. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  65372. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65373. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65374. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65375. /**
  65376. * Block used to subtract 2 vectors
  65377. */
  65378. export class SubtractBlock extends NodeMaterialBlock {
  65379. /**
  65380. * Creates a new SubtractBlock
  65381. * @param name defines the block name
  65382. */
  65383. constructor(name: string);
  65384. /**
  65385. * Gets the current class name
  65386. * @returns the class name
  65387. */
  65388. getClassName(): string;
  65389. /**
  65390. * Gets the left operand input component
  65391. */
  65392. get left(): NodeMaterialConnectionPoint;
  65393. /**
  65394. * Gets the right operand input component
  65395. */
  65396. get right(): NodeMaterialConnectionPoint;
  65397. /**
  65398. * Gets the output component
  65399. */
  65400. get output(): NodeMaterialConnectionPoint;
  65401. protected _buildBlock(state: NodeMaterialBuildState): this;
  65402. }
  65403. }
  65404. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  65405. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65406. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65407. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65408. /**
  65409. * Block used to step a value
  65410. */
  65411. export class StepBlock extends NodeMaterialBlock {
  65412. /**
  65413. * Creates a new StepBlock
  65414. * @param name defines the block name
  65415. */
  65416. constructor(name: string);
  65417. /**
  65418. * Gets the current class name
  65419. * @returns the class name
  65420. */
  65421. getClassName(): string;
  65422. /**
  65423. * Gets the value operand input component
  65424. */
  65425. get value(): NodeMaterialConnectionPoint;
  65426. /**
  65427. * Gets the edge operand input component
  65428. */
  65429. get edge(): NodeMaterialConnectionPoint;
  65430. /**
  65431. * Gets the output component
  65432. */
  65433. get output(): NodeMaterialConnectionPoint;
  65434. protected _buildBlock(state: NodeMaterialBuildState): this;
  65435. }
  65436. }
  65437. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  65438. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65439. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65440. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65441. /**
  65442. * Block used to get the opposite (1 - x) of a value
  65443. */
  65444. export class OneMinusBlock extends NodeMaterialBlock {
  65445. /**
  65446. * Creates a new OneMinusBlock
  65447. * @param name defines the block name
  65448. */
  65449. constructor(name: string);
  65450. /**
  65451. * Gets the current class name
  65452. * @returns the class name
  65453. */
  65454. getClassName(): string;
  65455. /**
  65456. * Gets the input component
  65457. */
  65458. get input(): NodeMaterialConnectionPoint;
  65459. /**
  65460. * Gets the output component
  65461. */
  65462. get output(): NodeMaterialConnectionPoint;
  65463. protected _buildBlock(state: NodeMaterialBuildState): this;
  65464. }
  65465. }
  65466. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  65467. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65468. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65469. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65470. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65471. /**
  65472. * Block used to get the view direction
  65473. */
  65474. export class ViewDirectionBlock extends NodeMaterialBlock {
  65475. /**
  65476. * Creates a new ViewDirectionBlock
  65477. * @param name defines the block name
  65478. */
  65479. constructor(name: string);
  65480. /**
  65481. * Gets the current class name
  65482. * @returns the class name
  65483. */
  65484. getClassName(): string;
  65485. /**
  65486. * Gets the world position component
  65487. */
  65488. get worldPosition(): NodeMaterialConnectionPoint;
  65489. /**
  65490. * Gets the camera position component
  65491. */
  65492. get cameraPosition(): NodeMaterialConnectionPoint;
  65493. /**
  65494. * Gets the output component
  65495. */
  65496. get output(): NodeMaterialConnectionPoint;
  65497. autoConfigure(material: NodeMaterial): void;
  65498. protected _buildBlock(state: NodeMaterialBuildState): this;
  65499. }
  65500. }
  65501. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  65502. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65503. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65504. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65505. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65506. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  65507. /**
  65508. * Block used to compute fresnel value
  65509. */
  65510. export class FresnelBlock extends NodeMaterialBlock {
  65511. /**
  65512. * Create a new FresnelBlock
  65513. * @param name defines the block name
  65514. */
  65515. constructor(name: string);
  65516. /**
  65517. * Gets the current class name
  65518. * @returns the class name
  65519. */
  65520. getClassName(): string;
  65521. /**
  65522. * Gets the world normal input component
  65523. */
  65524. get worldNormal(): NodeMaterialConnectionPoint;
  65525. /**
  65526. * Gets the view direction input component
  65527. */
  65528. get viewDirection(): NodeMaterialConnectionPoint;
  65529. /**
  65530. * Gets the bias input component
  65531. */
  65532. get bias(): NodeMaterialConnectionPoint;
  65533. /**
  65534. * Gets the camera (or eye) position component
  65535. */
  65536. get power(): NodeMaterialConnectionPoint;
  65537. /**
  65538. * Gets the fresnel output component
  65539. */
  65540. get fresnel(): NodeMaterialConnectionPoint;
  65541. autoConfigure(material: NodeMaterial): void;
  65542. protected _buildBlock(state: NodeMaterialBuildState): this;
  65543. }
  65544. }
  65545. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  65546. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65547. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65548. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65549. /**
  65550. * Block used to get the max of 2 values
  65551. */
  65552. export class MaxBlock extends NodeMaterialBlock {
  65553. /**
  65554. * Creates a new MaxBlock
  65555. * @param name defines the block name
  65556. */
  65557. constructor(name: string);
  65558. /**
  65559. * Gets the current class name
  65560. * @returns the class name
  65561. */
  65562. getClassName(): string;
  65563. /**
  65564. * Gets the left operand input component
  65565. */
  65566. get left(): NodeMaterialConnectionPoint;
  65567. /**
  65568. * Gets the right operand input component
  65569. */
  65570. get right(): NodeMaterialConnectionPoint;
  65571. /**
  65572. * Gets the output component
  65573. */
  65574. get output(): NodeMaterialConnectionPoint;
  65575. protected _buildBlock(state: NodeMaterialBuildState): this;
  65576. }
  65577. }
  65578. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  65579. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65580. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65581. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65582. /**
  65583. * Block used to get the min of 2 values
  65584. */
  65585. export class MinBlock extends NodeMaterialBlock {
  65586. /**
  65587. * Creates a new MinBlock
  65588. * @param name defines the block name
  65589. */
  65590. constructor(name: string);
  65591. /**
  65592. * Gets the current class name
  65593. * @returns the class name
  65594. */
  65595. getClassName(): string;
  65596. /**
  65597. * Gets the left operand input component
  65598. */
  65599. get left(): NodeMaterialConnectionPoint;
  65600. /**
  65601. * Gets the right operand input component
  65602. */
  65603. get right(): NodeMaterialConnectionPoint;
  65604. /**
  65605. * Gets the output component
  65606. */
  65607. get output(): NodeMaterialConnectionPoint;
  65608. protected _buildBlock(state: NodeMaterialBuildState): this;
  65609. }
  65610. }
  65611. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  65612. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65613. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65614. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65615. /**
  65616. * Block used to get the distance between 2 values
  65617. */
  65618. export class DistanceBlock extends NodeMaterialBlock {
  65619. /**
  65620. * Creates a new DistanceBlock
  65621. * @param name defines the block name
  65622. */
  65623. constructor(name: string);
  65624. /**
  65625. * Gets the current class name
  65626. * @returns the class name
  65627. */
  65628. getClassName(): string;
  65629. /**
  65630. * Gets the left operand input component
  65631. */
  65632. get left(): NodeMaterialConnectionPoint;
  65633. /**
  65634. * Gets the right operand input component
  65635. */
  65636. get right(): NodeMaterialConnectionPoint;
  65637. /**
  65638. * Gets the output component
  65639. */
  65640. get output(): NodeMaterialConnectionPoint;
  65641. protected _buildBlock(state: NodeMaterialBuildState): this;
  65642. }
  65643. }
  65644. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  65645. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65646. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65647. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65648. /**
  65649. * Block used to get the length of a vector
  65650. */
  65651. export class LengthBlock extends NodeMaterialBlock {
  65652. /**
  65653. * Creates a new LengthBlock
  65654. * @param name defines the block name
  65655. */
  65656. constructor(name: string);
  65657. /**
  65658. * Gets the current class name
  65659. * @returns the class name
  65660. */
  65661. getClassName(): string;
  65662. /**
  65663. * Gets the value input component
  65664. */
  65665. get value(): NodeMaterialConnectionPoint;
  65666. /**
  65667. * Gets the output component
  65668. */
  65669. get output(): NodeMaterialConnectionPoint;
  65670. protected _buildBlock(state: NodeMaterialBuildState): this;
  65671. }
  65672. }
  65673. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  65674. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65675. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65676. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65677. /**
  65678. * Block used to get negative version of a value (i.e. x * -1)
  65679. */
  65680. export class NegateBlock extends NodeMaterialBlock {
  65681. /**
  65682. * Creates a new NegateBlock
  65683. * @param name defines the block name
  65684. */
  65685. constructor(name: string);
  65686. /**
  65687. * Gets the current class name
  65688. * @returns the class name
  65689. */
  65690. getClassName(): string;
  65691. /**
  65692. * Gets the value input component
  65693. */
  65694. get value(): NodeMaterialConnectionPoint;
  65695. /**
  65696. * Gets the output component
  65697. */
  65698. get output(): NodeMaterialConnectionPoint;
  65699. protected _buildBlock(state: NodeMaterialBuildState): this;
  65700. }
  65701. }
  65702. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  65703. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65704. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65705. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65706. /**
  65707. * Block used to get the value of the first parameter raised to the power of the second
  65708. */
  65709. export class PowBlock extends NodeMaterialBlock {
  65710. /**
  65711. * Creates a new PowBlock
  65712. * @param name defines the block name
  65713. */
  65714. constructor(name: string);
  65715. /**
  65716. * Gets the current class name
  65717. * @returns the class name
  65718. */
  65719. getClassName(): string;
  65720. /**
  65721. * Gets the value operand input component
  65722. */
  65723. get value(): NodeMaterialConnectionPoint;
  65724. /**
  65725. * Gets the power operand input component
  65726. */
  65727. get power(): NodeMaterialConnectionPoint;
  65728. /**
  65729. * Gets the output component
  65730. */
  65731. get output(): NodeMaterialConnectionPoint;
  65732. protected _buildBlock(state: NodeMaterialBuildState): this;
  65733. }
  65734. }
  65735. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  65736. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65737. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65738. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65739. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65740. /**
  65741. * Block used to get a random number
  65742. */
  65743. export class RandomNumberBlock extends NodeMaterialBlock {
  65744. /**
  65745. * Creates a new RandomNumberBlock
  65746. * @param name defines the block name
  65747. */
  65748. constructor(name: string);
  65749. /**
  65750. * Gets the current class name
  65751. * @returns the class name
  65752. */
  65753. getClassName(): string;
  65754. /**
  65755. * Gets the seed input component
  65756. */
  65757. get seed(): NodeMaterialConnectionPoint;
  65758. /**
  65759. * Gets the output component
  65760. */
  65761. get output(): NodeMaterialConnectionPoint;
  65762. protected _buildBlock(state: NodeMaterialBuildState): this;
  65763. }
  65764. }
  65765. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  65766. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65767. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65768. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65769. /**
  65770. * Block used to compute arc tangent of 2 values
  65771. */
  65772. export class ArcTan2Block extends NodeMaterialBlock {
  65773. /**
  65774. * Creates a new ArcTan2Block
  65775. * @param name defines the block name
  65776. */
  65777. constructor(name: string);
  65778. /**
  65779. * Gets the current class name
  65780. * @returns the class name
  65781. */
  65782. getClassName(): string;
  65783. /**
  65784. * Gets the x operand input component
  65785. */
  65786. get x(): NodeMaterialConnectionPoint;
  65787. /**
  65788. * Gets the y operand input component
  65789. */
  65790. get y(): NodeMaterialConnectionPoint;
  65791. /**
  65792. * Gets the output component
  65793. */
  65794. get output(): NodeMaterialConnectionPoint;
  65795. protected _buildBlock(state: NodeMaterialBuildState): this;
  65796. }
  65797. }
  65798. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  65799. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65800. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65801. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65802. /**
  65803. * Block used to smooth step a value
  65804. */
  65805. export class SmoothStepBlock extends NodeMaterialBlock {
  65806. /**
  65807. * Creates a new SmoothStepBlock
  65808. * @param name defines the block name
  65809. */
  65810. constructor(name: string);
  65811. /**
  65812. * Gets the current class name
  65813. * @returns the class name
  65814. */
  65815. getClassName(): string;
  65816. /**
  65817. * Gets the value operand input component
  65818. */
  65819. get value(): NodeMaterialConnectionPoint;
  65820. /**
  65821. * Gets the first edge operand input component
  65822. */
  65823. get edge0(): NodeMaterialConnectionPoint;
  65824. /**
  65825. * Gets the second edge operand input component
  65826. */
  65827. get edge1(): NodeMaterialConnectionPoint;
  65828. /**
  65829. * Gets the output component
  65830. */
  65831. get output(): NodeMaterialConnectionPoint;
  65832. protected _buildBlock(state: NodeMaterialBuildState): this;
  65833. }
  65834. }
  65835. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  65836. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65837. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65838. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65839. /**
  65840. * Block used to get the reciprocal (1 / x) of a value
  65841. */
  65842. export class ReciprocalBlock extends NodeMaterialBlock {
  65843. /**
  65844. * Creates a new ReciprocalBlock
  65845. * @param name defines the block name
  65846. */
  65847. constructor(name: string);
  65848. /**
  65849. * Gets the current class name
  65850. * @returns the class name
  65851. */
  65852. getClassName(): string;
  65853. /**
  65854. * Gets the input component
  65855. */
  65856. get input(): NodeMaterialConnectionPoint;
  65857. /**
  65858. * Gets the output component
  65859. */
  65860. get output(): NodeMaterialConnectionPoint;
  65861. protected _buildBlock(state: NodeMaterialBuildState): this;
  65862. }
  65863. }
  65864. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  65865. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65866. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65867. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65868. /**
  65869. * Block used to replace a color by another one
  65870. */
  65871. export class ReplaceColorBlock extends NodeMaterialBlock {
  65872. /**
  65873. * Creates a new ReplaceColorBlock
  65874. * @param name defines the block name
  65875. */
  65876. constructor(name: string);
  65877. /**
  65878. * Gets the current class name
  65879. * @returns the class name
  65880. */
  65881. getClassName(): string;
  65882. /**
  65883. * Gets the value input component
  65884. */
  65885. get value(): NodeMaterialConnectionPoint;
  65886. /**
  65887. * Gets the reference input component
  65888. */
  65889. get reference(): NodeMaterialConnectionPoint;
  65890. /**
  65891. * Gets the distance input component
  65892. */
  65893. get distance(): NodeMaterialConnectionPoint;
  65894. /**
  65895. * Gets the replacement input component
  65896. */
  65897. get replacement(): NodeMaterialConnectionPoint;
  65898. /**
  65899. * Gets the output component
  65900. */
  65901. get output(): NodeMaterialConnectionPoint;
  65902. protected _buildBlock(state: NodeMaterialBuildState): this;
  65903. }
  65904. }
  65905. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  65906. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65907. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65908. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65909. /**
  65910. * Block used to posterize a value
  65911. * @see https://en.wikipedia.org/wiki/Posterization
  65912. */
  65913. export class PosterizeBlock extends NodeMaterialBlock {
  65914. /**
  65915. * Creates a new PosterizeBlock
  65916. * @param name defines the block name
  65917. */
  65918. constructor(name: string);
  65919. /**
  65920. * Gets the current class name
  65921. * @returns the class name
  65922. */
  65923. getClassName(): string;
  65924. /**
  65925. * Gets the value input component
  65926. */
  65927. get value(): NodeMaterialConnectionPoint;
  65928. /**
  65929. * Gets the steps input component
  65930. */
  65931. get steps(): NodeMaterialConnectionPoint;
  65932. /**
  65933. * Gets the output component
  65934. */
  65935. get output(): NodeMaterialConnectionPoint;
  65936. protected _buildBlock(state: NodeMaterialBuildState): this;
  65937. }
  65938. }
  65939. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  65940. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65941. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65942. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65943. import { Scene } from "babylonjs/scene";
  65944. /**
  65945. * Operations supported by the Wave block
  65946. */
  65947. export enum WaveBlockKind {
  65948. /** SawTooth */
  65949. SawTooth = 0,
  65950. /** Square */
  65951. Square = 1,
  65952. /** Triangle */
  65953. Triangle = 2
  65954. }
  65955. /**
  65956. * Block used to apply wave operation to floats
  65957. */
  65958. export class WaveBlock extends NodeMaterialBlock {
  65959. /**
  65960. * Gets or sets the kibnd of wave to be applied by the block
  65961. */
  65962. kind: WaveBlockKind;
  65963. /**
  65964. * Creates a new WaveBlock
  65965. * @param name defines the block name
  65966. */
  65967. constructor(name: string);
  65968. /**
  65969. * Gets the current class name
  65970. * @returns the class name
  65971. */
  65972. getClassName(): string;
  65973. /**
  65974. * Gets the input component
  65975. */
  65976. get input(): NodeMaterialConnectionPoint;
  65977. /**
  65978. * Gets the output component
  65979. */
  65980. get output(): NodeMaterialConnectionPoint;
  65981. protected _buildBlock(state: NodeMaterialBuildState): this;
  65982. serialize(): any;
  65983. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65984. }
  65985. }
  65986. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  65987. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65988. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65989. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65990. import { Color3 } from "babylonjs/Maths/math.color";
  65991. import { Scene } from "babylonjs/scene";
  65992. /**
  65993. * Class used to store a color step for the GradientBlock
  65994. */
  65995. export class GradientBlockColorStep {
  65996. /**
  65997. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  65998. */
  65999. step: number;
  66000. /**
  66001. * Gets or sets the color associated with this step
  66002. */
  66003. color: Color3;
  66004. /**
  66005. * Creates a new GradientBlockColorStep
  66006. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  66007. * @param color defines the color associated with this step
  66008. */
  66009. constructor(
  66010. /**
  66011. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66012. */
  66013. step: number,
  66014. /**
  66015. * Gets or sets the color associated with this step
  66016. */
  66017. color: Color3);
  66018. }
  66019. /**
  66020. * Block used to return a color from a gradient based on an input value between 0 and 1
  66021. */
  66022. export class GradientBlock extends NodeMaterialBlock {
  66023. /**
  66024. * Gets or sets the list of color steps
  66025. */
  66026. colorSteps: GradientBlockColorStep[];
  66027. /**
  66028. * Creates a new GradientBlock
  66029. * @param name defines the block name
  66030. */
  66031. constructor(name: string);
  66032. /**
  66033. * Gets the current class name
  66034. * @returns the class name
  66035. */
  66036. getClassName(): string;
  66037. /**
  66038. * Gets the gradient input component
  66039. */
  66040. get gradient(): NodeMaterialConnectionPoint;
  66041. /**
  66042. * Gets the output component
  66043. */
  66044. get output(): NodeMaterialConnectionPoint;
  66045. private _writeColorConstant;
  66046. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66047. serialize(): any;
  66048. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66049. protected _dumpPropertiesCode(): string;
  66050. }
  66051. }
  66052. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  66053. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66054. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66055. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66056. /**
  66057. * Block used to normalize lerp between 2 values
  66058. */
  66059. export class NLerpBlock extends NodeMaterialBlock {
  66060. /**
  66061. * Creates a new NLerpBlock
  66062. * @param name defines the block name
  66063. */
  66064. constructor(name: string);
  66065. /**
  66066. * Gets the current class name
  66067. * @returns the class name
  66068. */
  66069. getClassName(): string;
  66070. /**
  66071. * Gets the left operand input component
  66072. */
  66073. get left(): NodeMaterialConnectionPoint;
  66074. /**
  66075. * Gets the right operand input component
  66076. */
  66077. get right(): NodeMaterialConnectionPoint;
  66078. /**
  66079. * Gets the gradient operand input component
  66080. */
  66081. get gradient(): NodeMaterialConnectionPoint;
  66082. /**
  66083. * Gets the output component
  66084. */
  66085. get output(): NodeMaterialConnectionPoint;
  66086. protected _buildBlock(state: NodeMaterialBuildState): this;
  66087. }
  66088. }
  66089. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  66090. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66091. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66092. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66093. import { Scene } from "babylonjs/scene";
  66094. /**
  66095. * block used to Generate a Worley Noise 3D Noise Pattern
  66096. */
  66097. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  66098. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66099. manhattanDistance: boolean;
  66100. /**
  66101. * Creates a new WorleyNoise3DBlock
  66102. * @param name defines the block name
  66103. */
  66104. constructor(name: string);
  66105. /**
  66106. * Gets the current class name
  66107. * @returns the class name
  66108. */
  66109. getClassName(): string;
  66110. /**
  66111. * Gets the seed input component
  66112. */
  66113. get seed(): NodeMaterialConnectionPoint;
  66114. /**
  66115. * Gets the jitter input component
  66116. */
  66117. get jitter(): NodeMaterialConnectionPoint;
  66118. /**
  66119. * Gets the output component
  66120. */
  66121. get output(): NodeMaterialConnectionPoint;
  66122. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66123. /**
  66124. * Exposes the properties to the UI?
  66125. */
  66126. protected _dumpPropertiesCode(): string;
  66127. /**
  66128. * Exposes the properties to the Seralize?
  66129. */
  66130. serialize(): any;
  66131. /**
  66132. * Exposes the properties to the deseralize?
  66133. */
  66134. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66135. }
  66136. }
  66137. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  66138. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66139. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66140. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66141. /**
  66142. * block used to Generate a Simplex Perlin 3d Noise Pattern
  66143. */
  66144. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  66145. /**
  66146. * Creates a new SimplexPerlin3DBlock
  66147. * @param name defines the block name
  66148. */
  66149. constructor(name: string);
  66150. /**
  66151. * Gets the current class name
  66152. * @returns the class name
  66153. */
  66154. getClassName(): string;
  66155. /**
  66156. * Gets the seed operand input component
  66157. */
  66158. get seed(): NodeMaterialConnectionPoint;
  66159. /**
  66160. * Gets the output component
  66161. */
  66162. get output(): NodeMaterialConnectionPoint;
  66163. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66164. }
  66165. }
  66166. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  66167. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66168. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66169. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66170. /**
  66171. * Block used to blend normals
  66172. */
  66173. export class NormalBlendBlock extends NodeMaterialBlock {
  66174. /**
  66175. * Creates a new NormalBlendBlock
  66176. * @param name defines the block name
  66177. */
  66178. constructor(name: string);
  66179. /**
  66180. * Gets the current class name
  66181. * @returns the class name
  66182. */
  66183. getClassName(): string;
  66184. /**
  66185. * Gets the first input component
  66186. */
  66187. get normalMap0(): NodeMaterialConnectionPoint;
  66188. /**
  66189. * Gets the second input component
  66190. */
  66191. get normalMap1(): NodeMaterialConnectionPoint;
  66192. /**
  66193. * Gets the output component
  66194. */
  66195. get output(): NodeMaterialConnectionPoint;
  66196. protected _buildBlock(state: NodeMaterialBuildState): this;
  66197. }
  66198. }
  66199. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  66200. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66201. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66202. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66203. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66204. /**
  66205. * Block used to rotate a 2d vector by a given angle
  66206. */
  66207. export class Rotate2dBlock extends NodeMaterialBlock {
  66208. /**
  66209. * Creates a new Rotate2dBlock
  66210. * @param name defines the block name
  66211. */
  66212. constructor(name: string);
  66213. /**
  66214. * Gets the current class name
  66215. * @returns the class name
  66216. */
  66217. getClassName(): string;
  66218. /**
  66219. * Gets the input vector
  66220. */
  66221. get input(): NodeMaterialConnectionPoint;
  66222. /**
  66223. * Gets the input angle
  66224. */
  66225. get angle(): NodeMaterialConnectionPoint;
  66226. /**
  66227. * Gets the output component
  66228. */
  66229. get output(): NodeMaterialConnectionPoint;
  66230. autoConfigure(material: NodeMaterial): void;
  66231. protected _buildBlock(state: NodeMaterialBuildState): this;
  66232. }
  66233. }
  66234. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  66235. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66236. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66237. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66238. /**
  66239. * Block used to get the reflected vector from a direction and a normal
  66240. */
  66241. export class ReflectBlock extends NodeMaterialBlock {
  66242. /**
  66243. * Creates a new ReflectBlock
  66244. * @param name defines the block name
  66245. */
  66246. constructor(name: string);
  66247. /**
  66248. * Gets the current class name
  66249. * @returns the class name
  66250. */
  66251. getClassName(): string;
  66252. /**
  66253. * Gets the incident component
  66254. */
  66255. get incident(): NodeMaterialConnectionPoint;
  66256. /**
  66257. * Gets the normal component
  66258. */
  66259. get normal(): NodeMaterialConnectionPoint;
  66260. /**
  66261. * Gets the output component
  66262. */
  66263. get output(): NodeMaterialConnectionPoint;
  66264. protected _buildBlock(state: NodeMaterialBuildState): this;
  66265. }
  66266. }
  66267. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  66268. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66269. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66270. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66271. /**
  66272. * Block used to get the refracted vector from a direction and a normal
  66273. */
  66274. export class RefractBlock extends NodeMaterialBlock {
  66275. /**
  66276. * Creates a new RefractBlock
  66277. * @param name defines the block name
  66278. */
  66279. constructor(name: string);
  66280. /**
  66281. * Gets the current class name
  66282. * @returns the class name
  66283. */
  66284. getClassName(): string;
  66285. /**
  66286. * Gets the incident component
  66287. */
  66288. get incident(): NodeMaterialConnectionPoint;
  66289. /**
  66290. * Gets the normal component
  66291. */
  66292. get normal(): NodeMaterialConnectionPoint;
  66293. /**
  66294. * Gets the index of refraction component
  66295. */
  66296. get ior(): NodeMaterialConnectionPoint;
  66297. /**
  66298. * Gets the output component
  66299. */
  66300. get output(): NodeMaterialConnectionPoint;
  66301. protected _buildBlock(state: NodeMaterialBuildState): this;
  66302. }
  66303. }
  66304. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  66305. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66306. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66307. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66308. /**
  66309. * Block used to desaturate a color
  66310. */
  66311. export class DesaturateBlock extends NodeMaterialBlock {
  66312. /**
  66313. * Creates a new DesaturateBlock
  66314. * @param name defines the block name
  66315. */
  66316. constructor(name: string);
  66317. /**
  66318. * Gets the current class name
  66319. * @returns the class name
  66320. */
  66321. getClassName(): string;
  66322. /**
  66323. * Gets the color operand input component
  66324. */
  66325. get color(): NodeMaterialConnectionPoint;
  66326. /**
  66327. * Gets the level operand input component
  66328. */
  66329. get level(): NodeMaterialConnectionPoint;
  66330. /**
  66331. * Gets the output component
  66332. */
  66333. get output(): NodeMaterialConnectionPoint;
  66334. protected _buildBlock(state: NodeMaterialBuildState): this;
  66335. }
  66336. }
  66337. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  66338. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66339. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66340. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66341. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66342. import { Nullable } from "babylonjs/types";
  66343. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66344. import { Scene } from "babylonjs/scene";
  66345. /**
  66346. * Block used to implement the ambient occlusion module of the PBR material
  66347. */
  66348. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  66349. /**
  66350. * Create a new AmbientOcclusionBlock
  66351. * @param name defines the block name
  66352. */
  66353. constructor(name: string);
  66354. /**
  66355. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  66356. */
  66357. useAmbientInGrayScale: boolean;
  66358. /**
  66359. * Initialize the block and prepare the context for build
  66360. * @param state defines the state that will be used for the build
  66361. */
  66362. initialize(state: NodeMaterialBuildState): void;
  66363. /**
  66364. * Gets the current class name
  66365. * @returns the class name
  66366. */
  66367. getClassName(): string;
  66368. /**
  66369. * Gets the texture input component
  66370. */
  66371. get texture(): NodeMaterialConnectionPoint;
  66372. /**
  66373. * Gets the texture intensity component
  66374. */
  66375. get intensity(): NodeMaterialConnectionPoint;
  66376. /**
  66377. * Gets the direct light intensity input component
  66378. */
  66379. get directLightIntensity(): NodeMaterialConnectionPoint;
  66380. /**
  66381. * Gets the ambient occlusion object output component
  66382. */
  66383. get ambientOcclusion(): NodeMaterialConnectionPoint;
  66384. /**
  66385. * Gets the main code of the block (fragment side)
  66386. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  66387. * @returns the shader code
  66388. */
  66389. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  66390. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66391. protected _buildBlock(state: NodeMaterialBuildState): this;
  66392. protected _dumpPropertiesCode(): string;
  66393. serialize(): any;
  66394. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66395. }
  66396. }
  66397. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  66398. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66399. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66400. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66401. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66402. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66403. import { Nullable } from "babylonjs/types";
  66404. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66405. import { Mesh } from "babylonjs/Meshes/mesh";
  66406. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66407. import { Effect } from "babylonjs/Materials/effect";
  66408. import { Scene } from "babylonjs/scene";
  66409. /**
  66410. * Block used to implement the reflection module of the PBR material
  66411. */
  66412. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  66413. /** @hidden */
  66414. _defineLODReflectionAlpha: string;
  66415. /** @hidden */
  66416. _defineLinearSpecularReflection: string;
  66417. private _vEnvironmentIrradianceName;
  66418. /** @hidden */
  66419. _vReflectionMicrosurfaceInfosName: string;
  66420. /** @hidden */
  66421. _vReflectionInfosName: string;
  66422. /** @hidden */
  66423. _vReflectionFilteringInfoName: string;
  66424. private _scene;
  66425. /**
  66426. * The three properties below are set by the main PBR block prior to calling methods of this class.
  66427. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  66428. * It's less burden on the user side in the editor part.
  66429. */
  66430. /** @hidden */
  66431. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  66432. /** @hidden */
  66433. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  66434. /** @hidden */
  66435. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  66436. /**
  66437. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  66438. * diffuse part of the IBL.
  66439. */
  66440. useSphericalHarmonics: boolean;
  66441. /**
  66442. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  66443. */
  66444. forceIrradianceInFragment: boolean;
  66445. /**
  66446. * Create a new ReflectionBlock
  66447. * @param name defines the block name
  66448. */
  66449. constructor(name: string);
  66450. /**
  66451. * Gets the current class name
  66452. * @returns the class name
  66453. */
  66454. getClassName(): string;
  66455. /**
  66456. * Gets the position input component
  66457. */
  66458. get position(): NodeMaterialConnectionPoint;
  66459. /**
  66460. * Gets the world position input component
  66461. */
  66462. get worldPosition(): NodeMaterialConnectionPoint;
  66463. /**
  66464. * Gets the world normal input component
  66465. */
  66466. get worldNormal(): NodeMaterialConnectionPoint;
  66467. /**
  66468. * Gets the world input component
  66469. */
  66470. get world(): NodeMaterialConnectionPoint;
  66471. /**
  66472. * Gets the camera (or eye) position component
  66473. */
  66474. get cameraPosition(): NodeMaterialConnectionPoint;
  66475. /**
  66476. * Gets the view input component
  66477. */
  66478. get view(): NodeMaterialConnectionPoint;
  66479. /**
  66480. * Gets the color input component
  66481. */
  66482. get color(): NodeMaterialConnectionPoint;
  66483. /**
  66484. * Gets the reflection object output component
  66485. */
  66486. get reflection(): NodeMaterialConnectionPoint;
  66487. /**
  66488. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  66489. */
  66490. get hasTexture(): boolean;
  66491. /**
  66492. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  66493. */
  66494. get reflectionColor(): string;
  66495. protected _getTexture(): Nullable<BaseTexture>;
  66496. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66497. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66498. /**
  66499. * Gets the code to inject in the vertex shader
  66500. * @param state current state of the node material building
  66501. * @returns the shader code
  66502. */
  66503. handleVertexSide(state: NodeMaterialBuildState): string;
  66504. /**
  66505. * Gets the main code of the block (fragment side)
  66506. * @param state current state of the node material building
  66507. * @param normalVarName name of the existing variable corresponding to the normal
  66508. * @returns the shader code
  66509. */
  66510. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  66511. protected _buildBlock(state: NodeMaterialBuildState): this;
  66512. protected _dumpPropertiesCode(): string;
  66513. serialize(): any;
  66514. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66515. }
  66516. }
  66517. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  66518. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66519. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66520. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66521. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66522. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66523. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66524. import { Scene } from "babylonjs/scene";
  66525. import { Nullable } from "babylonjs/types";
  66526. /**
  66527. * Block used to implement the sheen module of the PBR material
  66528. */
  66529. export class SheenBlock extends NodeMaterialBlock {
  66530. /**
  66531. * Create a new SheenBlock
  66532. * @param name defines the block name
  66533. */
  66534. constructor(name: string);
  66535. /**
  66536. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  66537. * It allows the strength of the sheen effect to not depend on the base color of the material,
  66538. * making it easier to setup and tweak the effect
  66539. */
  66540. albedoScaling: boolean;
  66541. /**
  66542. * Defines if the sheen is linked to the sheen color.
  66543. */
  66544. linkSheenWithAlbedo: boolean;
  66545. /**
  66546. * Initialize the block and prepare the context for build
  66547. * @param state defines the state that will be used for the build
  66548. */
  66549. initialize(state: NodeMaterialBuildState): void;
  66550. /**
  66551. * Gets the current class name
  66552. * @returns the class name
  66553. */
  66554. getClassName(): string;
  66555. /**
  66556. * Gets the intensity input component
  66557. */
  66558. get intensity(): NodeMaterialConnectionPoint;
  66559. /**
  66560. * Gets the color input component
  66561. */
  66562. get color(): NodeMaterialConnectionPoint;
  66563. /**
  66564. * Gets the roughness input component
  66565. */
  66566. get roughness(): NodeMaterialConnectionPoint;
  66567. /**
  66568. * Gets the sheen object output component
  66569. */
  66570. get sheen(): NodeMaterialConnectionPoint;
  66571. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66572. /**
  66573. * Gets the main code of the block (fragment side)
  66574. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66575. * @returns the shader code
  66576. */
  66577. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  66578. protected _buildBlock(state: NodeMaterialBuildState): this;
  66579. protected _dumpPropertiesCode(): string;
  66580. serialize(): any;
  66581. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66582. }
  66583. }
  66584. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  66585. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66586. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66587. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66589. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66590. import { Scene } from "babylonjs/scene";
  66591. import { Nullable } from "babylonjs/types";
  66592. import { Mesh } from "babylonjs/Meshes/mesh";
  66593. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66594. import { Effect } from "babylonjs/Materials/effect";
  66595. /**
  66596. * Block used to implement the reflectivity module of the PBR material
  66597. */
  66598. export class ReflectivityBlock extends NodeMaterialBlock {
  66599. private _metallicReflectanceColor;
  66600. private _metallicF0Factor;
  66601. /** @hidden */
  66602. _vMetallicReflectanceFactorsName: string;
  66603. /**
  66604. * The property below is set by the main PBR block prior to calling methods of this class.
  66605. */
  66606. /** @hidden */
  66607. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  66608. /**
  66609. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  66610. */
  66611. useAmbientOcclusionFromMetallicTextureRed: boolean;
  66612. /**
  66613. * Specifies if the metallic texture contains the metallness information in its blue channel.
  66614. */
  66615. useMetallnessFromMetallicTextureBlue: boolean;
  66616. /**
  66617. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  66618. */
  66619. useRoughnessFromMetallicTextureAlpha: boolean;
  66620. /**
  66621. * Specifies if the metallic texture contains the roughness information in its green channel.
  66622. */
  66623. useRoughnessFromMetallicTextureGreen: boolean;
  66624. /**
  66625. * Create a new ReflectivityBlock
  66626. * @param name defines the block name
  66627. */
  66628. constructor(name: string);
  66629. /**
  66630. * Initialize the block and prepare the context for build
  66631. * @param state defines the state that will be used for the build
  66632. */
  66633. initialize(state: NodeMaterialBuildState): void;
  66634. /**
  66635. * Gets the current class name
  66636. * @returns the class name
  66637. */
  66638. getClassName(): string;
  66639. /**
  66640. * Gets the metallic input component
  66641. */
  66642. get metallic(): NodeMaterialConnectionPoint;
  66643. /**
  66644. * Gets the roughness input component
  66645. */
  66646. get roughness(): NodeMaterialConnectionPoint;
  66647. /**
  66648. * Gets the texture input component
  66649. */
  66650. get texture(): NodeMaterialConnectionPoint;
  66651. /**
  66652. * Gets the reflectivity object output component
  66653. */
  66654. get reflectivity(): NodeMaterialConnectionPoint;
  66655. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66656. /**
  66657. * Gets the main code of the block (fragment side)
  66658. * @param state current state of the node material building
  66659. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  66660. * @returns the shader code
  66661. */
  66662. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  66663. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66664. protected _buildBlock(state: NodeMaterialBuildState): this;
  66665. protected _dumpPropertiesCode(): string;
  66666. serialize(): any;
  66667. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66668. }
  66669. }
  66670. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  66671. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66672. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66673. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66674. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66675. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66676. /**
  66677. * Block used to implement the anisotropy module of the PBR material
  66678. */
  66679. export class AnisotropyBlock extends NodeMaterialBlock {
  66680. /**
  66681. * The two properties below are set by the main PBR block prior to calling methods of this class.
  66682. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  66683. * It's less burden on the user side in the editor part.
  66684. */
  66685. /** @hidden */
  66686. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  66687. /** @hidden */
  66688. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  66689. /**
  66690. * Create a new AnisotropyBlock
  66691. * @param name defines the block name
  66692. */
  66693. constructor(name: string);
  66694. /**
  66695. * Initialize the block and prepare the context for build
  66696. * @param state defines the state that will be used for the build
  66697. */
  66698. initialize(state: NodeMaterialBuildState): void;
  66699. /**
  66700. * Gets the current class name
  66701. * @returns the class name
  66702. */
  66703. getClassName(): string;
  66704. /**
  66705. * Gets the intensity input component
  66706. */
  66707. get intensity(): NodeMaterialConnectionPoint;
  66708. /**
  66709. * Gets the direction input component
  66710. */
  66711. get direction(): NodeMaterialConnectionPoint;
  66712. /**
  66713. * Gets the texture input component
  66714. */
  66715. get texture(): NodeMaterialConnectionPoint;
  66716. /**
  66717. * Gets the uv input component
  66718. */
  66719. get uv(): NodeMaterialConnectionPoint;
  66720. /**
  66721. * Gets the worldTangent input component
  66722. */
  66723. get worldTangent(): NodeMaterialConnectionPoint;
  66724. /**
  66725. * Gets the anisotropy object output component
  66726. */
  66727. get anisotropy(): NodeMaterialConnectionPoint;
  66728. private _generateTBNSpace;
  66729. /**
  66730. * Gets the main code of the block (fragment side)
  66731. * @param state current state of the node material building
  66732. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66733. * @returns the shader code
  66734. */
  66735. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  66736. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66737. protected _buildBlock(state: NodeMaterialBuildState): this;
  66738. }
  66739. }
  66740. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  66741. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66742. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66743. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66744. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66745. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66746. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66747. import { Nullable } from "babylonjs/types";
  66748. import { Mesh } from "babylonjs/Meshes/mesh";
  66749. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66750. import { Effect } from "babylonjs/Materials/effect";
  66751. /**
  66752. * Block used to implement the clear coat module of the PBR material
  66753. */
  66754. export class ClearCoatBlock extends NodeMaterialBlock {
  66755. private _scene;
  66756. /**
  66757. * Create a new ClearCoatBlock
  66758. * @param name defines the block name
  66759. */
  66760. constructor(name: string);
  66761. /**
  66762. * Initialize the block and prepare the context for build
  66763. * @param state defines the state that will be used for the build
  66764. */
  66765. initialize(state: NodeMaterialBuildState): void;
  66766. /**
  66767. * Gets the current class name
  66768. * @returns the class name
  66769. */
  66770. getClassName(): string;
  66771. /**
  66772. * Gets the intensity input component
  66773. */
  66774. get intensity(): NodeMaterialConnectionPoint;
  66775. /**
  66776. * Gets the roughness input component
  66777. */
  66778. get roughness(): NodeMaterialConnectionPoint;
  66779. /**
  66780. * Gets the ior input component
  66781. */
  66782. get ior(): NodeMaterialConnectionPoint;
  66783. /**
  66784. * Gets the texture input component
  66785. */
  66786. get texture(): NodeMaterialConnectionPoint;
  66787. /**
  66788. * Gets the bump texture input component
  66789. */
  66790. get bumpTexture(): NodeMaterialConnectionPoint;
  66791. /**
  66792. * Gets the uv input component
  66793. */
  66794. get uv(): NodeMaterialConnectionPoint;
  66795. /**
  66796. * Gets the tint color input component
  66797. */
  66798. get tintColor(): NodeMaterialConnectionPoint;
  66799. /**
  66800. * Gets the tint "at distance" input component
  66801. */
  66802. get tintAtDistance(): NodeMaterialConnectionPoint;
  66803. /**
  66804. * Gets the tint thickness input component
  66805. */
  66806. get tintThickness(): NodeMaterialConnectionPoint;
  66807. /**
  66808. * Gets the world tangent input component
  66809. */
  66810. get worldTangent(): NodeMaterialConnectionPoint;
  66811. /**
  66812. * Gets the clear coat object output component
  66813. */
  66814. get clearcoat(): NodeMaterialConnectionPoint;
  66815. autoConfigure(material: NodeMaterial): void;
  66816. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66817. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66818. private _generateTBNSpace;
  66819. /**
  66820. * Gets the main code of the block (fragment side)
  66821. * @param state current state of the node material building
  66822. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  66823. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66824. * @param worldPosVarName name of the variable holding the world position
  66825. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66826. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  66827. * @param worldNormalVarName name of the variable holding the world normal
  66828. * @returns the shader code
  66829. */
  66830. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  66831. protected _buildBlock(state: NodeMaterialBuildState): this;
  66832. }
  66833. }
  66834. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  66835. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66836. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66837. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66838. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66839. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66840. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66841. import { Nullable } from "babylonjs/types";
  66842. /**
  66843. * Block used to implement the sub surface module of the PBR material
  66844. */
  66845. export class SubSurfaceBlock extends NodeMaterialBlock {
  66846. /**
  66847. * Create a new SubSurfaceBlock
  66848. * @param name defines the block name
  66849. */
  66850. constructor(name: string);
  66851. /**
  66852. * Stores the intensity of the different subsurface effects in the thickness texture.
  66853. * * the green channel is the translucency intensity.
  66854. * * the blue channel is the scattering intensity.
  66855. * * the alpha channel is the refraction intensity.
  66856. */
  66857. useMaskFromThicknessTexture: boolean;
  66858. /**
  66859. * Initialize the block and prepare the context for build
  66860. * @param state defines the state that will be used for the build
  66861. */
  66862. initialize(state: NodeMaterialBuildState): void;
  66863. /**
  66864. * Gets the current class name
  66865. * @returns the class name
  66866. */
  66867. getClassName(): string;
  66868. /**
  66869. * Gets the min thickness input component
  66870. */
  66871. get minThickness(): NodeMaterialConnectionPoint;
  66872. /**
  66873. * Gets the max thickness input component
  66874. */
  66875. get maxThickness(): NodeMaterialConnectionPoint;
  66876. /**
  66877. * Gets the thickness texture component
  66878. */
  66879. get thicknessTexture(): NodeMaterialConnectionPoint;
  66880. /**
  66881. * Gets the tint color input component
  66882. */
  66883. get tintColor(): NodeMaterialConnectionPoint;
  66884. /**
  66885. * Gets the translucency intensity input component
  66886. */
  66887. get translucencyIntensity(): NodeMaterialConnectionPoint;
  66888. /**
  66889. * Gets the translucency diffusion distance input component
  66890. */
  66891. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  66892. /**
  66893. * Gets the refraction object parameters
  66894. */
  66895. get refraction(): NodeMaterialConnectionPoint;
  66896. /**
  66897. * Gets the sub surface object output component
  66898. */
  66899. get subsurface(): NodeMaterialConnectionPoint;
  66900. autoConfigure(material: NodeMaterial): void;
  66901. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66902. /**
  66903. * Gets the main code of the block (fragment side)
  66904. * @param state current state of the node material building
  66905. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  66906. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66907. * @param worldPosVarName name of the variable holding the world position
  66908. * @returns the shader code
  66909. */
  66910. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  66911. protected _buildBlock(state: NodeMaterialBuildState): this;
  66912. }
  66913. }
  66914. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  66915. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66916. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66917. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66918. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66919. import { Light } from "babylonjs/Lights/light";
  66920. import { Nullable } from "babylonjs/types";
  66921. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66922. import { Effect } from "babylonjs/Materials/effect";
  66923. import { Mesh } from "babylonjs/Meshes/mesh";
  66924. import { Scene } from "babylonjs/scene";
  66925. /**
  66926. * Block used to implement the PBR metallic/roughness model
  66927. */
  66928. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  66929. /**
  66930. * Gets or sets the light associated with this block
  66931. */
  66932. light: Nullable<Light>;
  66933. private _lightId;
  66934. private _scene;
  66935. private _environmentBRDFTexture;
  66936. private _environmentBrdfSamplerName;
  66937. private _vNormalWName;
  66938. private _invertNormalName;
  66939. /**
  66940. * Create a new ReflectionBlock
  66941. * @param name defines the block name
  66942. */
  66943. constructor(name: string);
  66944. /**
  66945. * Intensity of the direct lights e.g. the four lights available in your scene.
  66946. * This impacts both the direct diffuse and specular highlights.
  66947. */
  66948. directIntensity: number;
  66949. /**
  66950. * Intensity of the environment e.g. how much the environment will light the object
  66951. * either through harmonics for rough material or through the refelction for shiny ones.
  66952. */
  66953. environmentIntensity: number;
  66954. /**
  66955. * This is a special control allowing the reduction of the specular highlights coming from the
  66956. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  66957. */
  66958. specularIntensity: number;
  66959. /**
  66960. * Defines the falloff type used in this material.
  66961. * It by default is Physical.
  66962. */
  66963. lightFalloff: number;
  66964. /**
  66965. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  66966. */
  66967. useAlphaFromAlbedoTexture: boolean;
  66968. /**
  66969. * Specifies that alpha test should be used
  66970. */
  66971. useAlphaTest: boolean;
  66972. /**
  66973. * Defines the alpha limits in alpha test mode.
  66974. */
  66975. alphaTestCutoff: number;
  66976. /**
  66977. * Specifies that alpha blending should be used
  66978. */
  66979. useAlphaBlending: boolean;
  66980. /**
  66981. * Defines if the alpha value should be determined via the rgb values.
  66982. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  66983. */
  66984. opacityRGB: boolean;
  66985. /**
  66986. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  66987. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  66988. */
  66989. useRadianceOverAlpha: boolean;
  66990. /**
  66991. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  66992. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  66993. */
  66994. useSpecularOverAlpha: boolean;
  66995. /**
  66996. * Enables specular anti aliasing in the PBR shader.
  66997. * It will both interacts on the Geometry for analytical and IBL lighting.
  66998. * It also prefilter the roughness map based on the bump values.
  66999. */
  67000. enableSpecularAntiAliasing: boolean;
  67001. /**
  67002. * Enables realtime filtering on the texture.
  67003. */
  67004. realTimeFiltering: boolean;
  67005. /**
  67006. * Quality switch for realtime filtering
  67007. */
  67008. realTimeFilteringQuality: number;
  67009. /**
  67010. * Defines if the material uses energy conservation.
  67011. */
  67012. useEnergyConservation: boolean;
  67013. /**
  67014. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  67015. * too much the area relying on ambient texture to define their ambient occlusion.
  67016. */
  67017. useRadianceOcclusion: boolean;
  67018. /**
  67019. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  67020. * makes the reflect vector face the model (under horizon).
  67021. */
  67022. useHorizonOcclusion: boolean;
  67023. /**
  67024. * If set to true, no lighting calculations will be applied.
  67025. */
  67026. unlit: boolean;
  67027. /**
  67028. * Force normal to face away from face.
  67029. */
  67030. forceNormalForward: boolean;
  67031. /**
  67032. * Defines the material debug mode.
  67033. * It helps seeing only some components of the material while troubleshooting.
  67034. */
  67035. debugMode: number;
  67036. /**
  67037. * Specify from where on screen the debug mode should start.
  67038. * The value goes from -1 (full screen) to 1 (not visible)
  67039. * It helps with side by side comparison against the final render
  67040. * This defaults to 0
  67041. */
  67042. debugLimit: number;
  67043. /**
  67044. * As the default viewing range might not be enough (if the ambient is really small for instance)
  67045. * You can use the factor to better multiply the final value.
  67046. */
  67047. debugFactor: number;
  67048. /**
  67049. * Initialize the block and prepare the context for build
  67050. * @param state defines the state that will be used for the build
  67051. */
  67052. initialize(state: NodeMaterialBuildState): void;
  67053. /**
  67054. * Gets the current class name
  67055. * @returns the class name
  67056. */
  67057. getClassName(): string;
  67058. /**
  67059. * Gets the world position input component
  67060. */
  67061. get worldPosition(): NodeMaterialConnectionPoint;
  67062. /**
  67063. * Gets the world normal input component
  67064. */
  67065. get worldNormal(): NodeMaterialConnectionPoint;
  67066. /**
  67067. * Gets the perturbed normal input component
  67068. */
  67069. get perturbedNormal(): NodeMaterialConnectionPoint;
  67070. /**
  67071. * Gets the camera position input component
  67072. */
  67073. get cameraPosition(): NodeMaterialConnectionPoint;
  67074. /**
  67075. * Gets the base color input component
  67076. */
  67077. get baseColor(): NodeMaterialConnectionPoint;
  67078. /**
  67079. * Gets the opacity texture input component
  67080. */
  67081. get opacityTexture(): NodeMaterialConnectionPoint;
  67082. /**
  67083. * Gets the ambient color input component
  67084. */
  67085. get ambientColor(): NodeMaterialConnectionPoint;
  67086. /**
  67087. * Gets the reflectivity object parameters
  67088. */
  67089. get reflectivity(): NodeMaterialConnectionPoint;
  67090. /**
  67091. * Gets the ambient occlusion object parameters
  67092. */
  67093. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67094. /**
  67095. * Gets the reflection object parameters
  67096. */
  67097. get reflection(): NodeMaterialConnectionPoint;
  67098. /**
  67099. * Gets the sheen object parameters
  67100. */
  67101. get sheen(): NodeMaterialConnectionPoint;
  67102. /**
  67103. * Gets the clear coat object parameters
  67104. */
  67105. get clearcoat(): NodeMaterialConnectionPoint;
  67106. /**
  67107. * Gets the sub surface object parameters
  67108. */
  67109. get subsurface(): NodeMaterialConnectionPoint;
  67110. /**
  67111. * Gets the anisotropy object parameters
  67112. */
  67113. get anisotropy(): NodeMaterialConnectionPoint;
  67114. /**
  67115. * Gets the ambient output component
  67116. */
  67117. get ambient(): NodeMaterialConnectionPoint;
  67118. /**
  67119. * Gets the diffuse output component
  67120. */
  67121. get diffuse(): NodeMaterialConnectionPoint;
  67122. /**
  67123. * Gets the specular output component
  67124. */
  67125. get specular(): NodeMaterialConnectionPoint;
  67126. /**
  67127. * Gets the sheen output component
  67128. */
  67129. get sheenDir(): NodeMaterialConnectionPoint;
  67130. /**
  67131. * Gets the clear coat output component
  67132. */
  67133. get clearcoatDir(): NodeMaterialConnectionPoint;
  67134. /**
  67135. * Gets the indirect diffuse output component
  67136. */
  67137. get diffuseIndirect(): NodeMaterialConnectionPoint;
  67138. /**
  67139. * Gets the indirect specular output component
  67140. */
  67141. get specularIndirect(): NodeMaterialConnectionPoint;
  67142. /**
  67143. * Gets the indirect sheen output component
  67144. */
  67145. get sheenIndirect(): NodeMaterialConnectionPoint;
  67146. /**
  67147. * Gets the indirect clear coat output component
  67148. */
  67149. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  67150. /**
  67151. * Gets the refraction output component
  67152. */
  67153. get refraction(): NodeMaterialConnectionPoint;
  67154. /**
  67155. * Gets the global lighting output component
  67156. */
  67157. get lighting(): NodeMaterialConnectionPoint;
  67158. /**
  67159. * Gets the shadow output component
  67160. */
  67161. get shadow(): NodeMaterialConnectionPoint;
  67162. /**
  67163. * Gets the alpha output component
  67164. */
  67165. get alpha(): NodeMaterialConnectionPoint;
  67166. autoConfigure(material: NodeMaterial): void;
  67167. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67168. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67169. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67170. private _injectVertexCode;
  67171. /**
  67172. * Gets the code corresponding to the albedo/opacity module
  67173. * @returns the shader code
  67174. */
  67175. getAlbedoOpacityCode(): string;
  67176. protected _buildBlock(state: NodeMaterialBuildState): this;
  67177. protected _dumpPropertiesCode(): string;
  67178. serialize(): any;
  67179. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67180. }
  67181. }
  67182. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  67183. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  67184. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  67185. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  67186. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  67187. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  67188. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67189. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  67190. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  67191. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  67192. }
  67193. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  67194. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  67195. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  67196. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  67197. }
  67198. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  67199. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67200. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67201. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67202. /**
  67203. * Block used to compute value of one parameter modulo another
  67204. */
  67205. export class ModBlock extends NodeMaterialBlock {
  67206. /**
  67207. * Creates a new ModBlock
  67208. * @param name defines the block name
  67209. */
  67210. constructor(name: string);
  67211. /**
  67212. * Gets the current class name
  67213. * @returns the class name
  67214. */
  67215. getClassName(): string;
  67216. /**
  67217. * Gets the left operand input component
  67218. */
  67219. get left(): NodeMaterialConnectionPoint;
  67220. /**
  67221. * Gets the right operand input component
  67222. */
  67223. get right(): NodeMaterialConnectionPoint;
  67224. /**
  67225. * Gets the output component
  67226. */
  67227. get output(): NodeMaterialConnectionPoint;
  67228. protected _buildBlock(state: NodeMaterialBuildState): this;
  67229. }
  67230. }
  67231. declare module "babylonjs/Materials/Node/Blocks/index" {
  67232. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  67233. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  67234. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  67235. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  67236. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  67237. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  67238. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  67239. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  67240. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  67241. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  67242. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  67243. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  67244. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  67245. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  67246. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  67247. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  67248. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  67249. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  67250. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  67251. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  67252. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  67253. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  67254. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  67255. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  67256. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  67257. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  67258. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  67259. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  67260. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  67261. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  67262. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  67263. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  67264. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  67265. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  67266. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  67267. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  67268. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  67269. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  67270. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  67271. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  67272. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  67273. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  67274. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  67275. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  67276. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  67277. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  67278. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  67279. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  67280. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  67281. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  67282. }
  67283. declare module "babylonjs/Materials/Node/Optimizers/index" {
  67284. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  67285. }
  67286. declare module "babylonjs/Materials/Node/index" {
  67287. export * from "babylonjs/Materials/Node/Enums/index";
  67288. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67289. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  67290. export * from "babylonjs/Materials/Node/nodeMaterial";
  67291. export * from "babylonjs/Materials/Node/Blocks/index";
  67292. export * from "babylonjs/Materials/Node/Optimizers/index";
  67293. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  67294. }
  67295. declare module "babylonjs/Materials/index" {
  67296. export * from "babylonjs/Materials/Background/index";
  67297. export * from "babylonjs/Materials/colorCurves";
  67298. export * from "babylonjs/Materials/iEffectFallbacks";
  67299. export * from "babylonjs/Materials/effectFallbacks";
  67300. export * from "babylonjs/Materials/effect";
  67301. export * from "babylonjs/Materials/fresnelParameters";
  67302. export * from "babylonjs/Materials/imageProcessingConfiguration";
  67303. export * from "babylonjs/Materials/material";
  67304. export * from "babylonjs/Materials/materialDefines";
  67305. export * from "babylonjs/Materials/materialHelper";
  67306. export * from "babylonjs/Materials/multiMaterial";
  67307. export * from "babylonjs/Materials/PBR/index";
  67308. export * from "babylonjs/Materials/pushMaterial";
  67309. export * from "babylonjs/Materials/shaderMaterial";
  67310. export * from "babylonjs/Materials/standardMaterial";
  67311. export * from "babylonjs/Materials/Textures/index";
  67312. export * from "babylonjs/Materials/uniformBuffer";
  67313. export * from "babylonjs/Materials/materialFlags";
  67314. export * from "babylonjs/Materials/Node/index";
  67315. export * from "babylonjs/Materials/effectRenderer";
  67316. export * from "babylonjs/Materials/shadowDepthWrapper";
  67317. }
  67318. declare module "babylonjs/Maths/index" {
  67319. export * from "babylonjs/Maths/math.scalar";
  67320. export * from "babylonjs/Maths/math";
  67321. export * from "babylonjs/Maths/sphericalPolynomial";
  67322. }
  67323. declare module "babylonjs/Misc/workerPool" {
  67324. import { IDisposable } from "babylonjs/scene";
  67325. /**
  67326. * Helper class to push actions to a pool of workers.
  67327. */
  67328. export class WorkerPool implements IDisposable {
  67329. private _workerInfos;
  67330. private _pendingActions;
  67331. /**
  67332. * Constructor
  67333. * @param workers Array of workers to use for actions
  67334. */
  67335. constructor(workers: Array<Worker>);
  67336. /**
  67337. * Terminates all workers and clears any pending actions.
  67338. */
  67339. dispose(): void;
  67340. /**
  67341. * Pushes an action to the worker pool. If all the workers are active, the action will be
  67342. * pended until a worker has completed its action.
  67343. * @param action The action to perform. Call onComplete when the action is complete.
  67344. */
  67345. push(action: (worker: Worker, onComplete: () => void) => void): void;
  67346. private _execute;
  67347. }
  67348. }
  67349. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  67350. import { IDisposable } from "babylonjs/scene";
  67351. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  67352. /**
  67353. * Configuration for Draco compression
  67354. */
  67355. export interface IDracoCompressionConfiguration {
  67356. /**
  67357. * Configuration for the decoder.
  67358. */
  67359. decoder: {
  67360. /**
  67361. * The url to the WebAssembly module.
  67362. */
  67363. wasmUrl?: string;
  67364. /**
  67365. * The url to the WebAssembly binary.
  67366. */
  67367. wasmBinaryUrl?: string;
  67368. /**
  67369. * The url to the fallback JavaScript module.
  67370. */
  67371. fallbackUrl?: string;
  67372. };
  67373. }
  67374. /**
  67375. * Draco compression (https://google.github.io/draco/)
  67376. *
  67377. * This class wraps the Draco module.
  67378. *
  67379. * **Encoder**
  67380. *
  67381. * The encoder is not currently implemented.
  67382. *
  67383. * **Decoder**
  67384. *
  67385. * 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.
  67386. *
  67387. * To update the configuration, use the following code:
  67388. * ```javascript
  67389. * DracoCompression.Configuration = {
  67390. * decoder: {
  67391. * wasmUrl: "<url to the WebAssembly library>",
  67392. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  67393. * fallbackUrl: "<url to the fallback JavaScript library>",
  67394. * }
  67395. * };
  67396. * ```
  67397. *
  67398. * 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.
  67399. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  67400. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  67401. *
  67402. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  67403. * ```javascript
  67404. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  67405. * ```
  67406. *
  67407. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  67408. */
  67409. export class DracoCompression implements IDisposable {
  67410. private _workerPoolPromise?;
  67411. private _decoderModulePromise?;
  67412. /**
  67413. * The configuration. Defaults to the following urls:
  67414. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  67415. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  67416. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  67417. */
  67418. static Configuration: IDracoCompressionConfiguration;
  67419. /**
  67420. * Returns true if the decoder configuration is available.
  67421. */
  67422. static get DecoderAvailable(): boolean;
  67423. /**
  67424. * Default number of workers to create when creating the draco compression object.
  67425. */
  67426. static DefaultNumWorkers: number;
  67427. private static GetDefaultNumWorkers;
  67428. private static _Default;
  67429. /**
  67430. * Default instance for the draco compression object.
  67431. */
  67432. static get Default(): DracoCompression;
  67433. /**
  67434. * Constructor
  67435. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  67436. */
  67437. constructor(numWorkers?: number);
  67438. /**
  67439. * Stop all async operations and release resources.
  67440. */
  67441. dispose(): void;
  67442. /**
  67443. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  67444. * @returns a promise that resolves when ready
  67445. */
  67446. whenReadyAsync(): Promise<void>;
  67447. /**
  67448. * Decode Draco compressed mesh data to vertex data.
  67449. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  67450. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  67451. * @returns A promise that resolves with the decoded vertex data
  67452. */
  67453. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  67454. [kind: string]: number;
  67455. }): Promise<VertexData>;
  67456. }
  67457. }
  67458. declare module "babylonjs/Meshes/Compression/index" {
  67459. export * from "babylonjs/Meshes/Compression/dracoCompression";
  67460. }
  67461. declare module "babylonjs/Meshes/csg" {
  67462. import { Nullable } from "babylonjs/types";
  67463. import { Scene } from "babylonjs/scene";
  67464. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  67465. import { Mesh } from "babylonjs/Meshes/mesh";
  67466. import { Material } from "babylonjs/Materials/material";
  67467. /**
  67468. * Class for building Constructive Solid Geometry
  67469. */
  67470. export class CSG {
  67471. private polygons;
  67472. /**
  67473. * The world matrix
  67474. */
  67475. matrix: Matrix;
  67476. /**
  67477. * Stores the position
  67478. */
  67479. position: Vector3;
  67480. /**
  67481. * Stores the rotation
  67482. */
  67483. rotation: Vector3;
  67484. /**
  67485. * Stores the rotation quaternion
  67486. */
  67487. rotationQuaternion: Nullable<Quaternion>;
  67488. /**
  67489. * Stores the scaling vector
  67490. */
  67491. scaling: Vector3;
  67492. /**
  67493. * Convert the Mesh to CSG
  67494. * @param mesh The Mesh to convert to CSG
  67495. * @returns A new CSG from the Mesh
  67496. */
  67497. static FromMesh(mesh: Mesh): CSG;
  67498. /**
  67499. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  67500. * @param polygons Polygons used to construct a CSG solid
  67501. */
  67502. private static FromPolygons;
  67503. /**
  67504. * Clones, or makes a deep copy, of the CSG
  67505. * @returns A new CSG
  67506. */
  67507. clone(): CSG;
  67508. /**
  67509. * Unions this CSG with another CSG
  67510. * @param csg The CSG to union against this CSG
  67511. * @returns The unioned CSG
  67512. */
  67513. union(csg: CSG): CSG;
  67514. /**
  67515. * Unions this CSG with another CSG in place
  67516. * @param csg The CSG to union against this CSG
  67517. */
  67518. unionInPlace(csg: CSG): void;
  67519. /**
  67520. * Subtracts this CSG with another CSG
  67521. * @param csg The CSG to subtract against this CSG
  67522. * @returns A new CSG
  67523. */
  67524. subtract(csg: CSG): CSG;
  67525. /**
  67526. * Subtracts this CSG with another CSG in place
  67527. * @param csg The CSG to subtact against this CSG
  67528. */
  67529. subtractInPlace(csg: CSG): void;
  67530. /**
  67531. * Intersect this CSG with another CSG
  67532. * @param csg The CSG to intersect against this CSG
  67533. * @returns A new CSG
  67534. */
  67535. intersect(csg: CSG): CSG;
  67536. /**
  67537. * Intersects this CSG with another CSG in place
  67538. * @param csg The CSG to intersect against this CSG
  67539. */
  67540. intersectInPlace(csg: CSG): void;
  67541. /**
  67542. * Return a new CSG solid with solid and empty space switched. This solid is
  67543. * not modified.
  67544. * @returns A new CSG solid with solid and empty space switched
  67545. */
  67546. inverse(): CSG;
  67547. /**
  67548. * Inverses the CSG in place
  67549. */
  67550. inverseInPlace(): void;
  67551. /**
  67552. * This is used to keep meshes transformations so they can be restored
  67553. * when we build back a Babylon Mesh
  67554. * NB : All CSG operations are performed in world coordinates
  67555. * @param csg The CSG to copy the transform attributes from
  67556. * @returns This CSG
  67557. */
  67558. copyTransformAttributes(csg: CSG): CSG;
  67559. /**
  67560. * Build Raw mesh from CSG
  67561. * Coordinates here are in world space
  67562. * @param name The name of the mesh geometry
  67563. * @param scene The Scene
  67564. * @param keepSubMeshes Specifies if the submeshes should be kept
  67565. * @returns A new Mesh
  67566. */
  67567. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  67568. /**
  67569. * Build Mesh from CSG taking material and transforms into account
  67570. * @param name The name of the Mesh
  67571. * @param material The material of the Mesh
  67572. * @param scene The Scene
  67573. * @param keepSubMeshes Specifies if submeshes should be kept
  67574. * @returns The new Mesh
  67575. */
  67576. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  67577. }
  67578. }
  67579. declare module "babylonjs/Meshes/trailMesh" {
  67580. import { Mesh } from "babylonjs/Meshes/mesh";
  67581. import { Scene } from "babylonjs/scene";
  67582. import { TransformNode } from "babylonjs/Meshes/transformNode";
  67583. /**
  67584. * Class used to create a trail following a mesh
  67585. */
  67586. export class TrailMesh extends Mesh {
  67587. private _generator;
  67588. private _autoStart;
  67589. private _running;
  67590. private _diameter;
  67591. private _length;
  67592. private _sectionPolygonPointsCount;
  67593. private _sectionVectors;
  67594. private _sectionNormalVectors;
  67595. private _beforeRenderObserver;
  67596. /**
  67597. * @constructor
  67598. * @param name The value used by scene.getMeshByName() to do a lookup.
  67599. * @param generator The mesh or transform node to generate a trail.
  67600. * @param scene The scene to add this mesh to.
  67601. * @param diameter Diameter of trailing mesh. Default is 1.
  67602. * @param length Length of trailing mesh. Default is 60.
  67603. * @param autoStart Automatically start trailing mesh. Default true.
  67604. */
  67605. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  67606. /**
  67607. * "TrailMesh"
  67608. * @returns "TrailMesh"
  67609. */
  67610. getClassName(): string;
  67611. private _createMesh;
  67612. /**
  67613. * Start trailing mesh.
  67614. */
  67615. start(): void;
  67616. /**
  67617. * Stop trailing mesh.
  67618. */
  67619. stop(): void;
  67620. /**
  67621. * Update trailing mesh geometry.
  67622. */
  67623. update(): void;
  67624. /**
  67625. * Returns a new TrailMesh object.
  67626. * @param name is a string, the name given to the new mesh
  67627. * @param newGenerator use new generator object for cloned trail mesh
  67628. * @returns a new mesh
  67629. */
  67630. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  67631. /**
  67632. * Serializes this trail mesh
  67633. * @param serializationObject object to write serialization to
  67634. */
  67635. serialize(serializationObject: any): void;
  67636. /**
  67637. * Parses a serialized trail mesh
  67638. * @param parsedMesh the serialized mesh
  67639. * @param scene the scene to create the trail mesh in
  67640. * @returns the created trail mesh
  67641. */
  67642. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  67643. }
  67644. }
  67645. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  67646. import { Nullable } from "babylonjs/types";
  67647. import { Scene } from "babylonjs/scene";
  67648. import { Vector4 } from "babylonjs/Maths/math.vector";
  67649. import { Color4 } from "babylonjs/Maths/math.color";
  67650. import { Mesh } from "babylonjs/Meshes/mesh";
  67651. /**
  67652. * Class containing static functions to help procedurally build meshes
  67653. */
  67654. export class TiledBoxBuilder {
  67655. /**
  67656. * Creates a box mesh
  67657. * faceTiles sets the pattern, tile size and number of tiles for a face * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements)
  67658. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67659. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67660. * * 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
  67661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67662. * @param name defines the name of the mesh
  67663. * @param options defines the options used to create the mesh
  67664. * @param scene defines the hosting scene
  67665. * @returns the box mesh
  67666. */
  67667. static CreateTiledBox(name: string, options: {
  67668. pattern?: number;
  67669. width?: number;
  67670. height?: number;
  67671. depth?: number;
  67672. tileSize?: number;
  67673. tileWidth?: number;
  67674. tileHeight?: number;
  67675. alignHorizontal?: number;
  67676. alignVertical?: number;
  67677. faceUV?: Vector4[];
  67678. faceColors?: Color4[];
  67679. sideOrientation?: number;
  67680. updatable?: boolean;
  67681. }, scene?: Nullable<Scene>): Mesh;
  67682. }
  67683. }
  67684. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  67685. import { Vector4 } from "babylonjs/Maths/math.vector";
  67686. import { Mesh } from "babylonjs/Meshes/mesh";
  67687. /**
  67688. * Class containing static functions to help procedurally build meshes
  67689. */
  67690. export class TorusKnotBuilder {
  67691. /**
  67692. * Creates a torus knot mesh
  67693. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67694. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67695. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67696. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67697. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67698. * * 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
  67699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67700. * @param name defines the name of the mesh
  67701. * @param options defines the options used to create the mesh
  67702. * @param scene defines the hosting scene
  67703. * @returns the torus knot mesh
  67704. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67705. */
  67706. static CreateTorusKnot(name: string, options: {
  67707. radius?: number;
  67708. tube?: number;
  67709. radialSegments?: number;
  67710. tubularSegments?: number;
  67711. p?: number;
  67712. q?: number;
  67713. updatable?: boolean;
  67714. sideOrientation?: number;
  67715. frontUVs?: Vector4;
  67716. backUVs?: Vector4;
  67717. }, scene: any): Mesh;
  67718. }
  67719. }
  67720. declare module "babylonjs/Meshes/polygonMesh" {
  67721. import { Scene } from "babylonjs/scene";
  67722. import { Vector2 } from "babylonjs/Maths/math.vector";
  67723. import { Mesh } from "babylonjs/Meshes/mesh";
  67724. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  67725. import { Path2 } from "babylonjs/Maths/math.path";
  67726. /**
  67727. * Polygon
  67728. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  67729. */
  67730. export class Polygon {
  67731. /**
  67732. * Creates a rectangle
  67733. * @param xmin bottom X coord
  67734. * @param ymin bottom Y coord
  67735. * @param xmax top X coord
  67736. * @param ymax top Y coord
  67737. * @returns points that make the resulting rectation
  67738. */
  67739. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  67740. /**
  67741. * Creates a circle
  67742. * @param radius radius of circle
  67743. * @param cx scale in x
  67744. * @param cy scale in y
  67745. * @param numberOfSides number of sides that make up the circle
  67746. * @returns points that make the resulting circle
  67747. */
  67748. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  67749. /**
  67750. * Creates a polygon from input string
  67751. * @param input Input polygon data
  67752. * @returns the parsed points
  67753. */
  67754. static Parse(input: string): Vector2[];
  67755. /**
  67756. * Starts building a polygon from x and y coordinates
  67757. * @param x x coordinate
  67758. * @param y y coordinate
  67759. * @returns the started path2
  67760. */
  67761. static StartingAt(x: number, y: number): Path2;
  67762. }
  67763. /**
  67764. * Builds a polygon
  67765. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  67766. */
  67767. export class PolygonMeshBuilder {
  67768. private _points;
  67769. private _outlinepoints;
  67770. private _holes;
  67771. private _name;
  67772. private _scene;
  67773. private _epoints;
  67774. private _eholes;
  67775. private _addToepoint;
  67776. /**
  67777. * Babylon reference to the earcut plugin.
  67778. */
  67779. bjsEarcut: any;
  67780. /**
  67781. * Creates a PolygonMeshBuilder
  67782. * @param name name of the builder
  67783. * @param contours Path of the polygon
  67784. * @param scene scene to add to when creating the mesh
  67785. * @param earcutInjection can be used to inject your own earcut reference
  67786. */
  67787. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  67788. /**
  67789. * Adds a whole within the polygon
  67790. * @param hole Array of points defining the hole
  67791. * @returns this
  67792. */
  67793. addHole(hole: Vector2[]): PolygonMeshBuilder;
  67794. /**
  67795. * Creates the polygon
  67796. * @param updatable If the mesh should be updatable
  67797. * @param depth The depth of the mesh created
  67798. * @returns the created mesh
  67799. */
  67800. build(updatable?: boolean, depth?: number): Mesh;
  67801. /**
  67802. * Creates the polygon
  67803. * @param depth The depth of the mesh created
  67804. * @returns the created VertexData
  67805. */
  67806. buildVertexData(depth?: number): VertexData;
  67807. /**
  67808. * Adds a side to the polygon
  67809. * @param positions points that make the polygon
  67810. * @param normals normals of the polygon
  67811. * @param uvs uvs of the polygon
  67812. * @param indices indices of the polygon
  67813. * @param bounds bounds of the polygon
  67814. * @param points points of the polygon
  67815. * @param depth depth of the polygon
  67816. * @param flip flip of the polygon
  67817. */
  67818. private addSide;
  67819. }
  67820. }
  67821. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  67822. import { Scene } from "babylonjs/scene";
  67823. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67824. import { Color4 } from "babylonjs/Maths/math.color";
  67825. import { Mesh } from "babylonjs/Meshes/mesh";
  67826. import { Nullable } from "babylonjs/types";
  67827. /**
  67828. * Class containing static functions to help procedurally build meshes
  67829. */
  67830. export class PolygonBuilder {
  67831. /**
  67832. * Creates a polygon mesh
  67833. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67834. * * 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
  67835. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67837. * * 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)
  67838. * * Remember you can only change the shape positions, not their number when updating a polygon
  67839. * @param name defines the name of the mesh
  67840. * @param options defines the options used to create the mesh
  67841. * @param scene defines the hosting scene
  67842. * @param earcutInjection can be used to inject your own earcut reference
  67843. * @returns the polygon mesh
  67844. */
  67845. static CreatePolygon(name: string, options: {
  67846. shape: Vector3[];
  67847. holes?: Vector3[][];
  67848. depth?: number;
  67849. faceUV?: Vector4[];
  67850. faceColors?: Color4[];
  67851. updatable?: boolean;
  67852. sideOrientation?: number;
  67853. frontUVs?: Vector4;
  67854. backUVs?: Vector4;
  67855. wrap?: boolean;
  67856. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67857. /**
  67858. * Creates an extruded polygon mesh, with depth in the Y direction.
  67859. * * 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)
  67860. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67861. * @param name defines the name of the mesh
  67862. * @param options defines the options used to create the mesh
  67863. * @param scene defines the hosting scene
  67864. * @param earcutInjection can be used to inject your own earcut reference
  67865. * @returns the polygon mesh
  67866. */
  67867. static ExtrudePolygon(name: string, options: {
  67868. shape: Vector3[];
  67869. holes?: Vector3[][];
  67870. depth?: number;
  67871. faceUV?: Vector4[];
  67872. faceColors?: Color4[];
  67873. updatable?: boolean;
  67874. sideOrientation?: number;
  67875. frontUVs?: Vector4;
  67876. backUVs?: Vector4;
  67877. wrap?: boolean;
  67878. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67879. }
  67880. }
  67881. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  67882. import { Scene } from "babylonjs/scene";
  67883. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67884. import { Mesh } from "babylonjs/Meshes/mesh";
  67885. import { Nullable } from "babylonjs/types";
  67886. /**
  67887. * Class containing static functions to help procedurally build meshes
  67888. */
  67889. export class LatheBuilder {
  67890. /**
  67891. * Creates lathe mesh.
  67892. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67893. * * 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
  67894. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67895. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67896. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67897. * * 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
  67898. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67899. * * 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
  67900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67901. * * 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
  67902. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67904. * @param name defines the name of the mesh
  67905. * @param options defines the options used to create the mesh
  67906. * @param scene defines the hosting scene
  67907. * @returns the lathe mesh
  67908. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67909. */
  67910. static CreateLathe(name: string, options: {
  67911. shape: Vector3[];
  67912. radius?: number;
  67913. tessellation?: number;
  67914. clip?: number;
  67915. arc?: number;
  67916. closed?: boolean;
  67917. updatable?: boolean;
  67918. sideOrientation?: number;
  67919. frontUVs?: Vector4;
  67920. backUVs?: Vector4;
  67921. cap?: number;
  67922. invertUV?: boolean;
  67923. }, scene?: Nullable<Scene>): Mesh;
  67924. }
  67925. }
  67926. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  67927. import { Nullable } from "babylonjs/types";
  67928. import { Scene } from "babylonjs/scene";
  67929. import { Vector4 } from "babylonjs/Maths/math.vector";
  67930. import { Mesh } from "babylonjs/Meshes/mesh";
  67931. /**
  67932. * Class containing static functions to help procedurally build meshes
  67933. */
  67934. export class TiledPlaneBuilder {
  67935. /**
  67936. * Creates a tiled plane mesh
  67937. * * The parameter `pattern` will, depending on value, do nothing or
  67938. * * * flip (reflect about central vertical) alternate tiles across and up
  67939. * * * flip every tile on alternate rows
  67940. * * * rotate (180 degs) alternate tiles across and up
  67941. * * * rotate every tile on alternate rows
  67942. * * * flip and rotate alternate tiles across and up
  67943. * * * flip and rotate every tile on alternate rows
  67944. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  67945. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  67946. * * 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
  67947. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67948. * * 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)
  67949. * * 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)
  67950. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67951. * @param name defines the name of the mesh
  67952. * @param options defines the options used to create the mesh
  67953. * @param scene defines the hosting scene
  67954. * @returns the box mesh
  67955. */
  67956. static CreateTiledPlane(name: string, options: {
  67957. pattern?: number;
  67958. tileSize?: number;
  67959. tileWidth?: number;
  67960. tileHeight?: number;
  67961. size?: number;
  67962. width?: number;
  67963. height?: number;
  67964. alignHorizontal?: number;
  67965. alignVertical?: number;
  67966. sideOrientation?: number;
  67967. frontUVs?: Vector4;
  67968. backUVs?: Vector4;
  67969. updatable?: boolean;
  67970. }, scene?: Nullable<Scene>): Mesh;
  67971. }
  67972. }
  67973. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  67974. import { Nullable } from "babylonjs/types";
  67975. import { Scene } from "babylonjs/scene";
  67976. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67977. import { Mesh } from "babylonjs/Meshes/mesh";
  67978. /**
  67979. * Class containing static functions to help procedurally build meshes
  67980. */
  67981. export class TubeBuilder {
  67982. /**
  67983. * Creates a tube mesh.
  67984. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67985. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67986. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67987. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67988. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67989. * * 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)
  67990. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67991. * * 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
  67992. * * 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
  67993. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67994. * * 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
  67995. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67997. * @param name defines the name of the mesh
  67998. * @param options defines the options used to create the mesh
  67999. * @param scene defines the hosting scene
  68000. * @returns the tube mesh
  68001. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68002. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68003. */
  68004. static CreateTube(name: string, options: {
  68005. path: Vector3[];
  68006. radius?: number;
  68007. tessellation?: number;
  68008. radiusFunction?: {
  68009. (i: number, distance: number): number;
  68010. };
  68011. cap?: number;
  68012. arc?: number;
  68013. updatable?: boolean;
  68014. sideOrientation?: number;
  68015. frontUVs?: Vector4;
  68016. backUVs?: Vector4;
  68017. instance?: Mesh;
  68018. invertUV?: boolean;
  68019. }, scene?: Nullable<Scene>): Mesh;
  68020. }
  68021. }
  68022. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  68023. import { Scene } from "babylonjs/scene";
  68024. import { Vector4 } from "babylonjs/Maths/math.vector";
  68025. import { Mesh } from "babylonjs/Meshes/mesh";
  68026. import { Nullable } from "babylonjs/types";
  68027. /**
  68028. * Class containing static functions to help procedurally build meshes
  68029. */
  68030. export class IcoSphereBuilder {
  68031. /**
  68032. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68033. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68034. * * 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`)
  68035. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68036. * * 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
  68037. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68038. * * 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
  68039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68040. * @param name defines the name of the mesh
  68041. * @param options defines the options used to create the mesh
  68042. * @param scene defines the hosting scene
  68043. * @returns the icosahedron mesh
  68044. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68045. */
  68046. static CreateIcoSphere(name: string, options: {
  68047. radius?: number;
  68048. radiusX?: number;
  68049. radiusY?: number;
  68050. radiusZ?: number;
  68051. flat?: boolean;
  68052. subdivisions?: number;
  68053. sideOrientation?: number;
  68054. frontUVs?: Vector4;
  68055. backUVs?: Vector4;
  68056. updatable?: boolean;
  68057. }, scene?: Nullable<Scene>): Mesh;
  68058. }
  68059. }
  68060. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  68061. import { Vector3 } from "babylonjs/Maths/math.vector";
  68062. import { Mesh } from "babylonjs/Meshes/mesh";
  68063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68064. /**
  68065. * Class containing static functions to help procedurally build meshes
  68066. */
  68067. export class DecalBuilder {
  68068. /**
  68069. * Creates a decal mesh.
  68070. * 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
  68071. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68072. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68073. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68074. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68075. * @param name defines the name of the mesh
  68076. * @param sourceMesh defines the mesh where the decal must be applied
  68077. * @param options defines the options used to create the mesh
  68078. * @param scene defines the hosting scene
  68079. * @returns the decal mesh
  68080. * @see https://doc.babylonjs.com/how_to/decals
  68081. */
  68082. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68083. position?: Vector3;
  68084. normal?: Vector3;
  68085. size?: Vector3;
  68086. angle?: number;
  68087. }): Mesh;
  68088. }
  68089. }
  68090. declare module "babylonjs/Meshes/meshBuilder" {
  68091. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  68092. import { Nullable } from "babylonjs/types";
  68093. import { Scene } from "babylonjs/scene";
  68094. import { Mesh } from "babylonjs/Meshes/mesh";
  68095. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  68096. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  68097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68098. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  68099. import { Plane } from "babylonjs/Maths/math.plane";
  68100. /**
  68101. * Class containing static functions to help procedurally build meshes
  68102. */
  68103. export class MeshBuilder {
  68104. /**
  68105. * Creates a box mesh
  68106. * * The parameter `size` sets the size (float) of each box side (default 1)
  68107. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  68108. * * 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)
  68109. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68111. * * 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
  68112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68113. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  68114. * @param name defines the name of the mesh
  68115. * @param options defines the options used to create the mesh
  68116. * @param scene defines the hosting scene
  68117. * @returns the box mesh
  68118. */
  68119. static CreateBox(name: string, options: {
  68120. size?: number;
  68121. width?: number;
  68122. height?: number;
  68123. depth?: number;
  68124. faceUV?: Vector4[];
  68125. faceColors?: Color4[];
  68126. sideOrientation?: number;
  68127. frontUVs?: Vector4;
  68128. backUVs?: Vector4;
  68129. wrap?: boolean;
  68130. topBaseAt?: number;
  68131. bottomBaseAt?: number;
  68132. updatable?: boolean;
  68133. }, scene?: Nullable<Scene>): Mesh;
  68134. /**
  68135. * Creates a tiled box mesh
  68136. * * faceTiles sets the pattern, tile size and number of tiles for a face
  68137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68138. * @param name defines the name of the mesh
  68139. * @param options defines the options used to create the mesh
  68140. * @param scene defines the hosting scene
  68141. * @returns the tiled box mesh
  68142. */
  68143. static CreateTiledBox(name: string, options: {
  68144. pattern?: number;
  68145. size?: number;
  68146. width?: number;
  68147. height?: number;
  68148. depth: number;
  68149. tileSize?: number;
  68150. tileWidth?: number;
  68151. tileHeight?: number;
  68152. faceUV?: Vector4[];
  68153. faceColors?: Color4[];
  68154. alignHorizontal?: number;
  68155. alignVertical?: number;
  68156. sideOrientation?: number;
  68157. updatable?: boolean;
  68158. }, scene?: Nullable<Scene>): Mesh;
  68159. /**
  68160. * Creates a sphere mesh
  68161. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  68162. * * 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`)
  68163. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  68164. * * 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
  68165. * * 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)
  68166. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68167. * * 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
  68168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68169. * @param name defines the name of the mesh
  68170. * @param options defines the options used to create the mesh
  68171. * @param scene defines the hosting scene
  68172. * @returns the sphere mesh
  68173. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  68174. */
  68175. static CreateSphere(name: string, options: {
  68176. segments?: number;
  68177. diameter?: number;
  68178. diameterX?: number;
  68179. diameterY?: number;
  68180. diameterZ?: number;
  68181. arc?: number;
  68182. slice?: number;
  68183. sideOrientation?: number;
  68184. frontUVs?: Vector4;
  68185. backUVs?: Vector4;
  68186. updatable?: boolean;
  68187. }, scene?: Nullable<Scene>): Mesh;
  68188. /**
  68189. * Creates a plane polygonal mesh. By default, this is a disc
  68190. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  68191. * * 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
  68192. * * 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
  68193. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68194. * * 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
  68195. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68196. * @param name defines the name of the mesh
  68197. * @param options defines the options used to create the mesh
  68198. * @param scene defines the hosting scene
  68199. * @returns the plane polygonal mesh
  68200. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  68201. */
  68202. static CreateDisc(name: string, options: {
  68203. radius?: number;
  68204. tessellation?: number;
  68205. arc?: number;
  68206. updatable?: boolean;
  68207. sideOrientation?: number;
  68208. frontUVs?: Vector4;
  68209. backUVs?: Vector4;
  68210. }, scene?: Nullable<Scene>): Mesh;
  68211. /**
  68212. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68213. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68214. * * 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`)
  68215. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68216. * * 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
  68217. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68218. * * 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
  68219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68220. * @param name defines the name of the mesh
  68221. * @param options defines the options used to create the mesh
  68222. * @param scene defines the hosting scene
  68223. * @returns the icosahedron mesh
  68224. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68225. */
  68226. static CreateIcoSphere(name: string, options: {
  68227. radius?: number;
  68228. radiusX?: number;
  68229. radiusY?: number;
  68230. radiusZ?: number;
  68231. flat?: boolean;
  68232. subdivisions?: number;
  68233. sideOrientation?: number;
  68234. frontUVs?: Vector4;
  68235. backUVs?: Vector4;
  68236. updatable?: boolean;
  68237. }, scene?: Nullable<Scene>): Mesh;
  68238. /**
  68239. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68240. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  68241. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  68242. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  68243. * * 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
  68244. * * 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
  68245. * * 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
  68246. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68247. * * 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
  68248. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68249. * * 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
  68250. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  68251. * * 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
  68252. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  68253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68254. * @param name defines the name of the mesh
  68255. * @param options defines the options used to create the mesh
  68256. * @param scene defines the hosting scene
  68257. * @returns the ribbon mesh
  68258. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  68259. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68260. */
  68261. static CreateRibbon(name: string, options: {
  68262. pathArray: Vector3[][];
  68263. closeArray?: boolean;
  68264. closePath?: boolean;
  68265. offset?: number;
  68266. updatable?: boolean;
  68267. sideOrientation?: number;
  68268. frontUVs?: Vector4;
  68269. backUVs?: Vector4;
  68270. instance?: Mesh;
  68271. invertUV?: boolean;
  68272. uvs?: Vector2[];
  68273. colors?: Color4[];
  68274. }, scene?: Nullable<Scene>): Mesh;
  68275. /**
  68276. * Creates a cylinder or a cone mesh
  68277. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  68278. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  68279. * * 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.
  68280. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  68281. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  68282. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  68283. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  68284. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  68285. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  68286. * * 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).
  68287. * * 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
  68288. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  68289. * * 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
  68290. * * 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.
  68291. * * If `enclose` is false, a ring surface is one element.
  68292. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  68293. * * 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
  68294. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68295. * * 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
  68296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68297. * @param name defines the name of the mesh
  68298. * @param options defines the options used to create the mesh
  68299. * @param scene defines the hosting scene
  68300. * @returns the cylinder mesh
  68301. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  68302. */
  68303. static CreateCylinder(name: string, options: {
  68304. height?: number;
  68305. diameterTop?: number;
  68306. diameterBottom?: number;
  68307. diameter?: number;
  68308. tessellation?: number;
  68309. subdivisions?: number;
  68310. arc?: number;
  68311. faceColors?: Color4[];
  68312. faceUV?: Vector4[];
  68313. updatable?: boolean;
  68314. hasRings?: boolean;
  68315. enclose?: boolean;
  68316. cap?: number;
  68317. sideOrientation?: number;
  68318. frontUVs?: Vector4;
  68319. backUVs?: Vector4;
  68320. }, scene?: Nullable<Scene>): Mesh;
  68321. /**
  68322. * Creates a torus mesh
  68323. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  68324. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  68325. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  68326. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68327. * * 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
  68328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68329. * @param name defines the name of the mesh
  68330. * @param options defines the options used to create the mesh
  68331. * @param scene defines the hosting scene
  68332. * @returns the torus mesh
  68333. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  68334. */
  68335. static CreateTorus(name: string, options: {
  68336. diameter?: number;
  68337. thickness?: number;
  68338. tessellation?: number;
  68339. updatable?: boolean;
  68340. sideOrientation?: number;
  68341. frontUVs?: Vector4;
  68342. backUVs?: Vector4;
  68343. }, scene?: Nullable<Scene>): Mesh;
  68344. /**
  68345. * Creates a torus knot mesh
  68346. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68347. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68348. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68349. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68350. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68351. * * 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
  68352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68353. * @param name defines the name of the mesh
  68354. * @param options defines the options used to create the mesh
  68355. * @param scene defines the hosting scene
  68356. * @returns the torus knot mesh
  68357. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68358. */
  68359. static CreateTorusKnot(name: string, options: {
  68360. radius?: number;
  68361. tube?: number;
  68362. radialSegments?: number;
  68363. tubularSegments?: number;
  68364. p?: number;
  68365. q?: number;
  68366. updatable?: boolean;
  68367. sideOrientation?: number;
  68368. frontUVs?: Vector4;
  68369. backUVs?: Vector4;
  68370. }, scene?: Nullable<Scene>): Mesh;
  68371. /**
  68372. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  68373. * * 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
  68374. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  68375. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  68376. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  68377. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  68378. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  68379. * * 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
  68380. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  68381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68382. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  68383. * @param name defines the name of the new line system
  68384. * @param options defines the options used to create the line system
  68385. * @param scene defines the hosting scene
  68386. * @returns a new line system mesh
  68387. */
  68388. static CreateLineSystem(name: string, options: {
  68389. lines: Vector3[][];
  68390. updatable?: boolean;
  68391. instance?: Nullable<LinesMesh>;
  68392. colors?: Nullable<Color4[][]>;
  68393. useVertexAlpha?: boolean;
  68394. }, scene: Nullable<Scene>): LinesMesh;
  68395. /**
  68396. * Creates a line mesh
  68397. * 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
  68398. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  68399. * * The parameter `points` is an array successive Vector3
  68400. * * 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
  68401. * * The optional parameter `colors` is an array of successive Color4, one per line point
  68402. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  68403. * * When updating an instance, remember that only point positions can change, not the number of points
  68404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68405. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  68406. * @param name defines the name of the new line system
  68407. * @param options defines the options used to create the line system
  68408. * @param scene defines the hosting scene
  68409. * @returns a new line mesh
  68410. */
  68411. static CreateLines(name: string, options: {
  68412. points: Vector3[];
  68413. updatable?: boolean;
  68414. instance?: Nullable<LinesMesh>;
  68415. colors?: Color4[];
  68416. useVertexAlpha?: boolean;
  68417. }, scene?: Nullable<Scene>): LinesMesh;
  68418. /**
  68419. * Creates a dashed line mesh
  68420. * * 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
  68421. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  68422. * * The parameter `points` is an array successive Vector3
  68423. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  68424. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  68425. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  68426. * * 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
  68427. * * When updating an instance, remember that only point positions can change, not the number of points
  68428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68429. * @param name defines the name of the mesh
  68430. * @param options defines the options used to create the mesh
  68431. * @param scene defines the hosting scene
  68432. * @returns the dashed line mesh
  68433. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  68434. */
  68435. static CreateDashedLines(name: string, options: {
  68436. points: Vector3[];
  68437. dashSize?: number;
  68438. gapSize?: number;
  68439. dashNb?: number;
  68440. updatable?: boolean;
  68441. instance?: LinesMesh;
  68442. }, scene?: Nullable<Scene>): LinesMesh;
  68443. /**
  68444. * 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.
  68445. * * 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.
  68446. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  68447. * * 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.
  68448. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  68449. * * 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
  68450. * * 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
  68451. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  68452. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68453. * * 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
  68454. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  68455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68456. * @param name defines the name of the mesh
  68457. * @param options defines the options used to create the mesh
  68458. * @param scene defines the hosting scene
  68459. * @returns the extruded shape mesh
  68460. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68461. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  68462. */
  68463. static ExtrudeShape(name: string, options: {
  68464. shape: Vector3[];
  68465. path: Vector3[];
  68466. scale?: number;
  68467. rotation?: number;
  68468. cap?: number;
  68469. updatable?: boolean;
  68470. sideOrientation?: number;
  68471. frontUVs?: Vector4;
  68472. backUVs?: Vector4;
  68473. instance?: Mesh;
  68474. invertUV?: boolean;
  68475. }, scene?: Nullable<Scene>): Mesh;
  68476. /**
  68477. * Creates an custom extruded shape mesh.
  68478. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  68479. * * 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.
  68480. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  68481. * * 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
  68482. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  68483. * * 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
  68484. * * It must returns a float value that will be the scale value applied to the shape on each path point
  68485. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  68486. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  68487. * * 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
  68488. * * 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
  68489. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  68490. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68491. * * 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
  68492. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68494. * @param name defines the name of the mesh
  68495. * @param options defines the options used to create the mesh
  68496. * @param scene defines the hosting scene
  68497. * @returns the custom extruded shape mesh
  68498. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  68499. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68500. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  68501. */
  68502. static ExtrudeShapeCustom(name: string, options: {
  68503. shape: Vector3[];
  68504. path: Vector3[];
  68505. scaleFunction?: any;
  68506. rotationFunction?: any;
  68507. ribbonCloseArray?: boolean;
  68508. ribbonClosePath?: boolean;
  68509. cap?: number;
  68510. updatable?: boolean;
  68511. sideOrientation?: number;
  68512. frontUVs?: Vector4;
  68513. backUVs?: Vector4;
  68514. instance?: Mesh;
  68515. invertUV?: boolean;
  68516. }, scene?: Nullable<Scene>): Mesh;
  68517. /**
  68518. * Creates lathe mesh.
  68519. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  68520. * * 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
  68521. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  68522. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  68523. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  68524. * * 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
  68525. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  68526. * * 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
  68527. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68528. * * 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
  68529. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68531. * @param name defines the name of the mesh
  68532. * @param options defines the options used to create the mesh
  68533. * @param scene defines the hosting scene
  68534. * @returns the lathe mesh
  68535. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  68536. */
  68537. static CreateLathe(name: string, options: {
  68538. shape: Vector3[];
  68539. radius?: number;
  68540. tessellation?: number;
  68541. clip?: number;
  68542. arc?: number;
  68543. closed?: boolean;
  68544. updatable?: boolean;
  68545. sideOrientation?: number;
  68546. frontUVs?: Vector4;
  68547. backUVs?: Vector4;
  68548. cap?: number;
  68549. invertUV?: boolean;
  68550. }, scene?: Nullable<Scene>): Mesh;
  68551. /**
  68552. * Creates a tiled plane mesh
  68553. * * You can set a limited pattern arrangement with the tiles
  68554. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68555. * * 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
  68556. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68557. * @param name defines the name of the mesh
  68558. * @param options defines the options used to create the mesh
  68559. * @param scene defines the hosting scene
  68560. * @returns the plane mesh
  68561. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  68562. */
  68563. static CreateTiledPlane(name: string, options: {
  68564. pattern?: number;
  68565. tileSize?: number;
  68566. tileWidth?: number;
  68567. tileHeight?: number;
  68568. size?: number;
  68569. width?: number;
  68570. height?: number;
  68571. alignHorizontal?: number;
  68572. alignVertical?: number;
  68573. sideOrientation?: number;
  68574. frontUVs?: Vector4;
  68575. backUVs?: Vector4;
  68576. updatable?: boolean;
  68577. }, scene?: Nullable<Scene>): Mesh;
  68578. /**
  68579. * Creates a plane mesh
  68580. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  68581. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  68582. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  68583. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68584. * * 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
  68585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68586. * @param name defines the name of the mesh
  68587. * @param options defines the options used to create the mesh
  68588. * @param scene defines the hosting scene
  68589. * @returns the plane mesh
  68590. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  68591. */
  68592. static CreatePlane(name: string, options: {
  68593. size?: number;
  68594. width?: number;
  68595. height?: number;
  68596. sideOrientation?: number;
  68597. frontUVs?: Vector4;
  68598. backUVs?: Vector4;
  68599. updatable?: boolean;
  68600. sourcePlane?: Plane;
  68601. }, scene?: Nullable<Scene>): Mesh;
  68602. /**
  68603. * Creates a ground mesh
  68604. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  68605. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  68606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68607. * @param name defines the name of the mesh
  68608. * @param options defines the options used to create the mesh
  68609. * @param scene defines the hosting scene
  68610. * @returns the ground mesh
  68611. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  68612. */
  68613. static CreateGround(name: string, options: {
  68614. width?: number;
  68615. height?: number;
  68616. subdivisions?: number;
  68617. subdivisionsX?: number;
  68618. subdivisionsY?: number;
  68619. updatable?: boolean;
  68620. }, scene?: Nullable<Scene>): Mesh;
  68621. /**
  68622. * Creates a tiled ground mesh
  68623. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  68624. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  68625. * * 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
  68626. * * 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
  68627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68628. * @param name defines the name of the mesh
  68629. * @param options defines the options used to create the mesh
  68630. * @param scene defines the hosting scene
  68631. * @returns the tiled ground mesh
  68632. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  68633. */
  68634. static CreateTiledGround(name: string, options: {
  68635. xmin: number;
  68636. zmin: number;
  68637. xmax: number;
  68638. zmax: number;
  68639. subdivisions?: {
  68640. w: number;
  68641. h: number;
  68642. };
  68643. precision?: {
  68644. w: number;
  68645. h: number;
  68646. };
  68647. updatable?: boolean;
  68648. }, scene?: Nullable<Scene>): Mesh;
  68649. /**
  68650. * Creates a ground mesh from a height map
  68651. * * The parameter `url` sets the URL of the height map image resource.
  68652. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  68653. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  68654. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  68655. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  68656. * * 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.
  68657. * * 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).
  68658. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  68659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68660. * @param name defines the name of the mesh
  68661. * @param url defines the url to the height map
  68662. * @param options defines the options used to create the mesh
  68663. * @param scene defines the hosting scene
  68664. * @returns the ground mesh
  68665. * @see https://doc.babylonjs.com/babylon101/height_map
  68666. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  68667. */
  68668. static CreateGroundFromHeightMap(name: string, url: string, options: {
  68669. width?: number;
  68670. height?: number;
  68671. subdivisions?: number;
  68672. minHeight?: number;
  68673. maxHeight?: number;
  68674. colorFilter?: Color3;
  68675. alphaFilter?: number;
  68676. updatable?: boolean;
  68677. onReady?: (mesh: GroundMesh) => void;
  68678. }, scene?: Nullable<Scene>): GroundMesh;
  68679. /**
  68680. * Creates a polygon mesh
  68681. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  68682. * * 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
  68683. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68685. * * 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)
  68686. * * Remember you can only change the shape positions, not their number when updating a polygon
  68687. * @param name defines the name of the mesh
  68688. * @param options defines the options used to create the mesh
  68689. * @param scene defines the hosting scene
  68690. * @param earcutInjection can be used to inject your own earcut reference
  68691. * @returns the polygon mesh
  68692. */
  68693. static CreatePolygon(name: string, options: {
  68694. shape: Vector3[];
  68695. holes?: Vector3[][];
  68696. depth?: number;
  68697. faceUV?: Vector4[];
  68698. faceColors?: Color4[];
  68699. updatable?: boolean;
  68700. sideOrientation?: number;
  68701. frontUVs?: Vector4;
  68702. backUVs?: Vector4;
  68703. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68704. /**
  68705. * Creates an extruded polygon mesh, with depth in the Y direction.
  68706. * * 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)
  68707. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68708. * @param name defines the name of the mesh
  68709. * @param options defines the options used to create the mesh
  68710. * @param scene defines the hosting scene
  68711. * @param earcutInjection can be used to inject your own earcut reference
  68712. * @returns the polygon mesh
  68713. */
  68714. static ExtrudePolygon(name: string, options: {
  68715. shape: Vector3[];
  68716. holes?: Vector3[][];
  68717. depth?: number;
  68718. faceUV?: Vector4[];
  68719. faceColors?: Color4[];
  68720. updatable?: boolean;
  68721. sideOrientation?: number;
  68722. frontUVs?: Vector4;
  68723. backUVs?: Vector4;
  68724. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68725. /**
  68726. * Creates a tube mesh.
  68727. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68728. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  68729. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  68730. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  68731. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  68732. * * 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)
  68733. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  68734. * * 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
  68735. * * 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
  68736. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68737. * * 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
  68738. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68739. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68740. * @param name defines the name of the mesh
  68741. * @param options defines the options used to create the mesh
  68742. * @param scene defines the hosting scene
  68743. * @returns the tube mesh
  68744. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68745. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68746. */
  68747. static CreateTube(name: string, options: {
  68748. path: Vector3[];
  68749. radius?: number;
  68750. tessellation?: number;
  68751. radiusFunction?: {
  68752. (i: number, distance: number): number;
  68753. };
  68754. cap?: number;
  68755. arc?: number;
  68756. updatable?: boolean;
  68757. sideOrientation?: number;
  68758. frontUVs?: Vector4;
  68759. backUVs?: Vector4;
  68760. instance?: Mesh;
  68761. invertUV?: boolean;
  68762. }, scene?: Nullable<Scene>): Mesh;
  68763. /**
  68764. * Creates a polyhedron mesh
  68765. * * 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
  68766. * * The parameter `size` (positive float, default 1) sets the polygon size
  68767. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  68768. * * 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`
  68769. * * 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
  68770. * * 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)`)
  68771. * * 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
  68772. * * 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
  68773. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68774. * * 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
  68775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68776. * @param name defines the name of the mesh
  68777. * @param options defines the options used to create the mesh
  68778. * @param scene defines the hosting scene
  68779. * @returns the polyhedron mesh
  68780. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  68781. */
  68782. static CreatePolyhedron(name: string, options: {
  68783. type?: number;
  68784. size?: number;
  68785. sizeX?: number;
  68786. sizeY?: number;
  68787. sizeZ?: number;
  68788. custom?: any;
  68789. faceUV?: Vector4[];
  68790. faceColors?: Color4[];
  68791. flat?: boolean;
  68792. updatable?: boolean;
  68793. sideOrientation?: number;
  68794. frontUVs?: Vector4;
  68795. backUVs?: Vector4;
  68796. }, scene?: Nullable<Scene>): Mesh;
  68797. /**
  68798. * Creates a decal mesh.
  68799. * 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
  68800. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68801. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68802. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68803. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68804. * @param name defines the name of the mesh
  68805. * @param sourceMesh defines the mesh where the decal must be applied
  68806. * @param options defines the options used to create the mesh
  68807. * @param scene defines the hosting scene
  68808. * @returns the decal mesh
  68809. * @see https://doc.babylonjs.com/how_to/decals
  68810. */
  68811. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68812. position?: Vector3;
  68813. normal?: Vector3;
  68814. size?: Vector3;
  68815. angle?: number;
  68816. }): Mesh;
  68817. }
  68818. }
  68819. declare module "babylonjs/Meshes/meshSimplification" {
  68820. import { Mesh } from "babylonjs/Meshes/mesh";
  68821. /**
  68822. * A simplifier interface for future simplification implementations
  68823. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68824. */
  68825. export interface ISimplifier {
  68826. /**
  68827. * Simplification of a given mesh according to the given settings.
  68828. * Since this requires computation, it is assumed that the function runs async.
  68829. * @param settings The settings of the simplification, including quality and distance
  68830. * @param successCallback A callback that will be called after the mesh was simplified.
  68831. * @param errorCallback in case of an error, this callback will be called. optional.
  68832. */
  68833. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  68834. }
  68835. /**
  68836. * Expected simplification settings.
  68837. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  68838. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68839. */
  68840. export interface ISimplificationSettings {
  68841. /**
  68842. * Gets or sets the expected quality
  68843. */
  68844. quality: number;
  68845. /**
  68846. * Gets or sets the distance when this optimized version should be used
  68847. */
  68848. distance: number;
  68849. /**
  68850. * Gets an already optimized mesh
  68851. */
  68852. optimizeMesh?: boolean;
  68853. }
  68854. /**
  68855. * Class used to specify simplification options
  68856. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68857. */
  68858. export class SimplificationSettings implements ISimplificationSettings {
  68859. /** expected quality */
  68860. quality: number;
  68861. /** distance when this optimized version should be used */
  68862. distance: number;
  68863. /** already optimized mesh */
  68864. optimizeMesh?: boolean | undefined;
  68865. /**
  68866. * Creates a SimplificationSettings
  68867. * @param quality expected quality
  68868. * @param distance distance when this optimized version should be used
  68869. * @param optimizeMesh already optimized mesh
  68870. */
  68871. constructor(
  68872. /** expected quality */
  68873. quality: number,
  68874. /** distance when this optimized version should be used */
  68875. distance: number,
  68876. /** already optimized mesh */
  68877. optimizeMesh?: boolean | undefined);
  68878. }
  68879. /**
  68880. * Interface used to define a simplification task
  68881. */
  68882. export interface ISimplificationTask {
  68883. /**
  68884. * Array of settings
  68885. */
  68886. settings: Array<ISimplificationSettings>;
  68887. /**
  68888. * Simplification type
  68889. */
  68890. simplificationType: SimplificationType;
  68891. /**
  68892. * Mesh to simplify
  68893. */
  68894. mesh: Mesh;
  68895. /**
  68896. * Callback called on success
  68897. */
  68898. successCallback?: () => void;
  68899. /**
  68900. * Defines if parallel processing can be used
  68901. */
  68902. parallelProcessing: boolean;
  68903. }
  68904. /**
  68905. * Queue used to order the simplification tasks
  68906. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68907. */
  68908. export class SimplificationQueue {
  68909. private _simplificationArray;
  68910. /**
  68911. * Gets a boolean indicating that the process is still running
  68912. */
  68913. running: boolean;
  68914. /**
  68915. * Creates a new queue
  68916. */
  68917. constructor();
  68918. /**
  68919. * Adds a new simplification task
  68920. * @param task defines a task to add
  68921. */
  68922. addTask(task: ISimplificationTask): void;
  68923. /**
  68924. * Execute next task
  68925. */
  68926. executeNext(): void;
  68927. /**
  68928. * Execute a simplification task
  68929. * @param task defines the task to run
  68930. */
  68931. runSimplification(task: ISimplificationTask): void;
  68932. private getSimplifier;
  68933. }
  68934. /**
  68935. * The implemented types of simplification
  68936. * At the moment only Quadratic Error Decimation is implemented
  68937. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68938. */
  68939. export enum SimplificationType {
  68940. /** Quadratic error decimation */
  68941. QUADRATIC = 0
  68942. }
  68943. /**
  68944. * An implementation of the Quadratic Error simplification algorithm.
  68945. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  68946. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  68947. * @author RaananW
  68948. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68949. */
  68950. export class QuadraticErrorSimplification implements ISimplifier {
  68951. private _mesh;
  68952. private triangles;
  68953. private vertices;
  68954. private references;
  68955. private _reconstructedMesh;
  68956. /** Gets or sets the number pf sync interations */
  68957. syncIterations: number;
  68958. /** Gets or sets the aggressiveness of the simplifier */
  68959. aggressiveness: number;
  68960. /** Gets or sets the number of allowed iterations for decimation */
  68961. decimationIterations: number;
  68962. /** Gets or sets the espilon to use for bounding box computation */
  68963. boundingBoxEpsilon: number;
  68964. /**
  68965. * Creates a new QuadraticErrorSimplification
  68966. * @param _mesh defines the target mesh
  68967. */
  68968. constructor(_mesh: Mesh);
  68969. /**
  68970. * Simplification of a given mesh according to the given settings.
  68971. * Since this requires computation, it is assumed that the function runs async.
  68972. * @param settings The settings of the simplification, including quality and distance
  68973. * @param successCallback A callback that will be called after the mesh was simplified.
  68974. */
  68975. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  68976. private runDecimation;
  68977. private initWithMesh;
  68978. private init;
  68979. private reconstructMesh;
  68980. private initDecimatedMesh;
  68981. private isFlipped;
  68982. private updateTriangles;
  68983. private identifyBorder;
  68984. private updateMesh;
  68985. private vertexError;
  68986. private calculateError;
  68987. }
  68988. }
  68989. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  68990. import { Scene } from "babylonjs/scene";
  68991. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  68992. import { ISceneComponent } from "babylonjs/sceneComponent";
  68993. module "babylonjs/scene" {
  68994. interface Scene {
  68995. /** @hidden (Backing field) */
  68996. _simplificationQueue: SimplificationQueue;
  68997. /**
  68998. * Gets or sets the simplification queue attached to the scene
  68999. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69000. */
  69001. simplificationQueue: SimplificationQueue;
  69002. }
  69003. }
  69004. module "babylonjs/Meshes/mesh" {
  69005. interface Mesh {
  69006. /**
  69007. * Simplify the mesh according to the given array of settings.
  69008. * Function will return immediately and will simplify async
  69009. * @param settings a collection of simplification settings
  69010. * @param parallelProcessing should all levels calculate parallel or one after the other
  69011. * @param simplificationType the type of simplification to run
  69012. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  69013. * @returns the current mesh
  69014. */
  69015. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  69016. }
  69017. }
  69018. /**
  69019. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  69020. * created in a scene
  69021. */
  69022. export class SimplicationQueueSceneComponent implements ISceneComponent {
  69023. /**
  69024. * The component name helpfull to identify the component in the list of scene components.
  69025. */
  69026. readonly name: string;
  69027. /**
  69028. * The scene the component belongs to.
  69029. */
  69030. scene: Scene;
  69031. /**
  69032. * Creates a new instance of the component for the given scene
  69033. * @param scene Defines the scene to register the component in
  69034. */
  69035. constructor(scene: Scene);
  69036. /**
  69037. * Registers the component in a given scene
  69038. */
  69039. register(): void;
  69040. /**
  69041. * Rebuilds the elements related to this component in case of
  69042. * context lost for instance.
  69043. */
  69044. rebuild(): void;
  69045. /**
  69046. * Disposes the component and the associated ressources
  69047. */
  69048. dispose(): void;
  69049. private _beforeCameraUpdate;
  69050. }
  69051. }
  69052. declare module "babylonjs/Meshes/Builders/index" {
  69053. export * from "babylonjs/Meshes/Builders/boxBuilder";
  69054. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  69055. export * from "babylonjs/Meshes/Builders/discBuilder";
  69056. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  69057. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  69058. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  69059. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  69060. export * from "babylonjs/Meshes/Builders/torusBuilder";
  69061. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  69062. export * from "babylonjs/Meshes/Builders/linesBuilder";
  69063. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  69064. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  69065. export * from "babylonjs/Meshes/Builders/latheBuilder";
  69066. export * from "babylonjs/Meshes/Builders/planeBuilder";
  69067. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  69068. export * from "babylonjs/Meshes/Builders/groundBuilder";
  69069. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  69070. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  69071. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  69072. export * from "babylonjs/Meshes/Builders/decalBuilder";
  69073. }
  69074. declare module "babylonjs/Meshes/thinInstanceMesh" {
  69075. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  69076. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  69077. import { Matrix } from "babylonjs/Maths/math.vector";
  69078. module "babylonjs/Meshes/mesh" {
  69079. interface Mesh {
  69080. /**
  69081. * Creates a new thin instance
  69082. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  69083. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  69084. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  69085. */
  69086. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  69087. /**
  69088. * Adds the transformation (matrix) of the current mesh as a thin instance
  69089. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  69090. * @returns the thin instance index number
  69091. */
  69092. thinInstanceAddSelf(refresh: boolean): number;
  69093. /**
  69094. * Registers a custom attribute to be used with thin instances
  69095. * @param kind name of the attribute
  69096. * @param stride size in floats of the attribute
  69097. */
  69098. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  69099. /**
  69100. * Sets the matrix of a thin instance
  69101. * @param index index of the thin instance
  69102. * @param matrix matrix to set
  69103. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  69104. */
  69105. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  69106. /**
  69107. * Sets the value of a custom attribute for a thin instance
  69108. * @param kind name of the attribute
  69109. * @param index index of the thin instance
  69110. * @param value value to set
  69111. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  69112. */
  69113. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  69114. /**
  69115. * Gets / sets the number of thin instances to display. Note that you can't set a number higher than what the underlying buffer can handle.
  69116. */
  69117. thinInstanceCount: number;
  69118. /**
  69119. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  69120. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  69121. * @param buffer buffer to set
  69122. * @param stride size in floats of each value of the buffer
  69123. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  69124. */
  69125. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  69126. /**
  69127. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  69128. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  69129. */
  69130. thinInstanceBufferUpdated(kind: string): void;
  69131. /**
  69132. * Refreshes the bounding info, taking into account all the thin instances defined
  69133. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  69134. */
  69135. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  69136. /** @hidden */
  69137. _thinInstanceInitializeUserStorage(): void;
  69138. /** @hidden */
  69139. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  69140. /** @hidden */
  69141. _userThinInstanceBuffersStorage: {
  69142. data: {
  69143. [key: string]: Float32Array;
  69144. };
  69145. sizes: {
  69146. [key: string]: number;
  69147. };
  69148. vertexBuffers: {
  69149. [key: string]: Nullable<VertexBuffer>;
  69150. };
  69151. strides: {
  69152. [key: string]: number;
  69153. };
  69154. };
  69155. }
  69156. }
  69157. }
  69158. declare module "babylonjs/Meshes/index" {
  69159. export * from "babylonjs/Meshes/abstractMesh";
  69160. export * from "babylonjs/Meshes/buffer";
  69161. export * from "babylonjs/Meshes/Compression/index";
  69162. export * from "babylonjs/Meshes/csg";
  69163. export * from "babylonjs/Meshes/geometry";
  69164. export * from "babylonjs/Meshes/groundMesh";
  69165. export * from "babylonjs/Meshes/trailMesh";
  69166. export * from "babylonjs/Meshes/instancedMesh";
  69167. export * from "babylonjs/Meshes/linesMesh";
  69168. export * from "babylonjs/Meshes/mesh";
  69169. export * from "babylonjs/Meshes/mesh.vertexData";
  69170. export * from "babylonjs/Meshes/meshBuilder";
  69171. export * from "babylonjs/Meshes/meshSimplification";
  69172. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  69173. export * from "babylonjs/Meshes/polygonMesh";
  69174. export * from "babylonjs/Meshes/subMesh";
  69175. export * from "babylonjs/Meshes/meshLODLevel";
  69176. export * from "babylonjs/Meshes/transformNode";
  69177. export * from "babylonjs/Meshes/Builders/index";
  69178. export * from "babylonjs/Meshes/dataBuffer";
  69179. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  69180. import "babylonjs/Meshes/thinInstanceMesh";
  69181. export * from "babylonjs/Meshes/thinInstanceMesh";
  69182. }
  69183. declare module "babylonjs/Morph/index" {
  69184. export * from "babylonjs/Morph/morphTarget";
  69185. export * from "babylonjs/Morph/morphTargetManager";
  69186. }
  69187. declare module "babylonjs/Navigation/INavigationEngine" {
  69188. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69189. import { Vector3 } from "babylonjs/Maths/math";
  69190. import { Mesh } from "babylonjs/Meshes/mesh";
  69191. import { Scene } from "babylonjs/scene";
  69192. /**
  69193. * Navigation plugin interface to add navigation constrained by a navigation mesh
  69194. */
  69195. export interface INavigationEnginePlugin {
  69196. /**
  69197. * plugin name
  69198. */
  69199. name: string;
  69200. /**
  69201. * Creates a navigation mesh
  69202. * @param meshes array of all the geometry used to compute the navigatio mesh
  69203. * @param parameters bunch of parameters used to filter geometry
  69204. */
  69205. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  69206. /**
  69207. * Create a navigation mesh debug mesh
  69208. * @param scene is where the mesh will be added
  69209. * @returns debug display mesh
  69210. */
  69211. createDebugNavMesh(scene: Scene): Mesh;
  69212. /**
  69213. * Get a navigation mesh constrained position, closest to the parameter position
  69214. * @param position world position
  69215. * @returns the closest point to position constrained by the navigation mesh
  69216. */
  69217. getClosestPoint(position: Vector3): Vector3;
  69218. /**
  69219. * Get a navigation mesh constrained position, closest to the parameter position
  69220. * @param position world position
  69221. * @param result output the closest point to position constrained by the navigation mesh
  69222. */
  69223. getClosestPointToRef(position: Vector3, result: Vector3): void;
  69224. /**
  69225. * Get a navigation mesh constrained position, within a particular radius
  69226. * @param position world position
  69227. * @param maxRadius the maximum distance to the constrained world position
  69228. * @returns the closest point to position constrained by the navigation mesh
  69229. */
  69230. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  69231. /**
  69232. * Get a navigation mesh constrained position, within a particular radius
  69233. * @param position world position
  69234. * @param maxRadius the maximum distance to the constrained world position
  69235. * @param result output the closest point to position constrained by the navigation mesh
  69236. */
  69237. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  69238. /**
  69239. * Compute the final position from a segment made of destination-position
  69240. * @param position world position
  69241. * @param destination world position
  69242. * @returns the resulting point along the navmesh
  69243. */
  69244. moveAlong(position: Vector3, destination: Vector3): Vector3;
  69245. /**
  69246. * Compute the final position from a segment made of destination-position
  69247. * @param position world position
  69248. * @param destination world position
  69249. * @param result output the resulting point along the navmesh
  69250. */
  69251. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  69252. /**
  69253. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  69254. * @param start world position
  69255. * @param end world position
  69256. * @returns array containing world position composing the path
  69257. */
  69258. computePath(start: Vector3, end: Vector3): Vector3[];
  69259. /**
  69260. * If this plugin is supported
  69261. * @returns true if plugin is supported
  69262. */
  69263. isSupported(): boolean;
  69264. /**
  69265. * Create a new Crowd so you can add agents
  69266. * @param maxAgents the maximum agent count in the crowd
  69267. * @param maxAgentRadius the maximum radius an agent can have
  69268. * @param scene to attach the crowd to
  69269. * @returns the crowd you can add agents to
  69270. */
  69271. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  69272. /**
  69273. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69274. * The queries will try to find a solution within those bounds
  69275. * default is (1,1,1)
  69276. * @param extent x,y,z value that define the extent around the queries point of reference
  69277. */
  69278. setDefaultQueryExtent(extent: Vector3): void;
  69279. /**
  69280. * Get the Bounding box extent specified by setDefaultQueryExtent
  69281. * @returns the box extent values
  69282. */
  69283. getDefaultQueryExtent(): Vector3;
  69284. /**
  69285. * build the navmesh from a previously saved state using getNavmeshData
  69286. * @param data the Uint8Array returned by getNavmeshData
  69287. */
  69288. buildFromNavmeshData(data: Uint8Array): void;
  69289. /**
  69290. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  69291. * @returns data the Uint8Array that can be saved and reused
  69292. */
  69293. getNavmeshData(): Uint8Array;
  69294. /**
  69295. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69296. * @param result output the box extent values
  69297. */
  69298. getDefaultQueryExtentToRef(result: Vector3): void;
  69299. /**
  69300. * Release all resources
  69301. */
  69302. dispose(): void;
  69303. }
  69304. /**
  69305. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  69306. */
  69307. export interface ICrowd {
  69308. /**
  69309. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  69310. * You can attach anything to that node. The node position is updated in the scene update tick.
  69311. * @param pos world position that will be constrained by the navigation mesh
  69312. * @param parameters agent parameters
  69313. * @param transform hooked to the agent that will be update by the scene
  69314. * @returns agent index
  69315. */
  69316. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  69317. /**
  69318. * Returns the agent position in world space
  69319. * @param index agent index returned by addAgent
  69320. * @returns world space position
  69321. */
  69322. getAgentPosition(index: number): Vector3;
  69323. /**
  69324. * Gets the agent position result in world space
  69325. * @param index agent index returned by addAgent
  69326. * @param result output world space position
  69327. */
  69328. getAgentPositionToRef(index: number, result: Vector3): void;
  69329. /**
  69330. * Gets the agent velocity in world space
  69331. * @param index agent index returned by addAgent
  69332. * @returns world space velocity
  69333. */
  69334. getAgentVelocity(index: number): Vector3;
  69335. /**
  69336. * Gets the agent velocity result in world space
  69337. * @param index agent index returned by addAgent
  69338. * @param result output world space velocity
  69339. */
  69340. getAgentVelocityToRef(index: number, result: Vector3): void;
  69341. /**
  69342. * remove a particular agent previously created
  69343. * @param index agent index returned by addAgent
  69344. */
  69345. removeAgent(index: number): void;
  69346. /**
  69347. * get the list of all agents attached to this crowd
  69348. * @returns list of agent indices
  69349. */
  69350. getAgents(): number[];
  69351. /**
  69352. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  69353. * @param deltaTime in seconds
  69354. */
  69355. update(deltaTime: number): void;
  69356. /**
  69357. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  69358. * @param index agent index returned by addAgent
  69359. * @param destination targeted world position
  69360. */
  69361. agentGoto(index: number, destination: Vector3): void;
  69362. /**
  69363. * Teleport the agent to a new position
  69364. * @param index agent index returned by addAgent
  69365. * @param destination targeted world position
  69366. */
  69367. agentTeleport(index: number, destination: Vector3): void;
  69368. /**
  69369. * Update agent parameters
  69370. * @param index agent index returned by addAgent
  69371. * @param parameters agent parameters
  69372. */
  69373. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  69374. /**
  69375. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69376. * The queries will try to find a solution within those bounds
  69377. * default is (1,1,1)
  69378. * @param extent x,y,z value that define the extent around the queries point of reference
  69379. */
  69380. setDefaultQueryExtent(extent: Vector3): void;
  69381. /**
  69382. * Get the Bounding box extent specified by setDefaultQueryExtent
  69383. * @returns the box extent values
  69384. */
  69385. getDefaultQueryExtent(): Vector3;
  69386. /**
  69387. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69388. * @param result output the box extent values
  69389. */
  69390. getDefaultQueryExtentToRef(result: Vector3): void;
  69391. /**
  69392. * Release all resources
  69393. */
  69394. dispose(): void;
  69395. }
  69396. /**
  69397. * Configures an agent
  69398. */
  69399. export interface IAgentParameters {
  69400. /**
  69401. * Agent radius. [Limit: >= 0]
  69402. */
  69403. radius: number;
  69404. /**
  69405. * Agent height. [Limit: > 0]
  69406. */
  69407. height: number;
  69408. /**
  69409. * Maximum allowed acceleration. [Limit: >= 0]
  69410. */
  69411. maxAcceleration: number;
  69412. /**
  69413. * Maximum allowed speed. [Limit: >= 0]
  69414. */
  69415. maxSpeed: number;
  69416. /**
  69417. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  69418. */
  69419. collisionQueryRange: number;
  69420. /**
  69421. * The path visibility optimization range. [Limit: > 0]
  69422. */
  69423. pathOptimizationRange: number;
  69424. /**
  69425. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  69426. */
  69427. separationWeight: number;
  69428. }
  69429. /**
  69430. * Configures the navigation mesh creation
  69431. */
  69432. export interface INavMeshParameters {
  69433. /**
  69434. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  69435. */
  69436. cs: number;
  69437. /**
  69438. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  69439. */
  69440. ch: number;
  69441. /**
  69442. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  69443. */
  69444. walkableSlopeAngle: number;
  69445. /**
  69446. * Minimum floor to 'ceiling' height that will still allow the floor area to
  69447. * be considered walkable. [Limit: >= 3] [Units: vx]
  69448. */
  69449. walkableHeight: number;
  69450. /**
  69451. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  69452. */
  69453. walkableClimb: number;
  69454. /**
  69455. * The distance to erode/shrink the walkable area of the heightfield away from
  69456. * obstructions. [Limit: >=0] [Units: vx]
  69457. */
  69458. walkableRadius: number;
  69459. /**
  69460. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  69461. */
  69462. maxEdgeLen: number;
  69463. /**
  69464. * The maximum distance a simplfied contour's border edges should deviate
  69465. * the original raw contour. [Limit: >=0] [Units: vx]
  69466. */
  69467. maxSimplificationError: number;
  69468. /**
  69469. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  69470. */
  69471. minRegionArea: number;
  69472. /**
  69473. * Any regions with a span count smaller than this value will, if possible,
  69474. * be merged with larger regions. [Limit: >=0] [Units: vx]
  69475. */
  69476. mergeRegionArea: number;
  69477. /**
  69478. * The maximum number of vertices allowed for polygons generated during the
  69479. * contour to polygon conversion process. [Limit: >= 3]
  69480. */
  69481. maxVertsPerPoly: number;
  69482. /**
  69483. * Sets the sampling distance to use when generating the detail mesh.
  69484. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  69485. */
  69486. detailSampleDist: number;
  69487. /**
  69488. * The maximum distance the detail mesh surface should deviate from heightfield
  69489. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  69490. */
  69491. detailSampleMaxError: number;
  69492. }
  69493. }
  69494. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  69495. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  69496. import { Mesh } from "babylonjs/Meshes/mesh";
  69497. import { Scene } from "babylonjs/scene";
  69498. import { Vector3 } from "babylonjs/Maths/math";
  69499. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69500. /**
  69501. * RecastJS navigation plugin
  69502. */
  69503. export class RecastJSPlugin implements INavigationEnginePlugin {
  69504. /**
  69505. * Reference to the Recast library
  69506. */
  69507. bjsRECAST: any;
  69508. /**
  69509. * plugin name
  69510. */
  69511. name: string;
  69512. /**
  69513. * the first navmesh created. We might extend this to support multiple navmeshes
  69514. */
  69515. navMesh: any;
  69516. /**
  69517. * Initializes the recastJS plugin
  69518. * @param recastInjection can be used to inject your own recast reference
  69519. */
  69520. constructor(recastInjection?: any);
  69521. /**
  69522. * Creates a navigation mesh
  69523. * @param meshes array of all the geometry used to compute the navigatio mesh
  69524. * @param parameters bunch of parameters used to filter geometry
  69525. */
  69526. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  69527. /**
  69528. * Create a navigation mesh debug mesh
  69529. * @param scene is where the mesh will be added
  69530. * @returns debug display mesh
  69531. */
  69532. createDebugNavMesh(scene: Scene): Mesh;
  69533. /**
  69534. * Get a navigation mesh constrained position, closest to the parameter position
  69535. * @param position world position
  69536. * @returns the closest point to position constrained by the navigation mesh
  69537. */
  69538. getClosestPoint(position: Vector3): Vector3;
  69539. /**
  69540. * Get a navigation mesh constrained position, closest to the parameter position
  69541. * @param position world position
  69542. * @param result output the closest point to position constrained by the navigation mesh
  69543. */
  69544. getClosestPointToRef(position: Vector3, result: Vector3): void;
  69545. /**
  69546. * Get a navigation mesh constrained position, within a particular radius
  69547. * @param position world position
  69548. * @param maxRadius the maximum distance to the constrained world position
  69549. * @returns the closest point to position constrained by the navigation mesh
  69550. */
  69551. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  69552. /**
  69553. * Get a navigation mesh constrained position, within a particular radius
  69554. * @param position world position
  69555. * @param maxRadius the maximum distance to the constrained world position
  69556. * @param result output the closest point to position constrained by the navigation mesh
  69557. */
  69558. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  69559. /**
  69560. * Compute the final position from a segment made of destination-position
  69561. * @param position world position
  69562. * @param destination world position
  69563. * @returns the resulting point along the navmesh
  69564. */
  69565. moveAlong(position: Vector3, destination: Vector3): Vector3;
  69566. /**
  69567. * Compute the final position from a segment made of destination-position
  69568. * @param position world position
  69569. * @param destination world position
  69570. * @param result output the resulting point along the navmesh
  69571. */
  69572. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  69573. /**
  69574. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  69575. * @param start world position
  69576. * @param end world position
  69577. * @returns array containing world position composing the path
  69578. */
  69579. computePath(start: Vector3, end: Vector3): Vector3[];
  69580. /**
  69581. * Create a new Crowd so you can add agents
  69582. * @param maxAgents the maximum agent count in the crowd
  69583. * @param maxAgentRadius the maximum radius an agent can have
  69584. * @param scene to attach the crowd to
  69585. * @returns the crowd you can add agents to
  69586. */
  69587. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  69588. /**
  69589. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69590. * The queries will try to find a solution within those bounds
  69591. * default is (1,1,1)
  69592. * @param extent x,y,z value that define the extent around the queries point of reference
  69593. */
  69594. setDefaultQueryExtent(extent: Vector3): void;
  69595. /**
  69596. * Get the Bounding box extent specified by setDefaultQueryExtent
  69597. * @returns the box extent values
  69598. */
  69599. getDefaultQueryExtent(): Vector3;
  69600. /**
  69601. * build the navmesh from a previously saved state using getNavmeshData
  69602. * @param data the Uint8Array returned by getNavmeshData
  69603. */
  69604. buildFromNavmeshData(data: Uint8Array): void;
  69605. /**
  69606. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  69607. * @returns data the Uint8Array that can be saved and reused
  69608. */
  69609. getNavmeshData(): Uint8Array;
  69610. /**
  69611. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69612. * @param result output the box extent values
  69613. */
  69614. getDefaultQueryExtentToRef(result: Vector3): void;
  69615. /**
  69616. * Disposes
  69617. */
  69618. dispose(): void;
  69619. /**
  69620. * If this plugin is supported
  69621. * @returns true if plugin is supported
  69622. */
  69623. isSupported(): boolean;
  69624. }
  69625. /**
  69626. * Recast detour crowd implementation
  69627. */
  69628. export class RecastJSCrowd implements ICrowd {
  69629. /**
  69630. * Recast/detour plugin
  69631. */
  69632. bjsRECASTPlugin: RecastJSPlugin;
  69633. /**
  69634. * Link to the detour crowd
  69635. */
  69636. recastCrowd: any;
  69637. /**
  69638. * One transform per agent
  69639. */
  69640. transforms: TransformNode[];
  69641. /**
  69642. * All agents created
  69643. */
  69644. agents: number[];
  69645. /**
  69646. * Link to the scene is kept to unregister the crowd from the scene
  69647. */
  69648. private _scene;
  69649. /**
  69650. * Observer for crowd updates
  69651. */
  69652. private _onBeforeAnimationsObserver;
  69653. /**
  69654. * Constructor
  69655. * @param plugin recastJS plugin
  69656. * @param maxAgents the maximum agent count in the crowd
  69657. * @param maxAgentRadius the maximum radius an agent can have
  69658. * @param scene to attach the crowd to
  69659. * @returns the crowd you can add agents to
  69660. */
  69661. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  69662. /**
  69663. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  69664. * You can attach anything to that node. The node position is updated in the scene update tick.
  69665. * @param pos world position that will be constrained by the navigation mesh
  69666. * @param parameters agent parameters
  69667. * @param transform hooked to the agent that will be update by the scene
  69668. * @returns agent index
  69669. */
  69670. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  69671. /**
  69672. * Returns the agent position in world space
  69673. * @param index agent index returned by addAgent
  69674. * @returns world space position
  69675. */
  69676. getAgentPosition(index: number): Vector3;
  69677. /**
  69678. * Returns the agent position result in world space
  69679. * @param index agent index returned by addAgent
  69680. * @param result output world space position
  69681. */
  69682. getAgentPositionToRef(index: number, result: Vector3): void;
  69683. /**
  69684. * Returns the agent velocity in world space
  69685. * @param index agent index returned by addAgent
  69686. * @returns world space velocity
  69687. */
  69688. getAgentVelocity(index: number): Vector3;
  69689. /**
  69690. * Returns the agent velocity result in world space
  69691. * @param index agent index returned by addAgent
  69692. * @param result output world space velocity
  69693. */
  69694. getAgentVelocityToRef(index: number, result: Vector3): void;
  69695. /**
  69696. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  69697. * @param index agent index returned by addAgent
  69698. * @param destination targeted world position
  69699. */
  69700. agentGoto(index: number, destination: Vector3): void;
  69701. /**
  69702. * Teleport the agent to a new position
  69703. * @param index agent index returned by addAgent
  69704. * @param destination targeted world position
  69705. */
  69706. agentTeleport(index: number, destination: Vector3): void;
  69707. /**
  69708. * Update agent parameters
  69709. * @param index agent index returned by addAgent
  69710. * @param parameters agent parameters
  69711. */
  69712. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  69713. /**
  69714. * remove a particular agent previously created
  69715. * @param index agent index returned by addAgent
  69716. */
  69717. removeAgent(index: number): void;
  69718. /**
  69719. * get the list of all agents attached to this crowd
  69720. * @returns list of agent indices
  69721. */
  69722. getAgents(): number[];
  69723. /**
  69724. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  69725. * @param deltaTime in seconds
  69726. */
  69727. update(deltaTime: number): void;
  69728. /**
  69729. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69730. * The queries will try to find a solution within those bounds
  69731. * default is (1,1,1)
  69732. * @param extent x,y,z value that define the extent around the queries point of reference
  69733. */
  69734. setDefaultQueryExtent(extent: Vector3): void;
  69735. /**
  69736. * Get the Bounding box extent specified by setDefaultQueryExtent
  69737. * @returns the box extent values
  69738. */
  69739. getDefaultQueryExtent(): Vector3;
  69740. /**
  69741. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69742. * @param result output the box extent values
  69743. */
  69744. getDefaultQueryExtentToRef(result: Vector3): void;
  69745. /**
  69746. * Release all resources
  69747. */
  69748. dispose(): void;
  69749. }
  69750. }
  69751. declare module "babylonjs/Navigation/Plugins/index" {
  69752. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  69753. }
  69754. declare module "babylonjs/Navigation/index" {
  69755. export * from "babylonjs/Navigation/INavigationEngine";
  69756. export * from "babylonjs/Navigation/Plugins/index";
  69757. }
  69758. declare module "babylonjs/Offline/database" {
  69759. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  69760. /**
  69761. * Class used to enable access to IndexedDB
  69762. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69763. */
  69764. export class Database implements IOfflineProvider {
  69765. private _callbackManifestChecked;
  69766. private _currentSceneUrl;
  69767. private _db;
  69768. private _enableSceneOffline;
  69769. private _enableTexturesOffline;
  69770. private _manifestVersionFound;
  69771. private _mustUpdateRessources;
  69772. private _hasReachedQuota;
  69773. private _isSupported;
  69774. private _idbFactory;
  69775. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  69776. private static IsUASupportingBlobStorage;
  69777. /**
  69778. * Gets a boolean indicating if Database storate is enabled (off by default)
  69779. */
  69780. static IDBStorageEnabled: boolean;
  69781. /**
  69782. * Gets a boolean indicating if scene must be saved in the database
  69783. */
  69784. get enableSceneOffline(): boolean;
  69785. /**
  69786. * Gets a boolean indicating if textures must be saved in the database
  69787. */
  69788. get enableTexturesOffline(): boolean;
  69789. /**
  69790. * Creates a new Database
  69791. * @param urlToScene defines the url to load the scene
  69792. * @param callbackManifestChecked defines the callback to use when manifest is checked
  69793. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  69794. */
  69795. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  69796. private static _ParseURL;
  69797. private static _ReturnFullUrlLocation;
  69798. private _checkManifestFile;
  69799. /**
  69800. * Open the database and make it available
  69801. * @param successCallback defines the callback to call on success
  69802. * @param errorCallback defines the callback to call on error
  69803. */
  69804. open(successCallback: () => void, errorCallback: () => void): void;
  69805. /**
  69806. * Loads an image from the database
  69807. * @param url defines the url to load from
  69808. * @param image defines the target DOM image
  69809. */
  69810. loadImage(url: string, image: HTMLImageElement): void;
  69811. private _loadImageFromDBAsync;
  69812. private _saveImageIntoDBAsync;
  69813. private _checkVersionFromDB;
  69814. private _loadVersionFromDBAsync;
  69815. private _saveVersionIntoDBAsync;
  69816. /**
  69817. * Loads a file from database
  69818. * @param url defines the URL to load from
  69819. * @param sceneLoaded defines a callback to call on success
  69820. * @param progressCallBack defines a callback to call when progress changed
  69821. * @param errorCallback defines a callback to call on error
  69822. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69823. */
  69824. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69825. private _loadFileAsync;
  69826. private _saveFileAsync;
  69827. /**
  69828. * Validates if xhr data is correct
  69829. * @param xhr defines the request to validate
  69830. * @param dataType defines the expected data type
  69831. * @returns true if data is correct
  69832. */
  69833. private static _ValidateXHRData;
  69834. }
  69835. }
  69836. declare module "babylonjs/Offline/index" {
  69837. export * from "babylonjs/Offline/database";
  69838. export * from "babylonjs/Offline/IOfflineProvider";
  69839. }
  69840. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  69841. /** @hidden */
  69842. export var gpuUpdateParticlesPixelShader: {
  69843. name: string;
  69844. shader: string;
  69845. };
  69846. }
  69847. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  69848. /** @hidden */
  69849. export var gpuUpdateParticlesVertexShader: {
  69850. name: string;
  69851. shader: string;
  69852. };
  69853. }
  69854. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  69855. /** @hidden */
  69856. export var clipPlaneFragmentDeclaration2: {
  69857. name: string;
  69858. shader: string;
  69859. };
  69860. }
  69861. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  69862. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  69863. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  69864. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  69865. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  69866. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  69867. /** @hidden */
  69868. export var gpuRenderParticlesPixelShader: {
  69869. name: string;
  69870. shader: string;
  69871. };
  69872. }
  69873. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  69874. /** @hidden */
  69875. export var clipPlaneVertexDeclaration2: {
  69876. name: string;
  69877. shader: string;
  69878. };
  69879. }
  69880. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  69881. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  69882. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  69883. /** @hidden */
  69884. export var gpuRenderParticlesVertexShader: {
  69885. name: string;
  69886. shader: string;
  69887. };
  69888. }
  69889. declare module "babylonjs/Particles/gpuParticleSystem" {
  69890. import { Nullable } from "babylonjs/types";
  69891. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  69892. import { Observable } from "babylonjs/Misc/observable";
  69893. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69894. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69895. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  69896. import { Scene, IDisposable } from "babylonjs/scene";
  69897. import { Effect } from "babylonjs/Materials/effect";
  69898. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  69899. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69900. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  69901. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  69902. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  69903. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  69904. /**
  69905. * This represents a GPU particle system in Babylon
  69906. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  69907. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  69908. */
  69909. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  69910. /**
  69911. * The layer mask we are rendering the particles through.
  69912. */
  69913. layerMask: number;
  69914. private _capacity;
  69915. private _activeCount;
  69916. private _currentActiveCount;
  69917. private _accumulatedCount;
  69918. private _renderEffect;
  69919. private _updateEffect;
  69920. private _buffer0;
  69921. private _buffer1;
  69922. private _spriteBuffer;
  69923. private _updateVAO;
  69924. private _renderVAO;
  69925. private _targetIndex;
  69926. private _sourceBuffer;
  69927. private _targetBuffer;
  69928. private _engine;
  69929. private _currentRenderId;
  69930. private _started;
  69931. private _stopped;
  69932. private _timeDelta;
  69933. private _randomTexture;
  69934. private _randomTexture2;
  69935. private _attributesStrideSize;
  69936. private _updateEffectOptions;
  69937. private _randomTextureSize;
  69938. private _actualFrame;
  69939. private _customEffect;
  69940. private readonly _rawTextureWidth;
  69941. /**
  69942. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  69943. */
  69944. static get IsSupported(): boolean;
  69945. /**
  69946. * An event triggered when the system is disposed.
  69947. */
  69948. onDisposeObservable: Observable<IParticleSystem>;
  69949. /**
  69950. * Gets the maximum number of particles active at the same time.
  69951. * @returns The max number of active particles.
  69952. */
  69953. getCapacity(): number;
  69954. /**
  69955. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  69956. * to override the particles.
  69957. */
  69958. forceDepthWrite: boolean;
  69959. /**
  69960. * Gets or set the number of active particles
  69961. */
  69962. get activeParticleCount(): number;
  69963. set activeParticleCount(value: number);
  69964. private _preWarmDone;
  69965. /**
  69966. * Specifies if the particles are updated in emitter local space or world space.
  69967. */
  69968. isLocal: boolean;
  69969. /**
  69970. * Is this system ready to be used/rendered
  69971. * @return true if the system is ready
  69972. */
  69973. isReady(): boolean;
  69974. /**
  69975. * Gets if the system has been started. (Note: this will still be true after stop is called)
  69976. * @returns True if it has been started, otherwise false.
  69977. */
  69978. isStarted(): boolean;
  69979. /**
  69980. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  69981. * @returns True if it has been stopped, otherwise false.
  69982. */
  69983. isStopped(): boolean;
  69984. /**
  69985. * Gets a boolean indicating that the system is stopping
  69986. * @returns true if the system is currently stopping
  69987. */
  69988. isStopping(): boolean;
  69989. /**
  69990. * Gets the number of particles active at the same time.
  69991. * @returns The number of active particles.
  69992. */
  69993. getActiveCount(): number;
  69994. /**
  69995. * Starts the particle system and begins to emit
  69996. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  69997. */
  69998. start(delay?: number): void;
  69999. /**
  70000. * Stops the particle system.
  70001. */
  70002. stop(): void;
  70003. /**
  70004. * Remove all active particles
  70005. */
  70006. reset(): void;
  70007. /**
  70008. * Returns the string "GPUParticleSystem"
  70009. * @returns a string containing the class name
  70010. */
  70011. getClassName(): string;
  70012. /**
  70013. * Gets the custom effect used to render the particles
  70014. * @param blendMode Blend mode for which the effect should be retrieved
  70015. * @returns The effect
  70016. */
  70017. getCustomEffect(blendMode?: number): Nullable<Effect>;
  70018. /**
  70019. * Sets the custom effect used to render the particles
  70020. * @param effect The effect to set
  70021. * @param blendMode Blend mode for which the effect should be set
  70022. */
  70023. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  70024. /** @hidden */
  70025. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  70026. /**
  70027. * Observable that will be called just before the particles are drawn
  70028. */
  70029. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  70030. /**
  70031. * Gets the name of the particle vertex shader
  70032. */
  70033. get vertexShaderName(): string;
  70034. private _colorGradientsTexture;
  70035. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  70036. /**
  70037. * Adds a new color gradient
  70038. * @param gradient defines the gradient to use (between 0 and 1)
  70039. * @param color1 defines the color to affect to the specified gradient
  70040. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  70041. * @returns the current particle system
  70042. */
  70043. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  70044. private _refreshColorGradient;
  70045. /** Force the system to rebuild all gradients that need to be resync */
  70046. forceRefreshGradients(): void;
  70047. /**
  70048. * Remove a specific color gradient
  70049. * @param gradient defines the gradient to remove
  70050. * @returns the current particle system
  70051. */
  70052. removeColorGradient(gradient: number): GPUParticleSystem;
  70053. private _angularSpeedGradientsTexture;
  70054. private _sizeGradientsTexture;
  70055. private _velocityGradientsTexture;
  70056. private _limitVelocityGradientsTexture;
  70057. private _dragGradientsTexture;
  70058. private _addFactorGradient;
  70059. /**
  70060. * Adds a new size gradient
  70061. * @param gradient defines the gradient to use (between 0 and 1)
  70062. * @param factor defines the size factor to affect to the specified gradient
  70063. * @returns the current particle system
  70064. */
  70065. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  70066. /**
  70067. * Remove a specific size gradient
  70068. * @param gradient defines the gradient to remove
  70069. * @returns the current particle system
  70070. */
  70071. removeSizeGradient(gradient: number): GPUParticleSystem;
  70072. private _refreshFactorGradient;
  70073. /**
  70074. * Adds a new angular speed gradient
  70075. * @param gradient defines the gradient to use (between 0 and 1)
  70076. * @param factor defines the angular speed to affect to the specified gradient
  70077. * @returns the current particle system
  70078. */
  70079. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  70080. /**
  70081. * Remove a specific angular speed gradient
  70082. * @param gradient defines the gradient to remove
  70083. * @returns the current particle system
  70084. */
  70085. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  70086. /**
  70087. * Adds a new velocity gradient
  70088. * @param gradient defines the gradient to use (between 0 and 1)
  70089. * @param factor defines the velocity to affect to the specified gradient
  70090. * @returns the current particle system
  70091. */
  70092. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  70093. /**
  70094. * Remove a specific velocity gradient
  70095. * @param gradient defines the gradient to remove
  70096. * @returns the current particle system
  70097. */
  70098. removeVelocityGradient(gradient: number): GPUParticleSystem;
  70099. /**
  70100. * Adds a new limit velocity gradient
  70101. * @param gradient defines the gradient to use (between 0 and 1)
  70102. * @param factor defines the limit velocity value to affect to the specified gradient
  70103. * @returns the current particle system
  70104. */
  70105. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  70106. /**
  70107. * Remove a specific limit velocity gradient
  70108. * @param gradient defines the gradient to remove
  70109. * @returns the current particle system
  70110. */
  70111. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  70112. /**
  70113. * Adds a new drag gradient
  70114. * @param gradient defines the gradient to use (between 0 and 1)
  70115. * @param factor defines the drag value to affect to the specified gradient
  70116. * @returns the current particle system
  70117. */
  70118. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  70119. /**
  70120. * Remove a specific drag gradient
  70121. * @param gradient defines the gradient to remove
  70122. * @returns the current particle system
  70123. */
  70124. removeDragGradient(gradient: number): GPUParticleSystem;
  70125. /**
  70126. * Not supported by GPUParticleSystem
  70127. * @param gradient defines the gradient to use (between 0 and 1)
  70128. * @param factor defines the emit rate value to affect to the specified gradient
  70129. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70130. * @returns the current particle system
  70131. */
  70132. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70133. /**
  70134. * Not supported by GPUParticleSystem
  70135. * @param gradient defines the gradient to remove
  70136. * @returns the current particle system
  70137. */
  70138. removeEmitRateGradient(gradient: number): IParticleSystem;
  70139. /**
  70140. * Not supported by GPUParticleSystem
  70141. * @param gradient defines the gradient to use (between 0 and 1)
  70142. * @param factor defines the start size value to affect to the specified gradient
  70143. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70144. * @returns the current particle system
  70145. */
  70146. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70147. /**
  70148. * Not supported by GPUParticleSystem
  70149. * @param gradient defines the gradient to remove
  70150. * @returns the current particle system
  70151. */
  70152. removeStartSizeGradient(gradient: number): IParticleSystem;
  70153. /**
  70154. * Not supported by GPUParticleSystem
  70155. * @param gradient defines the gradient to use (between 0 and 1)
  70156. * @param min defines the color remap minimal range
  70157. * @param max defines the color remap maximal range
  70158. * @returns the current particle system
  70159. */
  70160. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70161. /**
  70162. * Not supported by GPUParticleSystem
  70163. * @param gradient defines the gradient to remove
  70164. * @returns the current particle system
  70165. */
  70166. removeColorRemapGradient(): IParticleSystem;
  70167. /**
  70168. * Not supported by GPUParticleSystem
  70169. * @param gradient defines the gradient to use (between 0 and 1)
  70170. * @param min defines the alpha remap minimal range
  70171. * @param max defines the alpha remap maximal range
  70172. * @returns the current particle system
  70173. */
  70174. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70175. /**
  70176. * Not supported by GPUParticleSystem
  70177. * @param gradient defines the gradient to remove
  70178. * @returns the current particle system
  70179. */
  70180. removeAlphaRemapGradient(): IParticleSystem;
  70181. /**
  70182. * Not supported by GPUParticleSystem
  70183. * @param gradient defines the gradient to use (between 0 and 1)
  70184. * @param color defines the color to affect to the specified gradient
  70185. * @returns the current particle system
  70186. */
  70187. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  70188. /**
  70189. * Not supported by GPUParticleSystem
  70190. * @param gradient defines the gradient to remove
  70191. * @returns the current particle system
  70192. */
  70193. removeRampGradient(): IParticleSystem;
  70194. /**
  70195. * Not supported by GPUParticleSystem
  70196. * @returns the list of ramp gradients
  70197. */
  70198. getRampGradients(): Nullable<Array<Color3Gradient>>;
  70199. /**
  70200. * Not supported by GPUParticleSystem
  70201. * Gets or sets a boolean indicating that ramp gradients must be used
  70202. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  70203. */
  70204. get useRampGradients(): boolean;
  70205. set useRampGradients(value: boolean);
  70206. /**
  70207. * Not supported by GPUParticleSystem
  70208. * @param gradient defines the gradient to use (between 0 and 1)
  70209. * @param factor defines the life time factor to affect to the specified gradient
  70210. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70211. * @returns the current particle system
  70212. */
  70213. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70214. /**
  70215. * Not supported by GPUParticleSystem
  70216. * @param gradient defines the gradient to remove
  70217. * @returns the current particle system
  70218. */
  70219. removeLifeTimeGradient(gradient: number): IParticleSystem;
  70220. /**
  70221. * Instantiates a GPU particle system.
  70222. * 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.
  70223. * @param name The name of the particle system
  70224. * @param options The options used to create the system
  70225. * @param scene The scene the particle system belongs to
  70226. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  70227. * @param customEffect a custom effect used to change the way particles are rendered by default
  70228. */
  70229. constructor(name: string, options: Partial<{
  70230. capacity: number;
  70231. randomTextureSize: number;
  70232. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  70233. protected _reset(): void;
  70234. private _createUpdateVAO;
  70235. private _createRenderVAO;
  70236. private _initialize;
  70237. /** @hidden */
  70238. _recreateUpdateEffect(): void;
  70239. private _getEffect;
  70240. /**
  70241. * Fill the defines array according to the current settings of the particle system
  70242. * @param defines Array to be updated
  70243. * @param blendMode blend mode to take into account when updating the array
  70244. */
  70245. fillDefines(defines: Array<string>, blendMode?: number): void;
  70246. /**
  70247. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  70248. * @param uniforms Uniforms array to fill
  70249. * @param attributes Attributes array to fill
  70250. * @param samplers Samplers array to fill
  70251. */
  70252. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  70253. /** @hidden */
  70254. _recreateRenderEffect(): Effect;
  70255. /**
  70256. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  70257. * @param preWarm defines if we are in the pre-warmimg phase
  70258. */
  70259. animate(preWarm?: boolean): void;
  70260. private _createFactorGradientTexture;
  70261. private _createSizeGradientTexture;
  70262. private _createAngularSpeedGradientTexture;
  70263. private _createVelocityGradientTexture;
  70264. private _createLimitVelocityGradientTexture;
  70265. private _createDragGradientTexture;
  70266. private _createColorGradientTexture;
  70267. /**
  70268. * Renders the particle system in its current state
  70269. * @param preWarm defines if the system should only update the particles but not render them
  70270. * @returns the current number of particles
  70271. */
  70272. render(preWarm?: boolean): number;
  70273. /**
  70274. * Rebuilds the particle system
  70275. */
  70276. rebuild(): void;
  70277. private _releaseBuffers;
  70278. private _releaseVAOs;
  70279. /**
  70280. * Disposes the particle system and free the associated resources
  70281. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  70282. */
  70283. dispose(disposeTexture?: boolean): void;
  70284. /**
  70285. * Clones the particle system.
  70286. * @param name The name of the cloned object
  70287. * @param newEmitter The new emitter to use
  70288. * @returns the cloned particle system
  70289. */
  70290. clone(name: string, newEmitter: any): GPUParticleSystem;
  70291. /**
  70292. * Serializes the particle system to a JSON object
  70293. * @param serializeTexture defines if the texture must be serialized as well
  70294. * @returns the JSON object
  70295. */
  70296. serialize(serializeTexture?: boolean): any;
  70297. /**
  70298. * Parses a JSON object to create a GPU particle system.
  70299. * @param parsedParticleSystem The JSON object to parse
  70300. * @param scene The scene to create the particle system in
  70301. * @param rootUrl The root url to use to load external dependencies like texture
  70302. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  70303. * @returns the parsed GPU particle system
  70304. */
  70305. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  70306. }
  70307. }
  70308. declare module "babylonjs/Particles/particleSystemSet" {
  70309. import { Nullable } from "babylonjs/types";
  70310. import { Color3 } from "babylonjs/Maths/math.color";
  70311. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70313. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70314. import { Scene, IDisposable } from "babylonjs/scene";
  70315. /**
  70316. * Represents a set of particle systems working together to create a specific effect
  70317. */
  70318. export class ParticleSystemSet implements IDisposable {
  70319. /**
  70320. * Gets or sets base Assets URL
  70321. */
  70322. static BaseAssetsUrl: string;
  70323. private _emitterCreationOptions;
  70324. private _emitterNode;
  70325. /**
  70326. * Gets the particle system list
  70327. */
  70328. systems: IParticleSystem[];
  70329. /**
  70330. * Gets the emitter node used with this set
  70331. */
  70332. get emitterNode(): Nullable<TransformNode>;
  70333. /**
  70334. * Creates a new emitter mesh as a sphere
  70335. * @param options defines the options used to create the sphere
  70336. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  70337. * @param scene defines the hosting scene
  70338. */
  70339. setEmitterAsSphere(options: {
  70340. diameter: number;
  70341. segments: number;
  70342. color: Color3;
  70343. }, renderingGroupId: number, scene: Scene): void;
  70344. /**
  70345. * Starts all particle systems of the set
  70346. * @param emitter defines an optional mesh to use as emitter for the particle systems
  70347. */
  70348. start(emitter?: AbstractMesh): void;
  70349. /**
  70350. * Release all associated resources
  70351. */
  70352. dispose(): void;
  70353. /**
  70354. * Serialize the set into a JSON compatible object
  70355. * @param serializeTexture defines if the texture must be serialized as well
  70356. * @returns a JSON compatible representation of the set
  70357. */
  70358. serialize(serializeTexture?: boolean): any;
  70359. /**
  70360. * Parse a new ParticleSystemSet from a serialized source
  70361. * @param data defines a JSON compatible representation of the set
  70362. * @param scene defines the hosting scene
  70363. * @param gpu defines if we want GPU particles or CPU particles
  70364. * @returns a new ParticleSystemSet
  70365. */
  70366. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  70367. }
  70368. }
  70369. declare module "babylonjs/Particles/particleHelper" {
  70370. import { Nullable } from "babylonjs/types";
  70371. import { Scene } from "babylonjs/scene";
  70372. import { Vector3 } from "babylonjs/Maths/math.vector";
  70373. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70374. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70375. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  70376. /**
  70377. * This class is made for on one-liner static method to help creating particle system set.
  70378. */
  70379. export class ParticleHelper {
  70380. /**
  70381. * Gets or sets base Assets URL
  70382. */
  70383. static BaseAssetsUrl: string;
  70384. /** Define the Url to load snippets */
  70385. static SnippetUrl: string;
  70386. /**
  70387. * Create a default particle system that you can tweak
  70388. * @param emitter defines the emitter to use
  70389. * @param capacity defines the system capacity (default is 500 particles)
  70390. * @param scene defines the hosting scene
  70391. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  70392. * @returns the new Particle system
  70393. */
  70394. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  70395. /**
  70396. * This is the main static method (one-liner) of this helper to create different particle systems
  70397. * @param type This string represents the type to the particle system to create
  70398. * @param scene The scene where the particle system should live
  70399. * @param gpu If the system will use gpu
  70400. * @returns the ParticleSystemSet created
  70401. */
  70402. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  70403. /**
  70404. * Static function used to export a particle system to a ParticleSystemSet variable.
  70405. * Please note that the emitter shape is not exported
  70406. * @param systems defines the particle systems to export
  70407. * @returns the created particle system set
  70408. */
  70409. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  70410. /**
  70411. * Creates a particle system from a snippet saved in a remote file
  70412. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  70413. * @param url defines the url to load from
  70414. * @param scene defines the hosting scene
  70415. * @param gpu If the system will use gpu
  70416. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70417. * @returns a promise that will resolve to the new particle system
  70418. */
  70419. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  70420. /**
  70421. * Creates a particle system from a snippet saved by the particle system editor
  70422. * @param snippetId defines the snippet to load
  70423. * @param scene defines the hosting scene
  70424. * @param gpu If the system will use gpu
  70425. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70426. * @returns a promise that will resolve to the new particle system
  70427. */
  70428. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  70429. }
  70430. }
  70431. declare module "babylonjs/Particles/particleSystemComponent" {
  70432. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70433. import { Effect } from "babylonjs/Materials/effect";
  70434. import "babylonjs/Shaders/particles.vertex";
  70435. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  70436. module "babylonjs/Engines/engine" {
  70437. interface Engine {
  70438. /**
  70439. * Create an effect to use with particle systems.
  70440. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  70441. * the particle system for which you want to create a custom effect in the last parameter
  70442. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  70443. * @param uniformsNames defines a list of attribute names
  70444. * @param samplers defines an array of string used to represent textures
  70445. * @param defines defines the string containing the defines to use to compile the shaders
  70446. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  70447. * @param onCompiled defines a function to call when the effect creation is successful
  70448. * @param onError defines a function to call when the effect creation has failed
  70449. * @param particleSystem the particle system you want to create the effect for
  70450. * @returns the new Effect
  70451. */
  70452. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  70453. }
  70454. }
  70455. module "babylonjs/Meshes/mesh" {
  70456. interface Mesh {
  70457. /**
  70458. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  70459. * @returns an array of IParticleSystem
  70460. */
  70461. getEmittedParticleSystems(): IParticleSystem[];
  70462. /**
  70463. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  70464. * @returns an array of IParticleSystem
  70465. */
  70466. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  70467. }
  70468. }
  70469. }
  70470. declare module "babylonjs/Particles/pointsCloudSystem" {
  70471. import { Color4 } from "babylonjs/Maths/math";
  70472. import { Mesh } from "babylonjs/Meshes/mesh";
  70473. import { Scene, IDisposable } from "babylonjs/scene";
  70474. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  70475. /** Defines the 4 color options */
  70476. export enum PointColor {
  70477. /** color value */
  70478. Color = 2,
  70479. /** uv value */
  70480. UV = 1,
  70481. /** random value */
  70482. Random = 0,
  70483. /** stated value */
  70484. Stated = 3
  70485. }
  70486. /**
  70487. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  70488. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  70489. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  70490. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  70491. *
  70492. * Full documentation here : TO BE ENTERED
  70493. */
  70494. export class PointsCloudSystem implements IDisposable {
  70495. /**
  70496. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  70497. * Example : var p = SPS.particles[i];
  70498. */
  70499. particles: CloudPoint[];
  70500. /**
  70501. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  70502. */
  70503. nbParticles: number;
  70504. /**
  70505. * This a counter for your own usage. It's not set by any SPS functions.
  70506. */
  70507. counter: number;
  70508. /**
  70509. * The PCS name. This name is also given to the underlying mesh.
  70510. */
  70511. name: string;
  70512. /**
  70513. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  70514. */
  70515. mesh: Mesh;
  70516. /**
  70517. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  70518. * Please read :
  70519. */
  70520. vars: any;
  70521. /**
  70522. * @hidden
  70523. */
  70524. _size: number;
  70525. private _scene;
  70526. private _promises;
  70527. private _positions;
  70528. private _indices;
  70529. private _normals;
  70530. private _colors;
  70531. private _uvs;
  70532. private _indices32;
  70533. private _positions32;
  70534. private _colors32;
  70535. private _uvs32;
  70536. private _updatable;
  70537. private _isVisibilityBoxLocked;
  70538. private _alwaysVisible;
  70539. private _groups;
  70540. private _groupCounter;
  70541. private _computeParticleColor;
  70542. private _computeParticleTexture;
  70543. private _computeParticleRotation;
  70544. private _computeBoundingBox;
  70545. private _isReady;
  70546. /**
  70547. * Creates a PCS (Points Cloud System) object
  70548. * @param name (String) is the PCS name, this will be the underlying mesh name
  70549. * @param pointSize (number) is the size for each point
  70550. * @param scene (Scene) is the scene in which the PCS is added
  70551. * @param options defines the options of the PCS e.g.
  70552. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  70553. */
  70554. constructor(name: string, pointSize: number, scene: Scene, options?: {
  70555. updatable?: boolean;
  70556. });
  70557. /**
  70558. * Builds the PCS underlying mesh. Returns a standard Mesh.
  70559. * If no points were added to the PCS, the returned mesh is just a single point.
  70560. * @returns a promise for the created mesh
  70561. */
  70562. buildMeshAsync(): Promise<Mesh>;
  70563. /**
  70564. * @hidden
  70565. */
  70566. private _buildMesh;
  70567. private _addParticle;
  70568. private _randomUnitVector;
  70569. private _getColorIndicesForCoord;
  70570. private _setPointsColorOrUV;
  70571. private _colorFromTexture;
  70572. private _calculateDensity;
  70573. /**
  70574. * Adds points to the PCS in random positions within a unit sphere
  70575. * @param nb (positive integer) the number of particles to be created from this model
  70576. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  70577. * @returns the number of groups in the system
  70578. */
  70579. addPoints(nb: number, pointFunction?: any): number;
  70580. /**
  70581. * Adds points to the PCS from the surface of the model shape
  70582. * @param mesh is any Mesh object that will be used as a surface model for the points
  70583. * @param nb (positive integer) the number of particles to be created from this model
  70584. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  70585. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  70586. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  70587. * @returns the number of groups in the system
  70588. */
  70589. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  70590. /**
  70591. * Adds points to the PCS inside the model shape
  70592. * @param mesh is any Mesh object that will be used as a surface model for the points
  70593. * @param nb (positive integer) the number of particles to be created from this model
  70594. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  70595. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  70596. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  70597. * @returns the number of groups in the system
  70598. */
  70599. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  70600. /**
  70601. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  70602. * This method calls `updateParticle()` for each particle of the SPS.
  70603. * For an animated SPS, it is usually called within the render loop.
  70604. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  70605. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  70606. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  70607. * @returns the PCS.
  70608. */
  70609. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  70610. /**
  70611. * Disposes the PCS.
  70612. */
  70613. dispose(): void;
  70614. /**
  70615. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  70616. * doc :
  70617. * @returns the PCS.
  70618. */
  70619. refreshVisibleSize(): PointsCloudSystem;
  70620. /**
  70621. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  70622. * @param size the size (float) of the visibility box
  70623. * note : this doesn't lock the PCS mesh bounding box.
  70624. * doc :
  70625. */
  70626. setVisibilityBox(size: number): void;
  70627. /**
  70628. * Gets whether the PCS is always visible or not
  70629. * doc :
  70630. */
  70631. get isAlwaysVisible(): boolean;
  70632. /**
  70633. * Sets the PCS as always visible or not
  70634. * doc :
  70635. */
  70636. set isAlwaysVisible(val: boolean);
  70637. /**
  70638. * Tells to `setParticles()` to compute the particle rotations or not
  70639. * Default value : false. The PCS is faster when it's set to false
  70640. * Note : particle rotations are only applied to parent particles
  70641. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  70642. */
  70643. set computeParticleRotation(val: boolean);
  70644. /**
  70645. * Tells to `setParticles()` to compute the particle colors or not.
  70646. * Default value : true. The PCS is faster when it's set to false.
  70647. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  70648. */
  70649. set computeParticleColor(val: boolean);
  70650. set computeParticleTexture(val: boolean);
  70651. /**
  70652. * Gets if `setParticles()` computes the particle colors or not.
  70653. * Default value : false. The PCS is faster when it's set to false.
  70654. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  70655. */
  70656. get computeParticleColor(): boolean;
  70657. /**
  70658. * Gets if `setParticles()` computes the particle textures or not.
  70659. * Default value : false. The PCS is faster when it's set to false.
  70660. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  70661. */
  70662. get computeParticleTexture(): boolean;
  70663. /**
  70664. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  70665. */
  70666. set computeBoundingBox(val: boolean);
  70667. /**
  70668. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  70669. */
  70670. get computeBoundingBox(): boolean;
  70671. /**
  70672. * This function does nothing. It may be overwritten to set all the particle first values.
  70673. * The PCS doesn't call this function, you may have to call it by your own.
  70674. * doc :
  70675. */
  70676. initParticles(): void;
  70677. /**
  70678. * This function does nothing. It may be overwritten to recycle a particle
  70679. * The PCS doesn't call this function, you can to call it
  70680. * doc :
  70681. * @param particle The particle to recycle
  70682. * @returns the recycled particle
  70683. */
  70684. recycleParticle(particle: CloudPoint): CloudPoint;
  70685. /**
  70686. * Updates a particle : this function should be overwritten by the user.
  70687. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  70688. * doc :
  70689. * @example : just set a particle position or velocity and recycle conditions
  70690. * @param particle The particle to update
  70691. * @returns the updated particle
  70692. */
  70693. updateParticle(particle: CloudPoint): CloudPoint;
  70694. /**
  70695. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  70696. * This does nothing and may be overwritten by the user.
  70697. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  70698. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  70699. * @param update the boolean update value actually passed to setParticles()
  70700. */
  70701. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  70702. /**
  70703. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  70704. * This will be passed three parameters.
  70705. * This does nothing and may be overwritten by the user.
  70706. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  70707. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  70708. * @param update the boolean update value actually passed to setParticles()
  70709. */
  70710. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  70711. }
  70712. }
  70713. declare module "babylonjs/Particles/cloudPoint" {
  70714. import { Nullable } from "babylonjs/types";
  70715. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  70716. import { Mesh } from "babylonjs/Meshes/mesh";
  70717. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  70718. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  70719. /**
  70720. * Represents one particle of a points cloud system.
  70721. */
  70722. export class CloudPoint {
  70723. /**
  70724. * particle global index
  70725. */
  70726. idx: number;
  70727. /**
  70728. * The color of the particle
  70729. */
  70730. color: Nullable<Color4>;
  70731. /**
  70732. * The world space position of the particle.
  70733. */
  70734. position: Vector3;
  70735. /**
  70736. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  70737. */
  70738. rotation: Vector3;
  70739. /**
  70740. * The world space rotation quaternion of the particle.
  70741. */
  70742. rotationQuaternion: Nullable<Quaternion>;
  70743. /**
  70744. * The uv of the particle.
  70745. */
  70746. uv: Nullable<Vector2>;
  70747. /**
  70748. * The current speed of the particle.
  70749. */
  70750. velocity: Vector3;
  70751. /**
  70752. * The pivot point in the particle local space.
  70753. */
  70754. pivot: Vector3;
  70755. /**
  70756. * Must the particle be translated from its pivot point in its local space ?
  70757. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  70758. * Default : false
  70759. */
  70760. translateFromPivot: boolean;
  70761. /**
  70762. * Index of this particle in the global "positions" array (Internal use)
  70763. * @hidden
  70764. */
  70765. _pos: number;
  70766. /**
  70767. * @hidden Index of this particle in the global "indices" array (Internal use)
  70768. */
  70769. _ind: number;
  70770. /**
  70771. * Group this particle belongs to
  70772. */
  70773. _group: PointsGroup;
  70774. /**
  70775. * Group id of this particle
  70776. */
  70777. groupId: number;
  70778. /**
  70779. * Index of the particle in its group id (Internal use)
  70780. */
  70781. idxInGroup: number;
  70782. /**
  70783. * @hidden Particle BoundingInfo object (Internal use)
  70784. */
  70785. _boundingInfo: BoundingInfo;
  70786. /**
  70787. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  70788. */
  70789. _pcs: PointsCloudSystem;
  70790. /**
  70791. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  70792. */
  70793. _stillInvisible: boolean;
  70794. /**
  70795. * @hidden Last computed particle rotation matrix
  70796. */
  70797. _rotationMatrix: number[];
  70798. /**
  70799. * Parent particle Id, if any.
  70800. * Default null.
  70801. */
  70802. parentId: Nullable<number>;
  70803. /**
  70804. * @hidden Internal global position in the PCS.
  70805. */
  70806. _globalPosition: Vector3;
  70807. /**
  70808. * Creates a Point Cloud object.
  70809. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  70810. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  70811. * @param group (PointsGroup) is the group the particle belongs to
  70812. * @param groupId (integer) is the group identifier in the PCS.
  70813. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  70814. * @param pcs defines the PCS it is associated to
  70815. */
  70816. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  70817. /**
  70818. * get point size
  70819. */
  70820. get size(): Vector3;
  70821. /**
  70822. * Set point size
  70823. */
  70824. set size(scale: Vector3);
  70825. /**
  70826. * Legacy support, changed quaternion to rotationQuaternion
  70827. */
  70828. get quaternion(): Nullable<Quaternion>;
  70829. /**
  70830. * Legacy support, changed quaternion to rotationQuaternion
  70831. */
  70832. set quaternion(q: Nullable<Quaternion>);
  70833. /**
  70834. * Returns a boolean. True if the particle intersects a mesh, else false
  70835. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  70836. * @param target is the object (point or mesh) what the intersection is computed against
  70837. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  70838. * @returns true if it intersects
  70839. */
  70840. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  70841. /**
  70842. * get the rotation matrix of the particle
  70843. * @hidden
  70844. */
  70845. getRotationMatrix(m: Matrix): void;
  70846. }
  70847. /**
  70848. * Represents a group of points in a points cloud system
  70849. * * PCS internal tool, don't use it manually.
  70850. */
  70851. export class PointsGroup {
  70852. /**
  70853. * The group id
  70854. * @hidden
  70855. */
  70856. groupID: number;
  70857. /**
  70858. * image data for group (internal use)
  70859. * @hidden
  70860. */
  70861. _groupImageData: Nullable<ArrayBufferView>;
  70862. /**
  70863. * Image Width (internal use)
  70864. * @hidden
  70865. */
  70866. _groupImgWidth: number;
  70867. /**
  70868. * Image Height (internal use)
  70869. * @hidden
  70870. */
  70871. _groupImgHeight: number;
  70872. /**
  70873. * Custom position function (internal use)
  70874. * @hidden
  70875. */
  70876. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  70877. /**
  70878. * density per facet for surface points
  70879. * @hidden
  70880. */
  70881. _groupDensity: number[];
  70882. /**
  70883. * Only when points are colored by texture carries pointer to texture list array
  70884. * @hidden
  70885. */
  70886. _textureNb: number;
  70887. /**
  70888. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  70889. * PCS internal tool, don't use it manually.
  70890. * @hidden
  70891. */
  70892. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  70893. }
  70894. }
  70895. declare module "babylonjs/Particles/index" {
  70896. export * from "babylonjs/Particles/baseParticleSystem";
  70897. export * from "babylonjs/Particles/EmitterTypes/index";
  70898. export * from "babylonjs/Particles/gpuParticleSystem";
  70899. export * from "babylonjs/Particles/IParticleSystem";
  70900. export * from "babylonjs/Particles/particle";
  70901. export * from "babylonjs/Particles/particleHelper";
  70902. export * from "babylonjs/Particles/particleSystem";
  70903. import "babylonjs/Particles/particleSystemComponent";
  70904. export * from "babylonjs/Particles/particleSystemComponent";
  70905. export * from "babylonjs/Particles/particleSystemSet";
  70906. export * from "babylonjs/Particles/solidParticle";
  70907. export * from "babylonjs/Particles/solidParticleSystem";
  70908. export * from "babylonjs/Particles/cloudPoint";
  70909. export * from "babylonjs/Particles/pointsCloudSystem";
  70910. export * from "babylonjs/Particles/subEmitter";
  70911. }
  70912. declare module "babylonjs/Physics/physicsEngineComponent" {
  70913. import { Nullable } from "babylonjs/types";
  70914. import { Observable, Observer } from "babylonjs/Misc/observable";
  70915. import { Vector3 } from "babylonjs/Maths/math.vector";
  70916. import { Mesh } from "babylonjs/Meshes/mesh";
  70917. import { ISceneComponent } from "babylonjs/sceneComponent";
  70918. import { Scene } from "babylonjs/scene";
  70919. import { Node } from "babylonjs/node";
  70920. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  70921. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  70922. module "babylonjs/scene" {
  70923. interface Scene {
  70924. /** @hidden (Backing field) */
  70925. _physicsEngine: Nullable<IPhysicsEngine>;
  70926. /** @hidden */
  70927. _physicsTimeAccumulator: number;
  70928. /**
  70929. * Gets the current physics engine
  70930. * @returns a IPhysicsEngine or null if none attached
  70931. */
  70932. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  70933. /**
  70934. * Enables physics to the current scene
  70935. * @param gravity defines the scene's gravity for the physics engine
  70936. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  70937. * @return a boolean indicating if the physics engine was initialized
  70938. */
  70939. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  70940. /**
  70941. * Disables and disposes the physics engine associated with the scene
  70942. */
  70943. disablePhysicsEngine(): void;
  70944. /**
  70945. * Gets a boolean indicating if there is an active physics engine
  70946. * @returns a boolean indicating if there is an active physics engine
  70947. */
  70948. isPhysicsEnabled(): boolean;
  70949. /**
  70950. * Deletes a physics compound impostor
  70951. * @param compound defines the compound to delete
  70952. */
  70953. deleteCompoundImpostor(compound: any): void;
  70954. /**
  70955. * An event triggered when physic simulation is about to be run
  70956. */
  70957. onBeforePhysicsObservable: Observable<Scene>;
  70958. /**
  70959. * An event triggered when physic simulation has been done
  70960. */
  70961. onAfterPhysicsObservable: Observable<Scene>;
  70962. }
  70963. }
  70964. module "babylonjs/Meshes/abstractMesh" {
  70965. interface AbstractMesh {
  70966. /** @hidden */
  70967. _physicsImpostor: Nullable<PhysicsImpostor>;
  70968. /**
  70969. * Gets or sets impostor used for physic simulation
  70970. * @see https://doc.babylonjs.com/features/physics_engine
  70971. */
  70972. physicsImpostor: Nullable<PhysicsImpostor>;
  70973. /**
  70974. * Gets the current physics impostor
  70975. * @see https://doc.babylonjs.com/features/physics_engine
  70976. * @returns a physics impostor or null
  70977. */
  70978. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  70979. /** Apply a physic impulse to the mesh
  70980. * @param force defines the force to apply
  70981. * @param contactPoint defines where to apply the force
  70982. * @returns the current mesh
  70983. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  70984. */
  70985. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  70986. /**
  70987. * Creates a physic joint between two meshes
  70988. * @param otherMesh defines the other mesh to use
  70989. * @param pivot1 defines the pivot to use on this mesh
  70990. * @param pivot2 defines the pivot to use on the other mesh
  70991. * @param options defines additional options (can be plugin dependent)
  70992. * @returns the current mesh
  70993. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  70994. */
  70995. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  70996. /** @hidden */
  70997. _disposePhysicsObserver: Nullable<Observer<Node>>;
  70998. }
  70999. }
  71000. /**
  71001. * Defines the physics engine scene component responsible to manage a physics engine
  71002. */
  71003. export class PhysicsEngineSceneComponent implements ISceneComponent {
  71004. /**
  71005. * The component name helpful to identify the component in the list of scene components.
  71006. */
  71007. readonly name: string;
  71008. /**
  71009. * The scene the component belongs to.
  71010. */
  71011. scene: Scene;
  71012. /**
  71013. * Creates a new instance of the component for the given scene
  71014. * @param scene Defines the scene to register the component in
  71015. */
  71016. constructor(scene: Scene);
  71017. /**
  71018. * Registers the component in a given scene
  71019. */
  71020. register(): void;
  71021. /**
  71022. * Rebuilds the elements related to this component in case of
  71023. * context lost for instance.
  71024. */
  71025. rebuild(): void;
  71026. /**
  71027. * Disposes the component and the associated ressources
  71028. */
  71029. dispose(): void;
  71030. }
  71031. }
  71032. declare module "babylonjs/Physics/physicsHelper" {
  71033. import { Nullable } from "babylonjs/types";
  71034. import { Vector3 } from "babylonjs/Maths/math.vector";
  71035. import { Mesh } from "babylonjs/Meshes/mesh";
  71036. import { Scene } from "babylonjs/scene";
  71037. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  71038. /**
  71039. * A helper for physics simulations
  71040. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71041. */
  71042. export class PhysicsHelper {
  71043. private _scene;
  71044. private _physicsEngine;
  71045. /**
  71046. * Initializes the Physics helper
  71047. * @param scene Babylon.js scene
  71048. */
  71049. constructor(scene: Scene);
  71050. /**
  71051. * Applies a radial explosion impulse
  71052. * @param origin the origin of the explosion
  71053. * @param radiusOrEventOptions the radius or the options of radial explosion
  71054. * @param strength the explosion strength
  71055. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71056. * @returns A physics radial explosion event, or null
  71057. */
  71058. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71059. /**
  71060. * Applies a radial explosion force
  71061. * @param origin the origin of the explosion
  71062. * @param radiusOrEventOptions the radius or the options of radial explosion
  71063. * @param strength the explosion strength
  71064. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71065. * @returns A physics radial explosion event, or null
  71066. */
  71067. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71068. /**
  71069. * Creates a gravitational field
  71070. * @param origin the origin of the explosion
  71071. * @param radiusOrEventOptions the radius or the options of radial explosion
  71072. * @param strength the explosion strength
  71073. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71074. * @returns A physics gravitational field event, or null
  71075. */
  71076. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  71077. /**
  71078. * Creates a physics updraft event
  71079. * @param origin the origin of the updraft
  71080. * @param radiusOrEventOptions the radius or the options of the updraft
  71081. * @param strength the strength of the updraft
  71082. * @param height the height of the updraft
  71083. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  71084. * @returns A physics updraft event, or null
  71085. */
  71086. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  71087. /**
  71088. * Creates a physics vortex event
  71089. * @param origin the of the vortex
  71090. * @param radiusOrEventOptions the radius or the options of the vortex
  71091. * @param strength the strength of the vortex
  71092. * @param height the height of the vortex
  71093. * @returns a Physics vortex event, or null
  71094. * A physics vortex event or null
  71095. */
  71096. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  71097. }
  71098. /**
  71099. * Represents a physics radial explosion event
  71100. */
  71101. class PhysicsRadialExplosionEvent {
  71102. private _scene;
  71103. private _options;
  71104. private _sphere;
  71105. private _dataFetched;
  71106. /**
  71107. * Initializes a radial explosioin event
  71108. * @param _scene BabylonJS scene
  71109. * @param _options The options for the vortex event
  71110. */
  71111. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  71112. /**
  71113. * Returns the data related to the radial explosion event (sphere).
  71114. * @returns The radial explosion event data
  71115. */
  71116. getData(): PhysicsRadialExplosionEventData;
  71117. /**
  71118. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  71119. * @param impostor A physics imposter
  71120. * @param origin the origin of the explosion
  71121. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  71122. */
  71123. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  71124. /**
  71125. * Triggers affecterd impostors callbacks
  71126. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  71127. */
  71128. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  71129. /**
  71130. * Disposes the sphere.
  71131. * @param force Specifies if the sphere should be disposed by force
  71132. */
  71133. dispose(force?: boolean): void;
  71134. /*** Helpers ***/
  71135. private _prepareSphere;
  71136. private _intersectsWithSphere;
  71137. }
  71138. /**
  71139. * Represents a gravitational field event
  71140. */
  71141. class PhysicsGravitationalFieldEvent {
  71142. private _physicsHelper;
  71143. private _scene;
  71144. private _origin;
  71145. private _options;
  71146. private _tickCallback;
  71147. private _sphere;
  71148. private _dataFetched;
  71149. /**
  71150. * Initializes the physics gravitational field event
  71151. * @param _physicsHelper A physics helper
  71152. * @param _scene BabylonJS scene
  71153. * @param _origin The origin position of the gravitational field event
  71154. * @param _options The options for the vortex event
  71155. */
  71156. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  71157. /**
  71158. * Returns the data related to the gravitational field event (sphere).
  71159. * @returns A gravitational field event
  71160. */
  71161. getData(): PhysicsGravitationalFieldEventData;
  71162. /**
  71163. * Enables the gravitational field.
  71164. */
  71165. enable(): void;
  71166. /**
  71167. * Disables the gravitational field.
  71168. */
  71169. disable(): void;
  71170. /**
  71171. * Disposes the sphere.
  71172. * @param force The force to dispose from the gravitational field event
  71173. */
  71174. dispose(force?: boolean): void;
  71175. private _tick;
  71176. }
  71177. /**
  71178. * Represents a physics updraft event
  71179. */
  71180. class PhysicsUpdraftEvent {
  71181. private _scene;
  71182. private _origin;
  71183. private _options;
  71184. private _physicsEngine;
  71185. private _originTop;
  71186. private _originDirection;
  71187. private _tickCallback;
  71188. private _cylinder;
  71189. private _cylinderPosition;
  71190. private _dataFetched;
  71191. /**
  71192. * Initializes the physics updraft event
  71193. * @param _scene BabylonJS scene
  71194. * @param _origin The origin position of the updraft
  71195. * @param _options The options for the updraft event
  71196. */
  71197. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  71198. /**
  71199. * Returns the data related to the updraft event (cylinder).
  71200. * @returns A physics updraft event
  71201. */
  71202. getData(): PhysicsUpdraftEventData;
  71203. /**
  71204. * Enables the updraft.
  71205. */
  71206. enable(): void;
  71207. /**
  71208. * Disables the updraft.
  71209. */
  71210. disable(): void;
  71211. /**
  71212. * Disposes the cylinder.
  71213. * @param force Specifies if the updraft should be disposed by force
  71214. */
  71215. dispose(force?: boolean): void;
  71216. private getImpostorHitData;
  71217. private _tick;
  71218. /*** Helpers ***/
  71219. private _prepareCylinder;
  71220. private _intersectsWithCylinder;
  71221. }
  71222. /**
  71223. * Represents a physics vortex event
  71224. */
  71225. class PhysicsVortexEvent {
  71226. private _scene;
  71227. private _origin;
  71228. private _options;
  71229. private _physicsEngine;
  71230. private _originTop;
  71231. private _tickCallback;
  71232. private _cylinder;
  71233. private _cylinderPosition;
  71234. private _dataFetched;
  71235. /**
  71236. * Initializes the physics vortex event
  71237. * @param _scene The BabylonJS scene
  71238. * @param _origin The origin position of the vortex
  71239. * @param _options The options for the vortex event
  71240. */
  71241. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  71242. /**
  71243. * Returns the data related to the vortex event (cylinder).
  71244. * @returns The physics vortex event data
  71245. */
  71246. getData(): PhysicsVortexEventData;
  71247. /**
  71248. * Enables the vortex.
  71249. */
  71250. enable(): void;
  71251. /**
  71252. * Disables the cortex.
  71253. */
  71254. disable(): void;
  71255. /**
  71256. * Disposes the sphere.
  71257. * @param force
  71258. */
  71259. dispose(force?: boolean): void;
  71260. private getImpostorHitData;
  71261. private _tick;
  71262. /*** Helpers ***/
  71263. private _prepareCylinder;
  71264. private _intersectsWithCylinder;
  71265. }
  71266. /**
  71267. * Options fot the radial explosion event
  71268. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71269. */
  71270. export class PhysicsRadialExplosionEventOptions {
  71271. /**
  71272. * The radius of the sphere for the radial explosion.
  71273. */
  71274. radius: number;
  71275. /**
  71276. * The strenth of the explosion.
  71277. */
  71278. strength: number;
  71279. /**
  71280. * The strenght of the force in correspondence to the distance of the affected object
  71281. */
  71282. falloff: PhysicsRadialImpulseFalloff;
  71283. /**
  71284. * Sphere options for the radial explosion.
  71285. */
  71286. sphere: {
  71287. segments: number;
  71288. diameter: number;
  71289. };
  71290. /**
  71291. * Sphere options for the radial explosion.
  71292. */
  71293. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  71294. }
  71295. /**
  71296. * Options fot the updraft event
  71297. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71298. */
  71299. export class PhysicsUpdraftEventOptions {
  71300. /**
  71301. * The radius of the cylinder for the vortex
  71302. */
  71303. radius: number;
  71304. /**
  71305. * The strenth of the updraft.
  71306. */
  71307. strength: number;
  71308. /**
  71309. * The height of the cylinder for the updraft.
  71310. */
  71311. height: number;
  71312. /**
  71313. * The mode for the the updraft.
  71314. */
  71315. updraftMode: PhysicsUpdraftMode;
  71316. }
  71317. /**
  71318. * Options fot the vortex event
  71319. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71320. */
  71321. export class PhysicsVortexEventOptions {
  71322. /**
  71323. * The radius of the cylinder for the vortex
  71324. */
  71325. radius: number;
  71326. /**
  71327. * The strenth of the vortex.
  71328. */
  71329. strength: number;
  71330. /**
  71331. * The height of the cylinder for the vortex.
  71332. */
  71333. height: number;
  71334. /**
  71335. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  71336. */
  71337. centripetalForceThreshold: number;
  71338. /**
  71339. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  71340. */
  71341. centripetalForceMultiplier: number;
  71342. /**
  71343. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  71344. */
  71345. centrifugalForceMultiplier: number;
  71346. /**
  71347. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  71348. */
  71349. updraftForceMultiplier: number;
  71350. }
  71351. /**
  71352. * The strenght of the force in correspondence to the distance of the affected object
  71353. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71354. */
  71355. export enum PhysicsRadialImpulseFalloff {
  71356. /** Defines that impulse is constant in strength across it's whole radius */
  71357. Constant = 0,
  71358. /** Defines that impulse gets weaker if it's further from the origin */
  71359. Linear = 1
  71360. }
  71361. /**
  71362. * The strength of the force in correspondence to the distance of the affected object
  71363. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71364. */
  71365. export enum PhysicsUpdraftMode {
  71366. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  71367. Center = 0,
  71368. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  71369. Perpendicular = 1
  71370. }
  71371. /**
  71372. * Interface for a physics hit data
  71373. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71374. */
  71375. export interface PhysicsHitData {
  71376. /**
  71377. * The force applied at the contact point
  71378. */
  71379. force: Vector3;
  71380. /**
  71381. * The contact point
  71382. */
  71383. contactPoint: Vector3;
  71384. /**
  71385. * The distance from the origin to the contact point
  71386. */
  71387. distanceFromOrigin: number;
  71388. }
  71389. /**
  71390. * Interface for radial explosion event data
  71391. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71392. */
  71393. export interface PhysicsRadialExplosionEventData {
  71394. /**
  71395. * A sphere used for the radial explosion event
  71396. */
  71397. sphere: Mesh;
  71398. }
  71399. /**
  71400. * Interface for gravitational field event data
  71401. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71402. */
  71403. export interface PhysicsGravitationalFieldEventData {
  71404. /**
  71405. * A sphere mesh used for the gravitational field event
  71406. */
  71407. sphere: Mesh;
  71408. }
  71409. /**
  71410. * Interface for updraft event data
  71411. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71412. */
  71413. export interface PhysicsUpdraftEventData {
  71414. /**
  71415. * A cylinder used for the updraft event
  71416. */
  71417. cylinder: Mesh;
  71418. }
  71419. /**
  71420. * Interface for vortex event data
  71421. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71422. */
  71423. export interface PhysicsVortexEventData {
  71424. /**
  71425. * A cylinder used for the vortex event
  71426. */
  71427. cylinder: Mesh;
  71428. }
  71429. /**
  71430. * Interface for an affected physics impostor
  71431. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71432. */
  71433. export interface PhysicsAffectedImpostorWithData {
  71434. /**
  71435. * The impostor affected by the effect
  71436. */
  71437. impostor: PhysicsImpostor;
  71438. /**
  71439. * The data about the hit/horce from the explosion
  71440. */
  71441. hitData: PhysicsHitData;
  71442. }
  71443. }
  71444. declare module "babylonjs/Physics/Plugins/index" {
  71445. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  71446. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  71447. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  71448. }
  71449. declare module "babylonjs/Physics/index" {
  71450. export * from "babylonjs/Physics/IPhysicsEngine";
  71451. export * from "babylonjs/Physics/physicsEngine";
  71452. export * from "babylonjs/Physics/physicsEngineComponent";
  71453. export * from "babylonjs/Physics/physicsHelper";
  71454. export * from "babylonjs/Physics/physicsImpostor";
  71455. export * from "babylonjs/Physics/physicsJoint";
  71456. export * from "babylonjs/Physics/Plugins/index";
  71457. }
  71458. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  71459. /** @hidden */
  71460. export var blackAndWhitePixelShader: {
  71461. name: string;
  71462. shader: string;
  71463. };
  71464. }
  71465. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  71466. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71467. import { Camera } from "babylonjs/Cameras/camera";
  71468. import { Engine } from "babylonjs/Engines/engine";
  71469. import "babylonjs/Shaders/blackAndWhite.fragment";
  71470. /**
  71471. * Post process used to render in black and white
  71472. */
  71473. export class BlackAndWhitePostProcess extends PostProcess {
  71474. /**
  71475. * Linear about to convert he result to black and white (default: 1)
  71476. */
  71477. degree: number;
  71478. /**
  71479. * Creates a black and white post process
  71480. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  71481. * @param name The name of the effect.
  71482. * @param options The required width/height ratio to downsize to before computing the render pass.
  71483. * @param camera The camera to apply the render pass to.
  71484. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71485. * @param engine The engine which the post process will be applied. (default: current engine)
  71486. * @param reusable If the post process can be reused on the same frame. (default: false)
  71487. */
  71488. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71489. }
  71490. }
  71491. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  71492. import { Nullable } from "babylonjs/types";
  71493. import { Camera } from "babylonjs/Cameras/camera";
  71494. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71495. import { Engine } from "babylonjs/Engines/engine";
  71496. /**
  71497. * This represents a set of one or more post processes in Babylon.
  71498. * A post process can be used to apply a shader to a texture after it is rendered.
  71499. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71500. */
  71501. export class PostProcessRenderEffect {
  71502. private _postProcesses;
  71503. private _getPostProcesses;
  71504. private _singleInstance;
  71505. private _cameras;
  71506. private _indicesForCamera;
  71507. /**
  71508. * Name of the effect
  71509. * @hidden
  71510. */
  71511. _name: string;
  71512. /**
  71513. * Instantiates a post process render effect.
  71514. * A post process can be used to apply a shader to a texture after it is rendered.
  71515. * @param engine The engine the effect is tied to
  71516. * @param name The name of the effect
  71517. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  71518. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  71519. */
  71520. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  71521. /**
  71522. * Checks if all the post processes in the effect are supported.
  71523. */
  71524. get isSupported(): boolean;
  71525. /**
  71526. * Updates the current state of the effect
  71527. * @hidden
  71528. */
  71529. _update(): void;
  71530. /**
  71531. * Attaches the effect on cameras
  71532. * @param cameras The camera to attach to.
  71533. * @hidden
  71534. */
  71535. _attachCameras(cameras: Camera): void;
  71536. /**
  71537. * Attaches the effect on cameras
  71538. * @param cameras The camera to attach to.
  71539. * @hidden
  71540. */
  71541. _attachCameras(cameras: Camera[]): void;
  71542. /**
  71543. * Detaches the effect on cameras
  71544. * @param cameras The camera to detatch from.
  71545. * @hidden
  71546. */
  71547. _detachCameras(cameras: Camera): void;
  71548. /**
  71549. * Detatches the effect on cameras
  71550. * @param cameras The camera to detatch from.
  71551. * @hidden
  71552. */
  71553. _detachCameras(cameras: Camera[]): void;
  71554. /**
  71555. * Enables the effect on given cameras
  71556. * @param cameras The camera to enable.
  71557. * @hidden
  71558. */
  71559. _enable(cameras: Camera): void;
  71560. /**
  71561. * Enables the effect on given cameras
  71562. * @param cameras The camera to enable.
  71563. * @hidden
  71564. */
  71565. _enable(cameras: Nullable<Camera[]>): void;
  71566. /**
  71567. * Disables the effect on the given cameras
  71568. * @param cameras The camera to disable.
  71569. * @hidden
  71570. */
  71571. _disable(cameras: Camera): void;
  71572. /**
  71573. * Disables the effect on the given cameras
  71574. * @param cameras The camera to disable.
  71575. * @hidden
  71576. */
  71577. _disable(cameras: Nullable<Camera[]>): void;
  71578. /**
  71579. * Gets a list of the post processes contained in the effect.
  71580. * @param camera The camera to get the post processes on.
  71581. * @returns The list of the post processes in the effect.
  71582. */
  71583. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  71584. }
  71585. }
  71586. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  71587. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71588. /** @hidden */
  71589. export var extractHighlightsPixelShader: {
  71590. name: string;
  71591. shader: string;
  71592. };
  71593. }
  71594. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  71595. import { Nullable } from "babylonjs/types";
  71596. import { Camera } from "babylonjs/Cameras/camera";
  71597. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71598. import { Engine } from "babylonjs/Engines/engine";
  71599. import "babylonjs/Shaders/extractHighlights.fragment";
  71600. /**
  71601. * 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.
  71602. */
  71603. export class ExtractHighlightsPostProcess extends PostProcess {
  71604. /**
  71605. * The luminance threshold, pixels below this value will be set to black.
  71606. */
  71607. threshold: number;
  71608. /** @hidden */
  71609. _exposure: number;
  71610. /**
  71611. * Post process which has the input texture to be used when performing highlight extraction
  71612. * @hidden
  71613. */
  71614. _inputPostProcess: Nullable<PostProcess>;
  71615. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71616. }
  71617. }
  71618. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  71619. /** @hidden */
  71620. export var bloomMergePixelShader: {
  71621. name: string;
  71622. shader: string;
  71623. };
  71624. }
  71625. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  71626. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71627. import { Nullable } from "babylonjs/types";
  71628. import { Engine } from "babylonjs/Engines/engine";
  71629. import { Camera } from "babylonjs/Cameras/camera";
  71630. import "babylonjs/Shaders/bloomMerge.fragment";
  71631. /**
  71632. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  71633. */
  71634. export class BloomMergePostProcess extends PostProcess {
  71635. /** Weight of the bloom to be added to the original input. */
  71636. weight: number;
  71637. /**
  71638. * Creates a new instance of @see BloomMergePostProcess
  71639. * @param name The name of the effect.
  71640. * @param originalFromInput Post process which's input will be used for the merge.
  71641. * @param blurred Blurred highlights post process which's output will be used.
  71642. * @param weight Weight of the bloom to be added to the original input.
  71643. * @param options The required width/height ratio to downsize to before computing the render pass.
  71644. * @param camera The camera to apply the render pass to.
  71645. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71646. * @param engine The engine which the post process will be applied. (default: current engine)
  71647. * @param reusable If the post process can be reused on the same frame. (default: false)
  71648. * @param textureType Type of textures used when performing the post process. (default: 0)
  71649. * @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)
  71650. */
  71651. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  71652. /** Weight of the bloom to be added to the original input. */
  71653. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71654. }
  71655. }
  71656. declare module "babylonjs/PostProcesses/bloomEffect" {
  71657. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  71658. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71659. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  71660. import { Camera } from "babylonjs/Cameras/camera";
  71661. import { Scene } from "babylonjs/scene";
  71662. /**
  71663. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  71664. */
  71665. export class BloomEffect extends PostProcessRenderEffect {
  71666. private bloomScale;
  71667. /**
  71668. * @hidden Internal
  71669. */
  71670. _effects: Array<PostProcess>;
  71671. /**
  71672. * @hidden Internal
  71673. */
  71674. _downscale: ExtractHighlightsPostProcess;
  71675. private _blurX;
  71676. private _blurY;
  71677. private _merge;
  71678. /**
  71679. * The luminance threshold to find bright areas of the image to bloom.
  71680. */
  71681. get threshold(): number;
  71682. set threshold(value: number);
  71683. /**
  71684. * The strength of the bloom.
  71685. */
  71686. get weight(): number;
  71687. set weight(value: number);
  71688. /**
  71689. * Specifies the size of the bloom blur kernel, relative to the final output size
  71690. */
  71691. get kernel(): number;
  71692. set kernel(value: number);
  71693. /**
  71694. * Creates a new instance of @see BloomEffect
  71695. * @param scene The scene the effect belongs to.
  71696. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  71697. * @param bloomKernel The size of the kernel to be used when applying the blur.
  71698. * @param bloomWeight The the strength of bloom.
  71699. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  71700. * @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)
  71701. */
  71702. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  71703. /**
  71704. * Disposes each of the internal effects for a given camera.
  71705. * @param camera The camera to dispose the effect on.
  71706. */
  71707. disposeEffects(camera: Camera): void;
  71708. /**
  71709. * @hidden Internal
  71710. */
  71711. _updateEffects(): void;
  71712. /**
  71713. * Internal
  71714. * @returns if all the contained post processes are ready.
  71715. * @hidden
  71716. */
  71717. _isReady(): boolean;
  71718. }
  71719. }
  71720. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  71721. /** @hidden */
  71722. export var chromaticAberrationPixelShader: {
  71723. name: string;
  71724. shader: string;
  71725. };
  71726. }
  71727. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  71728. import { Vector2 } from "babylonjs/Maths/math.vector";
  71729. import { Nullable } from "babylonjs/types";
  71730. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71731. import { Camera } from "babylonjs/Cameras/camera";
  71732. import { Engine } from "babylonjs/Engines/engine";
  71733. import "babylonjs/Shaders/chromaticAberration.fragment";
  71734. /**
  71735. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  71736. */
  71737. export class ChromaticAberrationPostProcess extends PostProcess {
  71738. /**
  71739. * The amount of seperation of rgb channels (default: 30)
  71740. */
  71741. aberrationAmount: number;
  71742. /**
  71743. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  71744. */
  71745. radialIntensity: number;
  71746. /**
  71747. * 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))
  71748. */
  71749. direction: Vector2;
  71750. /**
  71751. * 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))
  71752. */
  71753. centerPosition: Vector2;
  71754. /**
  71755. * Creates a new instance ChromaticAberrationPostProcess
  71756. * @param name The name of the effect.
  71757. * @param screenWidth The width of the screen to apply the effect on.
  71758. * @param screenHeight The height of the screen to apply the effect on.
  71759. * @param options The required width/height ratio to downsize to before computing the render pass.
  71760. * @param camera The camera to apply the render pass to.
  71761. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71762. * @param engine The engine which the post process will be applied. (default: current engine)
  71763. * @param reusable If the post process can be reused on the same frame. (default: false)
  71764. * @param textureType Type of textures used when performing the post process. (default: 0)
  71765. * @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)
  71766. */
  71767. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71768. }
  71769. }
  71770. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  71771. /** @hidden */
  71772. export var circleOfConfusionPixelShader: {
  71773. name: string;
  71774. shader: string;
  71775. };
  71776. }
  71777. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  71778. import { Nullable } from "babylonjs/types";
  71779. import { Engine } from "babylonjs/Engines/engine";
  71780. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71781. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  71782. import { Camera } from "babylonjs/Cameras/camera";
  71783. import "babylonjs/Shaders/circleOfConfusion.fragment";
  71784. /**
  71785. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  71786. */
  71787. export class CircleOfConfusionPostProcess extends PostProcess {
  71788. /**
  71789. * 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.
  71790. */
  71791. lensSize: number;
  71792. /**
  71793. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71794. */
  71795. fStop: number;
  71796. /**
  71797. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71798. */
  71799. focusDistance: number;
  71800. /**
  71801. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  71802. */
  71803. focalLength: number;
  71804. private _depthTexture;
  71805. /**
  71806. * Creates a new instance CircleOfConfusionPostProcess
  71807. * @param name The name of the effect.
  71808. * @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.
  71809. * @param options The required width/height ratio to downsize to before computing the render pass.
  71810. * @param camera The camera to apply the render pass to.
  71811. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71812. * @param engine The engine which the post process will be applied. (default: current engine)
  71813. * @param reusable If the post process can be reused on the same frame. (default: false)
  71814. * @param textureType Type of textures used when performing the post process. (default: 0)
  71815. * @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)
  71816. */
  71817. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71818. /**
  71819. * 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.
  71820. */
  71821. set depthTexture(value: RenderTargetTexture);
  71822. }
  71823. }
  71824. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  71825. /** @hidden */
  71826. export var colorCorrectionPixelShader: {
  71827. name: string;
  71828. shader: string;
  71829. };
  71830. }
  71831. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  71832. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71833. import { Engine } from "babylonjs/Engines/engine";
  71834. import { Camera } from "babylonjs/Cameras/camera";
  71835. import "babylonjs/Shaders/colorCorrection.fragment";
  71836. /**
  71837. *
  71838. * This post-process allows the modification of rendered colors by using
  71839. * a 'look-up table' (LUT). This effect is also called Color Grading.
  71840. *
  71841. * The object needs to be provided an url to a texture containing the color
  71842. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  71843. * Use an image editing software to tweak the LUT to match your needs.
  71844. *
  71845. * For an example of a color LUT, see here:
  71846. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  71847. * For explanations on color grading, see here:
  71848. * @see http://udn.epicgames.com/Three/ColorGrading.html
  71849. *
  71850. */
  71851. export class ColorCorrectionPostProcess extends PostProcess {
  71852. private _colorTableTexture;
  71853. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71854. }
  71855. }
  71856. declare module "babylonjs/Shaders/convolution.fragment" {
  71857. /** @hidden */
  71858. export var convolutionPixelShader: {
  71859. name: string;
  71860. shader: string;
  71861. };
  71862. }
  71863. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  71864. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71865. import { Nullable } from "babylonjs/types";
  71866. import { Camera } from "babylonjs/Cameras/camera";
  71867. import { Engine } from "babylonjs/Engines/engine";
  71868. import "babylonjs/Shaders/convolution.fragment";
  71869. /**
  71870. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  71871. * input texture to perform effects such as edge detection or sharpening
  71872. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71873. */
  71874. export class ConvolutionPostProcess extends PostProcess {
  71875. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  71876. kernel: number[];
  71877. /**
  71878. * Creates a new instance ConvolutionPostProcess
  71879. * @param name The name of the effect.
  71880. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  71881. * @param options The required width/height ratio to downsize to before computing the render pass.
  71882. * @param camera The camera to apply the render pass to.
  71883. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71884. * @param engine The engine which the post process will be applied. (default: current engine)
  71885. * @param reusable If the post process can be reused on the same frame. (default: false)
  71886. * @param textureType Type of textures used when performing the post process. (default: 0)
  71887. */
  71888. constructor(name: string,
  71889. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  71890. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71891. /**
  71892. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71893. */
  71894. static EdgeDetect0Kernel: number[];
  71895. /**
  71896. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71897. */
  71898. static EdgeDetect1Kernel: number[];
  71899. /**
  71900. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71901. */
  71902. static EdgeDetect2Kernel: number[];
  71903. /**
  71904. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71905. */
  71906. static SharpenKernel: number[];
  71907. /**
  71908. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71909. */
  71910. static EmbossKernel: number[];
  71911. /**
  71912. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71913. */
  71914. static GaussianKernel: number[];
  71915. }
  71916. }
  71917. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  71918. import { Nullable } from "babylonjs/types";
  71919. import { Vector2 } from "babylonjs/Maths/math.vector";
  71920. import { Camera } from "babylonjs/Cameras/camera";
  71921. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71922. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  71923. import { Engine } from "babylonjs/Engines/engine";
  71924. import { Scene } from "babylonjs/scene";
  71925. /**
  71926. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  71927. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  71928. * based on samples that have a large difference in distance than the center pixel.
  71929. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  71930. */
  71931. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  71932. direction: Vector2;
  71933. /**
  71934. * Creates a new instance CircleOfConfusionPostProcess
  71935. * @param name The name of the effect.
  71936. * @param scene The scene the effect belongs to.
  71937. * @param direction The direction the blur should be applied.
  71938. * @param kernel The size of the kernel used to blur.
  71939. * @param options The required width/height ratio to downsize to before computing the render pass.
  71940. * @param camera The camera to apply the render pass to.
  71941. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  71942. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  71943. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71944. * @param engine The engine which the post process will be applied. (default: current engine)
  71945. * @param reusable If the post process can be reused on the same frame. (default: false)
  71946. * @param textureType Type of textures used when performing the post process. (default: 0)
  71947. * @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)
  71948. */
  71949. 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);
  71950. }
  71951. }
  71952. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  71953. /** @hidden */
  71954. export var depthOfFieldMergePixelShader: {
  71955. name: string;
  71956. shader: string;
  71957. };
  71958. }
  71959. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  71960. import { Nullable } from "babylonjs/types";
  71961. import { Camera } from "babylonjs/Cameras/camera";
  71962. import { Effect } from "babylonjs/Materials/effect";
  71963. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71964. import { Engine } from "babylonjs/Engines/engine";
  71965. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  71966. /**
  71967. * Options to be set when merging outputs from the default pipeline.
  71968. */
  71969. export class DepthOfFieldMergePostProcessOptions {
  71970. /**
  71971. * The original image to merge on top of
  71972. */
  71973. originalFromInput: PostProcess;
  71974. /**
  71975. * Parameters to perform the merge of the depth of field effect
  71976. */
  71977. depthOfField?: {
  71978. circleOfConfusion: PostProcess;
  71979. blurSteps: Array<PostProcess>;
  71980. };
  71981. /**
  71982. * Parameters to perform the merge of bloom effect
  71983. */
  71984. bloom?: {
  71985. blurred: PostProcess;
  71986. weight: number;
  71987. };
  71988. }
  71989. /**
  71990. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  71991. */
  71992. export class DepthOfFieldMergePostProcess extends PostProcess {
  71993. private blurSteps;
  71994. /**
  71995. * Creates a new instance of DepthOfFieldMergePostProcess
  71996. * @param name The name of the effect.
  71997. * @param originalFromInput Post process which's input will be used for the merge.
  71998. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  71999. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  72000. * @param options The required width/height ratio to downsize to before computing the render pass.
  72001. * @param camera The camera to apply the render pass to.
  72002. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72003. * @param engine The engine which the post process will be applied. (default: current engine)
  72004. * @param reusable If the post process can be reused on the same frame. (default: false)
  72005. * @param textureType Type of textures used when performing the post process. (default: 0)
  72006. * @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)
  72007. */
  72008. 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);
  72009. /**
  72010. * Updates the effect with the current post process compile time values and recompiles the shader.
  72011. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  72012. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  72013. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  72014. * @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
  72015. * @param onCompiled Called when the shader has been compiled.
  72016. * @param onError Called if there is an error when compiling a shader.
  72017. */
  72018. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72019. }
  72020. }
  72021. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  72022. import { Nullable } from "babylonjs/types";
  72023. import { Camera } from "babylonjs/Cameras/camera";
  72024. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72025. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72026. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72027. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  72028. import { Scene } from "babylonjs/scene";
  72029. /**
  72030. * Specifies the level of max blur that should be applied when using the depth of field effect
  72031. */
  72032. export enum DepthOfFieldEffectBlurLevel {
  72033. /**
  72034. * Subtle blur
  72035. */
  72036. Low = 0,
  72037. /**
  72038. * Medium blur
  72039. */
  72040. Medium = 1,
  72041. /**
  72042. * Large blur
  72043. */
  72044. High = 2
  72045. }
  72046. /**
  72047. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  72048. */
  72049. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  72050. private _circleOfConfusion;
  72051. /**
  72052. * @hidden Internal, blurs from high to low
  72053. */
  72054. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  72055. private _depthOfFieldBlurY;
  72056. private _dofMerge;
  72057. /**
  72058. * @hidden Internal post processes in depth of field effect
  72059. */
  72060. _effects: Array<PostProcess>;
  72061. /**
  72062. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  72063. */
  72064. set focalLength(value: number);
  72065. get focalLength(): number;
  72066. /**
  72067. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  72068. */
  72069. set fStop(value: number);
  72070. get fStop(): number;
  72071. /**
  72072. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  72073. */
  72074. set focusDistance(value: number);
  72075. get focusDistance(): number;
  72076. /**
  72077. * 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.
  72078. */
  72079. set lensSize(value: number);
  72080. get lensSize(): number;
  72081. /**
  72082. * Creates a new instance DepthOfFieldEffect
  72083. * @param scene The scene the effect belongs to.
  72084. * @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.
  72085. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72086. * @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)
  72087. */
  72088. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  72089. /**
  72090. * Get the current class name of the current effet
  72091. * @returns "DepthOfFieldEffect"
  72092. */
  72093. getClassName(): string;
  72094. /**
  72095. * 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.
  72096. */
  72097. set depthTexture(value: RenderTargetTexture);
  72098. /**
  72099. * Disposes each of the internal effects for a given camera.
  72100. * @param camera The camera to dispose the effect on.
  72101. */
  72102. disposeEffects(camera: Camera): void;
  72103. /**
  72104. * @hidden Internal
  72105. */
  72106. _updateEffects(): void;
  72107. /**
  72108. * Internal
  72109. * @returns if all the contained post processes are ready.
  72110. * @hidden
  72111. */
  72112. _isReady(): boolean;
  72113. }
  72114. }
  72115. declare module "babylonjs/Shaders/displayPass.fragment" {
  72116. /** @hidden */
  72117. export var displayPassPixelShader: {
  72118. name: string;
  72119. shader: string;
  72120. };
  72121. }
  72122. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  72123. import { Nullable } from "babylonjs/types";
  72124. import { Camera } from "babylonjs/Cameras/camera";
  72125. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72126. import { Engine } from "babylonjs/Engines/engine";
  72127. import "babylonjs/Shaders/displayPass.fragment";
  72128. /**
  72129. * DisplayPassPostProcess which produces an output the same as it's input
  72130. */
  72131. export class DisplayPassPostProcess extends PostProcess {
  72132. /**
  72133. * Creates the DisplayPassPostProcess
  72134. * @param name The name of the effect.
  72135. * @param options The required width/height ratio to downsize to before computing the render pass.
  72136. * @param camera The camera to apply the render pass to.
  72137. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72138. * @param engine The engine which the post process will be applied. (default: current engine)
  72139. * @param reusable If the post process can be reused on the same frame. (default: false)
  72140. */
  72141. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72142. }
  72143. }
  72144. declare module "babylonjs/Shaders/filter.fragment" {
  72145. /** @hidden */
  72146. export var filterPixelShader: {
  72147. name: string;
  72148. shader: string;
  72149. };
  72150. }
  72151. declare module "babylonjs/PostProcesses/filterPostProcess" {
  72152. import { Nullable } from "babylonjs/types";
  72153. import { Matrix } from "babylonjs/Maths/math.vector";
  72154. import { Camera } from "babylonjs/Cameras/camera";
  72155. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72156. import { Engine } from "babylonjs/Engines/engine";
  72157. import "babylonjs/Shaders/filter.fragment";
  72158. /**
  72159. * Applies a kernel filter to the image
  72160. */
  72161. export class FilterPostProcess extends PostProcess {
  72162. /** The matrix to be applied to the image */
  72163. kernelMatrix: Matrix;
  72164. /**
  72165. *
  72166. * @param name The name of the effect.
  72167. * @param kernelMatrix The matrix to be applied to the image
  72168. * @param options The required width/height ratio to downsize to before computing the render pass.
  72169. * @param camera The camera to apply the render pass to.
  72170. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72171. * @param engine The engine which the post process will be applied. (default: current engine)
  72172. * @param reusable If the post process can be reused on the same frame. (default: false)
  72173. */
  72174. constructor(name: string,
  72175. /** The matrix to be applied to the image */
  72176. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72177. }
  72178. }
  72179. declare module "babylonjs/Shaders/fxaa.fragment" {
  72180. /** @hidden */
  72181. export var fxaaPixelShader: {
  72182. name: string;
  72183. shader: string;
  72184. };
  72185. }
  72186. declare module "babylonjs/Shaders/fxaa.vertex" {
  72187. /** @hidden */
  72188. export var fxaaVertexShader: {
  72189. name: string;
  72190. shader: string;
  72191. };
  72192. }
  72193. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  72194. import { Nullable } from "babylonjs/types";
  72195. import { Camera } from "babylonjs/Cameras/camera";
  72196. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72197. import { Engine } from "babylonjs/Engines/engine";
  72198. import "babylonjs/Shaders/fxaa.fragment";
  72199. import "babylonjs/Shaders/fxaa.vertex";
  72200. /**
  72201. * Fxaa post process
  72202. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  72203. */
  72204. export class FxaaPostProcess extends PostProcess {
  72205. /** @hidden */
  72206. texelWidth: number;
  72207. /** @hidden */
  72208. texelHeight: number;
  72209. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72210. private _getDefines;
  72211. }
  72212. }
  72213. declare module "babylonjs/Shaders/grain.fragment" {
  72214. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72215. /** @hidden */
  72216. export var grainPixelShader: {
  72217. name: string;
  72218. shader: string;
  72219. };
  72220. }
  72221. declare module "babylonjs/PostProcesses/grainPostProcess" {
  72222. import { Nullable } from "babylonjs/types";
  72223. import { Camera } from "babylonjs/Cameras/camera";
  72224. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72225. import { Engine } from "babylonjs/Engines/engine";
  72226. import "babylonjs/Shaders/grain.fragment";
  72227. /**
  72228. * The GrainPostProcess adds noise to the image at mid luminance levels
  72229. */
  72230. export class GrainPostProcess extends PostProcess {
  72231. /**
  72232. * The intensity of the grain added (default: 30)
  72233. */
  72234. intensity: number;
  72235. /**
  72236. * If the grain should be randomized on every frame
  72237. */
  72238. animated: boolean;
  72239. /**
  72240. * Creates a new instance of @see GrainPostProcess
  72241. * @param name The name of the effect.
  72242. * @param options The required width/height ratio to downsize to before computing the render pass.
  72243. * @param camera The camera to apply the render pass to.
  72244. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72245. * @param engine The engine which the post process will be applied. (default: current engine)
  72246. * @param reusable If the post process can be reused on the same frame. (default: false)
  72247. * @param textureType Type of textures used when performing the post process. (default: 0)
  72248. * @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)
  72249. */
  72250. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72251. }
  72252. }
  72253. declare module "babylonjs/Shaders/highlights.fragment" {
  72254. /** @hidden */
  72255. export var highlightsPixelShader: {
  72256. name: string;
  72257. shader: string;
  72258. };
  72259. }
  72260. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  72261. import { Nullable } from "babylonjs/types";
  72262. import { Camera } from "babylonjs/Cameras/camera";
  72263. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72264. import { Engine } from "babylonjs/Engines/engine";
  72265. import "babylonjs/Shaders/highlights.fragment";
  72266. /**
  72267. * Extracts highlights from the image
  72268. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72269. */
  72270. export class HighlightsPostProcess extends PostProcess {
  72271. /**
  72272. * Extracts highlights from the image
  72273. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72274. * @param name The name of the effect.
  72275. * @param options The required width/height ratio to downsize to before computing the render pass.
  72276. * @param camera The camera to apply the render pass to.
  72277. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72278. * @param engine The engine which the post process will be applied. (default: current engine)
  72279. * @param reusable If the post process can be reused on the same frame. (default: false)
  72280. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  72281. */
  72282. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72283. }
  72284. }
  72285. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  72286. /** @hidden */
  72287. export var mrtFragmentDeclaration: {
  72288. name: string;
  72289. shader: string;
  72290. };
  72291. }
  72292. declare module "babylonjs/Shaders/geometry.fragment" {
  72293. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  72294. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  72295. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  72296. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  72297. /** @hidden */
  72298. export var geometryPixelShader: {
  72299. name: string;
  72300. shader: string;
  72301. };
  72302. }
  72303. declare module "babylonjs/Shaders/geometry.vertex" {
  72304. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  72305. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  72306. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  72307. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  72308. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  72309. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  72310. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  72311. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  72312. /** @hidden */
  72313. export var geometryVertexShader: {
  72314. name: string;
  72315. shader: string;
  72316. };
  72317. }
  72318. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  72319. import { Matrix } from "babylonjs/Maths/math.vector";
  72320. import { SubMesh } from "babylonjs/Meshes/subMesh";
  72321. import { Mesh } from "babylonjs/Meshes/mesh";
  72322. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  72323. import { Effect } from "babylonjs/Materials/effect";
  72324. import { Scene } from "babylonjs/scene";
  72325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72326. import "babylonjs/Shaders/geometry.fragment";
  72327. import "babylonjs/Shaders/geometry.vertex";
  72328. /** @hidden */
  72329. interface ISavedTransformationMatrix {
  72330. world: Matrix;
  72331. viewProjection: Matrix;
  72332. }
  72333. /**
  72334. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  72335. */
  72336. export class GeometryBufferRenderer {
  72337. /**
  72338. * Constant used to retrieve the position texture index in the G-Buffer textures array
  72339. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  72340. */
  72341. static readonly POSITION_TEXTURE_TYPE: number;
  72342. /**
  72343. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  72344. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  72345. */
  72346. static readonly VELOCITY_TEXTURE_TYPE: number;
  72347. /**
  72348. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  72349. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  72350. */
  72351. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  72352. /**
  72353. * Dictionary used to store the previous transformation matrices of each rendered mesh
  72354. * in order to compute objects velocities when enableVelocity is set to "true"
  72355. * @hidden
  72356. */
  72357. _previousTransformationMatrices: {
  72358. [index: number]: ISavedTransformationMatrix;
  72359. };
  72360. /**
  72361. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  72362. * in order to compute objects velocities when enableVelocity is set to "true"
  72363. * @hidden
  72364. */
  72365. _previousBonesTransformationMatrices: {
  72366. [index: number]: Float32Array;
  72367. };
  72368. /**
  72369. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  72370. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  72371. */
  72372. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  72373. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  72374. renderTransparentMeshes: boolean;
  72375. private _scene;
  72376. private _multiRenderTarget;
  72377. private _ratio;
  72378. private _enablePosition;
  72379. private _enableVelocity;
  72380. private _enableReflectivity;
  72381. private _positionIndex;
  72382. private _velocityIndex;
  72383. private _reflectivityIndex;
  72384. protected _effect: Effect;
  72385. protected _cachedDefines: string;
  72386. /**
  72387. * Set the render list (meshes to be rendered) used in the G buffer.
  72388. */
  72389. set renderList(meshes: Mesh[]);
  72390. /**
  72391. * Gets wether or not G buffer are supported by the running hardware.
  72392. * This requires draw buffer supports
  72393. */
  72394. get isSupported(): boolean;
  72395. /**
  72396. * Returns the index of the given texture type in the G-Buffer textures array
  72397. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  72398. * @returns the index of the given texture type in the G-Buffer textures array
  72399. */
  72400. getTextureIndex(textureType: number): number;
  72401. /**
  72402. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  72403. */
  72404. get enablePosition(): boolean;
  72405. /**
  72406. * Sets whether or not objects positions are enabled for the G buffer.
  72407. */
  72408. set enablePosition(enable: boolean);
  72409. /**
  72410. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  72411. */
  72412. get enableVelocity(): boolean;
  72413. /**
  72414. * Sets wether or not objects velocities are enabled for the G buffer.
  72415. */
  72416. set enableVelocity(enable: boolean);
  72417. /**
  72418. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  72419. */
  72420. get enableReflectivity(): boolean;
  72421. /**
  72422. * Sets wether or not objects roughness are enabled for the G buffer.
  72423. */
  72424. set enableReflectivity(enable: boolean);
  72425. /**
  72426. * Gets the scene associated with the buffer.
  72427. */
  72428. get scene(): Scene;
  72429. /**
  72430. * Gets the ratio used by the buffer during its creation.
  72431. * How big is the buffer related to the main canvas.
  72432. */
  72433. get ratio(): number;
  72434. /** @hidden */
  72435. static _SceneComponentInitialization: (scene: Scene) => void;
  72436. /**
  72437. * Creates a new G Buffer for the scene
  72438. * @param scene The scene the buffer belongs to
  72439. * @param ratio How big is the buffer related to the main canvas.
  72440. */
  72441. constructor(scene: Scene, ratio?: number);
  72442. /**
  72443. * Checks wether everything is ready to render a submesh to the G buffer.
  72444. * @param subMesh the submesh to check readiness for
  72445. * @param useInstances is the mesh drawn using instance or not
  72446. * @returns true if ready otherwise false
  72447. */
  72448. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72449. /**
  72450. * Gets the current underlying G Buffer.
  72451. * @returns the buffer
  72452. */
  72453. getGBuffer(): MultiRenderTarget;
  72454. /**
  72455. * Gets the number of samples used to render the buffer (anti aliasing).
  72456. */
  72457. get samples(): number;
  72458. /**
  72459. * Sets the number of samples used to render the buffer (anti aliasing).
  72460. */
  72461. set samples(value: number);
  72462. /**
  72463. * Disposes the renderer and frees up associated resources.
  72464. */
  72465. dispose(): void;
  72466. protected _createRenderTargets(): void;
  72467. private _copyBonesTransformationMatrices;
  72468. }
  72469. }
  72470. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  72471. import { Nullable } from "babylonjs/types";
  72472. import { Scene } from "babylonjs/scene";
  72473. import { ISceneComponent } from "babylonjs/sceneComponent";
  72474. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  72475. module "babylonjs/scene" {
  72476. interface Scene {
  72477. /** @hidden (Backing field) */
  72478. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  72479. /**
  72480. * Gets or Sets the current geometry buffer associated to the scene.
  72481. */
  72482. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  72483. /**
  72484. * Enables a GeometryBufferRender and associates it with the scene
  72485. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  72486. * @returns the GeometryBufferRenderer
  72487. */
  72488. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  72489. /**
  72490. * Disables the GeometryBufferRender associated with the scene
  72491. */
  72492. disableGeometryBufferRenderer(): void;
  72493. }
  72494. }
  72495. /**
  72496. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72497. * in several rendering techniques.
  72498. */
  72499. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  72500. /**
  72501. * The component name helpful to identify the component in the list of scene components.
  72502. */
  72503. readonly name: string;
  72504. /**
  72505. * The scene the component belongs to.
  72506. */
  72507. scene: Scene;
  72508. /**
  72509. * Creates a new instance of the component for the given scene
  72510. * @param scene Defines the scene to register the component in
  72511. */
  72512. constructor(scene: Scene);
  72513. /**
  72514. * Registers the component in a given scene
  72515. */
  72516. register(): void;
  72517. /**
  72518. * Rebuilds the elements related to this component in case of
  72519. * context lost for instance.
  72520. */
  72521. rebuild(): void;
  72522. /**
  72523. * Disposes the component and the associated ressources
  72524. */
  72525. dispose(): void;
  72526. private _gatherRenderTargets;
  72527. }
  72528. }
  72529. declare module "babylonjs/Shaders/motionBlur.fragment" {
  72530. /** @hidden */
  72531. export var motionBlurPixelShader: {
  72532. name: string;
  72533. shader: string;
  72534. };
  72535. }
  72536. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  72537. import { Nullable } from "babylonjs/types";
  72538. import { Camera } from "babylonjs/Cameras/camera";
  72539. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72540. import { Scene } from "babylonjs/scene";
  72541. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72542. import "babylonjs/Animations/animatable";
  72543. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  72544. import "babylonjs/Shaders/motionBlur.fragment";
  72545. import { Engine } from "babylonjs/Engines/engine";
  72546. /**
  72547. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  72548. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  72549. * As an example, all you have to do is to create the post-process:
  72550. * var mb = new BABYLON.MotionBlurPostProcess(
  72551. * 'mb', // The name of the effect.
  72552. * scene, // The scene containing the objects to blur according to their velocity.
  72553. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  72554. * camera // The camera to apply the render pass to.
  72555. * );
  72556. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  72557. */
  72558. export class MotionBlurPostProcess extends PostProcess {
  72559. /**
  72560. * Defines how much the image is blurred by the movement. Default value is equal to 1
  72561. */
  72562. motionStrength: number;
  72563. /**
  72564. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  72565. */
  72566. get motionBlurSamples(): number;
  72567. /**
  72568. * Sets the number of iterations to be used for motion blur quality
  72569. */
  72570. set motionBlurSamples(samples: number);
  72571. private _motionBlurSamples;
  72572. private _geometryBufferRenderer;
  72573. /**
  72574. * Creates a new instance MotionBlurPostProcess
  72575. * @param name The name of the effect.
  72576. * @param scene The scene containing the objects to blur according to their velocity.
  72577. * @param options The required width/height ratio to downsize to before computing the render pass.
  72578. * @param camera The camera to apply the render pass to.
  72579. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72580. * @param engine The engine which the post process will be applied. (default: current engine)
  72581. * @param reusable If the post process can be reused on the same frame. (default: false)
  72582. * @param textureType Type of textures used when performing the post process. (default: 0)
  72583. * @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)
  72584. */
  72585. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72586. /**
  72587. * Excludes the given skinned mesh from computing bones velocities.
  72588. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  72589. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  72590. */
  72591. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  72592. /**
  72593. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  72594. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  72595. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  72596. */
  72597. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  72598. /**
  72599. * Disposes the post process.
  72600. * @param camera The camera to dispose the post process on.
  72601. */
  72602. dispose(camera?: Camera): void;
  72603. }
  72604. }
  72605. declare module "babylonjs/Shaders/refraction.fragment" {
  72606. /** @hidden */
  72607. export var refractionPixelShader: {
  72608. name: string;
  72609. shader: string;
  72610. };
  72611. }
  72612. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  72613. import { Color3 } from "babylonjs/Maths/math.color";
  72614. import { Camera } from "babylonjs/Cameras/camera";
  72615. import { Texture } from "babylonjs/Materials/Textures/texture";
  72616. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72617. import { Engine } from "babylonjs/Engines/engine";
  72618. import "babylonjs/Shaders/refraction.fragment";
  72619. /**
  72620. * Post process which applies a refractin texture
  72621. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  72622. */
  72623. export class RefractionPostProcess extends PostProcess {
  72624. /** the base color of the refraction (used to taint the rendering) */
  72625. color: Color3;
  72626. /** simulated refraction depth */
  72627. depth: number;
  72628. /** the coefficient of the base color (0 to remove base color tainting) */
  72629. colorLevel: number;
  72630. private _refTexture;
  72631. private _ownRefractionTexture;
  72632. /**
  72633. * Gets or sets the refraction texture
  72634. * Please note that you are responsible for disposing the texture if you set it manually
  72635. */
  72636. get refractionTexture(): Texture;
  72637. set refractionTexture(value: Texture);
  72638. /**
  72639. * Initializes the RefractionPostProcess
  72640. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  72641. * @param name The name of the effect.
  72642. * @param refractionTextureUrl Url of the refraction texture to use
  72643. * @param color the base color of the refraction (used to taint the rendering)
  72644. * @param depth simulated refraction depth
  72645. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  72646. * @param camera The camera to apply the render pass to.
  72647. * @param options The required width/height ratio to downsize to before computing the render pass.
  72648. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72649. * @param engine The engine which the post process will be applied. (default: current engine)
  72650. * @param reusable If the post process can be reused on the same frame. (default: false)
  72651. */
  72652. constructor(name: string, refractionTextureUrl: string,
  72653. /** the base color of the refraction (used to taint the rendering) */
  72654. color: Color3,
  72655. /** simulated refraction depth */
  72656. depth: number,
  72657. /** the coefficient of the base color (0 to remove base color tainting) */
  72658. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72659. /**
  72660. * Disposes of the post process
  72661. * @param camera Camera to dispose post process on
  72662. */
  72663. dispose(camera: Camera): void;
  72664. }
  72665. }
  72666. declare module "babylonjs/Shaders/sharpen.fragment" {
  72667. /** @hidden */
  72668. export var sharpenPixelShader: {
  72669. name: string;
  72670. shader: string;
  72671. };
  72672. }
  72673. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  72674. import { Nullable } from "babylonjs/types";
  72675. import { Camera } from "babylonjs/Cameras/camera";
  72676. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72677. import "babylonjs/Shaders/sharpen.fragment";
  72678. import { Engine } from "babylonjs/Engines/engine";
  72679. /**
  72680. * The SharpenPostProcess applies a sharpen kernel to every pixel
  72681. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  72682. */
  72683. export class SharpenPostProcess extends PostProcess {
  72684. /**
  72685. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  72686. */
  72687. colorAmount: number;
  72688. /**
  72689. * How much sharpness should be applied (default: 0.3)
  72690. */
  72691. edgeAmount: number;
  72692. /**
  72693. * Creates a new instance ConvolutionPostProcess
  72694. * @param name The name of the effect.
  72695. * @param options The required width/height ratio to downsize to before computing the render pass.
  72696. * @param camera The camera to apply the render pass to.
  72697. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72698. * @param engine The engine which the post process will be applied. (default: current engine)
  72699. * @param reusable If the post process can be reused on the same frame. (default: false)
  72700. * @param textureType Type of textures used when performing the post process. (default: 0)
  72701. * @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)
  72702. */
  72703. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72704. }
  72705. }
  72706. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  72707. import { Nullable } from "babylonjs/types";
  72708. import { Camera } from "babylonjs/Cameras/camera";
  72709. import { Engine } from "babylonjs/Engines/engine";
  72710. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72711. import { IInspectable } from "babylonjs/Misc/iInspectable";
  72712. /**
  72713. * PostProcessRenderPipeline
  72714. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72715. */
  72716. export class PostProcessRenderPipeline {
  72717. private engine;
  72718. private _renderEffects;
  72719. private _renderEffectsForIsolatedPass;
  72720. /**
  72721. * List of inspectable custom properties (used by the Inspector)
  72722. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72723. */
  72724. inspectableCustomProperties: IInspectable[];
  72725. /**
  72726. * @hidden
  72727. */
  72728. protected _cameras: Camera[];
  72729. /** @hidden */
  72730. _name: string;
  72731. /**
  72732. * Gets pipeline name
  72733. */
  72734. get name(): string;
  72735. /** Gets the list of attached cameras */
  72736. get cameras(): Camera[];
  72737. /**
  72738. * Initializes a PostProcessRenderPipeline
  72739. * @param engine engine to add the pipeline to
  72740. * @param name name of the pipeline
  72741. */
  72742. constructor(engine: Engine, name: string);
  72743. /**
  72744. * Gets the class name
  72745. * @returns "PostProcessRenderPipeline"
  72746. */
  72747. getClassName(): string;
  72748. /**
  72749. * If all the render effects in the pipeline are supported
  72750. */
  72751. get isSupported(): boolean;
  72752. /**
  72753. * Adds an effect to the pipeline
  72754. * @param renderEffect the effect to add
  72755. */
  72756. addEffect(renderEffect: PostProcessRenderEffect): void;
  72757. /** @hidden */
  72758. _rebuild(): void;
  72759. /** @hidden */
  72760. _enableEffect(renderEffectName: string, cameras: Camera): void;
  72761. /** @hidden */
  72762. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  72763. /** @hidden */
  72764. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72765. /** @hidden */
  72766. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72767. /** @hidden */
  72768. _attachCameras(cameras: Camera, unique: boolean): void;
  72769. /** @hidden */
  72770. _attachCameras(cameras: Camera[], unique: boolean): void;
  72771. /** @hidden */
  72772. _detachCameras(cameras: Camera): void;
  72773. /** @hidden */
  72774. _detachCameras(cameras: Nullable<Camera[]>): void;
  72775. /** @hidden */
  72776. _update(): void;
  72777. /** @hidden */
  72778. _reset(): void;
  72779. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  72780. /**
  72781. * Disposes of the pipeline
  72782. */
  72783. dispose(): void;
  72784. }
  72785. }
  72786. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  72787. import { Camera } from "babylonjs/Cameras/camera";
  72788. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72789. /**
  72790. * PostProcessRenderPipelineManager class
  72791. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72792. */
  72793. export class PostProcessRenderPipelineManager {
  72794. private _renderPipelines;
  72795. /**
  72796. * Initializes a PostProcessRenderPipelineManager
  72797. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72798. */
  72799. constructor();
  72800. /**
  72801. * Gets the list of supported render pipelines
  72802. */
  72803. get supportedPipelines(): PostProcessRenderPipeline[];
  72804. /**
  72805. * Adds a pipeline to the manager
  72806. * @param renderPipeline The pipeline to add
  72807. */
  72808. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  72809. /**
  72810. * Attaches a camera to the pipeline
  72811. * @param renderPipelineName The name of the pipeline to attach to
  72812. * @param cameras the camera to attach
  72813. * @param unique if the camera can be attached multiple times to the pipeline
  72814. */
  72815. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  72816. /**
  72817. * Detaches a camera from the pipeline
  72818. * @param renderPipelineName The name of the pipeline to detach from
  72819. * @param cameras the camera to detach
  72820. */
  72821. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  72822. /**
  72823. * Enables an effect by name on a pipeline
  72824. * @param renderPipelineName the name of the pipeline to enable the effect in
  72825. * @param renderEffectName the name of the effect to enable
  72826. * @param cameras the cameras that the effect should be enabled on
  72827. */
  72828. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72829. /**
  72830. * Disables an effect by name on a pipeline
  72831. * @param renderPipelineName the name of the pipeline to disable the effect in
  72832. * @param renderEffectName the name of the effect to disable
  72833. * @param cameras the cameras that the effect should be disabled on
  72834. */
  72835. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72836. /**
  72837. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  72838. */
  72839. update(): void;
  72840. /** @hidden */
  72841. _rebuild(): void;
  72842. /**
  72843. * Disposes of the manager and pipelines
  72844. */
  72845. dispose(): void;
  72846. }
  72847. }
  72848. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  72849. import { ISceneComponent } from "babylonjs/sceneComponent";
  72850. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  72851. import { Scene } from "babylonjs/scene";
  72852. module "babylonjs/scene" {
  72853. interface Scene {
  72854. /** @hidden (Backing field) */
  72855. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  72856. /**
  72857. * Gets the postprocess render pipeline manager
  72858. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72859. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  72860. */
  72861. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  72862. }
  72863. }
  72864. /**
  72865. * Defines the Render Pipeline scene component responsible to rendering pipelines
  72866. */
  72867. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  72868. /**
  72869. * The component name helpfull to identify the component in the list of scene components.
  72870. */
  72871. readonly name: string;
  72872. /**
  72873. * The scene the component belongs to.
  72874. */
  72875. scene: Scene;
  72876. /**
  72877. * Creates a new instance of the component for the given scene
  72878. * @param scene Defines the scene to register the component in
  72879. */
  72880. constructor(scene: Scene);
  72881. /**
  72882. * Registers the component in a given scene
  72883. */
  72884. register(): void;
  72885. /**
  72886. * Rebuilds the elements related to this component in case of
  72887. * context lost for instance.
  72888. */
  72889. rebuild(): void;
  72890. /**
  72891. * Disposes the component and the associated ressources
  72892. */
  72893. dispose(): void;
  72894. private _gatherRenderTargets;
  72895. }
  72896. }
  72897. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  72898. import { Nullable } from "babylonjs/types";
  72899. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  72900. import { Camera } from "babylonjs/Cameras/camera";
  72901. import { IDisposable } from "babylonjs/scene";
  72902. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  72903. import { Scene } from "babylonjs/scene";
  72904. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  72905. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  72906. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  72907. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  72908. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  72909. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72910. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  72911. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72912. import { Animation } from "babylonjs/Animations/animation";
  72913. /**
  72914. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  72915. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  72916. */
  72917. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72918. private _scene;
  72919. private _camerasToBeAttached;
  72920. /**
  72921. * ID of the sharpen post process,
  72922. */
  72923. private readonly SharpenPostProcessId;
  72924. /**
  72925. * @ignore
  72926. * ID of the image processing post process;
  72927. */
  72928. readonly ImageProcessingPostProcessId: string;
  72929. /**
  72930. * @ignore
  72931. * ID of the Fast Approximate Anti-Aliasing post process;
  72932. */
  72933. readonly FxaaPostProcessId: string;
  72934. /**
  72935. * ID of the chromatic aberration post process,
  72936. */
  72937. private readonly ChromaticAberrationPostProcessId;
  72938. /**
  72939. * ID of the grain post process
  72940. */
  72941. private readonly GrainPostProcessId;
  72942. /**
  72943. * Sharpen post process which will apply a sharpen convolution to enhance edges
  72944. */
  72945. sharpen: SharpenPostProcess;
  72946. private _sharpenEffect;
  72947. private bloom;
  72948. /**
  72949. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  72950. */
  72951. depthOfField: DepthOfFieldEffect;
  72952. /**
  72953. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72954. */
  72955. fxaa: FxaaPostProcess;
  72956. /**
  72957. * Image post processing pass used to perform operations such as tone mapping or color grading.
  72958. */
  72959. imageProcessing: ImageProcessingPostProcess;
  72960. /**
  72961. * Chromatic aberration post process which will shift rgb colors in the image
  72962. */
  72963. chromaticAberration: ChromaticAberrationPostProcess;
  72964. private _chromaticAberrationEffect;
  72965. /**
  72966. * Grain post process which add noise to the image
  72967. */
  72968. grain: GrainPostProcess;
  72969. private _grainEffect;
  72970. /**
  72971. * Glow post process which adds a glow to emissive areas of the image
  72972. */
  72973. private _glowLayer;
  72974. /**
  72975. * Animations which can be used to tweak settings over a period of time
  72976. */
  72977. animations: Animation[];
  72978. private _imageProcessingConfigurationObserver;
  72979. private _sharpenEnabled;
  72980. private _bloomEnabled;
  72981. private _depthOfFieldEnabled;
  72982. private _depthOfFieldBlurLevel;
  72983. private _fxaaEnabled;
  72984. private _imageProcessingEnabled;
  72985. private _defaultPipelineTextureType;
  72986. private _bloomScale;
  72987. private _chromaticAberrationEnabled;
  72988. private _grainEnabled;
  72989. private _buildAllowed;
  72990. /**
  72991. * Gets active scene
  72992. */
  72993. get scene(): Scene;
  72994. /**
  72995. * Enable or disable the sharpen process from the pipeline
  72996. */
  72997. set sharpenEnabled(enabled: boolean);
  72998. get sharpenEnabled(): boolean;
  72999. private _resizeObserver;
  73000. private _hardwareScaleLevel;
  73001. private _bloomKernel;
  73002. /**
  73003. * Specifies the size of the bloom blur kernel, relative to the final output size
  73004. */
  73005. get bloomKernel(): number;
  73006. set bloomKernel(value: number);
  73007. /**
  73008. * Specifies the weight of the bloom in the final rendering
  73009. */
  73010. private _bloomWeight;
  73011. /**
  73012. * Specifies the luma threshold for the area that will be blurred by the bloom
  73013. */
  73014. private _bloomThreshold;
  73015. private _hdr;
  73016. /**
  73017. * The strength of the bloom.
  73018. */
  73019. set bloomWeight(value: number);
  73020. get bloomWeight(): number;
  73021. /**
  73022. * The strength of the bloom.
  73023. */
  73024. set bloomThreshold(value: number);
  73025. get bloomThreshold(): number;
  73026. /**
  73027. * The scale of the bloom, lower value will provide better performance.
  73028. */
  73029. set bloomScale(value: number);
  73030. get bloomScale(): number;
  73031. /**
  73032. * Enable or disable the bloom from the pipeline
  73033. */
  73034. set bloomEnabled(enabled: boolean);
  73035. get bloomEnabled(): boolean;
  73036. private _rebuildBloom;
  73037. /**
  73038. * If the depth of field is enabled.
  73039. */
  73040. get depthOfFieldEnabled(): boolean;
  73041. set depthOfFieldEnabled(enabled: boolean);
  73042. /**
  73043. * Blur level of the depth of field effect. (Higher blur will effect performance)
  73044. */
  73045. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  73046. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  73047. /**
  73048. * If the anti aliasing is enabled.
  73049. */
  73050. set fxaaEnabled(enabled: boolean);
  73051. get fxaaEnabled(): boolean;
  73052. private _samples;
  73053. /**
  73054. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  73055. */
  73056. set samples(sampleCount: number);
  73057. get samples(): number;
  73058. /**
  73059. * If image processing is enabled.
  73060. */
  73061. set imageProcessingEnabled(enabled: boolean);
  73062. get imageProcessingEnabled(): boolean;
  73063. /**
  73064. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  73065. */
  73066. set glowLayerEnabled(enabled: boolean);
  73067. get glowLayerEnabled(): boolean;
  73068. /**
  73069. * Gets the glow layer (or null if not defined)
  73070. */
  73071. get glowLayer(): Nullable<GlowLayer>;
  73072. /**
  73073. * Enable or disable the chromaticAberration process from the pipeline
  73074. */
  73075. set chromaticAberrationEnabled(enabled: boolean);
  73076. get chromaticAberrationEnabled(): boolean;
  73077. /**
  73078. * Enable or disable the grain process from the pipeline
  73079. */
  73080. set grainEnabled(enabled: boolean);
  73081. get grainEnabled(): boolean;
  73082. /**
  73083. * @constructor
  73084. * @param name - The rendering pipeline name (default: "")
  73085. * @param hdr - If high dynamic range textures should be used (default: true)
  73086. * @param scene - The scene linked to this pipeline (default: the last created scene)
  73087. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  73088. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  73089. */
  73090. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  73091. /**
  73092. * Get the class name
  73093. * @returns "DefaultRenderingPipeline"
  73094. */
  73095. getClassName(): string;
  73096. /**
  73097. * Force the compilation of the entire pipeline.
  73098. */
  73099. prepare(): void;
  73100. private _hasCleared;
  73101. private _prevPostProcess;
  73102. private _prevPrevPostProcess;
  73103. private _setAutoClearAndTextureSharing;
  73104. private _depthOfFieldSceneObserver;
  73105. private _buildPipeline;
  73106. private _disposePostProcesses;
  73107. /**
  73108. * Adds a camera to the pipeline
  73109. * @param camera the camera to be added
  73110. */
  73111. addCamera(camera: Camera): void;
  73112. /**
  73113. * Removes a camera from the pipeline
  73114. * @param camera the camera to remove
  73115. */
  73116. removeCamera(camera: Camera): void;
  73117. /**
  73118. * Dispose of the pipeline and stop all post processes
  73119. */
  73120. dispose(): void;
  73121. /**
  73122. * Serialize the rendering pipeline (Used when exporting)
  73123. * @returns the serialized object
  73124. */
  73125. serialize(): any;
  73126. /**
  73127. * Parse the serialized pipeline
  73128. * @param source Source pipeline.
  73129. * @param scene The scene to load the pipeline to.
  73130. * @param rootUrl The URL of the serialized pipeline.
  73131. * @returns An instantiated pipeline from the serialized object.
  73132. */
  73133. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  73134. }
  73135. }
  73136. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  73137. /** @hidden */
  73138. export var lensHighlightsPixelShader: {
  73139. name: string;
  73140. shader: string;
  73141. };
  73142. }
  73143. declare module "babylonjs/Shaders/depthOfField.fragment" {
  73144. /** @hidden */
  73145. export var depthOfFieldPixelShader: {
  73146. name: string;
  73147. shader: string;
  73148. };
  73149. }
  73150. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  73151. import { Camera } from "babylonjs/Cameras/camera";
  73152. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73153. import { Scene } from "babylonjs/scene";
  73154. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73155. import "babylonjs/Shaders/chromaticAberration.fragment";
  73156. import "babylonjs/Shaders/lensHighlights.fragment";
  73157. import "babylonjs/Shaders/depthOfField.fragment";
  73158. /**
  73159. * BABYLON.JS Chromatic Aberration GLSL Shader
  73160. * Author: Olivier Guyot
  73161. * Separates very slightly R, G and B colors on the edges of the screen
  73162. * Inspired by Francois Tarlier & Martins Upitis
  73163. */
  73164. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  73165. /**
  73166. * @ignore
  73167. * The chromatic aberration PostProcess id in the pipeline
  73168. */
  73169. LensChromaticAberrationEffect: string;
  73170. /**
  73171. * @ignore
  73172. * The highlights enhancing PostProcess id in the pipeline
  73173. */
  73174. HighlightsEnhancingEffect: string;
  73175. /**
  73176. * @ignore
  73177. * The depth-of-field PostProcess id in the pipeline
  73178. */
  73179. LensDepthOfFieldEffect: string;
  73180. private _scene;
  73181. private _depthTexture;
  73182. private _grainTexture;
  73183. private _chromaticAberrationPostProcess;
  73184. private _highlightsPostProcess;
  73185. private _depthOfFieldPostProcess;
  73186. private _edgeBlur;
  73187. private _grainAmount;
  73188. private _chromaticAberration;
  73189. private _distortion;
  73190. private _highlightsGain;
  73191. private _highlightsThreshold;
  73192. private _dofDistance;
  73193. private _dofAperture;
  73194. private _dofDarken;
  73195. private _dofPentagon;
  73196. private _blurNoise;
  73197. /**
  73198. * @constructor
  73199. *
  73200. * Effect parameters are as follow:
  73201. * {
  73202. * chromatic_aberration: number; // from 0 to x (1 for realism)
  73203. * edge_blur: number; // from 0 to x (1 for realism)
  73204. * distortion: number; // from 0 to x (1 for realism)
  73205. * grain_amount: number; // from 0 to 1
  73206. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  73207. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  73208. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  73209. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  73210. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  73211. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  73212. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  73213. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  73214. * }
  73215. * Note: if an effect parameter is unset, effect is disabled
  73216. *
  73217. * @param name The rendering pipeline name
  73218. * @param parameters - An object containing all parameters (see above)
  73219. * @param scene The scene linked to this pipeline
  73220. * @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)
  73221. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73222. */
  73223. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  73224. /**
  73225. * Get the class name
  73226. * @returns "LensRenderingPipeline"
  73227. */
  73228. getClassName(): string;
  73229. /**
  73230. * Gets associated scene
  73231. */
  73232. get scene(): Scene;
  73233. /**
  73234. * Gets or sets the edge blur
  73235. */
  73236. get edgeBlur(): number;
  73237. set edgeBlur(value: number);
  73238. /**
  73239. * Gets or sets the grain amount
  73240. */
  73241. get grainAmount(): number;
  73242. set grainAmount(value: number);
  73243. /**
  73244. * Gets or sets the chromatic aberration amount
  73245. */
  73246. get chromaticAberration(): number;
  73247. set chromaticAberration(value: number);
  73248. /**
  73249. * Gets or sets the depth of field aperture
  73250. */
  73251. get dofAperture(): number;
  73252. set dofAperture(value: number);
  73253. /**
  73254. * Gets or sets the edge distortion
  73255. */
  73256. get edgeDistortion(): number;
  73257. set edgeDistortion(value: number);
  73258. /**
  73259. * Gets or sets the depth of field distortion
  73260. */
  73261. get dofDistortion(): number;
  73262. set dofDistortion(value: number);
  73263. /**
  73264. * Gets or sets the darken out of focus amount
  73265. */
  73266. get darkenOutOfFocus(): number;
  73267. set darkenOutOfFocus(value: number);
  73268. /**
  73269. * Gets or sets a boolean indicating if blur noise is enabled
  73270. */
  73271. get blurNoise(): boolean;
  73272. set blurNoise(value: boolean);
  73273. /**
  73274. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  73275. */
  73276. get pentagonBokeh(): boolean;
  73277. set pentagonBokeh(value: boolean);
  73278. /**
  73279. * Gets or sets the highlight grain amount
  73280. */
  73281. get highlightsGain(): number;
  73282. set highlightsGain(value: number);
  73283. /**
  73284. * Gets or sets the highlight threshold
  73285. */
  73286. get highlightsThreshold(): number;
  73287. set highlightsThreshold(value: number);
  73288. /**
  73289. * Sets the amount of blur at the edges
  73290. * @param amount blur amount
  73291. */
  73292. setEdgeBlur(amount: number): void;
  73293. /**
  73294. * Sets edge blur to 0
  73295. */
  73296. disableEdgeBlur(): void;
  73297. /**
  73298. * Sets the amout of grain
  73299. * @param amount Amount of grain
  73300. */
  73301. setGrainAmount(amount: number): void;
  73302. /**
  73303. * Set grain amount to 0
  73304. */
  73305. disableGrain(): void;
  73306. /**
  73307. * Sets the chromatic aberration amount
  73308. * @param amount amount of chromatic aberration
  73309. */
  73310. setChromaticAberration(amount: number): void;
  73311. /**
  73312. * Sets chromatic aberration amount to 0
  73313. */
  73314. disableChromaticAberration(): void;
  73315. /**
  73316. * Sets the EdgeDistortion amount
  73317. * @param amount amount of EdgeDistortion
  73318. */
  73319. setEdgeDistortion(amount: number): void;
  73320. /**
  73321. * Sets edge distortion to 0
  73322. */
  73323. disableEdgeDistortion(): void;
  73324. /**
  73325. * Sets the FocusDistance amount
  73326. * @param amount amount of FocusDistance
  73327. */
  73328. setFocusDistance(amount: number): void;
  73329. /**
  73330. * Disables depth of field
  73331. */
  73332. disableDepthOfField(): void;
  73333. /**
  73334. * Sets the Aperture amount
  73335. * @param amount amount of Aperture
  73336. */
  73337. setAperture(amount: number): void;
  73338. /**
  73339. * Sets the DarkenOutOfFocus amount
  73340. * @param amount amount of DarkenOutOfFocus
  73341. */
  73342. setDarkenOutOfFocus(amount: number): void;
  73343. private _pentagonBokehIsEnabled;
  73344. /**
  73345. * Creates a pentagon bokeh effect
  73346. */
  73347. enablePentagonBokeh(): void;
  73348. /**
  73349. * Disables the pentagon bokeh effect
  73350. */
  73351. disablePentagonBokeh(): void;
  73352. /**
  73353. * Enables noise blur
  73354. */
  73355. enableNoiseBlur(): void;
  73356. /**
  73357. * Disables noise blur
  73358. */
  73359. disableNoiseBlur(): void;
  73360. /**
  73361. * Sets the HighlightsGain amount
  73362. * @param amount amount of HighlightsGain
  73363. */
  73364. setHighlightsGain(amount: number): void;
  73365. /**
  73366. * Sets the HighlightsThreshold amount
  73367. * @param amount amount of HighlightsThreshold
  73368. */
  73369. setHighlightsThreshold(amount: number): void;
  73370. /**
  73371. * Disables highlights
  73372. */
  73373. disableHighlights(): void;
  73374. /**
  73375. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  73376. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  73377. */
  73378. dispose(disableDepthRender?: boolean): void;
  73379. private _createChromaticAberrationPostProcess;
  73380. private _createHighlightsPostProcess;
  73381. private _createDepthOfFieldPostProcess;
  73382. private _createGrainTexture;
  73383. }
  73384. }
  73385. declare module "babylonjs/Shaders/ssao2.fragment" {
  73386. /** @hidden */
  73387. export var ssao2PixelShader: {
  73388. name: string;
  73389. shader: string;
  73390. };
  73391. }
  73392. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  73393. /** @hidden */
  73394. export var ssaoCombinePixelShader: {
  73395. name: string;
  73396. shader: string;
  73397. };
  73398. }
  73399. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  73400. import { Camera } from "babylonjs/Cameras/camera";
  73401. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73402. import { Scene } from "babylonjs/scene";
  73403. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73404. import "babylonjs/Shaders/ssao2.fragment";
  73405. import "babylonjs/Shaders/ssaoCombine.fragment";
  73406. /**
  73407. * Render pipeline to produce ssao effect
  73408. */
  73409. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  73410. /**
  73411. * @ignore
  73412. * The PassPostProcess id in the pipeline that contains the original scene color
  73413. */
  73414. SSAOOriginalSceneColorEffect: string;
  73415. /**
  73416. * @ignore
  73417. * The SSAO PostProcess id in the pipeline
  73418. */
  73419. SSAORenderEffect: string;
  73420. /**
  73421. * @ignore
  73422. * The horizontal blur PostProcess id in the pipeline
  73423. */
  73424. SSAOBlurHRenderEffect: string;
  73425. /**
  73426. * @ignore
  73427. * The vertical blur PostProcess id in the pipeline
  73428. */
  73429. SSAOBlurVRenderEffect: string;
  73430. /**
  73431. * @ignore
  73432. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  73433. */
  73434. SSAOCombineRenderEffect: string;
  73435. /**
  73436. * The output strength of the SSAO post-process. Default value is 1.0.
  73437. */
  73438. totalStrength: number;
  73439. /**
  73440. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  73441. */
  73442. maxZ: number;
  73443. /**
  73444. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  73445. */
  73446. minZAspect: number;
  73447. private _samples;
  73448. /**
  73449. * Number of samples used for the SSAO calculations. Default value is 8
  73450. */
  73451. set samples(n: number);
  73452. get samples(): number;
  73453. private _textureSamples;
  73454. /**
  73455. * Number of samples to use for antialiasing
  73456. */
  73457. set textureSamples(n: number);
  73458. get textureSamples(): number;
  73459. /**
  73460. * Ratio object used for SSAO ratio and blur ratio
  73461. */
  73462. private _ratio;
  73463. /**
  73464. * Dynamically generated sphere sampler.
  73465. */
  73466. private _sampleSphere;
  73467. /**
  73468. * Blur filter offsets
  73469. */
  73470. private _samplerOffsets;
  73471. private _expensiveBlur;
  73472. /**
  73473. * If bilateral blur should be used
  73474. */
  73475. set expensiveBlur(b: boolean);
  73476. get expensiveBlur(): boolean;
  73477. /**
  73478. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  73479. */
  73480. radius: number;
  73481. /**
  73482. * The base color of the SSAO post-process
  73483. * The final result is "base + ssao" between [0, 1]
  73484. */
  73485. base: number;
  73486. /**
  73487. * Support test.
  73488. */
  73489. static get IsSupported(): boolean;
  73490. private _scene;
  73491. private _depthTexture;
  73492. private _normalTexture;
  73493. private _randomTexture;
  73494. private _originalColorPostProcess;
  73495. private _ssaoPostProcess;
  73496. private _blurHPostProcess;
  73497. private _blurVPostProcess;
  73498. private _ssaoCombinePostProcess;
  73499. /**
  73500. * Gets active scene
  73501. */
  73502. get scene(): Scene;
  73503. /**
  73504. * @constructor
  73505. * @param name The rendering pipeline name
  73506. * @param scene The scene linked to this pipeline
  73507. * @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 }
  73508. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73509. */
  73510. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  73511. /**
  73512. * Get the class name
  73513. * @returns "SSAO2RenderingPipeline"
  73514. */
  73515. getClassName(): string;
  73516. /**
  73517. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  73518. */
  73519. dispose(disableGeometryBufferRenderer?: boolean): void;
  73520. private _createBlurPostProcess;
  73521. /** @hidden */
  73522. _rebuild(): void;
  73523. private _bits;
  73524. private _radicalInverse_VdC;
  73525. private _hammersley;
  73526. private _hemisphereSample_uniform;
  73527. private _generateHemisphere;
  73528. private _createSSAOPostProcess;
  73529. private _createSSAOCombinePostProcess;
  73530. private _createRandomTexture;
  73531. /**
  73532. * Serialize the rendering pipeline (Used when exporting)
  73533. * @returns the serialized object
  73534. */
  73535. serialize(): any;
  73536. /**
  73537. * Parse the serialized pipeline
  73538. * @param source Source pipeline.
  73539. * @param scene The scene to load the pipeline to.
  73540. * @param rootUrl The URL of the serialized pipeline.
  73541. * @returns An instantiated pipeline from the serialized object.
  73542. */
  73543. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  73544. }
  73545. }
  73546. declare module "babylonjs/Shaders/ssao.fragment" {
  73547. /** @hidden */
  73548. export var ssaoPixelShader: {
  73549. name: string;
  73550. shader: string;
  73551. };
  73552. }
  73553. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  73554. import { Camera } from "babylonjs/Cameras/camera";
  73555. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73556. import { Scene } from "babylonjs/scene";
  73557. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73558. import "babylonjs/Shaders/ssao.fragment";
  73559. import "babylonjs/Shaders/ssaoCombine.fragment";
  73560. /**
  73561. * Render pipeline to produce ssao effect
  73562. */
  73563. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  73564. /**
  73565. * @ignore
  73566. * The PassPostProcess id in the pipeline that contains the original scene color
  73567. */
  73568. SSAOOriginalSceneColorEffect: string;
  73569. /**
  73570. * @ignore
  73571. * The SSAO PostProcess id in the pipeline
  73572. */
  73573. SSAORenderEffect: string;
  73574. /**
  73575. * @ignore
  73576. * The horizontal blur PostProcess id in the pipeline
  73577. */
  73578. SSAOBlurHRenderEffect: string;
  73579. /**
  73580. * @ignore
  73581. * The vertical blur PostProcess id in the pipeline
  73582. */
  73583. SSAOBlurVRenderEffect: string;
  73584. /**
  73585. * @ignore
  73586. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  73587. */
  73588. SSAOCombineRenderEffect: string;
  73589. /**
  73590. * The output strength of the SSAO post-process. Default value is 1.0.
  73591. */
  73592. totalStrength: number;
  73593. /**
  73594. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  73595. */
  73596. radius: number;
  73597. /**
  73598. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  73599. * Must not be equal to fallOff and superior to fallOff.
  73600. * Default value is 0.0075
  73601. */
  73602. area: number;
  73603. /**
  73604. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  73605. * Must not be equal to area and inferior to area.
  73606. * Default value is 0.000001
  73607. */
  73608. fallOff: number;
  73609. /**
  73610. * The base color of the SSAO post-process
  73611. * The final result is "base + ssao" between [0, 1]
  73612. */
  73613. base: number;
  73614. private _scene;
  73615. private _depthTexture;
  73616. private _randomTexture;
  73617. private _originalColorPostProcess;
  73618. private _ssaoPostProcess;
  73619. private _blurHPostProcess;
  73620. private _blurVPostProcess;
  73621. private _ssaoCombinePostProcess;
  73622. private _firstUpdate;
  73623. /**
  73624. * Gets active scene
  73625. */
  73626. get scene(): Scene;
  73627. /**
  73628. * @constructor
  73629. * @param name - The rendering pipeline name
  73630. * @param scene - The scene linked to this pipeline
  73631. * @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 }
  73632. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  73633. */
  73634. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  73635. /**
  73636. * Get the class name
  73637. * @returns "SSAORenderingPipeline"
  73638. */
  73639. getClassName(): string;
  73640. /**
  73641. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  73642. */
  73643. dispose(disableDepthRender?: boolean): void;
  73644. private _createBlurPostProcess;
  73645. /** @hidden */
  73646. _rebuild(): void;
  73647. private _createSSAOPostProcess;
  73648. private _createSSAOCombinePostProcess;
  73649. private _createRandomTexture;
  73650. }
  73651. }
  73652. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  73653. /** @hidden */
  73654. export var screenSpaceReflectionPixelShader: {
  73655. name: string;
  73656. shader: string;
  73657. };
  73658. }
  73659. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  73660. import { Nullable } from "babylonjs/types";
  73661. import { Camera } from "babylonjs/Cameras/camera";
  73662. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73663. import { Scene } from "babylonjs/scene";
  73664. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  73665. import { Engine } from "babylonjs/Engines/engine";
  73666. /**
  73667. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  73668. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  73669. */
  73670. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  73671. /**
  73672. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  73673. */
  73674. threshold: number;
  73675. /**
  73676. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  73677. */
  73678. strength: number;
  73679. /**
  73680. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  73681. */
  73682. reflectionSpecularFalloffExponent: number;
  73683. /**
  73684. * Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]
  73685. */
  73686. step: number;
  73687. /**
  73688. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  73689. */
  73690. roughnessFactor: number;
  73691. private _geometryBufferRenderer;
  73692. private _enableSmoothReflections;
  73693. private _reflectionSamples;
  73694. private _smoothSteps;
  73695. /**
  73696. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  73697. * @param name The name of the effect.
  73698. * @param scene The scene containing the objects to calculate reflections.
  73699. * @param options The required width/height ratio to downsize to before computing the render pass.
  73700. * @param camera The camera to apply the render pass to.
  73701. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73702. * @param engine The engine which the post process will be applied. (default: current engine)
  73703. * @param reusable If the post process can be reused on the same frame. (default: false)
  73704. * @param textureType Type of textures used when performing the post process. (default: 0)
  73705. * @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)
  73706. */
  73707. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73708. /**
  73709. * Gets wether or not smoothing reflections is enabled.
  73710. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  73711. */
  73712. get enableSmoothReflections(): boolean;
  73713. /**
  73714. * Sets wether or not smoothing reflections is enabled.
  73715. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  73716. */
  73717. set enableSmoothReflections(enabled: boolean);
  73718. /**
  73719. * Gets the number of samples taken while computing reflections. More samples count is high,
  73720. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  73721. */
  73722. get reflectionSamples(): number;
  73723. /**
  73724. * Sets the number of samples taken while computing reflections. More samples count is high,
  73725. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  73726. */
  73727. set reflectionSamples(samples: number);
  73728. /**
  73729. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  73730. * more the post-process will require GPU power and can generate a drop in FPS.
  73731. * Default value (5.0) work pretty well in all cases but can be adjusted.
  73732. */
  73733. get smoothSteps(): number;
  73734. set smoothSteps(steps: number);
  73735. private _updateEffectDefines;
  73736. }
  73737. }
  73738. declare module "babylonjs/Shaders/standard.fragment" {
  73739. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  73740. /** @hidden */
  73741. export var standardPixelShader: {
  73742. name: string;
  73743. shader: string;
  73744. };
  73745. }
  73746. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  73747. import { Nullable } from "babylonjs/types";
  73748. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  73749. import { Camera } from "babylonjs/Cameras/camera";
  73750. import { Texture } from "babylonjs/Materials/Textures/texture";
  73751. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73752. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73753. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73754. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  73755. import { IDisposable } from "babylonjs/scene";
  73756. import { SpotLight } from "babylonjs/Lights/spotLight";
  73757. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  73758. import { Scene } from "babylonjs/scene";
  73759. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  73760. import { Animation } from "babylonjs/Animations/animation";
  73761. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73762. import "babylonjs/Shaders/standard.fragment";
  73763. /**
  73764. * Standard rendering pipeline
  73765. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  73766. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  73767. */
  73768. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  73769. /**
  73770. * Public members
  73771. */
  73772. /**
  73773. * Post-process which contains the original scene color before the pipeline applies all the effects
  73774. */
  73775. originalPostProcess: Nullable<PostProcess>;
  73776. /**
  73777. * Post-process used to down scale an image x4
  73778. */
  73779. downSampleX4PostProcess: Nullable<PostProcess>;
  73780. /**
  73781. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  73782. */
  73783. brightPassPostProcess: Nullable<PostProcess>;
  73784. /**
  73785. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  73786. */
  73787. blurHPostProcesses: PostProcess[];
  73788. /**
  73789. * Post-process array storing all the vertical blur post-processes used by the pipeline
  73790. */
  73791. blurVPostProcesses: PostProcess[];
  73792. /**
  73793. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  73794. */
  73795. textureAdderPostProcess: Nullable<PostProcess>;
  73796. /**
  73797. * Post-process used to create volumetric lighting effect
  73798. */
  73799. volumetricLightPostProcess: Nullable<PostProcess>;
  73800. /**
  73801. * Post-process used to smooth the previous volumetric light post-process on the X axis
  73802. */
  73803. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  73804. /**
  73805. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  73806. */
  73807. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  73808. /**
  73809. * Post-process used to merge the volumetric light effect and the real scene color
  73810. */
  73811. volumetricLightMergePostProces: Nullable<PostProcess>;
  73812. /**
  73813. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  73814. */
  73815. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  73816. /**
  73817. * Base post-process used to calculate the average luminance of the final image for HDR
  73818. */
  73819. luminancePostProcess: Nullable<PostProcess>;
  73820. /**
  73821. * Post-processes used to create down sample post-processes in order to get
  73822. * the average luminance of the final image for HDR
  73823. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  73824. */
  73825. luminanceDownSamplePostProcesses: PostProcess[];
  73826. /**
  73827. * Post-process used to create a HDR effect (light adaptation)
  73828. */
  73829. hdrPostProcess: Nullable<PostProcess>;
  73830. /**
  73831. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  73832. */
  73833. textureAdderFinalPostProcess: Nullable<PostProcess>;
  73834. /**
  73835. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  73836. */
  73837. lensFlareFinalPostProcess: Nullable<PostProcess>;
  73838. /**
  73839. * Post-process used to merge the final HDR post-process and the real scene color
  73840. */
  73841. hdrFinalPostProcess: Nullable<PostProcess>;
  73842. /**
  73843. * Post-process used to create a lens flare effect
  73844. */
  73845. lensFlarePostProcess: Nullable<PostProcess>;
  73846. /**
  73847. * Post-process that merges the result of the lens flare post-process and the real scene color
  73848. */
  73849. lensFlareComposePostProcess: Nullable<PostProcess>;
  73850. /**
  73851. * Post-process used to create a motion blur effect
  73852. */
  73853. motionBlurPostProcess: Nullable<PostProcess>;
  73854. /**
  73855. * Post-process used to create a depth of field effect
  73856. */
  73857. depthOfFieldPostProcess: Nullable<PostProcess>;
  73858. /**
  73859. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  73860. */
  73861. fxaaPostProcess: Nullable<FxaaPostProcess>;
  73862. /**
  73863. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  73864. */
  73865. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  73866. /**
  73867. * Represents the brightness threshold in order to configure the illuminated surfaces
  73868. */
  73869. brightThreshold: number;
  73870. /**
  73871. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  73872. */
  73873. blurWidth: number;
  73874. /**
  73875. * Sets if the blur for highlighted surfaces must be only horizontal
  73876. */
  73877. horizontalBlur: boolean;
  73878. /**
  73879. * Gets the overall exposure used by the pipeline
  73880. */
  73881. get exposure(): number;
  73882. /**
  73883. * Sets the overall exposure used by the pipeline
  73884. */
  73885. set exposure(value: number);
  73886. /**
  73887. * Texture used typically to simulate "dirty" on camera lens
  73888. */
  73889. lensTexture: Nullable<Texture>;
  73890. /**
  73891. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  73892. */
  73893. volumetricLightCoefficient: number;
  73894. /**
  73895. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  73896. */
  73897. volumetricLightPower: number;
  73898. /**
  73899. * Used the set the blur intensity to smooth the volumetric lights
  73900. */
  73901. volumetricLightBlurScale: number;
  73902. /**
  73903. * Light (spot or directional) used to generate the volumetric lights rays
  73904. * The source light must have a shadow generate so the pipeline can get its
  73905. * depth map
  73906. */
  73907. sourceLight: Nullable<SpotLight | DirectionalLight>;
  73908. /**
  73909. * For eye adaptation, represents the minimum luminance the eye can see
  73910. */
  73911. hdrMinimumLuminance: number;
  73912. /**
  73913. * For eye adaptation, represents the decrease luminance speed
  73914. */
  73915. hdrDecreaseRate: number;
  73916. /**
  73917. * For eye adaptation, represents the increase luminance speed
  73918. */
  73919. hdrIncreaseRate: number;
  73920. /**
  73921. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  73922. */
  73923. get hdrAutoExposure(): boolean;
  73924. /**
  73925. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  73926. */
  73927. set hdrAutoExposure(value: boolean);
  73928. /**
  73929. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  73930. */
  73931. lensColorTexture: Nullable<Texture>;
  73932. /**
  73933. * The overall strengh for the lens flare effect
  73934. */
  73935. lensFlareStrength: number;
  73936. /**
  73937. * Dispersion coefficient for lens flare ghosts
  73938. */
  73939. lensFlareGhostDispersal: number;
  73940. /**
  73941. * Main lens flare halo width
  73942. */
  73943. lensFlareHaloWidth: number;
  73944. /**
  73945. * Based on the lens distortion effect, defines how much the lens flare result
  73946. * is distorted
  73947. */
  73948. lensFlareDistortionStrength: number;
  73949. /**
  73950. * Configures the blur intensity used for for lens flare (halo)
  73951. */
  73952. lensFlareBlurWidth: number;
  73953. /**
  73954. * Lens star texture must be used to simulate rays on the flares and is available
  73955. * in the documentation
  73956. */
  73957. lensStarTexture: Nullable<Texture>;
  73958. /**
  73959. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  73960. * flare effect by taking account of the dirt texture
  73961. */
  73962. lensFlareDirtTexture: Nullable<Texture>;
  73963. /**
  73964. * Represents the focal length for the depth of field effect
  73965. */
  73966. depthOfFieldDistance: number;
  73967. /**
  73968. * Represents the blur intensity for the blurred part of the depth of field effect
  73969. */
  73970. depthOfFieldBlurWidth: number;
  73971. /**
  73972. * Gets how much the image is blurred by the movement while using the motion blur post-process
  73973. */
  73974. get motionStrength(): number;
  73975. /**
  73976. * Sets how much the image is blurred by the movement while using the motion blur post-process
  73977. */
  73978. set motionStrength(strength: number);
  73979. /**
  73980. * Gets wether or not the motion blur post-process is object based or screen based.
  73981. */
  73982. get objectBasedMotionBlur(): boolean;
  73983. /**
  73984. * Sets wether or not the motion blur post-process should be object based or screen based
  73985. */
  73986. set objectBasedMotionBlur(value: boolean);
  73987. /**
  73988. * List of animations for the pipeline (IAnimatable implementation)
  73989. */
  73990. animations: Animation[];
  73991. /**
  73992. * Private members
  73993. */
  73994. private _scene;
  73995. private _currentDepthOfFieldSource;
  73996. private _basePostProcess;
  73997. private _fixedExposure;
  73998. private _currentExposure;
  73999. private _hdrAutoExposure;
  74000. private _hdrCurrentLuminance;
  74001. private _motionStrength;
  74002. private _isObjectBasedMotionBlur;
  74003. private _floatTextureType;
  74004. private _camerasToBeAttached;
  74005. private _ratio;
  74006. private _bloomEnabled;
  74007. private _depthOfFieldEnabled;
  74008. private _vlsEnabled;
  74009. private _lensFlareEnabled;
  74010. private _hdrEnabled;
  74011. private _motionBlurEnabled;
  74012. private _fxaaEnabled;
  74013. private _screenSpaceReflectionsEnabled;
  74014. private _motionBlurSamples;
  74015. private _volumetricLightStepsCount;
  74016. private _samples;
  74017. /**
  74018. * @ignore
  74019. * Specifies if the bloom pipeline is enabled
  74020. */
  74021. get BloomEnabled(): boolean;
  74022. set BloomEnabled(enabled: boolean);
  74023. /**
  74024. * @ignore
  74025. * Specifies if the depth of field pipeline is enabed
  74026. */
  74027. get DepthOfFieldEnabled(): boolean;
  74028. set DepthOfFieldEnabled(enabled: boolean);
  74029. /**
  74030. * @ignore
  74031. * Specifies if the lens flare pipeline is enabed
  74032. */
  74033. get LensFlareEnabled(): boolean;
  74034. set LensFlareEnabled(enabled: boolean);
  74035. /**
  74036. * @ignore
  74037. * Specifies if the HDR pipeline is enabled
  74038. */
  74039. get HDREnabled(): boolean;
  74040. set HDREnabled(enabled: boolean);
  74041. /**
  74042. * @ignore
  74043. * Specifies if the volumetric lights scattering effect is enabled
  74044. */
  74045. get VLSEnabled(): boolean;
  74046. set VLSEnabled(enabled: boolean);
  74047. /**
  74048. * @ignore
  74049. * Specifies if the motion blur effect is enabled
  74050. */
  74051. get MotionBlurEnabled(): boolean;
  74052. set MotionBlurEnabled(enabled: boolean);
  74053. /**
  74054. * Specifies if anti-aliasing is enabled
  74055. */
  74056. get fxaaEnabled(): boolean;
  74057. set fxaaEnabled(enabled: boolean);
  74058. /**
  74059. * Specifies if screen space reflections are enabled.
  74060. */
  74061. get screenSpaceReflectionsEnabled(): boolean;
  74062. set screenSpaceReflectionsEnabled(enabled: boolean);
  74063. /**
  74064. * Specifies the number of steps used to calculate the volumetric lights
  74065. * Typically in interval [50, 200]
  74066. */
  74067. get volumetricLightStepsCount(): number;
  74068. set volumetricLightStepsCount(count: number);
  74069. /**
  74070. * Specifies the number of samples used for the motion blur effect
  74071. * Typically in interval [16, 64]
  74072. */
  74073. get motionBlurSamples(): number;
  74074. set motionBlurSamples(samples: number);
  74075. /**
  74076. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74077. */
  74078. get samples(): number;
  74079. set samples(sampleCount: number);
  74080. /**
  74081. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  74082. * @constructor
  74083. * @param name The rendering pipeline name
  74084. * @param scene The scene linked to this pipeline
  74085. * @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)
  74086. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  74087. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74088. */
  74089. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  74090. private _buildPipeline;
  74091. private _createDownSampleX4PostProcess;
  74092. private _createBrightPassPostProcess;
  74093. private _createBlurPostProcesses;
  74094. private _createTextureAdderPostProcess;
  74095. private _createVolumetricLightPostProcess;
  74096. private _createLuminancePostProcesses;
  74097. private _createHdrPostProcess;
  74098. private _createLensFlarePostProcess;
  74099. private _createDepthOfFieldPostProcess;
  74100. private _createMotionBlurPostProcess;
  74101. private _getDepthTexture;
  74102. private _disposePostProcesses;
  74103. /**
  74104. * Dispose of the pipeline and stop all post processes
  74105. */
  74106. dispose(): void;
  74107. /**
  74108. * Serialize the rendering pipeline (Used when exporting)
  74109. * @returns the serialized object
  74110. */
  74111. serialize(): any;
  74112. /**
  74113. * Parse the serialized pipeline
  74114. * @param source Source pipeline.
  74115. * @param scene The scene to load the pipeline to.
  74116. * @param rootUrl The URL of the serialized pipeline.
  74117. * @returns An instantiated pipeline from the serialized object.
  74118. */
  74119. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  74120. /**
  74121. * Luminance steps
  74122. */
  74123. static LuminanceSteps: number;
  74124. }
  74125. }
  74126. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  74127. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  74128. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  74129. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  74130. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  74131. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  74132. }
  74133. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  74134. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  74135. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74136. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74137. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74138. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74139. }
  74140. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  74141. /** @hidden */
  74142. export var stereoscopicInterlacePixelShader: {
  74143. name: string;
  74144. shader: string;
  74145. };
  74146. }
  74147. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  74148. import { Camera } from "babylonjs/Cameras/camera";
  74149. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74150. import { Engine } from "babylonjs/Engines/engine";
  74151. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  74152. /**
  74153. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  74154. */
  74155. export class StereoscopicInterlacePostProcessI extends PostProcess {
  74156. private _stepSize;
  74157. private _passedProcess;
  74158. /**
  74159. * Initializes a StereoscopicInterlacePostProcessI
  74160. * @param name The name of the effect.
  74161. * @param rigCameras The rig cameras to be appled to the post process
  74162. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  74163. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  74164. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74165. * @param engine The engine which the post process will be applied. (default: current engine)
  74166. * @param reusable If the post process can be reused on the same frame. (default: false)
  74167. */
  74168. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74169. }
  74170. /**
  74171. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  74172. */
  74173. export class StereoscopicInterlacePostProcess extends PostProcess {
  74174. private _stepSize;
  74175. private _passedProcess;
  74176. /**
  74177. * Initializes a StereoscopicInterlacePostProcess
  74178. * @param name The name of the effect.
  74179. * @param rigCameras The rig cameras to be appled to the post process
  74180. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  74181. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74182. * @param engine The engine which the post process will be applied. (default: current engine)
  74183. * @param reusable If the post process can be reused on the same frame. (default: false)
  74184. */
  74185. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74186. }
  74187. }
  74188. declare module "babylonjs/Shaders/tonemap.fragment" {
  74189. /** @hidden */
  74190. export var tonemapPixelShader: {
  74191. name: string;
  74192. shader: string;
  74193. };
  74194. }
  74195. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  74196. import { Camera } from "babylonjs/Cameras/camera";
  74197. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74198. import "babylonjs/Shaders/tonemap.fragment";
  74199. import { Engine } from "babylonjs/Engines/engine";
  74200. /** Defines operator used for tonemapping */
  74201. export enum TonemappingOperator {
  74202. /** Hable */
  74203. Hable = 0,
  74204. /** Reinhard */
  74205. Reinhard = 1,
  74206. /** HejiDawson */
  74207. HejiDawson = 2,
  74208. /** Photographic */
  74209. Photographic = 3
  74210. }
  74211. /**
  74212. * Defines a post process to apply tone mapping
  74213. */
  74214. export class TonemapPostProcess extends PostProcess {
  74215. private _operator;
  74216. /** Defines the required exposure adjustement */
  74217. exposureAdjustment: number;
  74218. /**
  74219. * Creates a new TonemapPostProcess
  74220. * @param name defines the name of the postprocess
  74221. * @param _operator defines the operator to use
  74222. * @param exposureAdjustment defines the required exposure adjustement
  74223. * @param camera defines the camera to use (can be null)
  74224. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  74225. * @param engine defines the hosting engine (can be ignore if camera is set)
  74226. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  74227. */
  74228. constructor(name: string, _operator: TonemappingOperator,
  74229. /** Defines the required exposure adjustement */
  74230. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  74231. }
  74232. }
  74233. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  74234. /** @hidden */
  74235. export var volumetricLightScatteringPixelShader: {
  74236. name: string;
  74237. shader: string;
  74238. };
  74239. }
  74240. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  74241. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  74242. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  74243. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  74244. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  74245. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  74246. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  74247. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  74248. /** @hidden */
  74249. export var volumetricLightScatteringPassVertexShader: {
  74250. name: string;
  74251. shader: string;
  74252. };
  74253. }
  74254. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  74255. /** @hidden */
  74256. export var volumetricLightScatteringPassPixelShader: {
  74257. name: string;
  74258. shader: string;
  74259. };
  74260. }
  74261. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  74262. import { Vector3 } from "babylonjs/Maths/math.vector";
  74263. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74264. import { Mesh } from "babylonjs/Meshes/mesh";
  74265. import { Camera } from "babylonjs/Cameras/camera";
  74266. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74267. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74268. import { Scene } from "babylonjs/scene";
  74269. import "babylonjs/Meshes/Builders/planeBuilder";
  74270. import "babylonjs/Shaders/depth.vertex";
  74271. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  74272. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  74273. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  74274. import { Engine } from "babylonjs/Engines/engine";
  74275. /**
  74276. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  74277. */
  74278. export class VolumetricLightScatteringPostProcess extends PostProcess {
  74279. private _volumetricLightScatteringPass;
  74280. private _volumetricLightScatteringRTT;
  74281. private _viewPort;
  74282. private _screenCoordinates;
  74283. private _cachedDefines;
  74284. /**
  74285. * If not undefined, the mesh position is computed from the attached node position
  74286. */
  74287. attachedNode: {
  74288. position: Vector3;
  74289. };
  74290. /**
  74291. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  74292. */
  74293. customMeshPosition: Vector3;
  74294. /**
  74295. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  74296. */
  74297. useCustomMeshPosition: boolean;
  74298. /**
  74299. * If the post-process should inverse the light scattering direction
  74300. */
  74301. invert: boolean;
  74302. /**
  74303. * The internal mesh used by the post-process
  74304. */
  74305. mesh: Mesh;
  74306. /**
  74307. * @hidden
  74308. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  74309. */
  74310. get useDiffuseColor(): boolean;
  74311. set useDiffuseColor(useDiffuseColor: boolean);
  74312. /**
  74313. * Array containing the excluded meshes not rendered in the internal pass
  74314. */
  74315. excludedMeshes: AbstractMesh[];
  74316. /**
  74317. * Controls the overall intensity of the post-process
  74318. */
  74319. exposure: number;
  74320. /**
  74321. * Dissipates each sample's contribution in range [0, 1]
  74322. */
  74323. decay: number;
  74324. /**
  74325. * Controls the overall intensity of each sample
  74326. */
  74327. weight: number;
  74328. /**
  74329. * Controls the density of each sample
  74330. */
  74331. density: number;
  74332. /**
  74333. * @constructor
  74334. * @param name The post-process name
  74335. * @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)
  74336. * @param camera The camera that the post-process will be attached to
  74337. * @param mesh The mesh used to create the light scattering
  74338. * @param samples The post-process quality, default 100
  74339. * @param samplingModeThe post-process filtering mode
  74340. * @param engine The babylon engine
  74341. * @param reusable If the post-process is reusable
  74342. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  74343. */
  74344. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  74345. /**
  74346. * Returns the string "VolumetricLightScatteringPostProcess"
  74347. * @returns "VolumetricLightScatteringPostProcess"
  74348. */
  74349. getClassName(): string;
  74350. private _isReady;
  74351. /**
  74352. * Sets the new light position for light scattering effect
  74353. * @param position The new custom light position
  74354. */
  74355. setCustomMeshPosition(position: Vector3): void;
  74356. /**
  74357. * Returns the light position for light scattering effect
  74358. * @return Vector3 The custom light position
  74359. */
  74360. getCustomMeshPosition(): Vector3;
  74361. /**
  74362. * Disposes the internal assets and detaches the post-process from the camera
  74363. */
  74364. dispose(camera: Camera): void;
  74365. /**
  74366. * Returns the render target texture used by the post-process
  74367. * @return the render target texture used by the post-process
  74368. */
  74369. getPass(): RenderTargetTexture;
  74370. private _meshExcluded;
  74371. private _createPass;
  74372. private _updateMeshScreenCoordinates;
  74373. /**
  74374. * Creates a default mesh for the Volumeric Light Scattering post-process
  74375. * @param name The mesh name
  74376. * @param scene The scene where to create the mesh
  74377. * @return the default mesh
  74378. */
  74379. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  74380. }
  74381. }
  74382. declare module "babylonjs/PostProcesses/index" {
  74383. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  74384. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  74385. export * from "babylonjs/PostProcesses/bloomEffect";
  74386. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  74387. export * from "babylonjs/PostProcesses/blurPostProcess";
  74388. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74389. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  74390. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  74391. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  74392. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  74393. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  74394. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  74395. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  74396. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  74397. export * from "babylonjs/PostProcesses/filterPostProcess";
  74398. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  74399. export * from "babylonjs/PostProcesses/grainPostProcess";
  74400. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  74401. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74402. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  74403. export * from "babylonjs/PostProcesses/passPostProcess";
  74404. export * from "babylonjs/PostProcesses/postProcess";
  74405. export * from "babylonjs/PostProcesses/postProcessManager";
  74406. export * from "babylonjs/PostProcesses/refractionPostProcess";
  74407. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  74408. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  74409. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  74410. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  74411. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  74412. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  74413. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  74414. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  74415. }
  74416. declare module "babylonjs/Probes/index" {
  74417. export * from "babylonjs/Probes/reflectionProbe";
  74418. }
  74419. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  74420. import { Scene } from "babylonjs/scene";
  74421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74422. import { SmartArray } from "babylonjs/Misc/smartArray";
  74423. import { ISceneComponent } from "babylonjs/sceneComponent";
  74424. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  74425. import "babylonjs/Meshes/Builders/boxBuilder";
  74426. import "babylonjs/Shaders/color.fragment";
  74427. import "babylonjs/Shaders/color.vertex";
  74428. import { Color3 } from "babylonjs/Maths/math.color";
  74429. import { Observable } from "babylonjs/Misc/observable";
  74430. module "babylonjs/scene" {
  74431. interface Scene {
  74432. /** @hidden (Backing field) */
  74433. _boundingBoxRenderer: BoundingBoxRenderer;
  74434. /** @hidden (Backing field) */
  74435. _forceShowBoundingBoxes: boolean;
  74436. /**
  74437. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  74438. */
  74439. forceShowBoundingBoxes: boolean;
  74440. /**
  74441. * Gets the bounding box renderer associated with the scene
  74442. * @returns a BoundingBoxRenderer
  74443. */
  74444. getBoundingBoxRenderer(): BoundingBoxRenderer;
  74445. }
  74446. }
  74447. module "babylonjs/Meshes/abstractMesh" {
  74448. interface AbstractMesh {
  74449. /** @hidden (Backing field) */
  74450. _showBoundingBox: boolean;
  74451. /**
  74452. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  74453. */
  74454. showBoundingBox: boolean;
  74455. }
  74456. }
  74457. /**
  74458. * Component responsible of rendering the bounding box of the meshes in a scene.
  74459. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  74460. */
  74461. export class BoundingBoxRenderer implements ISceneComponent {
  74462. /**
  74463. * The component name helpfull to identify the component in the list of scene components.
  74464. */
  74465. readonly name: string;
  74466. /**
  74467. * The scene the component belongs to.
  74468. */
  74469. scene: Scene;
  74470. /**
  74471. * Color of the bounding box lines placed in front of an object
  74472. */
  74473. frontColor: Color3;
  74474. /**
  74475. * Color of the bounding box lines placed behind an object
  74476. */
  74477. backColor: Color3;
  74478. /**
  74479. * Defines if the renderer should show the back lines or not
  74480. */
  74481. showBackLines: boolean;
  74482. /**
  74483. * Observable raised before rendering a bounding box
  74484. */
  74485. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  74486. /**
  74487. * Observable raised after rendering a bounding box
  74488. */
  74489. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  74490. /**
  74491. * @hidden
  74492. */
  74493. renderList: SmartArray<BoundingBox>;
  74494. private _colorShader;
  74495. private _vertexBuffers;
  74496. private _indexBuffer;
  74497. private _fillIndexBuffer;
  74498. private _fillIndexData;
  74499. /**
  74500. * Instantiates a new bounding box renderer in a scene.
  74501. * @param scene the scene the renderer renders in
  74502. */
  74503. constructor(scene: Scene);
  74504. /**
  74505. * Registers the component in a given scene
  74506. */
  74507. register(): void;
  74508. private _evaluateSubMesh;
  74509. private _activeMesh;
  74510. private _prepareRessources;
  74511. private _createIndexBuffer;
  74512. /**
  74513. * Rebuilds the elements related to this component in case of
  74514. * context lost for instance.
  74515. */
  74516. rebuild(): void;
  74517. /**
  74518. * @hidden
  74519. */
  74520. reset(): void;
  74521. /**
  74522. * Render the bounding boxes of a specific rendering group
  74523. * @param renderingGroupId defines the rendering group to render
  74524. */
  74525. render(renderingGroupId: number): void;
  74526. /**
  74527. * In case of occlusion queries, we can render the occlusion bounding box through this method
  74528. * @param mesh Define the mesh to render the occlusion bounding box for
  74529. */
  74530. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  74531. /**
  74532. * Dispose and release the resources attached to this renderer.
  74533. */
  74534. dispose(): void;
  74535. }
  74536. }
  74537. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  74538. import { Nullable } from "babylonjs/types";
  74539. import { Scene } from "babylonjs/scene";
  74540. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  74541. import { Camera } from "babylonjs/Cameras/camera";
  74542. import { ISceneComponent } from "babylonjs/sceneComponent";
  74543. module "babylonjs/scene" {
  74544. interface Scene {
  74545. /** @hidden (Backing field) */
  74546. _depthRenderer: {
  74547. [id: string]: DepthRenderer;
  74548. };
  74549. /**
  74550. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  74551. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  74552. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  74553. * @returns the created depth renderer
  74554. */
  74555. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  74556. /**
  74557. * Disables a depth renderer for a given camera
  74558. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  74559. */
  74560. disableDepthRenderer(camera?: Nullable<Camera>): void;
  74561. }
  74562. }
  74563. /**
  74564. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  74565. * in several rendering techniques.
  74566. */
  74567. export class DepthRendererSceneComponent implements ISceneComponent {
  74568. /**
  74569. * The component name helpfull to identify the component in the list of scene components.
  74570. */
  74571. readonly name: string;
  74572. /**
  74573. * The scene the component belongs to.
  74574. */
  74575. scene: Scene;
  74576. /**
  74577. * Creates a new instance of the component for the given scene
  74578. * @param scene Defines the scene to register the component in
  74579. */
  74580. constructor(scene: Scene);
  74581. /**
  74582. * Registers the component in a given scene
  74583. */
  74584. register(): void;
  74585. /**
  74586. * Rebuilds the elements related to this component in case of
  74587. * context lost for instance.
  74588. */
  74589. rebuild(): void;
  74590. /**
  74591. * Disposes the component and the associated ressources
  74592. */
  74593. dispose(): void;
  74594. private _gatherRenderTargets;
  74595. private _gatherActiveCameraRenderTargets;
  74596. }
  74597. }
  74598. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  74599. /** @hidden */
  74600. export var fibonacci: {
  74601. name: string;
  74602. shader: string;
  74603. };
  74604. }
  74605. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  74606. /** @hidden */
  74607. export var diffusionProfile: {
  74608. name: string;
  74609. shader: string;
  74610. };
  74611. }
  74612. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  74613. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  74614. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  74615. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  74616. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  74617. /** @hidden */
  74618. export var subSurfaceScatteringPixelShader: {
  74619. name: string;
  74620. shader: string;
  74621. };
  74622. }
  74623. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  74624. import { Nullable } from "babylonjs/types";
  74625. import { Camera } from "babylonjs/Cameras/camera";
  74626. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74627. import { Engine } from "babylonjs/Engines/engine";
  74628. import { Scene } from "babylonjs/scene";
  74629. import "babylonjs/Shaders/imageProcessing.fragment";
  74630. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  74631. import "babylonjs/Shaders/postprocess.vertex";
  74632. /**
  74633. * Sub surface scattering post process
  74634. */
  74635. export class SubSurfaceScatteringPostProcess extends PostProcess {
  74636. /** @hidden */
  74637. texelWidth: number;
  74638. /** @hidden */
  74639. texelHeight: number;
  74640. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74641. }
  74642. }
  74643. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  74644. import { Color3 } from "babylonjs/Maths/math.color";
  74645. /**
  74646. * Contains all parameters needed for the prepass to perform
  74647. * screen space subsurface scattering
  74648. */
  74649. export class SubSurfaceConfiguration {
  74650. private _ssDiffusionS;
  74651. private _ssFilterRadii;
  74652. private _ssDiffusionD;
  74653. /**
  74654. * Diffusion profile color for subsurface scattering
  74655. */
  74656. get ssDiffusionS(): number[];
  74657. /**
  74658. * Diffusion profile max color channel value for subsurface scattering
  74659. */
  74660. get ssDiffusionD(): number[];
  74661. /**
  74662. * Diffusion profile filter radius for subsurface scattering
  74663. */
  74664. get ssFilterRadii(): number[];
  74665. /**
  74666. * Diffusion profile colors for subsurface scattering
  74667. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  74668. * See ...
  74669. * Note that you can only store up to 5 of them
  74670. */
  74671. ssDiffusionProfileColors: Color3[];
  74672. /**
  74673. * Defines the ratio real world => scene units.
  74674. * Used for subsurface scattering
  74675. */
  74676. metersPerUnit: number;
  74677. /**
  74678. * Builds a subsurface configuration object
  74679. * @param scene The scene
  74680. */
  74681. constructor();
  74682. /**
  74683. * Adds a new diffusion profile.
  74684. * Useful for more realistic subsurface scattering on diverse materials.
  74685. * @param color The color of the diffusion profile. Should be the average color of the material.
  74686. * @return The index of the diffusion profile for the material subsurface configuration
  74687. */
  74688. addDiffusionProfile(color: Color3): number;
  74689. /**
  74690. * Deletes all diffusion profiles.
  74691. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  74692. */
  74693. clearAllDiffusionProfiles(): void;
  74694. /**
  74695. * Disposes this object
  74696. */
  74697. dispose(): void;
  74698. /**
  74699. * @hidden
  74700. * https://zero-radiance.github.io/post/sampling-diffusion/
  74701. *
  74702. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  74703. * ------------------------------------------------------------------------------------
  74704. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  74705. * PDF[r, phi, s] = r * R[r, phi, s]
  74706. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  74707. * ------------------------------------------------------------------------------------
  74708. * We importance sample the color channel with the widest scattering distance.
  74709. */
  74710. getDiffusionProfileParameters(color: Color3): number;
  74711. /**
  74712. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  74713. * 'u' is the random number (the value of the CDF): [0, 1).
  74714. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  74715. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  74716. */
  74717. private _sampleBurleyDiffusionProfile;
  74718. }
  74719. }
  74720. declare module "babylonjs/Rendering/prePassRenderer" {
  74721. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  74722. import { Scene } from "babylonjs/scene";
  74723. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74724. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  74725. import { Effect } from "babylonjs/Materials/effect";
  74726. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  74727. /**
  74728. * Renders a pre pass of the scene
  74729. * This means every mesh in the scene will be rendered to a render target texture
  74730. * And then this texture will be composited to the rendering canvas with post processes
  74731. * It is necessary for effects like subsurface scattering or deferred shading
  74732. */
  74733. export class PrePassRenderer {
  74734. /** @hidden */
  74735. static _SceneComponentInitialization: (scene: Scene) => void;
  74736. private _scene;
  74737. private _engine;
  74738. private _isDirty;
  74739. /**
  74740. * Number of textures in the multi render target texture where the scene is directly rendered
  74741. */
  74742. readonly mrtCount: number;
  74743. /**
  74744. * The render target where the scene is directly rendered
  74745. */
  74746. prePassRT: MultiRenderTarget;
  74747. private _mrtTypes;
  74748. private _multiRenderAttachments;
  74749. private _defaultAttachments;
  74750. private _clearAttachments;
  74751. private readonly _clearColor;
  74752. /**
  74753. * Image processing post process for composition
  74754. */
  74755. imageProcessingPostProcess: ImageProcessingPostProcess;
  74756. /**
  74757. * Post process for subsurface scattering
  74758. */
  74759. subSurfaceScatteringPostProcess: SubSurfaceScatteringPostProcess;
  74760. /**
  74761. * Configuration for sub surface scattering post process
  74762. */
  74763. subSurfaceConfiguration: SubSurfaceConfiguration;
  74764. private _enabled;
  74765. /**
  74766. * Indicates if the prepass is enabled
  74767. */
  74768. get enabled(): boolean;
  74769. /**
  74770. * How many samples are used for MSAA of the scene render target
  74771. */
  74772. get samples(): number;
  74773. set samples(n: number);
  74774. /**
  74775. * Instanciates a prepass renderer
  74776. * @param scene The scene
  74777. */
  74778. constructor(scene: Scene);
  74779. private _initializeAttachments;
  74780. private _createEffects;
  74781. /**
  74782. * Indicates if rendering a prepass is supported
  74783. */
  74784. get isSupported(): boolean;
  74785. /**
  74786. * Sets the proper output textures to draw in the engine.
  74787. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  74788. */
  74789. bindAttachmentsForEffect(effect: Effect): void;
  74790. /**
  74791. * @hidden
  74792. */
  74793. _beforeCameraDraw(): void;
  74794. /**
  74795. * @hidden
  74796. */
  74797. _afterCameraDraw(): void;
  74798. private _checkRTSize;
  74799. private _bindFrameBuffer;
  74800. /**
  74801. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  74802. */
  74803. clear(): void;
  74804. private _setState;
  74805. private _enable;
  74806. private _disable;
  74807. /**
  74808. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  74809. */
  74810. markAsDirty(): void;
  74811. private _update;
  74812. /**
  74813. * Disposes the prepass renderer.
  74814. */
  74815. dispose(): void;
  74816. }
  74817. }
  74818. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  74819. import { Nullable } from "babylonjs/types";
  74820. import { Scene } from "babylonjs/scene";
  74821. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  74822. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74823. import { AbstractScene } from "babylonjs/abstractScene";
  74824. module "babylonjs/abstractScene" {
  74825. interface AbstractScene {
  74826. /** @hidden (Backing field) */
  74827. _prePassRenderer: Nullable<PrePassRenderer>;
  74828. /**
  74829. * Gets or Sets the current prepass renderer associated to the scene.
  74830. */
  74831. prePassRenderer: Nullable<PrePassRenderer>;
  74832. /**
  74833. * Enables the prepass and associates it with the scene
  74834. * @returns the PrePassRenderer
  74835. */
  74836. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  74837. /**
  74838. * Disables the prepass associated with the scene
  74839. */
  74840. disablePrePassRenderer(): void;
  74841. }
  74842. }
  74843. /**
  74844. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74845. * in several rendering techniques.
  74846. */
  74847. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  74848. /**
  74849. * The component name helpful to identify the component in the list of scene components.
  74850. */
  74851. readonly name: string;
  74852. /**
  74853. * The scene the component belongs to.
  74854. */
  74855. scene: Scene;
  74856. /**
  74857. * Creates a new instance of the component for the given scene
  74858. * @param scene Defines the scene to register the component in
  74859. */
  74860. constructor(scene: Scene);
  74861. /**
  74862. * Registers the component in a given scene
  74863. */
  74864. register(): void;
  74865. private _beforeCameraDraw;
  74866. private _afterCameraDraw;
  74867. private _beforeClearStage;
  74868. /**
  74869. * Serializes the component data to the specified json object
  74870. * @param serializationObject The object to serialize to
  74871. */
  74872. serialize(serializationObject: any): void;
  74873. /**
  74874. * Adds all the elements from the container to the scene
  74875. * @param container the container holding the elements
  74876. */
  74877. addFromContainer(container: AbstractScene): void;
  74878. /**
  74879. * Removes all the elements in the container from the scene
  74880. * @param container contains the elements to remove
  74881. * @param dispose if the removed element should be disposed (default: false)
  74882. */
  74883. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  74884. /**
  74885. * Rebuilds the elements related to this component in case of
  74886. * context lost for instance.
  74887. */
  74888. rebuild(): void;
  74889. /**
  74890. * Disposes the component and the associated ressources
  74891. */
  74892. dispose(): void;
  74893. }
  74894. }
  74895. declare module "babylonjs/Shaders/outline.fragment" {
  74896. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  74897. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  74898. /** @hidden */
  74899. export var outlinePixelShader: {
  74900. name: string;
  74901. shader: string;
  74902. };
  74903. }
  74904. declare module "babylonjs/Shaders/outline.vertex" {
  74905. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  74906. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  74907. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  74908. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  74909. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  74910. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  74911. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  74912. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  74913. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  74914. /** @hidden */
  74915. export var outlineVertexShader: {
  74916. name: string;
  74917. shader: string;
  74918. };
  74919. }
  74920. declare module "babylonjs/Rendering/outlineRenderer" {
  74921. import { SubMesh } from "babylonjs/Meshes/subMesh";
  74922. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  74923. import { Scene } from "babylonjs/scene";
  74924. import { ISceneComponent } from "babylonjs/sceneComponent";
  74925. import "babylonjs/Shaders/outline.fragment";
  74926. import "babylonjs/Shaders/outline.vertex";
  74927. module "babylonjs/scene" {
  74928. interface Scene {
  74929. /** @hidden */
  74930. _outlineRenderer: OutlineRenderer;
  74931. /**
  74932. * Gets the outline renderer associated with the scene
  74933. * @returns a OutlineRenderer
  74934. */
  74935. getOutlineRenderer(): OutlineRenderer;
  74936. }
  74937. }
  74938. module "babylonjs/Meshes/abstractMesh" {
  74939. interface AbstractMesh {
  74940. /** @hidden (Backing field) */
  74941. _renderOutline: boolean;
  74942. /**
  74943. * Gets or sets a boolean indicating if the outline must be rendered as well
  74944. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  74945. */
  74946. renderOutline: boolean;
  74947. /** @hidden (Backing field) */
  74948. _renderOverlay: boolean;
  74949. /**
  74950. * Gets or sets a boolean indicating if the overlay must be rendered as well
  74951. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  74952. */
  74953. renderOverlay: boolean;
  74954. }
  74955. }
  74956. /**
  74957. * This class is responsible to draw bothe outline/overlay of meshes.
  74958. * It should not be used directly but through the available method on mesh.
  74959. */
  74960. export class OutlineRenderer implements ISceneComponent {
  74961. /**
  74962. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  74963. */
  74964. private static _StencilReference;
  74965. /**
  74966. * The name of the component. Each component must have a unique name.
  74967. */
  74968. name: string;
  74969. /**
  74970. * The scene the component belongs to.
  74971. */
  74972. scene: Scene;
  74973. /**
  74974. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  74975. */
  74976. zOffset: number;
  74977. private _engine;
  74978. private _effect;
  74979. private _cachedDefines;
  74980. private _savedDepthWrite;
  74981. /**
  74982. * Instantiates a new outline renderer. (There could be only one per scene).
  74983. * @param scene Defines the scene it belongs to
  74984. */
  74985. constructor(scene: Scene);
  74986. /**
  74987. * Register the component to one instance of a scene.
  74988. */
  74989. register(): void;
  74990. /**
  74991. * Rebuilds the elements related to this component in case of
  74992. * context lost for instance.
  74993. */
  74994. rebuild(): void;
  74995. /**
  74996. * Disposes the component and the associated ressources.
  74997. */
  74998. dispose(): void;
  74999. /**
  75000. * Renders the outline in the canvas.
  75001. * @param subMesh Defines the sumesh to render
  75002. * @param batch Defines the batch of meshes in case of instances
  75003. * @param useOverlay Defines if the rendering is for the overlay or the outline
  75004. */
  75005. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  75006. /**
  75007. * Returns whether or not the outline renderer is ready for a given submesh.
  75008. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  75009. * @param subMesh Defines the submesh to check readyness for
  75010. * @param useInstances Defines wheter wee are trying to render instances or not
  75011. * @returns true if ready otherwise false
  75012. */
  75013. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75014. private _beforeRenderingMesh;
  75015. private _afterRenderingMesh;
  75016. }
  75017. }
  75018. declare module "babylonjs/Rendering/index" {
  75019. export * from "babylonjs/Rendering/boundingBoxRenderer";
  75020. export * from "babylonjs/Rendering/depthRenderer";
  75021. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  75022. export * from "babylonjs/Rendering/edgesRenderer";
  75023. export * from "babylonjs/Rendering/geometryBufferRenderer";
  75024. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75025. export * from "babylonjs/Rendering/prePassRenderer";
  75026. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  75027. export * from "babylonjs/Rendering/outlineRenderer";
  75028. export * from "babylonjs/Rendering/renderingGroup";
  75029. export * from "babylonjs/Rendering/renderingManager";
  75030. export * from "babylonjs/Rendering/utilityLayerRenderer";
  75031. }
  75032. declare module "babylonjs/Sprites/ISprites" {
  75033. /**
  75034. * Defines the basic options interface of a Sprite Frame Source Size.
  75035. */
  75036. export interface ISpriteJSONSpriteSourceSize {
  75037. /**
  75038. * number of the original width of the Frame
  75039. */
  75040. w: number;
  75041. /**
  75042. * number of the original height of the Frame
  75043. */
  75044. h: number;
  75045. }
  75046. /**
  75047. * Defines the basic options interface of a Sprite Frame Data.
  75048. */
  75049. export interface ISpriteJSONSpriteFrameData {
  75050. /**
  75051. * number of the x offset of the Frame
  75052. */
  75053. x: number;
  75054. /**
  75055. * number of the y offset of the Frame
  75056. */
  75057. y: number;
  75058. /**
  75059. * number of the width of the Frame
  75060. */
  75061. w: number;
  75062. /**
  75063. * number of the height of the Frame
  75064. */
  75065. h: number;
  75066. }
  75067. /**
  75068. * Defines the basic options interface of a JSON Sprite.
  75069. */
  75070. export interface ISpriteJSONSprite {
  75071. /**
  75072. * string name of the Frame
  75073. */
  75074. filename: string;
  75075. /**
  75076. * ISpriteJSONSpriteFrame basic object of the frame data
  75077. */
  75078. frame: ISpriteJSONSpriteFrameData;
  75079. /**
  75080. * boolean to flag is the frame was rotated.
  75081. */
  75082. rotated: boolean;
  75083. /**
  75084. * boolean to flag is the frame was trimmed.
  75085. */
  75086. trimmed: boolean;
  75087. /**
  75088. * ISpriteJSONSpriteFrame basic object of the source data
  75089. */
  75090. spriteSourceSize: ISpriteJSONSpriteFrameData;
  75091. /**
  75092. * ISpriteJSONSpriteFrame basic object of the source data
  75093. */
  75094. sourceSize: ISpriteJSONSpriteSourceSize;
  75095. }
  75096. /**
  75097. * Defines the basic options interface of a JSON atlas.
  75098. */
  75099. export interface ISpriteJSONAtlas {
  75100. /**
  75101. * Array of objects that contain the frame data.
  75102. */
  75103. frames: Array<ISpriteJSONSprite>;
  75104. /**
  75105. * object basic object containing the sprite meta data.
  75106. */
  75107. meta?: object;
  75108. }
  75109. }
  75110. declare module "babylonjs/Shaders/spriteMap.fragment" {
  75111. /** @hidden */
  75112. export var spriteMapPixelShader: {
  75113. name: string;
  75114. shader: string;
  75115. };
  75116. }
  75117. declare module "babylonjs/Shaders/spriteMap.vertex" {
  75118. /** @hidden */
  75119. export var spriteMapVertexShader: {
  75120. name: string;
  75121. shader: string;
  75122. };
  75123. }
  75124. declare module "babylonjs/Sprites/spriteMap" {
  75125. import { IDisposable, Scene } from "babylonjs/scene";
  75126. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  75127. import { Texture } from "babylonjs/Materials/Textures/texture";
  75128. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  75129. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  75130. import "babylonjs/Meshes/Builders/planeBuilder";
  75131. import "babylonjs/Shaders/spriteMap.fragment";
  75132. import "babylonjs/Shaders/spriteMap.vertex";
  75133. /**
  75134. * Defines the basic options interface of a SpriteMap
  75135. */
  75136. export interface ISpriteMapOptions {
  75137. /**
  75138. * Vector2 of the number of cells in the grid.
  75139. */
  75140. stageSize?: Vector2;
  75141. /**
  75142. * Vector2 of the size of the output plane in World Units.
  75143. */
  75144. outputSize?: Vector2;
  75145. /**
  75146. * Vector3 of the position of the output plane in World Units.
  75147. */
  75148. outputPosition?: Vector3;
  75149. /**
  75150. * Vector3 of the rotation of the output plane.
  75151. */
  75152. outputRotation?: Vector3;
  75153. /**
  75154. * number of layers that the system will reserve in resources.
  75155. */
  75156. layerCount?: number;
  75157. /**
  75158. * number of max animation frames a single cell will reserve in resources.
  75159. */
  75160. maxAnimationFrames?: number;
  75161. /**
  75162. * number cell index of the base tile when the system compiles.
  75163. */
  75164. baseTile?: number;
  75165. /**
  75166. * boolean flip the sprite after its been repositioned by the framing data.
  75167. */
  75168. flipU?: boolean;
  75169. /**
  75170. * Vector3 scalar of the global RGB values of the SpriteMap.
  75171. */
  75172. colorMultiply?: Vector3;
  75173. }
  75174. /**
  75175. * Defines the IDisposable interface in order to be cleanable from resources.
  75176. */
  75177. export interface ISpriteMap extends IDisposable {
  75178. /**
  75179. * String name of the SpriteMap.
  75180. */
  75181. name: string;
  75182. /**
  75183. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  75184. */
  75185. atlasJSON: ISpriteJSONAtlas;
  75186. /**
  75187. * Texture of the SpriteMap.
  75188. */
  75189. spriteSheet: Texture;
  75190. /**
  75191. * The parameters to initialize the SpriteMap with.
  75192. */
  75193. options: ISpriteMapOptions;
  75194. }
  75195. /**
  75196. * Class used to manage a grid restricted sprite deployment on an Output plane.
  75197. */
  75198. export class SpriteMap implements ISpriteMap {
  75199. /** The Name of the spriteMap */
  75200. name: string;
  75201. /** The JSON file with the frame and meta data */
  75202. atlasJSON: ISpriteJSONAtlas;
  75203. /** The systems Sprite Sheet Texture */
  75204. spriteSheet: Texture;
  75205. /** Arguments passed with the Constructor */
  75206. options: ISpriteMapOptions;
  75207. /** Public Sprite Storage array, parsed from atlasJSON */
  75208. sprites: Array<ISpriteJSONSprite>;
  75209. /** Returns the Number of Sprites in the System */
  75210. get spriteCount(): number;
  75211. /** Returns the Position of Output Plane*/
  75212. get position(): Vector3;
  75213. /** Returns the Position of Output Plane*/
  75214. set position(v: Vector3);
  75215. /** Returns the Rotation of Output Plane*/
  75216. get rotation(): Vector3;
  75217. /** Returns the Rotation of Output Plane*/
  75218. set rotation(v: Vector3);
  75219. /** Sets the AnimationMap*/
  75220. get animationMap(): RawTexture;
  75221. /** Sets the AnimationMap*/
  75222. set animationMap(v: RawTexture);
  75223. /** Scene that the SpriteMap was created in */
  75224. private _scene;
  75225. /** Texture Buffer of Float32 that holds tile frame data*/
  75226. private _frameMap;
  75227. /** Texture Buffers of Float32 that holds tileMap data*/
  75228. private _tileMaps;
  75229. /** Texture Buffer of Float32 that holds Animation Data*/
  75230. private _animationMap;
  75231. /** Custom ShaderMaterial Central to the System*/
  75232. private _material;
  75233. /** Custom ShaderMaterial Central to the System*/
  75234. private _output;
  75235. /** Systems Time Ticker*/
  75236. private _time;
  75237. /**
  75238. * Creates a new SpriteMap
  75239. * @param name defines the SpriteMaps Name
  75240. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  75241. * @param spriteSheet is the Texture that the Sprites are on.
  75242. * @param options a basic deployment configuration
  75243. * @param scene The Scene that the map is deployed on
  75244. */
  75245. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  75246. /**
  75247. * Returns tileID location
  75248. * @returns Vector2 the cell position ID
  75249. */
  75250. getTileID(): Vector2;
  75251. /**
  75252. * Gets the UV location of the mouse over the SpriteMap.
  75253. * @returns Vector2 the UV position of the mouse interaction
  75254. */
  75255. getMousePosition(): Vector2;
  75256. /**
  75257. * Creates the "frame" texture Buffer
  75258. * -------------------------------------
  75259. * Structure of frames
  75260. * "filename": "Falling-Water-2.png",
  75261. * "frame": {"x":69,"y":103,"w":24,"h":32},
  75262. * "rotated": true,
  75263. * "trimmed": true,
  75264. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  75265. * "sourceSize": {"w":32,"h":32}
  75266. * @returns RawTexture of the frameMap
  75267. */
  75268. private _createFrameBuffer;
  75269. /**
  75270. * Creates the tileMap texture Buffer
  75271. * @param buffer normally and array of numbers, or a false to generate from scratch
  75272. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  75273. * @returns RawTexture of the tileMap
  75274. */
  75275. private _createTileBuffer;
  75276. /**
  75277. * Modifies the data of the tileMaps
  75278. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  75279. * @param pos is the iVector2 Coordinates of the Tile
  75280. * @param tile The SpriteIndex of the new Tile
  75281. */
  75282. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  75283. /**
  75284. * Creates the animationMap texture Buffer
  75285. * @param buffer normally and array of numbers, or a false to generate from scratch
  75286. * @returns RawTexture of the animationMap
  75287. */
  75288. private _createTileAnimationBuffer;
  75289. /**
  75290. * Modifies the data of the animationMap
  75291. * @param cellID is the Index of the Sprite
  75292. * @param _frame is the target Animation frame
  75293. * @param toCell is the Target Index of the next frame of the animation
  75294. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  75295. * @param speed is a global scalar of the time variable on the map.
  75296. */
  75297. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  75298. /**
  75299. * Exports the .tilemaps file
  75300. */
  75301. saveTileMaps(): void;
  75302. /**
  75303. * Imports the .tilemaps file
  75304. * @param url of the .tilemaps file
  75305. */
  75306. loadTileMaps(url: string): void;
  75307. /**
  75308. * Release associated resources
  75309. */
  75310. dispose(): void;
  75311. }
  75312. }
  75313. declare module "babylonjs/Sprites/spritePackedManager" {
  75314. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  75315. import { Scene } from "babylonjs/scene";
  75316. /**
  75317. * Class used to manage multiple sprites of different sizes on the same spritesheet
  75318. * @see https://doc.babylonjs.com/babylon101/sprites
  75319. */
  75320. export class SpritePackedManager extends SpriteManager {
  75321. /** defines the packed manager's name */
  75322. name: string;
  75323. /**
  75324. * Creates a new sprite manager from a packed sprite sheet
  75325. * @param name defines the manager's name
  75326. * @param imgUrl defines the sprite sheet url
  75327. * @param capacity defines the maximum allowed number of sprites
  75328. * @param scene defines the hosting scene
  75329. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  75330. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  75331. * @param samplingMode defines the smapling mode to use with spritesheet
  75332. * @param fromPacked set to true; do not alter
  75333. */
  75334. constructor(
  75335. /** defines the packed manager's name */
  75336. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  75337. }
  75338. }
  75339. declare module "babylonjs/Sprites/index" {
  75340. export * from "babylonjs/Sprites/sprite";
  75341. export * from "babylonjs/Sprites/ISprites";
  75342. export * from "babylonjs/Sprites/spriteManager";
  75343. export * from "babylonjs/Sprites/spriteMap";
  75344. export * from "babylonjs/Sprites/spritePackedManager";
  75345. export * from "babylonjs/Sprites/spriteSceneComponent";
  75346. }
  75347. declare module "babylonjs/States/index" {
  75348. export * from "babylonjs/States/alphaCullingState";
  75349. export * from "babylonjs/States/depthCullingState";
  75350. export * from "babylonjs/States/stencilState";
  75351. }
  75352. declare module "babylonjs/Misc/assetsManager" {
  75353. import { Scene } from "babylonjs/scene";
  75354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75355. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  75356. import { Skeleton } from "babylonjs/Bones/skeleton";
  75357. import { Observable } from "babylonjs/Misc/observable";
  75358. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  75359. import { Texture } from "babylonjs/Materials/Textures/texture";
  75360. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  75361. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  75362. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  75363. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  75364. /**
  75365. * Defines the list of states available for a task inside a AssetsManager
  75366. */
  75367. export enum AssetTaskState {
  75368. /**
  75369. * Initialization
  75370. */
  75371. INIT = 0,
  75372. /**
  75373. * Running
  75374. */
  75375. RUNNING = 1,
  75376. /**
  75377. * Done
  75378. */
  75379. DONE = 2,
  75380. /**
  75381. * Error
  75382. */
  75383. ERROR = 3
  75384. }
  75385. /**
  75386. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  75387. */
  75388. export abstract class AbstractAssetTask {
  75389. /**
  75390. * Task name
  75391. */ name: string;
  75392. /**
  75393. * Callback called when the task is successful
  75394. */
  75395. onSuccess: (task: any) => void;
  75396. /**
  75397. * Callback called when the task is not successful
  75398. */
  75399. onError: (task: any, message?: string, exception?: any) => void;
  75400. /**
  75401. * Creates a new AssetsManager
  75402. * @param name defines the name of the task
  75403. */
  75404. constructor(
  75405. /**
  75406. * Task name
  75407. */ name: string);
  75408. private _isCompleted;
  75409. private _taskState;
  75410. private _errorObject;
  75411. /**
  75412. * Get if the task is completed
  75413. */
  75414. get isCompleted(): boolean;
  75415. /**
  75416. * Gets the current state of the task
  75417. */
  75418. get taskState(): AssetTaskState;
  75419. /**
  75420. * Gets the current error object (if task is in error)
  75421. */
  75422. get errorObject(): {
  75423. message?: string;
  75424. exception?: any;
  75425. };
  75426. /**
  75427. * Internal only
  75428. * @hidden
  75429. */
  75430. _setErrorObject(message?: string, exception?: any): void;
  75431. /**
  75432. * Execute the current task
  75433. * @param scene defines the scene where you want your assets to be loaded
  75434. * @param onSuccess is a callback called when the task is successfully executed
  75435. * @param onError is a callback called if an error occurs
  75436. */
  75437. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75438. /**
  75439. * Execute the current task
  75440. * @param scene defines the scene where you want your assets to be loaded
  75441. * @param onSuccess is a callback called when the task is successfully executed
  75442. * @param onError is a callback called if an error occurs
  75443. */
  75444. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75445. /**
  75446. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  75447. * This can be used with failed tasks that have the reason for failure fixed.
  75448. */
  75449. reset(): void;
  75450. private onErrorCallback;
  75451. private onDoneCallback;
  75452. }
  75453. /**
  75454. * Define the interface used by progress events raised during assets loading
  75455. */
  75456. export interface IAssetsProgressEvent {
  75457. /**
  75458. * Defines the number of remaining tasks to process
  75459. */
  75460. remainingCount: number;
  75461. /**
  75462. * Defines the total number of tasks
  75463. */
  75464. totalCount: number;
  75465. /**
  75466. * Defines the task that was just processed
  75467. */
  75468. task: AbstractAssetTask;
  75469. }
  75470. /**
  75471. * Class used to share progress information about assets loading
  75472. */
  75473. export class AssetsProgressEvent implements IAssetsProgressEvent {
  75474. /**
  75475. * Defines the number of remaining tasks to process
  75476. */
  75477. remainingCount: number;
  75478. /**
  75479. * Defines the total number of tasks
  75480. */
  75481. totalCount: number;
  75482. /**
  75483. * Defines the task that was just processed
  75484. */
  75485. task: AbstractAssetTask;
  75486. /**
  75487. * Creates a AssetsProgressEvent
  75488. * @param remainingCount defines the number of remaining tasks to process
  75489. * @param totalCount defines the total number of tasks
  75490. * @param task defines the task that was just processed
  75491. */
  75492. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  75493. }
  75494. /**
  75495. * Define a task used by AssetsManager to load meshes
  75496. */
  75497. export class MeshAssetTask extends AbstractAssetTask {
  75498. /**
  75499. * Defines the name of the task
  75500. */
  75501. name: string;
  75502. /**
  75503. * Defines the list of mesh's names you want to load
  75504. */
  75505. meshesNames: any;
  75506. /**
  75507. * Defines the root url to use as a base to load your meshes and associated resources
  75508. */
  75509. rootUrl: string;
  75510. /**
  75511. * Defines the filename or File of the scene to load from
  75512. */
  75513. sceneFilename: string | File;
  75514. /**
  75515. * Gets the list of loaded meshes
  75516. */
  75517. loadedMeshes: Array<AbstractMesh>;
  75518. /**
  75519. * Gets the list of loaded particle systems
  75520. */
  75521. loadedParticleSystems: Array<IParticleSystem>;
  75522. /**
  75523. * Gets the list of loaded skeletons
  75524. */
  75525. loadedSkeletons: Array<Skeleton>;
  75526. /**
  75527. * Gets the list of loaded animation groups
  75528. */
  75529. loadedAnimationGroups: Array<AnimationGroup>;
  75530. /**
  75531. * Callback called when the task is successful
  75532. */
  75533. onSuccess: (task: MeshAssetTask) => void;
  75534. /**
  75535. * Callback called when the task is successful
  75536. */
  75537. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  75538. /**
  75539. * Creates a new MeshAssetTask
  75540. * @param name defines the name of the task
  75541. * @param meshesNames defines the list of mesh's names you want to load
  75542. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  75543. * @param sceneFilename defines the filename or File of the scene to load from
  75544. */
  75545. constructor(
  75546. /**
  75547. * Defines the name of the task
  75548. */
  75549. name: string,
  75550. /**
  75551. * Defines the list of mesh's names you want to load
  75552. */
  75553. meshesNames: any,
  75554. /**
  75555. * Defines the root url to use as a base to load your meshes and associated resources
  75556. */
  75557. rootUrl: string,
  75558. /**
  75559. * Defines the filename or File of the scene to load from
  75560. */
  75561. sceneFilename: string | File);
  75562. /**
  75563. * Execute the current task
  75564. * @param scene defines the scene where you want your assets to be loaded
  75565. * @param onSuccess is a callback called when the task is successfully executed
  75566. * @param onError is a callback called if an error occurs
  75567. */
  75568. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75569. }
  75570. /**
  75571. * Define a task used by AssetsManager to load text content
  75572. */
  75573. export class TextFileAssetTask extends AbstractAssetTask {
  75574. /**
  75575. * Defines the name of the task
  75576. */
  75577. name: string;
  75578. /**
  75579. * Defines the location of the file to load
  75580. */
  75581. url: string;
  75582. /**
  75583. * Gets the loaded text string
  75584. */
  75585. text: string;
  75586. /**
  75587. * Callback called when the task is successful
  75588. */
  75589. onSuccess: (task: TextFileAssetTask) => void;
  75590. /**
  75591. * Callback called when the task is successful
  75592. */
  75593. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  75594. /**
  75595. * Creates a new TextFileAssetTask object
  75596. * @param name defines the name of the task
  75597. * @param url defines the location of the file to load
  75598. */
  75599. constructor(
  75600. /**
  75601. * Defines the name of the task
  75602. */
  75603. name: string,
  75604. /**
  75605. * Defines the location of the file to load
  75606. */
  75607. url: string);
  75608. /**
  75609. * Execute the current task
  75610. * @param scene defines the scene where you want your assets to be loaded
  75611. * @param onSuccess is a callback called when the task is successfully executed
  75612. * @param onError is a callback called if an error occurs
  75613. */
  75614. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75615. }
  75616. /**
  75617. * Define a task used by AssetsManager to load binary data
  75618. */
  75619. export class BinaryFileAssetTask extends AbstractAssetTask {
  75620. /**
  75621. * Defines the name of the task
  75622. */
  75623. name: string;
  75624. /**
  75625. * Defines the location of the file to load
  75626. */
  75627. url: string;
  75628. /**
  75629. * Gets the lodaded data (as an array buffer)
  75630. */
  75631. data: ArrayBuffer;
  75632. /**
  75633. * Callback called when the task is successful
  75634. */
  75635. onSuccess: (task: BinaryFileAssetTask) => void;
  75636. /**
  75637. * Callback called when the task is successful
  75638. */
  75639. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  75640. /**
  75641. * Creates a new BinaryFileAssetTask object
  75642. * @param name defines the name of the new task
  75643. * @param url defines the location of the file to load
  75644. */
  75645. constructor(
  75646. /**
  75647. * Defines the name of the task
  75648. */
  75649. name: string,
  75650. /**
  75651. * Defines the location of the file to load
  75652. */
  75653. url: string);
  75654. /**
  75655. * Execute the current task
  75656. * @param scene defines the scene where you want your assets to be loaded
  75657. * @param onSuccess is a callback called when the task is successfully executed
  75658. * @param onError is a callback called if an error occurs
  75659. */
  75660. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75661. }
  75662. /**
  75663. * Define a task used by AssetsManager to load images
  75664. */
  75665. export class ImageAssetTask extends AbstractAssetTask {
  75666. /**
  75667. * Defines the name of the task
  75668. */
  75669. name: string;
  75670. /**
  75671. * Defines the location of the image to load
  75672. */
  75673. url: string;
  75674. /**
  75675. * Gets the loaded images
  75676. */
  75677. image: HTMLImageElement;
  75678. /**
  75679. * Callback called when the task is successful
  75680. */
  75681. onSuccess: (task: ImageAssetTask) => void;
  75682. /**
  75683. * Callback called when the task is successful
  75684. */
  75685. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  75686. /**
  75687. * Creates a new ImageAssetTask
  75688. * @param name defines the name of the task
  75689. * @param url defines the location of the image to load
  75690. */
  75691. constructor(
  75692. /**
  75693. * Defines the name of the task
  75694. */
  75695. name: string,
  75696. /**
  75697. * Defines the location of the image to load
  75698. */
  75699. url: string);
  75700. /**
  75701. * Execute the current task
  75702. * @param scene defines the scene where you want your assets to be loaded
  75703. * @param onSuccess is a callback called when the task is successfully executed
  75704. * @param onError is a callback called if an error occurs
  75705. */
  75706. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75707. }
  75708. /**
  75709. * Defines the interface used by texture loading tasks
  75710. */
  75711. export interface ITextureAssetTask<TEX extends BaseTexture> {
  75712. /**
  75713. * Gets the loaded texture
  75714. */
  75715. texture: TEX;
  75716. }
  75717. /**
  75718. * Define a task used by AssetsManager to load 2D textures
  75719. */
  75720. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  75721. /**
  75722. * Defines the name of the task
  75723. */
  75724. name: string;
  75725. /**
  75726. * Defines the location of the file to load
  75727. */
  75728. url: string;
  75729. /**
  75730. * Defines if mipmap should not be generated (default is false)
  75731. */
  75732. noMipmap?: boolean | undefined;
  75733. /**
  75734. * Defines if texture must be inverted on Y axis (default is true)
  75735. */
  75736. invertY: boolean;
  75737. /**
  75738. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75739. */
  75740. samplingMode: number;
  75741. /**
  75742. * Gets the loaded texture
  75743. */
  75744. texture: Texture;
  75745. /**
  75746. * Callback called when the task is successful
  75747. */
  75748. onSuccess: (task: TextureAssetTask) => void;
  75749. /**
  75750. * Callback called when the task is successful
  75751. */
  75752. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  75753. /**
  75754. * Creates a new TextureAssetTask object
  75755. * @param name defines the name of the task
  75756. * @param url defines the location of the file to load
  75757. * @param noMipmap defines if mipmap should not be generated (default is false)
  75758. * @param invertY defines if texture must be inverted on Y axis (default is true)
  75759. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75760. */
  75761. constructor(
  75762. /**
  75763. * Defines the name of the task
  75764. */
  75765. name: string,
  75766. /**
  75767. * Defines the location of the file to load
  75768. */
  75769. url: string,
  75770. /**
  75771. * Defines if mipmap should not be generated (default is false)
  75772. */
  75773. noMipmap?: boolean | undefined,
  75774. /**
  75775. * Defines if texture must be inverted on Y axis (default is true)
  75776. */
  75777. invertY?: boolean,
  75778. /**
  75779. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75780. */
  75781. samplingMode?: number);
  75782. /**
  75783. * Execute the current task
  75784. * @param scene defines the scene where you want your assets to be loaded
  75785. * @param onSuccess is a callback called when the task is successfully executed
  75786. * @param onError is a callback called if an error occurs
  75787. */
  75788. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75789. }
  75790. /**
  75791. * Define a task used by AssetsManager to load cube textures
  75792. */
  75793. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  75794. /**
  75795. * Defines the name of the task
  75796. */
  75797. name: string;
  75798. /**
  75799. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75800. */
  75801. url: string;
  75802. /**
  75803. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75804. */
  75805. extensions?: string[] | undefined;
  75806. /**
  75807. * Defines if mipmaps should not be generated (default is false)
  75808. */
  75809. noMipmap?: boolean | undefined;
  75810. /**
  75811. * Defines the explicit list of files (undefined by default)
  75812. */
  75813. files?: string[] | undefined;
  75814. /**
  75815. * Gets the loaded texture
  75816. */
  75817. texture: CubeTexture;
  75818. /**
  75819. * Callback called when the task is successful
  75820. */
  75821. onSuccess: (task: CubeTextureAssetTask) => void;
  75822. /**
  75823. * Callback called when the task is successful
  75824. */
  75825. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  75826. /**
  75827. * Creates a new CubeTextureAssetTask
  75828. * @param name defines the name of the task
  75829. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75830. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75831. * @param noMipmap defines if mipmaps should not be generated (default is false)
  75832. * @param files defines the explicit list of files (undefined by default)
  75833. */
  75834. constructor(
  75835. /**
  75836. * Defines the name of the task
  75837. */
  75838. name: string,
  75839. /**
  75840. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75841. */
  75842. url: string,
  75843. /**
  75844. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75845. */
  75846. extensions?: string[] | undefined,
  75847. /**
  75848. * Defines if mipmaps should not be generated (default is false)
  75849. */
  75850. noMipmap?: boolean | undefined,
  75851. /**
  75852. * Defines the explicit list of files (undefined by default)
  75853. */
  75854. files?: string[] | undefined);
  75855. /**
  75856. * Execute the current task
  75857. * @param scene defines the scene where you want your assets to be loaded
  75858. * @param onSuccess is a callback called when the task is successfully executed
  75859. * @param onError is a callback called if an error occurs
  75860. */
  75861. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75862. }
  75863. /**
  75864. * Define a task used by AssetsManager to load HDR cube textures
  75865. */
  75866. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  75867. /**
  75868. * Defines the name of the task
  75869. */
  75870. name: string;
  75871. /**
  75872. * Defines the location of the file to load
  75873. */
  75874. url: string;
  75875. /**
  75876. * Defines the desired size (the more it increases the longer the generation will be)
  75877. */
  75878. size: number;
  75879. /**
  75880. * Defines if mipmaps should not be generated (default is false)
  75881. */
  75882. noMipmap: boolean;
  75883. /**
  75884. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75885. */
  75886. generateHarmonics: boolean;
  75887. /**
  75888. * 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)
  75889. */
  75890. gammaSpace: boolean;
  75891. /**
  75892. * Internal Use Only
  75893. */
  75894. reserved: boolean;
  75895. /**
  75896. * Gets the loaded texture
  75897. */
  75898. texture: HDRCubeTexture;
  75899. /**
  75900. * Callback called when the task is successful
  75901. */
  75902. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  75903. /**
  75904. * Callback called when the task is successful
  75905. */
  75906. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  75907. /**
  75908. * Creates a new HDRCubeTextureAssetTask object
  75909. * @param name defines the name of the task
  75910. * @param url defines the location of the file to load
  75911. * @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.
  75912. * @param noMipmap defines if mipmaps should not be generated (default is false)
  75913. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75914. * @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)
  75915. * @param reserved Internal use only
  75916. */
  75917. constructor(
  75918. /**
  75919. * Defines the name of the task
  75920. */
  75921. name: string,
  75922. /**
  75923. * Defines the location of the file to load
  75924. */
  75925. url: string,
  75926. /**
  75927. * Defines the desired size (the more it increases the longer the generation will be)
  75928. */
  75929. size: number,
  75930. /**
  75931. * Defines if mipmaps should not be generated (default is false)
  75932. */
  75933. noMipmap?: boolean,
  75934. /**
  75935. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75936. */
  75937. generateHarmonics?: boolean,
  75938. /**
  75939. * 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)
  75940. */
  75941. gammaSpace?: boolean,
  75942. /**
  75943. * Internal Use Only
  75944. */
  75945. reserved?: boolean);
  75946. /**
  75947. * Execute the current task
  75948. * @param scene defines the scene where you want your assets to be loaded
  75949. * @param onSuccess is a callback called when the task is successfully executed
  75950. * @param onError is a callback called if an error occurs
  75951. */
  75952. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75953. }
  75954. /**
  75955. * Define a task used by AssetsManager to load Equirectangular cube textures
  75956. */
  75957. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  75958. /**
  75959. * Defines the name of the task
  75960. */
  75961. name: string;
  75962. /**
  75963. * Defines the location of the file to load
  75964. */
  75965. url: string;
  75966. /**
  75967. * Defines the desired size (the more it increases the longer the generation will be)
  75968. */
  75969. size: number;
  75970. /**
  75971. * Defines if mipmaps should not be generated (default is false)
  75972. */
  75973. noMipmap: boolean;
  75974. /**
  75975. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  75976. * but the standard material would require them in Gamma space) (default is true)
  75977. */
  75978. gammaSpace: boolean;
  75979. /**
  75980. * Gets the loaded texture
  75981. */
  75982. texture: EquiRectangularCubeTexture;
  75983. /**
  75984. * Callback called when the task is successful
  75985. */
  75986. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  75987. /**
  75988. * Callback called when the task is successful
  75989. */
  75990. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  75991. /**
  75992. * Creates a new EquiRectangularCubeTextureAssetTask object
  75993. * @param name defines the name of the task
  75994. * @param url defines the location of the file to load
  75995. * @param size defines the desired size (the more it increases the longer the generation will be)
  75996. * If the size is omitted this implies you are using a preprocessed cubemap.
  75997. * @param noMipmap defines if mipmaps should not be generated (default is false)
  75998. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  75999. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  76000. * (default is true)
  76001. */
  76002. constructor(
  76003. /**
  76004. * Defines the name of the task
  76005. */
  76006. name: string,
  76007. /**
  76008. * Defines the location of the file to load
  76009. */
  76010. url: string,
  76011. /**
  76012. * Defines the desired size (the more it increases the longer the generation will be)
  76013. */
  76014. size: number,
  76015. /**
  76016. * Defines if mipmaps should not be generated (default is false)
  76017. */
  76018. noMipmap?: boolean,
  76019. /**
  76020. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  76021. * but the standard material would require them in Gamma space) (default is true)
  76022. */
  76023. gammaSpace?: boolean);
  76024. /**
  76025. * Execute the current task
  76026. * @param scene defines the scene where you want your assets to be loaded
  76027. * @param onSuccess is a callback called when the task is successfully executed
  76028. * @param onError is a callback called if an error occurs
  76029. */
  76030. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76031. }
  76032. /**
  76033. * This class can be used to easily import assets into a scene
  76034. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  76035. */
  76036. export class AssetsManager {
  76037. private _scene;
  76038. private _isLoading;
  76039. protected _tasks: AbstractAssetTask[];
  76040. protected _waitingTasksCount: number;
  76041. protected _totalTasksCount: number;
  76042. /**
  76043. * Callback called when all tasks are processed
  76044. */
  76045. onFinish: (tasks: AbstractAssetTask[]) => void;
  76046. /**
  76047. * Callback called when a task is successful
  76048. */
  76049. onTaskSuccess: (task: AbstractAssetTask) => void;
  76050. /**
  76051. * Callback called when a task had an error
  76052. */
  76053. onTaskError: (task: AbstractAssetTask) => void;
  76054. /**
  76055. * Callback called when a task is done (whatever the result is)
  76056. */
  76057. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  76058. /**
  76059. * Observable called when all tasks are processed
  76060. */
  76061. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  76062. /**
  76063. * Observable called when a task had an error
  76064. */
  76065. onTaskErrorObservable: Observable<AbstractAssetTask>;
  76066. /**
  76067. * Observable called when all tasks were executed
  76068. */
  76069. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  76070. /**
  76071. * Observable called when a task is done (whatever the result is)
  76072. */
  76073. onProgressObservable: Observable<IAssetsProgressEvent>;
  76074. /**
  76075. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  76076. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  76077. */
  76078. useDefaultLoadingScreen: boolean;
  76079. /**
  76080. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  76081. * when all assets have been downloaded.
  76082. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  76083. */
  76084. autoHideLoadingUI: boolean;
  76085. /**
  76086. * Creates a new AssetsManager
  76087. * @param scene defines the scene to work on
  76088. */
  76089. constructor(scene: Scene);
  76090. /**
  76091. * Add a MeshAssetTask to the list of active tasks
  76092. * @param taskName defines the name of the new task
  76093. * @param meshesNames defines the name of meshes to load
  76094. * @param rootUrl defines the root url to use to locate files
  76095. * @param sceneFilename defines the filename of the scene file
  76096. * @returns a new MeshAssetTask object
  76097. */
  76098. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  76099. /**
  76100. * Add a TextFileAssetTask to the list of active tasks
  76101. * @param taskName defines the name of the new task
  76102. * @param url defines the url of the file to load
  76103. * @returns a new TextFileAssetTask object
  76104. */
  76105. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  76106. /**
  76107. * Add a BinaryFileAssetTask to the list of active tasks
  76108. * @param taskName defines the name of the new task
  76109. * @param url defines the url of the file to load
  76110. * @returns a new BinaryFileAssetTask object
  76111. */
  76112. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  76113. /**
  76114. * Add a ImageAssetTask to the list of active tasks
  76115. * @param taskName defines the name of the new task
  76116. * @param url defines the url of the file to load
  76117. * @returns a new ImageAssetTask object
  76118. */
  76119. addImageTask(taskName: string, url: string): ImageAssetTask;
  76120. /**
  76121. * Add a TextureAssetTask to the list of active tasks
  76122. * @param taskName defines the name of the new task
  76123. * @param url defines the url of the file to load
  76124. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76125. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  76126. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  76127. * @returns a new TextureAssetTask object
  76128. */
  76129. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  76130. /**
  76131. * Add a CubeTextureAssetTask to the list of active tasks
  76132. * @param taskName defines the name of the new task
  76133. * @param url defines the url of the file to load
  76134. * @param extensions defines the extension to use to load the cube map (can be null)
  76135. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76136. * @param files defines the list of files to load (can be null)
  76137. * @returns a new CubeTextureAssetTask object
  76138. */
  76139. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  76140. /**
  76141. *
  76142. * Add a HDRCubeTextureAssetTask to the list of active tasks
  76143. * @param taskName defines the name of the new task
  76144. * @param url defines the url of the file to load
  76145. * @param size defines the size you want for the cubemap (can be null)
  76146. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76147. * @param generateHarmonics defines if you want to automatically generate (true by default)
  76148. * @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)
  76149. * @param reserved Internal use only
  76150. * @returns a new HDRCubeTextureAssetTask object
  76151. */
  76152. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  76153. /**
  76154. *
  76155. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  76156. * @param taskName defines the name of the new task
  76157. * @param url defines the url of the file to load
  76158. * @param size defines the size you want for the cubemap (can be null)
  76159. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76160. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  76161. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  76162. * @returns a new EquiRectangularCubeTextureAssetTask object
  76163. */
  76164. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  76165. /**
  76166. * Remove a task from the assets manager.
  76167. * @param task the task to remove
  76168. */
  76169. removeTask(task: AbstractAssetTask): void;
  76170. private _decreaseWaitingTasksCount;
  76171. private _runTask;
  76172. /**
  76173. * Reset the AssetsManager and remove all tasks
  76174. * @return the current instance of the AssetsManager
  76175. */
  76176. reset(): AssetsManager;
  76177. /**
  76178. * Start the loading process
  76179. * @return the current instance of the AssetsManager
  76180. */
  76181. load(): AssetsManager;
  76182. /**
  76183. * Start the loading process as an async operation
  76184. * @return a promise returning the list of failed tasks
  76185. */
  76186. loadAsync(): Promise<void>;
  76187. }
  76188. }
  76189. declare module "babylonjs/Misc/deferred" {
  76190. /**
  76191. * Wrapper class for promise with external resolve and reject.
  76192. */
  76193. export class Deferred<T> {
  76194. /**
  76195. * The promise associated with this deferred object.
  76196. */
  76197. readonly promise: Promise<T>;
  76198. private _resolve;
  76199. private _reject;
  76200. /**
  76201. * The resolve method of the promise associated with this deferred object.
  76202. */
  76203. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  76204. /**
  76205. * The reject method of the promise associated with this deferred object.
  76206. */
  76207. get reject(): (reason?: any) => void;
  76208. /**
  76209. * Constructor for this deferred object.
  76210. */
  76211. constructor();
  76212. }
  76213. }
  76214. declare module "babylonjs/Misc/meshExploder" {
  76215. import { Mesh } from "babylonjs/Meshes/mesh";
  76216. /**
  76217. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  76218. */
  76219. export class MeshExploder {
  76220. private _centerMesh;
  76221. private _meshes;
  76222. private _meshesOrigins;
  76223. private _toCenterVectors;
  76224. private _scaledDirection;
  76225. private _newPosition;
  76226. private _centerPosition;
  76227. /**
  76228. * Explodes meshes from a center mesh.
  76229. * @param meshes The meshes to explode.
  76230. * @param centerMesh The mesh to be center of explosion.
  76231. */
  76232. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  76233. private _setCenterMesh;
  76234. /**
  76235. * Get class name
  76236. * @returns "MeshExploder"
  76237. */
  76238. getClassName(): string;
  76239. /**
  76240. * "Exploded meshes"
  76241. * @returns Array of meshes with the centerMesh at index 0.
  76242. */
  76243. getMeshes(): Array<Mesh>;
  76244. /**
  76245. * Explodes meshes giving a specific direction
  76246. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  76247. */
  76248. explode(direction?: number): void;
  76249. }
  76250. }
  76251. declare module "babylonjs/Misc/filesInput" {
  76252. import { Engine } from "babylonjs/Engines/engine";
  76253. import { Scene } from "babylonjs/scene";
  76254. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  76255. import { Nullable } from "babylonjs/types";
  76256. /**
  76257. * Class used to help managing file picking and drag'n'drop
  76258. */
  76259. export class FilesInput {
  76260. /**
  76261. * List of files ready to be loaded
  76262. */
  76263. static get FilesToLoad(): {
  76264. [key: string]: File;
  76265. };
  76266. /**
  76267. * Callback called when a file is processed
  76268. */
  76269. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  76270. private _engine;
  76271. private _currentScene;
  76272. private _sceneLoadedCallback;
  76273. private _progressCallback;
  76274. private _additionalRenderLoopLogicCallback;
  76275. private _textureLoadingCallback;
  76276. private _startingProcessingFilesCallback;
  76277. private _onReloadCallback;
  76278. private _errorCallback;
  76279. private _elementToMonitor;
  76280. private _sceneFileToLoad;
  76281. private _filesToLoad;
  76282. /**
  76283. * Creates a new FilesInput
  76284. * @param engine defines the rendering engine
  76285. * @param scene defines the hosting scene
  76286. * @param sceneLoadedCallback callback called when scene is loaded
  76287. * @param progressCallback callback called to track progress
  76288. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  76289. * @param textureLoadingCallback callback called when a texture is loading
  76290. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  76291. * @param onReloadCallback callback called when a reload is requested
  76292. * @param errorCallback callback call if an error occurs
  76293. */
  76294. constructor(engine: Engine, scene: Nullable<Scene>, sceneLoadedCallback: Nullable<(sceneFile: File, scene: Scene) => void>, progressCallback: Nullable<(progress: ISceneLoaderProgressEvent) => void>, additionalRenderLoopLogicCallback: Nullable<() => void>, textureLoadingCallback: Nullable<(remaining: number) => void>, startingProcessingFilesCallback: Nullable<(files?: File[]) => void>, onReloadCallback: Nullable<(sceneFile: File) => void>, errorCallback: Nullable<(sceneFile: File, scene: Nullable<Scene>, message: string) => void>);
  76295. private _dragEnterHandler;
  76296. private _dragOverHandler;
  76297. private _dropHandler;
  76298. /**
  76299. * Calls this function to listen to drag'n'drop events on a specific DOM element
  76300. * @param elementToMonitor defines the DOM element to track
  76301. */
  76302. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  76303. /** Gets the current list of files to load */
  76304. get filesToLoad(): File[];
  76305. /**
  76306. * Release all associated resources
  76307. */
  76308. dispose(): void;
  76309. private renderFunction;
  76310. private drag;
  76311. private drop;
  76312. private _traverseFolder;
  76313. private _processFiles;
  76314. /**
  76315. * Load files from a drop event
  76316. * @param event defines the drop event to use as source
  76317. */
  76318. loadFiles(event: any): void;
  76319. private _processReload;
  76320. /**
  76321. * Reload the current scene from the loaded files
  76322. */
  76323. reload(): void;
  76324. }
  76325. }
  76326. declare module "babylonjs/Misc/HighDynamicRange/index" {
  76327. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  76328. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  76329. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  76330. }
  76331. declare module "babylonjs/Misc/sceneOptimizer" {
  76332. import { Scene, IDisposable } from "babylonjs/scene";
  76333. import { Observable } from "babylonjs/Misc/observable";
  76334. /**
  76335. * Defines the root class used to create scene optimization to use with SceneOptimizer
  76336. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76337. */
  76338. export class SceneOptimization {
  76339. /**
  76340. * Defines the priority of this optimization (0 by default which means first in the list)
  76341. */
  76342. priority: number;
  76343. /**
  76344. * Gets a string describing the action executed by the current optimization
  76345. * @returns description string
  76346. */
  76347. getDescription(): string;
  76348. /**
  76349. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76350. * @param scene defines the current scene where to apply this optimization
  76351. * @param optimizer defines the current optimizer
  76352. * @returns true if everything that can be done was applied
  76353. */
  76354. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76355. /**
  76356. * Creates the SceneOptimization object
  76357. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76358. * @param desc defines the description associated with the optimization
  76359. */
  76360. constructor(
  76361. /**
  76362. * Defines the priority of this optimization (0 by default which means first in the list)
  76363. */
  76364. priority?: number);
  76365. }
  76366. /**
  76367. * Defines an optimization used to reduce the size of render target textures
  76368. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76369. */
  76370. export class TextureOptimization extends SceneOptimization {
  76371. /**
  76372. * Defines the priority of this optimization (0 by default which means first in the list)
  76373. */
  76374. priority: number;
  76375. /**
  76376. * 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
  76377. */
  76378. maximumSize: number;
  76379. /**
  76380. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76381. */
  76382. step: number;
  76383. /**
  76384. * Gets a string describing the action executed by the current optimization
  76385. * @returns description string
  76386. */
  76387. getDescription(): string;
  76388. /**
  76389. * Creates the TextureOptimization object
  76390. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76391. * @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
  76392. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76393. */
  76394. constructor(
  76395. /**
  76396. * Defines the priority of this optimization (0 by default which means first in the list)
  76397. */
  76398. priority?: number,
  76399. /**
  76400. * 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
  76401. */
  76402. maximumSize?: number,
  76403. /**
  76404. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76405. */
  76406. step?: number);
  76407. /**
  76408. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76409. * @param scene defines the current scene where to apply this optimization
  76410. * @param optimizer defines the current optimizer
  76411. * @returns true if everything that can be done was applied
  76412. */
  76413. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76414. }
  76415. /**
  76416. * Defines an optimization used to increase or decrease the rendering resolution
  76417. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76418. */
  76419. export class HardwareScalingOptimization extends SceneOptimization {
  76420. /**
  76421. * Defines the priority of this optimization (0 by default which means first in the list)
  76422. */
  76423. priority: number;
  76424. /**
  76425. * Defines the maximum scale to use (2 by default)
  76426. */
  76427. maximumScale: number;
  76428. /**
  76429. * Defines the step to use between two passes (0.5 by default)
  76430. */
  76431. step: number;
  76432. private _currentScale;
  76433. private _directionOffset;
  76434. /**
  76435. * Gets a string describing the action executed by the current optimization
  76436. * @return description string
  76437. */
  76438. getDescription(): string;
  76439. /**
  76440. * Creates the HardwareScalingOptimization object
  76441. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76442. * @param maximumScale defines the maximum scale to use (2 by default)
  76443. * @param step defines the step to use between two passes (0.5 by default)
  76444. */
  76445. constructor(
  76446. /**
  76447. * Defines the priority of this optimization (0 by default which means first in the list)
  76448. */
  76449. priority?: number,
  76450. /**
  76451. * Defines the maximum scale to use (2 by default)
  76452. */
  76453. maximumScale?: number,
  76454. /**
  76455. * Defines the step to use between two passes (0.5 by default)
  76456. */
  76457. step?: number);
  76458. /**
  76459. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76460. * @param scene defines the current scene where to apply this optimization
  76461. * @param optimizer defines the current optimizer
  76462. * @returns true if everything that can be done was applied
  76463. */
  76464. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76465. }
  76466. /**
  76467. * Defines an optimization used to remove shadows
  76468. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76469. */
  76470. export class ShadowsOptimization extends SceneOptimization {
  76471. /**
  76472. * Gets a string describing the action executed by the current optimization
  76473. * @return description string
  76474. */
  76475. getDescription(): string;
  76476. /**
  76477. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76478. * @param scene defines the current scene where to apply this optimization
  76479. * @param optimizer defines the current optimizer
  76480. * @returns true if everything that can be done was applied
  76481. */
  76482. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76483. }
  76484. /**
  76485. * Defines an optimization used to turn post-processes off
  76486. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76487. */
  76488. export class PostProcessesOptimization extends SceneOptimization {
  76489. /**
  76490. * Gets a string describing the action executed by the current optimization
  76491. * @return description string
  76492. */
  76493. getDescription(): string;
  76494. /**
  76495. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76496. * @param scene defines the current scene where to apply this optimization
  76497. * @param optimizer defines the current optimizer
  76498. * @returns true if everything that can be done was applied
  76499. */
  76500. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76501. }
  76502. /**
  76503. * Defines an optimization used to turn lens flares off
  76504. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76505. */
  76506. export class LensFlaresOptimization extends SceneOptimization {
  76507. /**
  76508. * Gets a string describing the action executed by the current optimization
  76509. * @return description string
  76510. */
  76511. getDescription(): string;
  76512. /**
  76513. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76514. * @param scene defines the current scene where to apply this optimization
  76515. * @param optimizer defines the current optimizer
  76516. * @returns true if everything that can be done was applied
  76517. */
  76518. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76519. }
  76520. /**
  76521. * Defines an optimization based on user defined callback.
  76522. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76523. */
  76524. export class CustomOptimization extends SceneOptimization {
  76525. /**
  76526. * Callback called to apply the custom optimization.
  76527. */
  76528. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  76529. /**
  76530. * Callback called to get custom description
  76531. */
  76532. onGetDescription: () => string;
  76533. /**
  76534. * Gets a string describing the action executed by the current optimization
  76535. * @returns description string
  76536. */
  76537. getDescription(): string;
  76538. /**
  76539. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76540. * @param scene defines the current scene where to apply this optimization
  76541. * @param optimizer defines the current optimizer
  76542. * @returns true if everything that can be done was applied
  76543. */
  76544. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76545. }
  76546. /**
  76547. * Defines an optimization used to turn particles off
  76548. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76549. */
  76550. export class ParticlesOptimization extends SceneOptimization {
  76551. /**
  76552. * Gets a string describing the action executed by the current optimization
  76553. * @return description string
  76554. */
  76555. getDescription(): string;
  76556. /**
  76557. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76558. * @param scene defines the current scene where to apply this optimization
  76559. * @param optimizer defines the current optimizer
  76560. * @returns true if everything that can be done was applied
  76561. */
  76562. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76563. }
  76564. /**
  76565. * Defines an optimization used to turn render targets off
  76566. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76567. */
  76568. export class RenderTargetsOptimization extends SceneOptimization {
  76569. /**
  76570. * Gets a string describing the action executed by the current optimization
  76571. * @return description string
  76572. */
  76573. getDescription(): string;
  76574. /**
  76575. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76576. * @param scene defines the current scene where to apply this optimization
  76577. * @param optimizer defines the current optimizer
  76578. * @returns true if everything that can be done was applied
  76579. */
  76580. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76581. }
  76582. /**
  76583. * Defines an optimization used to merge meshes with compatible materials
  76584. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76585. */
  76586. export class MergeMeshesOptimization extends SceneOptimization {
  76587. private static _UpdateSelectionTree;
  76588. /**
  76589. * Gets or sets a boolean which defines if optimization octree has to be updated
  76590. */
  76591. static get UpdateSelectionTree(): boolean;
  76592. /**
  76593. * Gets or sets a boolean which defines if optimization octree has to be updated
  76594. */
  76595. static set UpdateSelectionTree(value: boolean);
  76596. /**
  76597. * Gets a string describing the action executed by the current optimization
  76598. * @return description string
  76599. */
  76600. getDescription(): string;
  76601. private _canBeMerged;
  76602. /**
  76603. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76604. * @param scene defines the current scene where to apply this optimization
  76605. * @param optimizer defines the current optimizer
  76606. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  76607. * @returns true if everything that can be done was applied
  76608. */
  76609. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  76610. }
  76611. /**
  76612. * Defines a list of options used by SceneOptimizer
  76613. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76614. */
  76615. export class SceneOptimizerOptions {
  76616. /**
  76617. * Defines the target frame rate to reach (60 by default)
  76618. */
  76619. targetFrameRate: number;
  76620. /**
  76621. * Defines the interval between two checkes (2000ms by default)
  76622. */
  76623. trackerDuration: number;
  76624. /**
  76625. * Gets the list of optimizations to apply
  76626. */
  76627. optimizations: SceneOptimization[];
  76628. /**
  76629. * Creates a new list of options used by SceneOptimizer
  76630. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  76631. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  76632. */
  76633. constructor(
  76634. /**
  76635. * Defines the target frame rate to reach (60 by default)
  76636. */
  76637. targetFrameRate?: number,
  76638. /**
  76639. * Defines the interval between two checkes (2000ms by default)
  76640. */
  76641. trackerDuration?: number);
  76642. /**
  76643. * Add a new optimization
  76644. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  76645. * @returns the current SceneOptimizerOptions
  76646. */
  76647. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  76648. /**
  76649. * Add a new custom optimization
  76650. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  76651. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  76652. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76653. * @returns the current SceneOptimizerOptions
  76654. */
  76655. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  76656. /**
  76657. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  76658. * @param targetFrameRate defines the target frame rate (60 by default)
  76659. * @returns a SceneOptimizerOptions object
  76660. */
  76661. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76662. /**
  76663. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  76664. * @param targetFrameRate defines the target frame rate (60 by default)
  76665. * @returns a SceneOptimizerOptions object
  76666. */
  76667. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76668. /**
  76669. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  76670. * @param targetFrameRate defines the target frame rate (60 by default)
  76671. * @returns a SceneOptimizerOptions object
  76672. */
  76673. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76674. }
  76675. /**
  76676. * Class used to run optimizations in order to reach a target frame rate
  76677. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76678. */
  76679. export class SceneOptimizer implements IDisposable {
  76680. private _isRunning;
  76681. private _options;
  76682. private _scene;
  76683. private _currentPriorityLevel;
  76684. private _targetFrameRate;
  76685. private _trackerDuration;
  76686. private _currentFrameRate;
  76687. private _sceneDisposeObserver;
  76688. private _improvementMode;
  76689. /**
  76690. * Defines an observable called when the optimizer reaches the target frame rate
  76691. */
  76692. onSuccessObservable: Observable<SceneOptimizer>;
  76693. /**
  76694. * Defines an observable called when the optimizer enables an optimization
  76695. */
  76696. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  76697. /**
  76698. * Defines an observable called when the optimizer is not able to reach the target frame rate
  76699. */
  76700. onFailureObservable: Observable<SceneOptimizer>;
  76701. /**
  76702. * Gets a boolean indicating if the optimizer is in improvement mode
  76703. */
  76704. get isInImprovementMode(): boolean;
  76705. /**
  76706. * Gets the current priority level (0 at start)
  76707. */
  76708. get currentPriorityLevel(): number;
  76709. /**
  76710. * Gets the current frame rate checked by the SceneOptimizer
  76711. */
  76712. get currentFrameRate(): number;
  76713. /**
  76714. * Gets or sets the current target frame rate (60 by default)
  76715. */
  76716. get targetFrameRate(): number;
  76717. /**
  76718. * Gets or sets the current target frame rate (60 by default)
  76719. */
  76720. set targetFrameRate(value: number);
  76721. /**
  76722. * Gets or sets the current interval between two checks (every 2000ms by default)
  76723. */
  76724. get trackerDuration(): number;
  76725. /**
  76726. * Gets or sets the current interval between two checks (every 2000ms by default)
  76727. */
  76728. set trackerDuration(value: number);
  76729. /**
  76730. * Gets the list of active optimizations
  76731. */
  76732. get optimizations(): SceneOptimization[];
  76733. /**
  76734. * Creates a new SceneOptimizer
  76735. * @param scene defines the scene to work on
  76736. * @param options defines the options to use with the SceneOptimizer
  76737. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  76738. * @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)
  76739. */
  76740. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  76741. /**
  76742. * Stops the current optimizer
  76743. */
  76744. stop(): void;
  76745. /**
  76746. * Reset the optimizer to initial step (current priority level = 0)
  76747. */
  76748. reset(): void;
  76749. /**
  76750. * Start the optimizer. By default it will try to reach a specific framerate
  76751. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  76752. */
  76753. start(): void;
  76754. private _checkCurrentState;
  76755. /**
  76756. * Release all resources
  76757. */
  76758. dispose(): void;
  76759. /**
  76760. * Helper function to create a SceneOptimizer with one single line of code
  76761. * @param scene defines the scene to work on
  76762. * @param options defines the options to use with the SceneOptimizer
  76763. * @param onSuccess defines a callback to call on success
  76764. * @param onFailure defines a callback to call on failure
  76765. * @returns the new SceneOptimizer object
  76766. */
  76767. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  76768. }
  76769. }
  76770. declare module "babylonjs/Misc/sceneSerializer" {
  76771. import { Scene } from "babylonjs/scene";
  76772. /**
  76773. * Class used to serialize a scene into a string
  76774. */
  76775. export class SceneSerializer {
  76776. /**
  76777. * Clear cache used by a previous serialization
  76778. */
  76779. static ClearCache(): void;
  76780. /**
  76781. * Serialize a scene into a JSON compatible object
  76782. * @param scene defines the scene to serialize
  76783. * @returns a JSON compatible object
  76784. */
  76785. static Serialize(scene: Scene): any;
  76786. /**
  76787. * Serialize a mesh into a JSON compatible object
  76788. * @param toSerialize defines the mesh to serialize
  76789. * @param withParents defines if parents must be serialized as well
  76790. * @param withChildren defines if children must be serialized as well
  76791. * @returns a JSON compatible object
  76792. */
  76793. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  76794. }
  76795. }
  76796. declare module "babylonjs/Misc/textureTools" {
  76797. import { Texture } from "babylonjs/Materials/Textures/texture";
  76798. /**
  76799. * Class used to host texture specific utilities
  76800. */
  76801. export class TextureTools {
  76802. /**
  76803. * Uses the GPU to create a copy texture rescaled at a given size
  76804. * @param texture Texture to copy from
  76805. * @param width defines the desired width
  76806. * @param height defines the desired height
  76807. * @param useBilinearMode defines if bilinear mode has to be used
  76808. * @return the generated texture
  76809. */
  76810. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  76811. }
  76812. }
  76813. declare module "babylonjs/Misc/videoRecorder" {
  76814. import { Nullable } from "babylonjs/types";
  76815. import { Engine } from "babylonjs/Engines/engine";
  76816. /**
  76817. * This represents the different options available for the video capture.
  76818. */
  76819. export interface VideoRecorderOptions {
  76820. /** Defines the mime type of the video. */
  76821. mimeType: string;
  76822. /** Defines the FPS the video should be recorded at. */
  76823. fps: number;
  76824. /** Defines the chunk size for the recording data. */
  76825. recordChunckSize: number;
  76826. /** The audio tracks to attach to the recording. */
  76827. audioTracks?: MediaStreamTrack[];
  76828. }
  76829. /**
  76830. * This can help with recording videos from BabylonJS.
  76831. * This is based on the available WebRTC functionalities of the browser.
  76832. *
  76833. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  76834. */
  76835. export class VideoRecorder {
  76836. private static readonly _defaultOptions;
  76837. /**
  76838. * Returns whether or not the VideoRecorder is available in your browser.
  76839. * @param engine Defines the Babylon Engine.
  76840. * @returns true if supported otherwise false.
  76841. */
  76842. static IsSupported(engine: Engine): boolean;
  76843. private readonly _options;
  76844. private _canvas;
  76845. private _mediaRecorder;
  76846. private _recordedChunks;
  76847. private _fileName;
  76848. private _resolve;
  76849. private _reject;
  76850. /**
  76851. * True when a recording is already in progress.
  76852. */
  76853. get isRecording(): boolean;
  76854. /**
  76855. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  76856. * @param engine Defines the BabylonJS Engine you wish to record.
  76857. * @param options Defines options that can be used to customize the capture.
  76858. */
  76859. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  76860. /**
  76861. * Stops the current recording before the default capture timeout passed in the startRecording function.
  76862. */
  76863. stopRecording(): void;
  76864. /**
  76865. * Starts recording the canvas for a max duration specified in parameters.
  76866. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  76867. * If null no automatic download will start and you can rely on the promise to get the data back.
  76868. * @param maxDuration Defines the maximum recording time in seconds.
  76869. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  76870. * @return A promise callback at the end of the recording with the video data in Blob.
  76871. */
  76872. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  76873. /**
  76874. * Releases internal resources used during the recording.
  76875. */
  76876. dispose(): void;
  76877. private _handleDataAvailable;
  76878. private _handleError;
  76879. private _handleStop;
  76880. }
  76881. }
  76882. declare module "babylonjs/Misc/screenshotTools" {
  76883. import { Camera } from "babylonjs/Cameras/camera";
  76884. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  76885. import { Engine } from "babylonjs/Engines/engine";
  76886. /**
  76887. * Class containing a set of static utilities functions for screenshots
  76888. */
  76889. export class ScreenshotTools {
  76890. /**
  76891. * Captures a screenshot of the current rendering
  76892. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  76893. * @param engine defines the rendering engine
  76894. * @param camera defines the source camera
  76895. * @param size This parameter can be set to a single number or to an object with the
  76896. * following (optional) properties: precision, width, height. If a single number is passed,
  76897. * it will be used for both width and height. If an object is passed, the screenshot size
  76898. * will be derived from the parameters. The precision property is a multiplier allowing
  76899. * rendering at a higher or lower resolution
  76900. * @param successCallback defines the callback receives a single parameter which contains the
  76901. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  76902. * src parameter of an <img> to display it
  76903. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  76904. * Check your browser for supported MIME types
  76905. */
  76906. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  76907. /**
  76908. * Captures a screenshot of the current rendering
  76909. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  76910. * @param engine defines the rendering engine
  76911. * @param camera defines the source camera
  76912. * @param size This parameter can be set to a single number or to an object with the
  76913. * following (optional) properties: precision, width, height. If a single number is passed,
  76914. * it will be used for both width and height. If an object is passed, the screenshot size
  76915. * will be derived from the parameters. The precision property is a multiplier allowing
  76916. * rendering at a higher or lower resolution
  76917. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  76918. * Check your browser for supported MIME types
  76919. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  76920. * to the src parameter of an <img> to display it
  76921. */
  76922. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  76923. /**
  76924. * Generates an image screenshot from the specified camera.
  76925. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  76926. * @param engine The engine to use for rendering
  76927. * @param camera The camera to use for rendering
  76928. * @param size This parameter can be set to a single number or to an object with the
  76929. * following (optional) properties: precision, width, height. If a single number is passed,
  76930. * it will be used for both width and height. If an object is passed, the screenshot size
  76931. * will be derived from the parameters. The precision property is a multiplier allowing
  76932. * rendering at a higher or lower resolution
  76933. * @param successCallback The callback receives a single parameter which contains the
  76934. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  76935. * src parameter of an <img> to display it
  76936. * @param mimeType The MIME type of the screenshot image (default: image/png).
  76937. * Check your browser for supported MIME types
  76938. * @param samples Texture samples (default: 1)
  76939. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  76940. * @param fileName A name for for the downloaded file.
  76941. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  76942. */
  76943. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  76944. /**
  76945. * Generates an image screenshot from the specified camera.
  76946. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  76947. * @param engine The engine to use for rendering
  76948. * @param camera The camera to use for rendering
  76949. * @param size This parameter can be set to a single number or to an object with the
  76950. * following (optional) properties: precision, width, height. If a single number is passed,
  76951. * it will be used for both width and height. If an object is passed, the screenshot size
  76952. * will be derived from the parameters. The precision property is a multiplier allowing
  76953. * rendering at a higher or lower resolution
  76954. * @param mimeType The MIME type of the screenshot image (default: image/png).
  76955. * Check your browser for supported MIME types
  76956. * @param samples Texture samples (default: 1)
  76957. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  76958. * @param fileName A name for for the downloaded file.
  76959. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  76960. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  76961. * to the src parameter of an <img> to display it
  76962. */
  76963. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  76964. /**
  76965. * Gets height and width for screenshot size
  76966. * @private
  76967. */
  76968. private static _getScreenshotSize;
  76969. }
  76970. }
  76971. declare module "babylonjs/Misc/dataReader" {
  76972. /**
  76973. * Interface for a data buffer
  76974. */
  76975. export interface IDataBuffer {
  76976. /**
  76977. * Reads bytes from the data buffer.
  76978. * @param byteOffset The byte offset to read
  76979. * @param byteLength The byte length to read
  76980. * @returns A promise that resolves when the bytes are read
  76981. */
  76982. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  76983. /**
  76984. * The byte length of the buffer.
  76985. */
  76986. readonly byteLength: number;
  76987. }
  76988. /**
  76989. * Utility class for reading from a data buffer
  76990. */
  76991. export class DataReader {
  76992. /**
  76993. * The data buffer associated with this data reader.
  76994. */
  76995. readonly buffer: IDataBuffer;
  76996. /**
  76997. * The current byte offset from the beginning of the data buffer.
  76998. */
  76999. byteOffset: number;
  77000. private _dataView;
  77001. private _dataByteOffset;
  77002. /**
  77003. * Constructor
  77004. * @param buffer The buffer to read
  77005. */
  77006. constructor(buffer: IDataBuffer);
  77007. /**
  77008. * Loads the given byte length.
  77009. * @param byteLength The byte length to load
  77010. * @returns A promise that resolves when the load is complete
  77011. */
  77012. loadAsync(byteLength: number): Promise<void>;
  77013. /**
  77014. * Read a unsigned 32-bit integer from the currently loaded data range.
  77015. * @returns The 32-bit integer read
  77016. */
  77017. readUint32(): number;
  77018. /**
  77019. * Read a byte array from the currently loaded data range.
  77020. * @param byteLength The byte length to read
  77021. * @returns The byte array read
  77022. */
  77023. readUint8Array(byteLength: number): Uint8Array;
  77024. /**
  77025. * Read a string from the currently loaded data range.
  77026. * @param byteLength The byte length to read
  77027. * @returns The string read
  77028. */
  77029. readString(byteLength: number): string;
  77030. /**
  77031. * Skips the given byte length the currently loaded data range.
  77032. * @param byteLength The byte length to skip
  77033. */
  77034. skipBytes(byteLength: number): void;
  77035. }
  77036. }
  77037. declare module "babylonjs/Misc/dataStorage" {
  77038. /**
  77039. * Class for storing data to local storage if available or in-memory storage otherwise
  77040. */
  77041. export class DataStorage {
  77042. private static _Storage;
  77043. private static _GetStorage;
  77044. /**
  77045. * Reads a string from the data storage
  77046. * @param key The key to read
  77047. * @param defaultValue The value if the key doesn't exist
  77048. * @returns The string value
  77049. */
  77050. static ReadString(key: string, defaultValue: string): string;
  77051. /**
  77052. * Writes a string to the data storage
  77053. * @param key The key to write
  77054. * @param value The value to write
  77055. */
  77056. static WriteString(key: string, value: string): void;
  77057. /**
  77058. * Reads a boolean from the data storage
  77059. * @param key The key to read
  77060. * @param defaultValue The value if the key doesn't exist
  77061. * @returns The boolean value
  77062. */
  77063. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  77064. /**
  77065. * Writes a boolean to the data storage
  77066. * @param key The key to write
  77067. * @param value The value to write
  77068. */
  77069. static WriteBoolean(key: string, value: boolean): void;
  77070. /**
  77071. * Reads a number from the data storage
  77072. * @param key The key to read
  77073. * @param defaultValue The value if the key doesn't exist
  77074. * @returns The number value
  77075. */
  77076. static ReadNumber(key: string, defaultValue: number): number;
  77077. /**
  77078. * Writes a number to the data storage
  77079. * @param key The key to write
  77080. * @param value The value to write
  77081. */
  77082. static WriteNumber(key: string, value: number): void;
  77083. }
  77084. }
  77085. declare module "babylonjs/Misc/index" {
  77086. export * from "babylonjs/Misc/andOrNotEvaluator";
  77087. export * from "babylonjs/Misc/assetsManager";
  77088. export * from "babylonjs/Misc/basis";
  77089. export * from "babylonjs/Misc/dds";
  77090. export * from "babylonjs/Misc/decorators";
  77091. export * from "babylonjs/Misc/deferred";
  77092. export * from "babylonjs/Misc/environmentTextureTools";
  77093. export * from "babylonjs/Misc/meshExploder";
  77094. export * from "babylonjs/Misc/filesInput";
  77095. export * from "babylonjs/Misc/HighDynamicRange/index";
  77096. export * from "babylonjs/Misc/khronosTextureContainer";
  77097. export * from "babylonjs/Misc/observable";
  77098. export * from "babylonjs/Misc/performanceMonitor";
  77099. export * from "babylonjs/Misc/promise";
  77100. export * from "babylonjs/Misc/sceneOptimizer";
  77101. export * from "babylonjs/Misc/sceneSerializer";
  77102. export * from "babylonjs/Misc/smartArray";
  77103. export * from "babylonjs/Misc/stringDictionary";
  77104. export * from "babylonjs/Misc/tags";
  77105. export * from "babylonjs/Misc/textureTools";
  77106. export * from "babylonjs/Misc/tga";
  77107. export * from "babylonjs/Misc/tools";
  77108. export * from "babylonjs/Misc/videoRecorder";
  77109. export * from "babylonjs/Misc/virtualJoystick";
  77110. export * from "babylonjs/Misc/workerPool";
  77111. export * from "babylonjs/Misc/logger";
  77112. export * from "babylonjs/Misc/typeStore";
  77113. export * from "babylonjs/Misc/filesInputStore";
  77114. export * from "babylonjs/Misc/deepCopier";
  77115. export * from "babylonjs/Misc/pivotTools";
  77116. export * from "babylonjs/Misc/precisionDate";
  77117. export * from "babylonjs/Misc/screenshotTools";
  77118. export * from "babylonjs/Misc/typeStore";
  77119. export * from "babylonjs/Misc/webRequest";
  77120. export * from "babylonjs/Misc/iInspectable";
  77121. export * from "babylonjs/Misc/brdfTextureTools";
  77122. export * from "babylonjs/Misc/rgbdTextureTools";
  77123. export * from "babylonjs/Misc/gradients";
  77124. export * from "babylonjs/Misc/perfCounter";
  77125. export * from "babylonjs/Misc/fileRequest";
  77126. export * from "babylonjs/Misc/customAnimationFrameRequester";
  77127. export * from "babylonjs/Misc/retryStrategy";
  77128. export * from "babylonjs/Misc/interfaces/screenshotSize";
  77129. export * from "babylonjs/Misc/canvasGenerator";
  77130. export * from "babylonjs/Misc/fileTools";
  77131. export * from "babylonjs/Misc/stringTools";
  77132. export * from "babylonjs/Misc/dataReader";
  77133. export * from "babylonjs/Misc/minMaxReducer";
  77134. export * from "babylonjs/Misc/depthReducer";
  77135. export * from "babylonjs/Misc/dataStorage";
  77136. }
  77137. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  77138. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  77139. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77140. import { Observable } from "babylonjs/Misc/observable";
  77141. import { Matrix } from "babylonjs/Maths/math.vector";
  77142. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77143. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77144. /**
  77145. * An interface for all Hit test features
  77146. */
  77147. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  77148. /**
  77149. * Triggered when new babylon (transformed) hit test results are available
  77150. */
  77151. onHitTestResultObservable: Observable<T[]>;
  77152. }
  77153. /**
  77154. * Options used for hit testing
  77155. */
  77156. export interface IWebXRLegacyHitTestOptions {
  77157. /**
  77158. * Only test when user interacted with the scene. Default - hit test every frame
  77159. */
  77160. testOnPointerDownOnly?: boolean;
  77161. /**
  77162. * The node to use to transform the local results to world coordinates
  77163. */
  77164. worldParentNode?: TransformNode;
  77165. }
  77166. /**
  77167. * Interface defining the babylon result of raycasting/hit-test
  77168. */
  77169. export interface IWebXRLegacyHitResult {
  77170. /**
  77171. * Transformation matrix that can be applied to a node that will put it in the hit point location
  77172. */
  77173. transformationMatrix: Matrix;
  77174. /**
  77175. * The native hit test result
  77176. */
  77177. xrHitResult: XRHitResult | XRHitTestResult;
  77178. }
  77179. /**
  77180. * The currently-working hit-test module.
  77181. * Hit test (or Ray-casting) is used to interact with the real world.
  77182. * For further information read here - https://github.com/immersive-web/hit-test
  77183. */
  77184. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  77185. /**
  77186. * options to use when constructing this feature
  77187. */
  77188. readonly options: IWebXRLegacyHitTestOptions;
  77189. private _direction;
  77190. private _mat;
  77191. private _onSelectEnabled;
  77192. private _origin;
  77193. /**
  77194. * The module's name
  77195. */
  77196. static readonly Name: string;
  77197. /**
  77198. * The (Babylon) version of this module.
  77199. * This is an integer representing the implementation version.
  77200. * This number does not correspond to the WebXR specs version
  77201. */
  77202. static readonly Version: number;
  77203. /**
  77204. * Populated with the last native XR Hit Results
  77205. */
  77206. lastNativeXRHitResults: XRHitResult[];
  77207. /**
  77208. * Triggered when new babylon (transformed) hit test results are available
  77209. */
  77210. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  77211. /**
  77212. * Creates a new instance of the (legacy version) hit test feature
  77213. * @param _xrSessionManager an instance of WebXRSessionManager
  77214. * @param options options to use when constructing this feature
  77215. */
  77216. constructor(_xrSessionManager: WebXRSessionManager,
  77217. /**
  77218. * options to use when constructing this feature
  77219. */
  77220. options?: IWebXRLegacyHitTestOptions);
  77221. /**
  77222. * execute a hit test with an XR Ray
  77223. *
  77224. * @param xrSession a native xrSession that will execute this hit test
  77225. * @param xrRay the ray (position and direction) to use for ray-casting
  77226. * @param referenceSpace native XR reference space to use for the hit-test
  77227. * @param filter filter function that will filter the results
  77228. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  77229. */
  77230. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  77231. /**
  77232. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  77233. * @param event the (select) event to use to select with
  77234. * @param referenceSpace the reference space to use for this hit test
  77235. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  77236. */
  77237. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  77238. /**
  77239. * attach this feature
  77240. * Will usually be called by the features manager
  77241. *
  77242. * @returns true if successful.
  77243. */
  77244. attach(): boolean;
  77245. /**
  77246. * detach this feature.
  77247. * Will usually be called by the features manager
  77248. *
  77249. * @returns true if successful.
  77250. */
  77251. detach(): boolean;
  77252. /**
  77253. * Dispose this feature and all of the resources attached
  77254. */
  77255. dispose(): void;
  77256. protected _onXRFrame(frame: XRFrame): void;
  77257. private _onHitTestResults;
  77258. private _onSelect;
  77259. }
  77260. }
  77261. declare module "babylonjs/XR/features/WebXRHitTest" {
  77262. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77263. import { Observable } from "babylonjs/Misc/observable";
  77264. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  77265. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77266. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  77267. /**
  77268. * Options used for hit testing (version 2)
  77269. */
  77270. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  77271. /**
  77272. * Do not create a permanent hit test. Will usually be used when only
  77273. * transient inputs are needed.
  77274. */
  77275. disablePermanentHitTest?: boolean;
  77276. /**
  77277. * Enable transient (for example touch-based) hit test inspections
  77278. */
  77279. enableTransientHitTest?: boolean;
  77280. /**
  77281. * Offset ray for the permanent hit test
  77282. */
  77283. offsetRay?: Vector3;
  77284. /**
  77285. * Offset ray for the transient hit test
  77286. */
  77287. transientOffsetRay?: Vector3;
  77288. /**
  77289. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  77290. */
  77291. useReferenceSpace?: boolean;
  77292. }
  77293. /**
  77294. * Interface defining the babylon result of hit-test
  77295. */
  77296. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  77297. /**
  77298. * The input source that generated this hit test (if transient)
  77299. */
  77300. inputSource?: XRInputSource;
  77301. /**
  77302. * Is this a transient hit test
  77303. */
  77304. isTransient?: boolean;
  77305. /**
  77306. * Position of the hit test result
  77307. */
  77308. position: Vector3;
  77309. /**
  77310. * Rotation of the hit test result
  77311. */
  77312. rotationQuaternion: Quaternion;
  77313. /**
  77314. * The native hit test result
  77315. */
  77316. xrHitResult: XRHitTestResult;
  77317. }
  77318. /**
  77319. * The currently-working hit-test module.
  77320. * Hit test (or Ray-casting) is used to interact with the real world.
  77321. * For further information read here - https://github.com/immersive-web/hit-test
  77322. *
  77323. * Tested on chrome (mobile) 80.
  77324. */
  77325. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  77326. /**
  77327. * options to use when constructing this feature
  77328. */
  77329. readonly options: IWebXRHitTestOptions;
  77330. private _tmpMat;
  77331. private _tmpPos;
  77332. private _tmpQuat;
  77333. private _transientXrHitTestSource;
  77334. private _xrHitTestSource;
  77335. private initHitTestSource;
  77336. /**
  77337. * The module's name
  77338. */
  77339. static readonly Name: string;
  77340. /**
  77341. * The (Babylon) version of this module.
  77342. * This is an integer representing the implementation version.
  77343. * This number does not correspond to the WebXR specs version
  77344. */
  77345. static readonly Version: number;
  77346. /**
  77347. * When set to true, each hit test will have its own position/rotation objects
  77348. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  77349. * the developers will clone them or copy them as they see fit.
  77350. */
  77351. autoCloneTransformation: boolean;
  77352. /**
  77353. * Triggered when new babylon (transformed) hit test results are available
  77354. */
  77355. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  77356. /**
  77357. * Use this to temporarily pause hit test checks.
  77358. */
  77359. paused: boolean;
  77360. /**
  77361. * Creates a new instance of the hit test feature
  77362. * @param _xrSessionManager an instance of WebXRSessionManager
  77363. * @param options options to use when constructing this feature
  77364. */
  77365. constructor(_xrSessionManager: WebXRSessionManager,
  77366. /**
  77367. * options to use when constructing this feature
  77368. */
  77369. options?: IWebXRHitTestOptions);
  77370. /**
  77371. * attach this feature
  77372. * Will usually be called by the features manager
  77373. *
  77374. * @returns true if successful.
  77375. */
  77376. attach(): boolean;
  77377. /**
  77378. * detach this feature.
  77379. * Will usually be called by the features manager
  77380. *
  77381. * @returns true if successful.
  77382. */
  77383. detach(): boolean;
  77384. /**
  77385. * Dispose this feature and all of the resources attached
  77386. */
  77387. dispose(): void;
  77388. protected _onXRFrame(frame: XRFrame): void;
  77389. private _processWebXRHitTestResult;
  77390. }
  77391. }
  77392. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  77393. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77394. import { Observable } from "babylonjs/Misc/observable";
  77395. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  77396. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77397. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77398. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  77399. /**
  77400. * Configuration options of the anchor system
  77401. */
  77402. export interface IWebXRAnchorSystemOptions {
  77403. /**
  77404. * a node that will be used to convert local to world coordinates
  77405. */
  77406. worldParentNode?: TransformNode;
  77407. /**
  77408. * If set to true a reference of the created anchors will be kept until the next session starts
  77409. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  77410. */
  77411. doNotRemoveAnchorsOnSessionEnded?: boolean;
  77412. }
  77413. /**
  77414. * A babylon container for an XR Anchor
  77415. */
  77416. export interface IWebXRAnchor {
  77417. /**
  77418. * A babylon-assigned ID for this anchor
  77419. */
  77420. id: number;
  77421. /**
  77422. * Transformation matrix to apply to an object attached to this anchor
  77423. */
  77424. transformationMatrix: Matrix;
  77425. /**
  77426. * The native anchor object
  77427. */
  77428. xrAnchor: XRAnchor;
  77429. /**
  77430. * if defined, this object will be constantly updated by the anchor's position and rotation
  77431. */
  77432. attachedNode?: TransformNode;
  77433. }
  77434. /**
  77435. * An implementation of the anchor system for WebXR.
  77436. * For further information see https://github.com/immersive-web/anchors/
  77437. */
  77438. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  77439. private _options;
  77440. private _lastFrameDetected;
  77441. private _trackedAnchors;
  77442. private _referenceSpaceForFrameAnchors;
  77443. private _futureAnchors;
  77444. /**
  77445. * The module's name
  77446. */
  77447. static readonly Name: string;
  77448. /**
  77449. * The (Babylon) version of this module.
  77450. * This is an integer representing the implementation version.
  77451. * This number does not correspond to the WebXR specs version
  77452. */
  77453. static readonly Version: number;
  77454. /**
  77455. * Observers registered here will be executed when a new anchor was added to the session
  77456. */
  77457. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  77458. /**
  77459. * Observers registered here will be executed when an anchor was removed from the session
  77460. */
  77461. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  77462. /**
  77463. * Observers registered here will be executed when an existing anchor updates
  77464. * This can execute N times every frame
  77465. */
  77466. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  77467. /**
  77468. * Set the reference space to use for anchor creation, when not using a hit test.
  77469. * Will default to the session's reference space if not defined
  77470. */
  77471. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  77472. /**
  77473. * constructs a new anchor system
  77474. * @param _xrSessionManager an instance of WebXRSessionManager
  77475. * @param _options configuration object for this feature
  77476. */
  77477. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  77478. private _tmpVector;
  77479. private _tmpQuaternion;
  77480. private _populateTmpTransformation;
  77481. /**
  77482. * Create a new anchor point using a hit test result at a specific point in the scene
  77483. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  77484. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  77485. *
  77486. * @param hitTestResult The hit test result to use for this anchor creation
  77487. * @param position an optional position offset for this anchor
  77488. * @param rotationQuaternion an optional rotation offset for this anchor
  77489. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  77490. */
  77491. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  77492. /**
  77493. * Add a new anchor at a specific position and rotation
  77494. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  77495. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  77496. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  77497. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  77498. *
  77499. * @param position the position in which to add an anchor
  77500. * @param rotationQuaternion an optional rotation for the anchor transformation
  77501. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  77502. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  77503. */
  77504. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  77505. /**
  77506. * detach this feature.
  77507. * Will usually be called by the features manager
  77508. *
  77509. * @returns true if successful.
  77510. */
  77511. detach(): boolean;
  77512. /**
  77513. * Dispose this feature and all of the resources attached
  77514. */
  77515. dispose(): void;
  77516. protected _onXRFrame(frame: XRFrame): void;
  77517. /**
  77518. * avoiding using Array.find for global support.
  77519. * @param xrAnchor the plane to find in the array
  77520. */
  77521. private _findIndexInAnchorArray;
  77522. private _updateAnchorWithXRFrame;
  77523. private _createAnchorAtTransformation;
  77524. }
  77525. }
  77526. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  77527. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77528. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77529. import { Observable } from "babylonjs/Misc/observable";
  77530. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  77531. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77532. /**
  77533. * Options used in the plane detector module
  77534. */
  77535. export interface IWebXRPlaneDetectorOptions {
  77536. /**
  77537. * The node to use to transform the local results to world coordinates
  77538. */
  77539. worldParentNode?: TransformNode;
  77540. /**
  77541. * If set to true a reference of the created planes will be kept until the next session starts
  77542. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  77543. */
  77544. doNotRemovePlanesOnSessionEnded?: boolean;
  77545. }
  77546. /**
  77547. * A babylon interface for a WebXR plane.
  77548. * A Plane is actually a polygon, built from N points in space
  77549. *
  77550. * Supported in chrome 79, not supported in canary 81 ATM
  77551. */
  77552. export interface IWebXRPlane {
  77553. /**
  77554. * a babylon-assigned ID for this polygon
  77555. */
  77556. id: number;
  77557. /**
  77558. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  77559. */
  77560. polygonDefinition: Array<Vector3>;
  77561. /**
  77562. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  77563. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  77564. */
  77565. transformationMatrix: Matrix;
  77566. /**
  77567. * the native xr-plane object
  77568. */
  77569. xrPlane: XRPlane;
  77570. }
  77571. /**
  77572. * The plane detector is used to detect planes in the real world when in AR
  77573. * For more information see https://github.com/immersive-web/real-world-geometry/
  77574. */
  77575. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  77576. private _options;
  77577. private _detectedPlanes;
  77578. private _enabled;
  77579. private _lastFrameDetected;
  77580. /**
  77581. * The module's name
  77582. */
  77583. static readonly Name: string;
  77584. /**
  77585. * The (Babylon) version of this module.
  77586. * This is an integer representing the implementation version.
  77587. * This number does not correspond to the WebXR specs version
  77588. */
  77589. static readonly Version: number;
  77590. /**
  77591. * Observers registered here will be executed when a new plane was added to the session
  77592. */
  77593. onPlaneAddedObservable: Observable<IWebXRPlane>;
  77594. /**
  77595. * Observers registered here will be executed when a plane is no longer detected in the session
  77596. */
  77597. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  77598. /**
  77599. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  77600. * This can execute N times every frame
  77601. */
  77602. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  77603. /**
  77604. * construct a new Plane Detector
  77605. * @param _xrSessionManager an instance of xr Session manager
  77606. * @param _options configuration to use when constructing this feature
  77607. */
  77608. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  77609. /**
  77610. * detach this feature.
  77611. * Will usually be called by the features manager
  77612. *
  77613. * @returns true if successful.
  77614. */
  77615. detach(): boolean;
  77616. /**
  77617. * Dispose this feature and all of the resources attached
  77618. */
  77619. dispose(): void;
  77620. protected _onXRFrame(frame: XRFrame): void;
  77621. private _init;
  77622. private _updatePlaneWithXRPlane;
  77623. /**
  77624. * avoiding using Array.find for global support.
  77625. * @param xrPlane the plane to find in the array
  77626. */
  77627. private findIndexInPlaneArray;
  77628. }
  77629. }
  77630. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  77631. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77633. import { Observable } from "babylonjs/Misc/observable";
  77634. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77635. /**
  77636. * Options interface for the background remover plugin
  77637. */
  77638. export interface IWebXRBackgroundRemoverOptions {
  77639. /**
  77640. * Further background meshes to disable when entering AR
  77641. */
  77642. backgroundMeshes?: AbstractMesh[];
  77643. /**
  77644. * flags to configure the removal of the environment helper.
  77645. * If not set, the entire background will be removed. If set, flags should be set as well.
  77646. */
  77647. environmentHelperRemovalFlags?: {
  77648. /**
  77649. * Should the skybox be removed (default false)
  77650. */
  77651. skyBox?: boolean;
  77652. /**
  77653. * Should the ground be removed (default false)
  77654. */
  77655. ground?: boolean;
  77656. };
  77657. /**
  77658. * don't disable the environment helper
  77659. */
  77660. ignoreEnvironmentHelper?: boolean;
  77661. }
  77662. /**
  77663. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  77664. */
  77665. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  77666. /**
  77667. * read-only options to be used in this module
  77668. */
  77669. readonly options: IWebXRBackgroundRemoverOptions;
  77670. /**
  77671. * The module's name
  77672. */
  77673. static readonly Name: string;
  77674. /**
  77675. * The (Babylon) version of this module.
  77676. * This is an integer representing the implementation version.
  77677. * This number does not correspond to the WebXR specs version
  77678. */
  77679. static readonly Version: number;
  77680. /**
  77681. * registered observers will be triggered when the background state changes
  77682. */
  77683. onBackgroundStateChangedObservable: Observable<boolean>;
  77684. /**
  77685. * constructs a new background remover module
  77686. * @param _xrSessionManager the session manager for this module
  77687. * @param options read-only options to be used in this module
  77688. */
  77689. constructor(_xrSessionManager: WebXRSessionManager,
  77690. /**
  77691. * read-only options to be used in this module
  77692. */
  77693. options?: IWebXRBackgroundRemoverOptions);
  77694. /**
  77695. * attach this feature
  77696. * Will usually be called by the features manager
  77697. *
  77698. * @returns true if successful.
  77699. */
  77700. attach(): boolean;
  77701. /**
  77702. * detach this feature.
  77703. * Will usually be called by the features manager
  77704. *
  77705. * @returns true if successful.
  77706. */
  77707. detach(): boolean;
  77708. /**
  77709. * Dispose this feature and all of the resources attached
  77710. */
  77711. dispose(): void;
  77712. protected _onXRFrame(_xrFrame: XRFrame): void;
  77713. private _setBackgroundState;
  77714. }
  77715. }
  77716. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  77717. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77718. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  77719. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  77720. import { WebXRInput } from "babylonjs/XR/webXRInput";
  77721. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77722. import { Nullable } from "babylonjs/types";
  77723. /**
  77724. * Options for the controller physics feature
  77725. */
  77726. export class IWebXRControllerPhysicsOptions {
  77727. /**
  77728. * Should the headset get its own impostor
  77729. */
  77730. enableHeadsetImpostor?: boolean;
  77731. /**
  77732. * Optional parameters for the headset impostor
  77733. */
  77734. headsetImpostorParams?: {
  77735. /**
  77736. * The type of impostor to create. Default is sphere
  77737. */
  77738. impostorType: number;
  77739. /**
  77740. * the size of the impostor. Defaults to 10cm
  77741. */
  77742. impostorSize?: number | {
  77743. width: number;
  77744. height: number;
  77745. depth: number;
  77746. };
  77747. /**
  77748. * Friction definitions
  77749. */
  77750. friction?: number;
  77751. /**
  77752. * Restitution
  77753. */
  77754. restitution?: number;
  77755. };
  77756. /**
  77757. * The physics properties of the future impostors
  77758. */
  77759. physicsProperties?: {
  77760. /**
  77761. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  77762. * Note that this requires a physics engine that supports mesh impostors!
  77763. */
  77764. useControllerMesh?: boolean;
  77765. /**
  77766. * The type of impostor to create. Default is sphere
  77767. */
  77768. impostorType?: number;
  77769. /**
  77770. * the size of the impostor. Defaults to 10cm
  77771. */
  77772. impostorSize?: number | {
  77773. width: number;
  77774. height: number;
  77775. depth: number;
  77776. };
  77777. /**
  77778. * Friction definitions
  77779. */
  77780. friction?: number;
  77781. /**
  77782. * Restitution
  77783. */
  77784. restitution?: number;
  77785. };
  77786. /**
  77787. * the xr input to use with this pointer selection
  77788. */
  77789. xrInput: WebXRInput;
  77790. }
  77791. /**
  77792. * Add physics impostor to your webxr controllers,
  77793. * including naive calculation of their linear and angular velocity
  77794. */
  77795. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  77796. private readonly _options;
  77797. private _attachController;
  77798. private _controllers;
  77799. private _debugMode;
  77800. private _delta;
  77801. private _headsetImpostor?;
  77802. private _headsetMesh?;
  77803. private _lastTimestamp;
  77804. private _tmpQuaternion;
  77805. private _tmpVector;
  77806. /**
  77807. * The module's name
  77808. */
  77809. static readonly Name: string;
  77810. /**
  77811. * The (Babylon) version of this module.
  77812. * This is an integer representing the implementation version.
  77813. * This number does not correspond to the webxr specs version
  77814. */
  77815. static readonly Version: number;
  77816. /**
  77817. * Construct a new Controller Physics Feature
  77818. * @param _xrSessionManager the corresponding xr session manager
  77819. * @param _options options to create this feature with
  77820. */
  77821. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  77822. /**
  77823. * @hidden
  77824. * enable debugging - will show console outputs and the impostor mesh
  77825. */
  77826. _enablePhysicsDebug(): void;
  77827. /**
  77828. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  77829. * @param xrController the controller to add
  77830. */
  77831. addController(xrController: WebXRInputSource): void;
  77832. /**
  77833. * attach this feature
  77834. * Will usually be called by the features manager
  77835. *
  77836. * @returns true if successful.
  77837. */
  77838. attach(): boolean;
  77839. /**
  77840. * detach this feature.
  77841. * Will usually be called by the features manager
  77842. *
  77843. * @returns true if successful.
  77844. */
  77845. detach(): boolean;
  77846. /**
  77847. * Get the headset impostor, if enabled
  77848. * @returns the impostor
  77849. */
  77850. getHeadsetImpostor(): PhysicsImpostor | undefined;
  77851. /**
  77852. * Get the physics impostor of a specific controller.
  77853. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  77854. * @param controller the controller or the controller id of which to get the impostor
  77855. * @returns the impostor or null
  77856. */
  77857. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  77858. /**
  77859. * Update the physics properties provided in the constructor
  77860. * @param newProperties the new properties object
  77861. */
  77862. setPhysicsProperties(newProperties: {
  77863. impostorType?: number;
  77864. impostorSize?: number | {
  77865. width: number;
  77866. height: number;
  77867. depth: number;
  77868. };
  77869. friction?: number;
  77870. restitution?: number;
  77871. }): void;
  77872. protected _onXRFrame(_xrFrame: any): void;
  77873. private _detachController;
  77874. }
  77875. }
  77876. declare module "babylonjs/XR/features/index" {
  77877. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  77878. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  77879. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  77880. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  77881. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  77882. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  77883. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  77884. export * from "babylonjs/XR/features/WebXRHitTest";
  77885. }
  77886. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  77887. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77889. import { Scene } from "babylonjs/scene";
  77890. /**
  77891. * The motion controller class for all microsoft mixed reality controllers
  77892. */
  77893. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  77894. protected readonly _mapping: {
  77895. defaultButton: {
  77896. valueNodeName: string;
  77897. unpressedNodeName: string;
  77898. pressedNodeName: string;
  77899. };
  77900. defaultAxis: {
  77901. valueNodeName: string;
  77902. minNodeName: string;
  77903. maxNodeName: string;
  77904. };
  77905. buttons: {
  77906. "xr-standard-trigger": {
  77907. rootNodeName: string;
  77908. componentProperty: string;
  77909. states: string[];
  77910. };
  77911. "xr-standard-squeeze": {
  77912. rootNodeName: string;
  77913. componentProperty: string;
  77914. states: string[];
  77915. };
  77916. "xr-standard-touchpad": {
  77917. rootNodeName: string;
  77918. labelAnchorNodeName: string;
  77919. touchPointNodeName: string;
  77920. };
  77921. "xr-standard-thumbstick": {
  77922. rootNodeName: string;
  77923. componentProperty: string;
  77924. states: string[];
  77925. };
  77926. };
  77927. axes: {
  77928. "xr-standard-touchpad": {
  77929. "x-axis": {
  77930. rootNodeName: string;
  77931. };
  77932. "y-axis": {
  77933. rootNodeName: string;
  77934. };
  77935. };
  77936. "xr-standard-thumbstick": {
  77937. "x-axis": {
  77938. rootNodeName: string;
  77939. };
  77940. "y-axis": {
  77941. rootNodeName: string;
  77942. };
  77943. };
  77944. };
  77945. };
  77946. /**
  77947. * The base url used to load the left and right controller models
  77948. */
  77949. static MODEL_BASE_URL: string;
  77950. /**
  77951. * The name of the left controller model file
  77952. */
  77953. static MODEL_LEFT_FILENAME: string;
  77954. /**
  77955. * The name of the right controller model file
  77956. */
  77957. static MODEL_RIGHT_FILENAME: string;
  77958. profileId: string;
  77959. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77960. protected _getFilenameAndPath(): {
  77961. filename: string;
  77962. path: string;
  77963. };
  77964. protected _getModelLoadingConstraints(): boolean;
  77965. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77966. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77967. protected _updateModel(): void;
  77968. }
  77969. }
  77970. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  77971. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77972. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77973. import { Scene } from "babylonjs/scene";
  77974. /**
  77975. * The motion controller class for oculus touch (quest, rift).
  77976. * This class supports legacy mapping as well the standard xr mapping
  77977. */
  77978. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  77979. private _forceLegacyControllers;
  77980. private _modelRootNode;
  77981. /**
  77982. * The base url used to load the left and right controller models
  77983. */
  77984. static MODEL_BASE_URL: string;
  77985. /**
  77986. * The name of the left controller model file
  77987. */
  77988. static MODEL_LEFT_FILENAME: string;
  77989. /**
  77990. * The name of the right controller model file
  77991. */
  77992. static MODEL_RIGHT_FILENAME: string;
  77993. /**
  77994. * Base Url for the Quest controller model.
  77995. */
  77996. static QUEST_MODEL_BASE_URL: string;
  77997. profileId: string;
  77998. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  77999. protected _getFilenameAndPath(): {
  78000. filename: string;
  78001. path: string;
  78002. };
  78003. protected _getModelLoadingConstraints(): boolean;
  78004. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78005. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78006. protected _updateModel(): void;
  78007. /**
  78008. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  78009. * between the touch and touch 2.
  78010. */
  78011. private _isQuest;
  78012. }
  78013. }
  78014. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  78015. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78016. import { Scene } from "babylonjs/scene";
  78017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78018. /**
  78019. * The motion controller class for the standard HTC-Vive controllers
  78020. */
  78021. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  78022. private _modelRootNode;
  78023. /**
  78024. * The base url used to load the left and right controller models
  78025. */
  78026. static MODEL_BASE_URL: string;
  78027. /**
  78028. * File name for the controller model.
  78029. */
  78030. static MODEL_FILENAME: string;
  78031. profileId: string;
  78032. /**
  78033. * Create a new Vive motion controller object
  78034. * @param scene the scene to use to create this controller
  78035. * @param gamepadObject the corresponding gamepad object
  78036. * @param handedness the handedness of the controller
  78037. */
  78038. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  78039. protected _getFilenameAndPath(): {
  78040. filename: string;
  78041. path: string;
  78042. };
  78043. protected _getModelLoadingConstraints(): boolean;
  78044. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78045. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78046. protected _updateModel(): void;
  78047. }
  78048. }
  78049. declare module "babylonjs/XR/motionController/index" {
  78050. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78051. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  78052. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  78053. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  78054. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  78055. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  78056. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  78057. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  78058. }
  78059. declare module "babylonjs/XR/index" {
  78060. export * from "babylonjs/XR/webXRCamera";
  78061. export * from "babylonjs/XR/webXREnterExitUI";
  78062. export * from "babylonjs/XR/webXRExperienceHelper";
  78063. export * from "babylonjs/XR/webXRInput";
  78064. export * from "babylonjs/XR/webXRInputSource";
  78065. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  78066. export * from "babylonjs/XR/webXRTypes";
  78067. export * from "babylonjs/XR/webXRSessionManager";
  78068. export * from "babylonjs/XR/webXRDefaultExperience";
  78069. export * from "babylonjs/XR/webXRFeaturesManager";
  78070. export * from "babylonjs/XR/features/index";
  78071. export * from "babylonjs/XR/motionController/index";
  78072. }
  78073. declare module "babylonjs/index" {
  78074. export * from "babylonjs/abstractScene";
  78075. export * from "babylonjs/Actions/index";
  78076. export * from "babylonjs/Animations/index";
  78077. export * from "babylonjs/assetContainer";
  78078. export * from "babylonjs/Audio/index";
  78079. export * from "babylonjs/Behaviors/index";
  78080. export * from "babylonjs/Bones/index";
  78081. export * from "babylonjs/Cameras/index";
  78082. export * from "babylonjs/Collisions/index";
  78083. export * from "babylonjs/Culling/index";
  78084. export * from "babylonjs/Debug/index";
  78085. export * from "babylonjs/DeviceInput/index";
  78086. export * from "babylonjs/Engines/index";
  78087. export * from "babylonjs/Events/index";
  78088. export * from "babylonjs/Gamepads/index";
  78089. export * from "babylonjs/Gizmos/index";
  78090. export * from "babylonjs/Helpers/index";
  78091. export * from "babylonjs/Instrumentation/index";
  78092. export * from "babylonjs/Layers/index";
  78093. export * from "babylonjs/LensFlares/index";
  78094. export * from "babylonjs/Lights/index";
  78095. export * from "babylonjs/Loading/index";
  78096. export * from "babylonjs/Materials/index";
  78097. export * from "babylonjs/Maths/index";
  78098. export * from "babylonjs/Meshes/index";
  78099. export * from "babylonjs/Morph/index";
  78100. export * from "babylonjs/Navigation/index";
  78101. export * from "babylonjs/node";
  78102. export * from "babylonjs/Offline/index";
  78103. export * from "babylonjs/Particles/index";
  78104. export * from "babylonjs/Physics/index";
  78105. export * from "babylonjs/PostProcesses/index";
  78106. export * from "babylonjs/Probes/index";
  78107. export * from "babylonjs/Rendering/index";
  78108. export * from "babylonjs/scene";
  78109. export * from "babylonjs/sceneComponent";
  78110. export * from "babylonjs/Sprites/index";
  78111. export * from "babylonjs/States/index";
  78112. export * from "babylonjs/Misc/index";
  78113. export * from "babylonjs/XR/index";
  78114. export * from "babylonjs/types";
  78115. }
  78116. declare module "babylonjs/Animations/pathCursor" {
  78117. import { Vector3 } from "babylonjs/Maths/math.vector";
  78118. import { Path2 } from "babylonjs/Maths/math.path";
  78119. /**
  78120. * A cursor which tracks a point on a path
  78121. */
  78122. export class PathCursor {
  78123. private path;
  78124. /**
  78125. * Stores path cursor callbacks for when an onchange event is triggered
  78126. */
  78127. private _onchange;
  78128. /**
  78129. * The value of the path cursor
  78130. */
  78131. value: number;
  78132. /**
  78133. * The animation array of the path cursor
  78134. */
  78135. animations: Animation[];
  78136. /**
  78137. * Initializes the path cursor
  78138. * @param path The path to track
  78139. */
  78140. constructor(path: Path2);
  78141. /**
  78142. * Gets the cursor point on the path
  78143. * @returns A point on the path cursor at the cursor location
  78144. */
  78145. getPoint(): Vector3;
  78146. /**
  78147. * Moves the cursor ahead by the step amount
  78148. * @param step The amount to move the cursor forward
  78149. * @returns This path cursor
  78150. */
  78151. moveAhead(step?: number): PathCursor;
  78152. /**
  78153. * Moves the cursor behind by the step amount
  78154. * @param step The amount to move the cursor back
  78155. * @returns This path cursor
  78156. */
  78157. moveBack(step?: number): PathCursor;
  78158. /**
  78159. * Moves the cursor by the step amount
  78160. * If the step amount is greater than one, an exception is thrown
  78161. * @param step The amount to move the cursor
  78162. * @returns This path cursor
  78163. */
  78164. move(step: number): PathCursor;
  78165. /**
  78166. * Ensures that the value is limited between zero and one
  78167. * @returns This path cursor
  78168. */
  78169. private ensureLimits;
  78170. /**
  78171. * Runs onchange callbacks on change (used by the animation engine)
  78172. * @returns This path cursor
  78173. */
  78174. private raiseOnChange;
  78175. /**
  78176. * Executes a function on change
  78177. * @param f A path cursor onchange callback
  78178. * @returns This path cursor
  78179. */
  78180. onchange(f: (cursor: PathCursor) => void): PathCursor;
  78181. }
  78182. }
  78183. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  78184. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  78185. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  78186. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  78187. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  78188. }
  78189. declare module "babylonjs/Engines/Processors/Expressions/index" {
  78190. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  78191. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  78192. }
  78193. declare module "babylonjs/Engines/Processors/index" {
  78194. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  78195. export * from "babylonjs/Engines/Processors/Expressions/index";
  78196. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  78197. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  78198. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  78199. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  78200. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  78201. export * from "babylonjs/Engines/Processors/shaderProcessor";
  78202. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  78203. }
  78204. declare module "babylonjs/Legacy/legacy" {
  78205. import * as Babylon from "babylonjs/index";
  78206. export * from "babylonjs/index";
  78207. }
  78208. declare module "babylonjs/Shaders/blur.fragment" {
  78209. /** @hidden */
  78210. export var blurPixelShader: {
  78211. name: string;
  78212. shader: string;
  78213. };
  78214. }
  78215. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  78216. /** @hidden */
  78217. export var pointCloudVertexDeclaration: {
  78218. name: string;
  78219. shader: string;
  78220. };
  78221. }
  78222. declare module "babylonjs" {
  78223. export * from "babylonjs/Legacy/legacy";
  78224. }
  78225. declare module BABYLON {
  78226. /** Alias type for value that can be null */
  78227. export type Nullable<T> = T | null;
  78228. /**
  78229. * Alias type for number that are floats
  78230. * @ignorenaming
  78231. */
  78232. export type float = number;
  78233. /**
  78234. * Alias type for number that are doubles.
  78235. * @ignorenaming
  78236. */
  78237. export type double = number;
  78238. /**
  78239. * Alias type for number that are integer
  78240. * @ignorenaming
  78241. */
  78242. export type int = number;
  78243. /** Alias type for number array or Float32Array */
  78244. export type FloatArray = number[] | Float32Array;
  78245. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  78246. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  78247. /**
  78248. * Alias for types that can be used by a Buffer or VertexBuffer.
  78249. */
  78250. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  78251. /**
  78252. * Alias type for primitive types
  78253. * @ignorenaming
  78254. */
  78255. type Primitive = undefined | null | boolean | string | number | Function;
  78256. /**
  78257. * Type modifier to make all the properties of an object Readonly
  78258. */
  78259. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  78260. /**
  78261. * Type modifier to make all the properties of an object Readonly recursively
  78262. */
  78263. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  78264. /**
  78265. * Type modifier to make object properties readonly.
  78266. */
  78267. export type DeepImmutableObject<T> = {
  78268. readonly [K in keyof T]: DeepImmutable<T[K]>;
  78269. };
  78270. /** @hidden */
  78271. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  78272. }
  78273. }
  78274. declare module BABYLON {
  78275. /**
  78276. * A class serves as a medium between the observable and its observers
  78277. */
  78278. export class EventState {
  78279. /**
  78280. * Create a new EventState
  78281. * @param mask defines the mask associated with this state
  78282. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  78283. * @param target defines the original target of the state
  78284. * @param currentTarget defines the current target of the state
  78285. */
  78286. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  78287. /**
  78288. * Initialize the current event state
  78289. * @param mask defines the mask associated with this state
  78290. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  78291. * @param target defines the original target of the state
  78292. * @param currentTarget defines the current target of the state
  78293. * @returns the current event state
  78294. */
  78295. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  78296. /**
  78297. * An Observer can set this property to true to prevent subsequent observers of being notified
  78298. */
  78299. skipNextObservers: boolean;
  78300. /**
  78301. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78302. */
  78303. mask: number;
  78304. /**
  78305. * The object that originally notified the event
  78306. */
  78307. target?: any;
  78308. /**
  78309. * The current object in the bubbling phase
  78310. */
  78311. currentTarget?: any;
  78312. /**
  78313. * This will be populated with the return value of the last function that was executed.
  78314. * If it is the first function in the callback chain it will be the event data.
  78315. */
  78316. lastReturnValue?: any;
  78317. }
  78318. /**
  78319. * Represent an Observer registered to a given Observable object.
  78320. */
  78321. export class Observer<T> {
  78322. /**
  78323. * Defines the callback to call when the observer is notified
  78324. */
  78325. callback: (eventData: T, eventState: EventState) => void;
  78326. /**
  78327. * Defines the mask of the observer (used to filter notifications)
  78328. */
  78329. mask: number;
  78330. /**
  78331. * Defines the current scope used to restore the JS context
  78332. */
  78333. scope: any;
  78334. /** @hidden */
  78335. _willBeUnregistered: boolean;
  78336. /**
  78337. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  78338. */
  78339. unregisterOnNextCall: boolean;
  78340. /**
  78341. * Creates a new observer
  78342. * @param callback defines the callback to call when the observer is notified
  78343. * @param mask defines the mask of the observer (used to filter notifications)
  78344. * @param scope defines the current scope used to restore the JS context
  78345. */
  78346. constructor(
  78347. /**
  78348. * Defines the callback to call when the observer is notified
  78349. */
  78350. callback: (eventData: T, eventState: EventState) => void,
  78351. /**
  78352. * Defines the mask of the observer (used to filter notifications)
  78353. */
  78354. mask: number,
  78355. /**
  78356. * Defines the current scope used to restore the JS context
  78357. */
  78358. scope?: any);
  78359. }
  78360. /**
  78361. * Represent a list of observers registered to multiple Observables object.
  78362. */
  78363. export class MultiObserver<T> {
  78364. private _observers;
  78365. private _observables;
  78366. /**
  78367. * Release associated resources
  78368. */
  78369. dispose(): void;
  78370. /**
  78371. * Raise a callback when one of the observable will notify
  78372. * @param observables defines a list of observables to watch
  78373. * @param callback defines the callback to call on notification
  78374. * @param mask defines the mask used to filter notifications
  78375. * @param scope defines the current scope used to restore the JS context
  78376. * @returns the new MultiObserver
  78377. */
  78378. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  78379. }
  78380. /**
  78381. * The Observable class is a simple implementation of the Observable pattern.
  78382. *
  78383. * 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.
  78384. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  78385. * 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).
  78386. * 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.
  78387. */
  78388. export class Observable<T> {
  78389. private _observers;
  78390. private _eventState;
  78391. private _onObserverAdded;
  78392. /**
  78393. * Gets the list of observers
  78394. */
  78395. get observers(): Array<Observer<T>>;
  78396. /**
  78397. * Creates a new observable
  78398. * @param onObserverAdded defines a callback to call when a new observer is added
  78399. */
  78400. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  78401. /**
  78402. * Create a new Observer with the specified callback
  78403. * @param callback the callback that will be executed for that Observer
  78404. * @param mask the mask used to filter observers
  78405. * @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.
  78406. * @param scope optional scope for the callback to be called from
  78407. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  78408. * @returns the new observer created for the callback
  78409. */
  78410. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  78411. /**
  78412. * Create a new Observer with the specified callback and unregisters after the next notification
  78413. * @param callback the callback that will be executed for that Observer
  78414. * @returns the new observer created for the callback
  78415. */
  78416. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  78417. /**
  78418. * Remove an Observer from the Observable object
  78419. * @param observer the instance of the Observer to remove
  78420. * @returns false if it doesn't belong to this Observable
  78421. */
  78422. remove(observer: Nullable<Observer<T>>): boolean;
  78423. /**
  78424. * Remove a callback from the Observable object
  78425. * @param callback the callback to remove
  78426. * @param scope optional scope. If used only the callbacks with this scope will be removed
  78427. * @returns false if it doesn't belong to this Observable
  78428. */
  78429. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  78430. private _deferUnregister;
  78431. private _remove;
  78432. /**
  78433. * Moves the observable to the top of the observer list making it get called first when notified
  78434. * @param observer the observer to move
  78435. */
  78436. makeObserverTopPriority(observer: Observer<T>): void;
  78437. /**
  78438. * Moves the observable to the bottom of the observer list making it get called last when notified
  78439. * @param observer the observer to move
  78440. */
  78441. makeObserverBottomPriority(observer: Observer<T>): void;
  78442. /**
  78443. * Notify all Observers by calling their respective callback with the given data
  78444. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  78445. * @param eventData defines the data to send to all observers
  78446. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  78447. * @param target defines the original target of the state
  78448. * @param currentTarget defines the current target of the state
  78449. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  78450. */
  78451. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  78452. /**
  78453. * Calling this will execute each callback, expecting it to be a promise or return a value.
  78454. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  78455. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  78456. * and it is crucial that all callbacks will be executed.
  78457. * The order of the callbacks is kept, callbacks are not executed parallel.
  78458. *
  78459. * @param eventData The data to be sent to each callback
  78460. * @param mask is used to filter observers defaults to -1
  78461. * @param target defines the callback target (see EventState)
  78462. * @param currentTarget defines he current object in the bubbling phase
  78463. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  78464. */
  78465. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  78466. /**
  78467. * Notify a specific observer
  78468. * @param observer defines the observer to notify
  78469. * @param eventData defines the data to be sent to each callback
  78470. * @param mask is used to filter observers defaults to -1
  78471. */
  78472. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  78473. /**
  78474. * Gets a boolean indicating if the observable has at least one observer
  78475. * @returns true is the Observable has at least one Observer registered
  78476. */
  78477. hasObservers(): boolean;
  78478. /**
  78479. * Clear the list of observers
  78480. */
  78481. clear(): void;
  78482. /**
  78483. * Clone the current observable
  78484. * @returns a new observable
  78485. */
  78486. clone(): Observable<T>;
  78487. /**
  78488. * Does this observable handles observer registered with a given mask
  78489. * @param mask defines the mask to be tested
  78490. * @return whether or not one observer registered with the given mask is handeled
  78491. **/
  78492. hasSpecificMask(mask?: number): boolean;
  78493. }
  78494. }
  78495. declare module BABYLON {
  78496. /**
  78497. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  78498. * Babylon.js
  78499. */
  78500. export class DomManagement {
  78501. /**
  78502. * Checks if the window object exists
  78503. * @returns true if the window object exists
  78504. */
  78505. static IsWindowObjectExist(): boolean;
  78506. /**
  78507. * Checks if the navigator object exists
  78508. * @returns true if the navigator object exists
  78509. */
  78510. static IsNavigatorAvailable(): boolean;
  78511. /**
  78512. * Check if the document object exists
  78513. * @returns true if the document object exists
  78514. */
  78515. static IsDocumentAvailable(): boolean;
  78516. /**
  78517. * Extracts text content from a DOM element hierarchy
  78518. * @param element defines the root element
  78519. * @returns a string
  78520. */
  78521. static GetDOMTextContent(element: HTMLElement): string;
  78522. }
  78523. }
  78524. declare module BABYLON {
  78525. /**
  78526. * Logger used througouht the application to allow configuration of
  78527. * the log level required for the messages.
  78528. */
  78529. export class Logger {
  78530. /**
  78531. * No log
  78532. */
  78533. static readonly NoneLogLevel: number;
  78534. /**
  78535. * Only message logs
  78536. */
  78537. static readonly MessageLogLevel: number;
  78538. /**
  78539. * Only warning logs
  78540. */
  78541. static readonly WarningLogLevel: number;
  78542. /**
  78543. * Only error logs
  78544. */
  78545. static readonly ErrorLogLevel: number;
  78546. /**
  78547. * All logs
  78548. */
  78549. static readonly AllLogLevel: number;
  78550. private static _LogCache;
  78551. /**
  78552. * Gets a value indicating the number of loading errors
  78553. * @ignorenaming
  78554. */
  78555. static errorsCount: number;
  78556. /**
  78557. * Callback called when a new log is added
  78558. */
  78559. static OnNewCacheEntry: (entry: string) => void;
  78560. private static _AddLogEntry;
  78561. private static _FormatMessage;
  78562. private static _LogDisabled;
  78563. private static _LogEnabled;
  78564. private static _WarnDisabled;
  78565. private static _WarnEnabled;
  78566. private static _ErrorDisabled;
  78567. private static _ErrorEnabled;
  78568. /**
  78569. * Log a message to the console
  78570. */
  78571. static Log: (message: string) => void;
  78572. /**
  78573. * Write a warning message to the console
  78574. */
  78575. static Warn: (message: string) => void;
  78576. /**
  78577. * Write an error message to the console
  78578. */
  78579. static Error: (message: string) => void;
  78580. /**
  78581. * Gets current log cache (list of logs)
  78582. */
  78583. static get LogCache(): string;
  78584. /**
  78585. * Clears the log cache
  78586. */
  78587. static ClearLogCache(): void;
  78588. /**
  78589. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  78590. */
  78591. static set LogLevels(level: number);
  78592. }
  78593. }
  78594. declare module BABYLON {
  78595. /** @hidden */
  78596. export class _TypeStore {
  78597. /** @hidden */
  78598. static RegisteredTypes: {
  78599. [key: string]: Object;
  78600. };
  78601. /** @hidden */
  78602. static GetClass(fqdn: string): any;
  78603. }
  78604. }
  78605. declare module BABYLON {
  78606. /**
  78607. * Helper to manipulate strings
  78608. */
  78609. export class StringTools {
  78610. /**
  78611. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  78612. * @param str Source string
  78613. * @param suffix Suffix to search for in the source string
  78614. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  78615. */
  78616. static EndsWith(str: string, suffix: string): boolean;
  78617. /**
  78618. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  78619. * @param str Source string
  78620. * @param suffix Suffix to search for in the source string
  78621. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  78622. */
  78623. static StartsWith(str: string, suffix: string): boolean;
  78624. /**
  78625. * Decodes a buffer into a string
  78626. * @param buffer The buffer to decode
  78627. * @returns The decoded string
  78628. */
  78629. static Decode(buffer: Uint8Array | Uint16Array): string;
  78630. /**
  78631. * Encode a buffer to a base64 string
  78632. * @param buffer defines the buffer to encode
  78633. * @returns the encoded string
  78634. */
  78635. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  78636. /**
  78637. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  78638. * @param num the number to convert and pad
  78639. * @param length the expected length of the string
  78640. * @returns the padded string
  78641. */
  78642. static PadNumber(num: number, length: number): string;
  78643. }
  78644. }
  78645. declare module BABYLON {
  78646. /**
  78647. * Class containing a set of static utilities functions for deep copy.
  78648. */
  78649. export class DeepCopier {
  78650. /**
  78651. * Tries to copy an object by duplicating every property
  78652. * @param source defines the source object
  78653. * @param destination defines the target object
  78654. * @param doNotCopyList defines a list of properties to avoid
  78655. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  78656. */
  78657. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  78658. }
  78659. }
  78660. declare module BABYLON {
  78661. /**
  78662. * Class containing a set of static utilities functions for precision date
  78663. */
  78664. export class PrecisionDate {
  78665. /**
  78666. * Gets either window.performance.now() if supported or Date.now() else
  78667. */
  78668. static get Now(): number;
  78669. }
  78670. }
  78671. declare module BABYLON {
  78672. /** @hidden */
  78673. export class _DevTools {
  78674. static WarnImport(name: string): string;
  78675. }
  78676. }
  78677. declare module BABYLON {
  78678. /**
  78679. * Interface used to define the mechanism to get data from the network
  78680. */
  78681. export interface IWebRequest {
  78682. /**
  78683. * Returns client's response url
  78684. */
  78685. responseURL: string;
  78686. /**
  78687. * Returns client's status
  78688. */
  78689. status: number;
  78690. /**
  78691. * Returns client's status as a text
  78692. */
  78693. statusText: string;
  78694. }
  78695. }
  78696. declare module BABYLON {
  78697. /**
  78698. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  78699. */
  78700. export class WebRequest implements IWebRequest {
  78701. private _xhr;
  78702. /**
  78703. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  78704. * i.e. when loading files, where the server/service expects an Authorization header
  78705. */
  78706. static CustomRequestHeaders: {
  78707. [key: string]: string;
  78708. };
  78709. /**
  78710. * Add callback functions in this array to update all the requests before they get sent to the network
  78711. */
  78712. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  78713. private _injectCustomRequestHeaders;
  78714. /**
  78715. * Gets or sets a function to be called when loading progress changes
  78716. */
  78717. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  78718. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  78719. /**
  78720. * Returns client's state
  78721. */
  78722. get readyState(): number;
  78723. /**
  78724. * Returns client's status
  78725. */
  78726. get status(): number;
  78727. /**
  78728. * Returns client's status as a text
  78729. */
  78730. get statusText(): string;
  78731. /**
  78732. * Returns client's response
  78733. */
  78734. get response(): any;
  78735. /**
  78736. * Returns client's response url
  78737. */
  78738. get responseURL(): string;
  78739. /**
  78740. * Returns client's response as text
  78741. */
  78742. get responseText(): string;
  78743. /**
  78744. * Gets or sets the expected response type
  78745. */
  78746. get responseType(): XMLHttpRequestResponseType;
  78747. set responseType(value: XMLHttpRequestResponseType);
  78748. /** @hidden */
  78749. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  78750. /** @hidden */
  78751. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  78752. /**
  78753. * Cancels any network activity
  78754. */
  78755. abort(): void;
  78756. /**
  78757. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  78758. * @param body defines an optional request body
  78759. */
  78760. send(body?: Document | BodyInit | null): void;
  78761. /**
  78762. * Sets the request method, request URL
  78763. * @param method defines the method to use (GET, POST, etc..)
  78764. * @param url defines the url to connect with
  78765. */
  78766. open(method: string, url: string): void;
  78767. /**
  78768. * Sets the value of a request header.
  78769. * @param name The name of the header whose value is to be set
  78770. * @param value The value to set as the body of the header
  78771. */
  78772. setRequestHeader(name: string, value: string): void;
  78773. /**
  78774. * Get the string containing the text of a particular header's value.
  78775. * @param name The name of the header
  78776. * @returns The string containing the text of the given header name
  78777. */
  78778. getResponseHeader(name: string): Nullable<string>;
  78779. }
  78780. }
  78781. declare module BABYLON {
  78782. /**
  78783. * File request interface
  78784. */
  78785. export interface IFileRequest {
  78786. /**
  78787. * Raised when the request is complete (success or error).
  78788. */
  78789. onCompleteObservable: Observable<IFileRequest>;
  78790. /**
  78791. * Aborts the request for a file.
  78792. */
  78793. abort: () => void;
  78794. }
  78795. }
  78796. declare module BABYLON {
  78797. /**
  78798. * Define options used to create a render target texture
  78799. */
  78800. export class RenderTargetCreationOptions {
  78801. /**
  78802. * Specifies is mipmaps must be generated
  78803. */
  78804. generateMipMaps?: boolean;
  78805. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  78806. generateDepthBuffer?: boolean;
  78807. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  78808. generateStencilBuffer?: boolean;
  78809. /** Defines texture type (int by default) */
  78810. type?: number;
  78811. /** Defines sampling mode (trilinear by default) */
  78812. samplingMode?: number;
  78813. /** Defines format (RGBA by default) */
  78814. format?: number;
  78815. }
  78816. }
  78817. declare module BABYLON {
  78818. /** Defines the cross module used constants to avoid circular dependncies */
  78819. export class Constants {
  78820. /** Defines that alpha blending is disabled */
  78821. static readonly ALPHA_DISABLE: number;
  78822. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  78823. static readonly ALPHA_ADD: number;
  78824. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  78825. static readonly ALPHA_COMBINE: number;
  78826. /** Defines that alpha blending is DEST - SRC * DEST */
  78827. static readonly ALPHA_SUBTRACT: number;
  78828. /** Defines that alpha blending is SRC * DEST */
  78829. static readonly ALPHA_MULTIPLY: number;
  78830. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  78831. static readonly ALPHA_MAXIMIZED: number;
  78832. /** Defines that alpha blending is SRC + DEST */
  78833. static readonly ALPHA_ONEONE: number;
  78834. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  78835. static readonly ALPHA_PREMULTIPLIED: number;
  78836. /**
  78837. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  78838. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  78839. */
  78840. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  78841. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  78842. static readonly ALPHA_INTERPOLATE: number;
  78843. /**
  78844. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  78845. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  78846. */
  78847. static readonly ALPHA_SCREENMODE: number;
  78848. /**
  78849. * Defines that alpha blending is SRC + DST
  78850. * Alpha will be set to SRC ALPHA + DST ALPHA
  78851. */
  78852. static readonly ALPHA_ONEONE_ONEONE: number;
  78853. /**
  78854. * Defines that alpha blending is SRC * DST ALPHA + DST
  78855. * Alpha will be set to 0
  78856. */
  78857. static readonly ALPHA_ALPHATOCOLOR: number;
  78858. /**
  78859. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  78860. */
  78861. static readonly ALPHA_REVERSEONEMINUS: number;
  78862. /**
  78863. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  78864. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  78865. */
  78866. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  78867. /**
  78868. * Defines that alpha blending is SRC + DST
  78869. * Alpha will be set to SRC ALPHA
  78870. */
  78871. static readonly ALPHA_ONEONE_ONEZERO: number;
  78872. /**
  78873. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  78874. * Alpha will be set to DST ALPHA
  78875. */
  78876. static readonly ALPHA_EXCLUSION: number;
  78877. /** Defines that alpha blending equation a SUM */
  78878. static readonly ALPHA_EQUATION_ADD: number;
  78879. /** Defines that alpha blending equation a SUBSTRACTION */
  78880. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  78881. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  78882. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  78883. /** Defines that alpha blending equation a MAX operation */
  78884. static readonly ALPHA_EQUATION_MAX: number;
  78885. /** Defines that alpha blending equation a MIN operation */
  78886. static readonly ALPHA_EQUATION_MIN: number;
  78887. /**
  78888. * Defines that alpha blending equation a DARKEN operation:
  78889. * It takes the min of the src and sums the alpha channels.
  78890. */
  78891. static readonly ALPHA_EQUATION_DARKEN: number;
  78892. /** Defines that the ressource is not delayed*/
  78893. static readonly DELAYLOADSTATE_NONE: number;
  78894. /** Defines that the ressource was successfully delay loaded */
  78895. static readonly DELAYLOADSTATE_LOADED: number;
  78896. /** Defines that the ressource is currently delay loading */
  78897. static readonly DELAYLOADSTATE_LOADING: number;
  78898. /** Defines that the ressource is delayed and has not started loading */
  78899. static readonly DELAYLOADSTATE_NOTLOADED: number;
  78900. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  78901. static readonly NEVER: number;
  78902. /** 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 */
  78903. static readonly ALWAYS: number;
  78904. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  78905. static readonly LESS: number;
  78906. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  78907. static readonly EQUAL: number;
  78908. /** 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 */
  78909. static readonly LEQUAL: number;
  78910. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  78911. static readonly GREATER: number;
  78912. /** 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 */
  78913. static readonly GEQUAL: number;
  78914. /** 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 */
  78915. static readonly NOTEQUAL: number;
  78916. /** Passed to stencilOperation to specify that stencil value must be kept */
  78917. static readonly KEEP: number;
  78918. /** Passed to stencilOperation to specify that stencil value must be replaced */
  78919. static readonly REPLACE: number;
  78920. /** Passed to stencilOperation to specify that stencil value must be incremented */
  78921. static readonly INCR: number;
  78922. /** Passed to stencilOperation to specify that stencil value must be decremented */
  78923. static readonly DECR: number;
  78924. /** Passed to stencilOperation to specify that stencil value must be inverted */
  78925. static readonly INVERT: number;
  78926. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  78927. static readonly INCR_WRAP: number;
  78928. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  78929. static readonly DECR_WRAP: number;
  78930. /** Texture is not repeating outside of 0..1 UVs */
  78931. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  78932. /** Texture is repeating outside of 0..1 UVs */
  78933. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  78934. /** Texture is repeating and mirrored */
  78935. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  78936. /** ALPHA */
  78937. static readonly TEXTUREFORMAT_ALPHA: number;
  78938. /** LUMINANCE */
  78939. static readonly TEXTUREFORMAT_LUMINANCE: number;
  78940. /** LUMINANCE_ALPHA */
  78941. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  78942. /** RGB */
  78943. static readonly TEXTUREFORMAT_RGB: number;
  78944. /** RGBA */
  78945. static readonly TEXTUREFORMAT_RGBA: number;
  78946. /** RED */
  78947. static readonly TEXTUREFORMAT_RED: number;
  78948. /** RED (2nd reference) */
  78949. static readonly TEXTUREFORMAT_R: number;
  78950. /** RG */
  78951. static readonly TEXTUREFORMAT_RG: number;
  78952. /** RED_INTEGER */
  78953. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  78954. /** RED_INTEGER (2nd reference) */
  78955. static readonly TEXTUREFORMAT_R_INTEGER: number;
  78956. /** RG_INTEGER */
  78957. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  78958. /** RGB_INTEGER */
  78959. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  78960. /** RGBA_INTEGER */
  78961. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  78962. /** UNSIGNED_BYTE */
  78963. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  78964. /** UNSIGNED_BYTE (2nd reference) */
  78965. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  78966. /** FLOAT */
  78967. static readonly TEXTURETYPE_FLOAT: number;
  78968. /** HALF_FLOAT */
  78969. static readonly TEXTURETYPE_HALF_FLOAT: number;
  78970. /** BYTE */
  78971. static readonly TEXTURETYPE_BYTE: number;
  78972. /** SHORT */
  78973. static readonly TEXTURETYPE_SHORT: number;
  78974. /** UNSIGNED_SHORT */
  78975. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  78976. /** INT */
  78977. static readonly TEXTURETYPE_INT: number;
  78978. /** UNSIGNED_INT */
  78979. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  78980. /** UNSIGNED_SHORT_4_4_4_4 */
  78981. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  78982. /** UNSIGNED_SHORT_5_5_5_1 */
  78983. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  78984. /** UNSIGNED_SHORT_5_6_5 */
  78985. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  78986. /** UNSIGNED_INT_2_10_10_10_REV */
  78987. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  78988. /** UNSIGNED_INT_24_8 */
  78989. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  78990. /** UNSIGNED_INT_10F_11F_11F_REV */
  78991. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  78992. /** UNSIGNED_INT_5_9_9_9_REV */
  78993. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  78994. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  78995. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  78996. /** nearest is mag = nearest and min = nearest and no mip */
  78997. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  78998. /** mag = nearest and min = nearest and mip = none */
  78999. static readonly TEXTURE_NEAREST_NEAREST: number;
  79000. /** Bilinear is mag = linear and min = linear and no mip */
  79001. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  79002. /** mag = linear and min = linear and mip = none */
  79003. static readonly TEXTURE_LINEAR_LINEAR: number;
  79004. /** Trilinear is mag = linear and min = linear and mip = linear */
  79005. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  79006. /** Trilinear is mag = linear and min = linear and mip = linear */
  79007. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  79008. /** mag = nearest and min = nearest and mip = nearest */
  79009. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  79010. /** mag = nearest and min = linear and mip = nearest */
  79011. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  79012. /** mag = nearest and min = linear and mip = linear */
  79013. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  79014. /** mag = nearest and min = linear and mip = none */
  79015. static readonly TEXTURE_NEAREST_LINEAR: number;
  79016. /** nearest is mag = nearest and min = nearest and mip = linear */
  79017. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  79018. /** mag = linear and min = nearest and mip = nearest */
  79019. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  79020. /** mag = linear and min = nearest and mip = linear */
  79021. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  79022. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79023. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  79024. /** mag = linear and min = nearest and mip = none */
  79025. static readonly TEXTURE_LINEAR_NEAREST: number;
  79026. /** Explicit coordinates mode */
  79027. static readonly TEXTURE_EXPLICIT_MODE: number;
  79028. /** Spherical coordinates mode */
  79029. static readonly TEXTURE_SPHERICAL_MODE: number;
  79030. /** Planar coordinates mode */
  79031. static readonly TEXTURE_PLANAR_MODE: number;
  79032. /** Cubic coordinates mode */
  79033. static readonly TEXTURE_CUBIC_MODE: number;
  79034. /** Projection coordinates mode */
  79035. static readonly TEXTURE_PROJECTION_MODE: number;
  79036. /** Skybox coordinates mode */
  79037. static readonly TEXTURE_SKYBOX_MODE: number;
  79038. /** Inverse Cubic coordinates mode */
  79039. static readonly TEXTURE_INVCUBIC_MODE: number;
  79040. /** Equirectangular coordinates mode */
  79041. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  79042. /** Equirectangular Fixed coordinates mode */
  79043. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  79044. /** Equirectangular Fixed Mirrored coordinates mode */
  79045. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  79046. /** Offline (baking) quality for texture filtering */
  79047. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  79048. /** High quality for texture filtering */
  79049. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  79050. /** Medium quality for texture filtering */
  79051. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  79052. /** Low quality for texture filtering */
  79053. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  79054. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  79055. static readonly SCALEMODE_FLOOR: number;
  79056. /** Defines that texture rescaling will look for the nearest power of 2 size */
  79057. static readonly SCALEMODE_NEAREST: number;
  79058. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  79059. static readonly SCALEMODE_CEILING: number;
  79060. /**
  79061. * The dirty texture flag value
  79062. */
  79063. static readonly MATERIAL_TextureDirtyFlag: number;
  79064. /**
  79065. * The dirty light flag value
  79066. */
  79067. static readonly MATERIAL_LightDirtyFlag: number;
  79068. /**
  79069. * The dirty fresnel flag value
  79070. */
  79071. static readonly MATERIAL_FresnelDirtyFlag: number;
  79072. /**
  79073. * The dirty attribute flag value
  79074. */
  79075. static readonly MATERIAL_AttributesDirtyFlag: number;
  79076. /**
  79077. * The dirty misc flag value
  79078. */
  79079. static readonly MATERIAL_MiscDirtyFlag: number;
  79080. /**
  79081. * The all dirty flag value
  79082. */
  79083. static readonly MATERIAL_AllDirtyFlag: number;
  79084. /**
  79085. * Returns the triangle fill mode
  79086. */
  79087. static readonly MATERIAL_TriangleFillMode: number;
  79088. /**
  79089. * Returns the wireframe mode
  79090. */
  79091. static readonly MATERIAL_WireFrameFillMode: number;
  79092. /**
  79093. * Returns the point fill mode
  79094. */
  79095. static readonly MATERIAL_PointFillMode: number;
  79096. /**
  79097. * Returns the point list draw mode
  79098. */
  79099. static readonly MATERIAL_PointListDrawMode: number;
  79100. /**
  79101. * Returns the line list draw mode
  79102. */
  79103. static readonly MATERIAL_LineListDrawMode: number;
  79104. /**
  79105. * Returns the line loop draw mode
  79106. */
  79107. static readonly MATERIAL_LineLoopDrawMode: number;
  79108. /**
  79109. * Returns the line strip draw mode
  79110. */
  79111. static readonly MATERIAL_LineStripDrawMode: number;
  79112. /**
  79113. * Returns the triangle strip draw mode
  79114. */
  79115. static readonly MATERIAL_TriangleStripDrawMode: number;
  79116. /**
  79117. * Returns the triangle fan draw mode
  79118. */
  79119. static readonly MATERIAL_TriangleFanDrawMode: number;
  79120. /**
  79121. * Stores the clock-wise side orientation
  79122. */
  79123. static readonly MATERIAL_ClockWiseSideOrientation: number;
  79124. /**
  79125. * Stores the counter clock-wise side orientation
  79126. */
  79127. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  79128. /**
  79129. * Nothing
  79130. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79131. */
  79132. static readonly ACTION_NothingTrigger: number;
  79133. /**
  79134. * On pick
  79135. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79136. */
  79137. static readonly ACTION_OnPickTrigger: number;
  79138. /**
  79139. * On left pick
  79140. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79141. */
  79142. static readonly ACTION_OnLeftPickTrigger: number;
  79143. /**
  79144. * On right pick
  79145. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79146. */
  79147. static readonly ACTION_OnRightPickTrigger: number;
  79148. /**
  79149. * On center pick
  79150. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79151. */
  79152. static readonly ACTION_OnCenterPickTrigger: number;
  79153. /**
  79154. * On pick down
  79155. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79156. */
  79157. static readonly ACTION_OnPickDownTrigger: number;
  79158. /**
  79159. * On double pick
  79160. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79161. */
  79162. static readonly ACTION_OnDoublePickTrigger: number;
  79163. /**
  79164. * On pick up
  79165. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79166. */
  79167. static readonly ACTION_OnPickUpTrigger: number;
  79168. /**
  79169. * On pick out.
  79170. * This trigger will only be raised if you also declared a OnPickDown
  79171. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79172. */
  79173. static readonly ACTION_OnPickOutTrigger: number;
  79174. /**
  79175. * On long press
  79176. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79177. */
  79178. static readonly ACTION_OnLongPressTrigger: number;
  79179. /**
  79180. * On pointer over
  79181. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79182. */
  79183. static readonly ACTION_OnPointerOverTrigger: number;
  79184. /**
  79185. * On pointer out
  79186. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79187. */
  79188. static readonly ACTION_OnPointerOutTrigger: number;
  79189. /**
  79190. * On every frame
  79191. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79192. */
  79193. static readonly ACTION_OnEveryFrameTrigger: number;
  79194. /**
  79195. * On intersection enter
  79196. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79197. */
  79198. static readonly ACTION_OnIntersectionEnterTrigger: number;
  79199. /**
  79200. * On intersection exit
  79201. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79202. */
  79203. static readonly ACTION_OnIntersectionExitTrigger: number;
  79204. /**
  79205. * On key down
  79206. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79207. */
  79208. static readonly ACTION_OnKeyDownTrigger: number;
  79209. /**
  79210. * On key up
  79211. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79212. */
  79213. static readonly ACTION_OnKeyUpTrigger: number;
  79214. /**
  79215. * Billboard mode will only apply to Y axis
  79216. */
  79217. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  79218. /**
  79219. * Billboard mode will apply to all axes
  79220. */
  79221. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  79222. /**
  79223. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  79224. */
  79225. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  79226. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  79227. * Test order :
  79228. * Is the bounding sphere outside the frustum ?
  79229. * If not, are the bounding box vertices outside the frustum ?
  79230. * It not, then the cullable object is in the frustum.
  79231. */
  79232. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  79233. /** Culling strategy : Bounding Sphere Only.
  79234. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  79235. * It's also less accurate than the standard because some not visible objects can still be selected.
  79236. * Test : is the bounding sphere outside the frustum ?
  79237. * If not, then the cullable object is in the frustum.
  79238. */
  79239. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  79240. /** Culling strategy : Optimistic Inclusion.
  79241. * This in an inclusion test first, then the standard exclusion test.
  79242. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  79243. * 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.
  79244. * Anyway, it's as accurate as the standard strategy.
  79245. * Test :
  79246. * Is the cullable object bounding sphere center in the frustum ?
  79247. * If not, apply the default culling strategy.
  79248. */
  79249. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  79250. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  79251. * This in an inclusion test first, then the bounding sphere only exclusion test.
  79252. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  79253. * 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.
  79254. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  79255. * Test :
  79256. * Is the cullable object bounding sphere center in the frustum ?
  79257. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  79258. */
  79259. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  79260. /**
  79261. * No logging while loading
  79262. */
  79263. static readonly SCENELOADER_NO_LOGGING: number;
  79264. /**
  79265. * Minimal logging while loading
  79266. */
  79267. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  79268. /**
  79269. * Summary logging while loading
  79270. */
  79271. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  79272. /**
  79273. * Detailled logging while loading
  79274. */
  79275. static readonly SCENELOADER_DETAILED_LOGGING: number;
  79276. }
  79277. }
  79278. declare module BABYLON {
  79279. /**
  79280. * This represents the required contract to create a new type of texture loader.
  79281. */
  79282. export interface IInternalTextureLoader {
  79283. /**
  79284. * Defines wether the loader supports cascade loading the different faces.
  79285. */
  79286. supportCascades: boolean;
  79287. /**
  79288. * This returns if the loader support the current file information.
  79289. * @param extension defines the file extension of the file being loaded
  79290. * @param mimeType defines the optional mime type of the file being loaded
  79291. * @returns true if the loader can load the specified file
  79292. */
  79293. canLoad(extension: string, mimeType?: string): boolean;
  79294. /**
  79295. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  79296. * @param data contains the texture data
  79297. * @param texture defines the BabylonJS internal texture
  79298. * @param createPolynomials will be true if polynomials have been requested
  79299. * @param onLoad defines the callback to trigger once the texture is ready
  79300. * @param onError defines the callback to trigger in case of error
  79301. */
  79302. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  79303. /**
  79304. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  79305. * @param data contains the texture data
  79306. * @param texture defines the BabylonJS internal texture
  79307. * @param callback defines the method to call once ready to upload
  79308. */
  79309. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  79310. }
  79311. }
  79312. declare module BABYLON {
  79313. /**
  79314. * Class used to store and describe the pipeline context associated with an effect
  79315. */
  79316. export interface IPipelineContext {
  79317. /**
  79318. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  79319. */
  79320. isAsync: boolean;
  79321. /**
  79322. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  79323. */
  79324. isReady: boolean;
  79325. /** @hidden */
  79326. _getVertexShaderCode(): string | null;
  79327. /** @hidden */
  79328. _getFragmentShaderCode(): string | null;
  79329. /** @hidden */
  79330. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  79331. }
  79332. }
  79333. declare module BABYLON {
  79334. /**
  79335. * Class used to store gfx data (like WebGLBuffer)
  79336. */
  79337. export class DataBuffer {
  79338. /**
  79339. * Gets or sets the number of objects referencing this buffer
  79340. */
  79341. references: number;
  79342. /** Gets or sets the size of the underlying buffer */
  79343. capacity: number;
  79344. /**
  79345. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  79346. */
  79347. is32Bits: boolean;
  79348. /**
  79349. * Gets the underlying buffer
  79350. */
  79351. get underlyingResource(): any;
  79352. }
  79353. }
  79354. declare module BABYLON {
  79355. /** @hidden */
  79356. export interface IShaderProcessor {
  79357. attributeProcessor?: (attribute: string) => string;
  79358. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  79359. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  79360. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  79361. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  79362. lineProcessor?: (line: string, isFragment: boolean) => string;
  79363. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  79364. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  79365. }
  79366. }
  79367. declare module BABYLON {
  79368. /** @hidden */
  79369. export interface ProcessingOptions {
  79370. defines: string[];
  79371. indexParameters: any;
  79372. isFragment: boolean;
  79373. shouldUseHighPrecisionShader: boolean;
  79374. supportsUniformBuffers: boolean;
  79375. shadersRepository: string;
  79376. includesShadersStore: {
  79377. [key: string]: string;
  79378. };
  79379. processor?: IShaderProcessor;
  79380. version: string;
  79381. platformName: string;
  79382. lookForClosingBracketForUniformBuffer?: boolean;
  79383. }
  79384. }
  79385. declare module BABYLON {
  79386. /** @hidden */
  79387. export class ShaderCodeNode {
  79388. line: string;
  79389. children: ShaderCodeNode[];
  79390. additionalDefineKey?: string;
  79391. additionalDefineValue?: string;
  79392. isValid(preprocessors: {
  79393. [key: string]: string;
  79394. }): boolean;
  79395. process(preprocessors: {
  79396. [key: string]: string;
  79397. }, options: ProcessingOptions): string;
  79398. }
  79399. }
  79400. declare module BABYLON {
  79401. /** @hidden */
  79402. export class ShaderCodeCursor {
  79403. private _lines;
  79404. lineIndex: number;
  79405. get currentLine(): string;
  79406. get canRead(): boolean;
  79407. set lines(value: string[]);
  79408. }
  79409. }
  79410. declare module BABYLON {
  79411. /** @hidden */
  79412. export class ShaderCodeConditionNode extends ShaderCodeNode {
  79413. process(preprocessors: {
  79414. [key: string]: string;
  79415. }, options: ProcessingOptions): string;
  79416. }
  79417. }
  79418. declare module BABYLON {
  79419. /** @hidden */
  79420. export class ShaderDefineExpression {
  79421. isTrue(preprocessors: {
  79422. [key: string]: string;
  79423. }): boolean;
  79424. private static _OperatorPriority;
  79425. private static _Stack;
  79426. static postfixToInfix(postfix: string[]): string;
  79427. static infixToPostfix(infix: string): string[];
  79428. }
  79429. }
  79430. declare module BABYLON {
  79431. /** @hidden */
  79432. export class ShaderCodeTestNode extends ShaderCodeNode {
  79433. testExpression: ShaderDefineExpression;
  79434. isValid(preprocessors: {
  79435. [key: string]: string;
  79436. }): boolean;
  79437. }
  79438. }
  79439. declare module BABYLON {
  79440. /** @hidden */
  79441. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  79442. define: string;
  79443. not: boolean;
  79444. constructor(define: string, not?: boolean);
  79445. isTrue(preprocessors: {
  79446. [key: string]: string;
  79447. }): boolean;
  79448. }
  79449. }
  79450. declare module BABYLON {
  79451. /** @hidden */
  79452. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  79453. leftOperand: ShaderDefineExpression;
  79454. rightOperand: ShaderDefineExpression;
  79455. isTrue(preprocessors: {
  79456. [key: string]: string;
  79457. }): boolean;
  79458. }
  79459. }
  79460. declare module BABYLON {
  79461. /** @hidden */
  79462. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  79463. leftOperand: ShaderDefineExpression;
  79464. rightOperand: ShaderDefineExpression;
  79465. isTrue(preprocessors: {
  79466. [key: string]: string;
  79467. }): boolean;
  79468. }
  79469. }
  79470. declare module BABYLON {
  79471. /** @hidden */
  79472. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  79473. define: string;
  79474. operand: string;
  79475. testValue: string;
  79476. constructor(define: string, operand: string, testValue: string);
  79477. isTrue(preprocessors: {
  79478. [key: string]: string;
  79479. }): boolean;
  79480. }
  79481. }
  79482. declare module BABYLON {
  79483. /**
  79484. * Class used to enable access to offline support
  79485. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  79486. */
  79487. export interface IOfflineProvider {
  79488. /**
  79489. * Gets a boolean indicating if scene must be saved in the database
  79490. */
  79491. enableSceneOffline: boolean;
  79492. /**
  79493. * Gets a boolean indicating if textures must be saved in the database
  79494. */
  79495. enableTexturesOffline: boolean;
  79496. /**
  79497. * Open the offline support and make it available
  79498. * @param successCallback defines the callback to call on success
  79499. * @param errorCallback defines the callback to call on error
  79500. */
  79501. open(successCallback: () => void, errorCallback: () => void): void;
  79502. /**
  79503. * Loads an image from the offline support
  79504. * @param url defines the url to load from
  79505. * @param image defines the target DOM image
  79506. */
  79507. loadImage(url: string, image: HTMLImageElement): void;
  79508. /**
  79509. * Loads a file from offline support
  79510. * @param url defines the URL to load from
  79511. * @param sceneLoaded defines a callback to call on success
  79512. * @param progressCallBack defines a callback to call when progress changed
  79513. * @param errorCallback defines a callback to call on error
  79514. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  79515. */
  79516. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  79517. }
  79518. }
  79519. declare module BABYLON {
  79520. /**
  79521. * Class used to help managing file picking and drag'n'drop
  79522. * File Storage
  79523. */
  79524. export class FilesInputStore {
  79525. /**
  79526. * List of files ready to be loaded
  79527. */
  79528. static FilesToLoad: {
  79529. [key: string]: File;
  79530. };
  79531. }
  79532. }
  79533. declare module BABYLON {
  79534. /**
  79535. * Class used to define a retry strategy when error happens while loading assets
  79536. */
  79537. export class RetryStrategy {
  79538. /**
  79539. * Function used to defines an exponential back off strategy
  79540. * @param maxRetries defines the maximum number of retries (3 by default)
  79541. * @param baseInterval defines the interval between retries
  79542. * @returns the strategy function to use
  79543. */
  79544. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  79545. }
  79546. }
  79547. declare module BABYLON {
  79548. /**
  79549. * @ignore
  79550. * Application error to support additional information when loading a file
  79551. */
  79552. export abstract class BaseError extends Error {
  79553. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  79554. }
  79555. }
  79556. declare module BABYLON {
  79557. /** @ignore */
  79558. export class LoadFileError extends BaseError {
  79559. request?: WebRequest;
  79560. file?: File;
  79561. /**
  79562. * Creates a new LoadFileError
  79563. * @param message defines the message of the error
  79564. * @param request defines the optional web request
  79565. * @param file defines the optional file
  79566. */
  79567. constructor(message: string, object?: WebRequest | File);
  79568. }
  79569. /** @ignore */
  79570. export class RequestFileError extends BaseError {
  79571. request: WebRequest;
  79572. /**
  79573. * Creates a new LoadFileError
  79574. * @param message defines the message of the error
  79575. * @param request defines the optional web request
  79576. */
  79577. constructor(message: string, request: WebRequest);
  79578. }
  79579. /** @ignore */
  79580. export class ReadFileError extends BaseError {
  79581. file: File;
  79582. /**
  79583. * Creates a new ReadFileError
  79584. * @param message defines the message of the error
  79585. * @param file defines the optional file
  79586. */
  79587. constructor(message: string, file: File);
  79588. }
  79589. /**
  79590. * @hidden
  79591. */
  79592. export class FileTools {
  79593. /**
  79594. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  79595. */
  79596. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  79597. /**
  79598. * Gets or sets the base URL to use to load assets
  79599. */
  79600. static BaseUrl: string;
  79601. /**
  79602. * Default behaviour for cors in the application.
  79603. * It can be a string if the expected behavior is identical in the entire app.
  79604. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  79605. */
  79606. static CorsBehavior: string | ((url: string | string[]) => string);
  79607. /**
  79608. * Gets or sets a function used to pre-process url before using them to load assets
  79609. */
  79610. static PreprocessUrl: (url: string) => string;
  79611. /**
  79612. * Removes unwanted characters from an url
  79613. * @param url defines the url to clean
  79614. * @returns the cleaned url
  79615. */
  79616. private static _CleanUrl;
  79617. /**
  79618. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  79619. * @param url define the url we are trying
  79620. * @param element define the dom element where to configure the cors policy
  79621. */
  79622. static SetCorsBehavior(url: string | string[], element: {
  79623. crossOrigin: string | null;
  79624. }): void;
  79625. /**
  79626. * Loads an image as an HTMLImageElement.
  79627. * @param input url string, ArrayBuffer, or Blob to load
  79628. * @param onLoad callback called when the image successfully loads
  79629. * @param onError callback called when the image fails to load
  79630. * @param offlineProvider offline provider for caching
  79631. * @param mimeType optional mime type
  79632. * @returns the HTMLImageElement of the loaded image
  79633. */
  79634. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  79635. /**
  79636. * Reads a file from a File object
  79637. * @param file defines the file to load
  79638. * @param onSuccess defines the callback to call when data is loaded
  79639. * @param onProgress defines the callback to call during loading process
  79640. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  79641. * @param onError defines the callback to call when an error occurs
  79642. * @returns a file request object
  79643. */
  79644. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  79645. /**
  79646. * Loads a file from a url
  79647. * @param url url to load
  79648. * @param onSuccess callback called when the file successfully loads
  79649. * @param onProgress callback called while file is loading (if the server supports this mode)
  79650. * @param offlineProvider defines the offline provider for caching
  79651. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79652. * @param onError callback called when the file fails to load
  79653. * @returns a file request object
  79654. */
  79655. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  79656. /**
  79657. * Loads a file
  79658. * @param url url to load
  79659. * @param onSuccess callback called when the file successfully loads
  79660. * @param onProgress callback called while file is loading (if the server supports this mode)
  79661. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79662. * @param onError callback called when the file fails to load
  79663. * @param onOpened callback called when the web request is opened
  79664. * @returns a file request object
  79665. */
  79666. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  79667. /**
  79668. * Checks if the loaded document was accessed via `file:`-Protocol.
  79669. * @returns boolean
  79670. */
  79671. static IsFileURL(): boolean;
  79672. }
  79673. }
  79674. declare module BABYLON {
  79675. /** @hidden */
  79676. export class ShaderProcessor {
  79677. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  79678. private static _ProcessPrecision;
  79679. private static _ExtractOperation;
  79680. private static _BuildSubExpression;
  79681. private static _BuildExpression;
  79682. private static _MoveCursorWithinIf;
  79683. private static _MoveCursor;
  79684. private static _EvaluatePreProcessors;
  79685. private static _PreparePreProcessors;
  79686. private static _ProcessShaderConversion;
  79687. private static _ProcessIncludes;
  79688. /**
  79689. * Loads a file from a url
  79690. * @param url url to load
  79691. * @param onSuccess callback called when the file successfully loads
  79692. * @param onProgress callback called while file is loading (if the server supports this mode)
  79693. * @param offlineProvider defines the offline provider for caching
  79694. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79695. * @param onError callback called when the file fails to load
  79696. * @returns a file request object
  79697. * @hidden
  79698. */
  79699. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  79700. }
  79701. }
  79702. declare module BABYLON {
  79703. /**
  79704. * @hidden
  79705. */
  79706. export interface IColor4Like {
  79707. r: float;
  79708. g: float;
  79709. b: float;
  79710. a: float;
  79711. }
  79712. /**
  79713. * @hidden
  79714. */
  79715. export interface IColor3Like {
  79716. r: float;
  79717. g: float;
  79718. b: float;
  79719. }
  79720. /**
  79721. * @hidden
  79722. */
  79723. export interface IVector4Like {
  79724. x: float;
  79725. y: float;
  79726. z: float;
  79727. w: float;
  79728. }
  79729. /**
  79730. * @hidden
  79731. */
  79732. export interface IVector3Like {
  79733. x: float;
  79734. y: float;
  79735. z: float;
  79736. }
  79737. /**
  79738. * @hidden
  79739. */
  79740. export interface IVector2Like {
  79741. x: float;
  79742. y: float;
  79743. }
  79744. /**
  79745. * @hidden
  79746. */
  79747. export interface IMatrixLike {
  79748. toArray(): DeepImmutable<Float32Array>;
  79749. updateFlag: int;
  79750. }
  79751. /**
  79752. * @hidden
  79753. */
  79754. export interface IViewportLike {
  79755. x: float;
  79756. y: float;
  79757. width: float;
  79758. height: float;
  79759. }
  79760. /**
  79761. * @hidden
  79762. */
  79763. export interface IPlaneLike {
  79764. normal: IVector3Like;
  79765. d: float;
  79766. normalize(): void;
  79767. }
  79768. }
  79769. declare module BABYLON {
  79770. /**
  79771. * Interface used to define common properties for effect fallbacks
  79772. */
  79773. export interface IEffectFallbacks {
  79774. /**
  79775. * Removes the defines that should be removed when falling back.
  79776. * @param currentDefines defines the current define statements for the shader.
  79777. * @param effect defines the current effect we try to compile
  79778. * @returns The resulting defines with defines of the current rank removed.
  79779. */
  79780. reduce(currentDefines: string, effect: Effect): string;
  79781. /**
  79782. * Removes the fallback from the bound mesh.
  79783. */
  79784. unBindMesh(): void;
  79785. /**
  79786. * Checks to see if more fallbacks are still availible.
  79787. */
  79788. hasMoreFallbacks: boolean;
  79789. }
  79790. }
  79791. declare module BABYLON {
  79792. /**
  79793. * Class used to evalaute queries containing `and` and `or` operators
  79794. */
  79795. export class AndOrNotEvaluator {
  79796. /**
  79797. * Evaluate a query
  79798. * @param query defines the query to evaluate
  79799. * @param evaluateCallback defines the callback used to filter result
  79800. * @returns true if the query matches
  79801. */
  79802. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  79803. private static _HandleParenthesisContent;
  79804. private static _SimplifyNegation;
  79805. }
  79806. }
  79807. declare module BABYLON {
  79808. /**
  79809. * Class used to store custom tags
  79810. */
  79811. export class Tags {
  79812. /**
  79813. * Adds support for tags on the given object
  79814. * @param obj defines the object to use
  79815. */
  79816. static EnableFor(obj: any): void;
  79817. /**
  79818. * Removes tags support
  79819. * @param obj defines the object to use
  79820. */
  79821. static DisableFor(obj: any): void;
  79822. /**
  79823. * Gets a boolean indicating if the given object has tags
  79824. * @param obj defines the object to use
  79825. * @returns a boolean
  79826. */
  79827. static HasTags(obj: any): boolean;
  79828. /**
  79829. * Gets the tags available on a given object
  79830. * @param obj defines the object to use
  79831. * @param asString defines if the tags must be returned as a string instead of an array of strings
  79832. * @returns the tags
  79833. */
  79834. static GetTags(obj: any, asString?: boolean): any;
  79835. /**
  79836. * Adds tags to an object
  79837. * @param obj defines the object to use
  79838. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  79839. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  79840. */
  79841. static AddTagsTo(obj: any, tagsString: string): void;
  79842. /**
  79843. * @hidden
  79844. */
  79845. static _AddTagTo(obj: any, tag: string): void;
  79846. /**
  79847. * Removes specific tags from a specific object
  79848. * @param obj defines the object to use
  79849. * @param tagsString defines the tags to remove
  79850. */
  79851. static RemoveTagsFrom(obj: any, tagsString: string): void;
  79852. /**
  79853. * @hidden
  79854. */
  79855. static _RemoveTagFrom(obj: any, tag: string): void;
  79856. /**
  79857. * Defines if tags hosted on an object match a given query
  79858. * @param obj defines the object to use
  79859. * @param tagsQuery defines the tag query
  79860. * @returns a boolean
  79861. */
  79862. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  79863. }
  79864. }
  79865. declare module BABYLON {
  79866. /**
  79867. * Scalar computation library
  79868. */
  79869. export class Scalar {
  79870. /**
  79871. * Two pi constants convenient for computation.
  79872. */
  79873. static TwoPi: number;
  79874. /**
  79875. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  79876. * @param a number
  79877. * @param b number
  79878. * @param epsilon (default = 1.401298E-45)
  79879. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  79880. */
  79881. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  79882. /**
  79883. * Returns a string : the upper case translation of the number i to hexadecimal.
  79884. * @param i number
  79885. * @returns the upper case translation of the number i to hexadecimal.
  79886. */
  79887. static ToHex(i: number): string;
  79888. /**
  79889. * Returns -1 if value is negative and +1 is value is positive.
  79890. * @param value the value
  79891. * @returns the value itself if it's equal to zero.
  79892. */
  79893. static Sign(value: number): number;
  79894. /**
  79895. * Returns the value itself if it's between min and max.
  79896. * Returns min if the value is lower than min.
  79897. * Returns max if the value is greater than max.
  79898. * @param value the value to clmap
  79899. * @param min the min value to clamp to (default: 0)
  79900. * @param max the max value to clamp to (default: 1)
  79901. * @returns the clamped value
  79902. */
  79903. static Clamp(value: number, min?: number, max?: number): number;
  79904. /**
  79905. * the log2 of value.
  79906. * @param value the value to compute log2 of
  79907. * @returns the log2 of value.
  79908. */
  79909. static Log2(value: number): number;
  79910. /**
  79911. * Loops the value, so that it is never larger than length and never smaller than 0.
  79912. *
  79913. * This is similar to the modulo operator but it works with floating point numbers.
  79914. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  79915. * With t = 5 and length = 2.5, the result would be 0.0.
  79916. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  79917. * @param value the value
  79918. * @param length the length
  79919. * @returns the looped value
  79920. */
  79921. static Repeat(value: number, length: number): number;
  79922. /**
  79923. * Normalize the value between 0.0 and 1.0 using min and max values
  79924. * @param value value to normalize
  79925. * @param min max to normalize between
  79926. * @param max min to normalize between
  79927. * @returns the normalized value
  79928. */
  79929. static Normalize(value: number, min: number, max: number): number;
  79930. /**
  79931. * Denormalize the value from 0.0 and 1.0 using min and max values
  79932. * @param normalized value to denormalize
  79933. * @param min max to denormalize between
  79934. * @param max min to denormalize between
  79935. * @returns the denormalized value
  79936. */
  79937. static Denormalize(normalized: number, min: number, max: number): number;
  79938. /**
  79939. * Calculates the shortest difference between two given angles given in degrees.
  79940. * @param current current angle in degrees
  79941. * @param target target angle in degrees
  79942. * @returns the delta
  79943. */
  79944. static DeltaAngle(current: number, target: number): number;
  79945. /**
  79946. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  79947. * @param tx value
  79948. * @param length length
  79949. * @returns The returned value will move back and forth between 0 and length
  79950. */
  79951. static PingPong(tx: number, length: number): number;
  79952. /**
  79953. * Interpolates between min and max with smoothing at the limits.
  79954. *
  79955. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  79956. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  79957. * @param from from
  79958. * @param to to
  79959. * @param tx value
  79960. * @returns the smooth stepped value
  79961. */
  79962. static SmoothStep(from: number, to: number, tx: number): number;
  79963. /**
  79964. * Moves a value current towards target.
  79965. *
  79966. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  79967. * Negative values of maxDelta pushes the value away from target.
  79968. * @param current current value
  79969. * @param target target value
  79970. * @param maxDelta max distance to move
  79971. * @returns resulting value
  79972. */
  79973. static MoveTowards(current: number, target: number, maxDelta: number): number;
  79974. /**
  79975. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  79976. *
  79977. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  79978. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  79979. * @param current current value
  79980. * @param target target value
  79981. * @param maxDelta max distance to move
  79982. * @returns resulting angle
  79983. */
  79984. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  79985. /**
  79986. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  79987. * @param start start value
  79988. * @param end target value
  79989. * @param amount amount to lerp between
  79990. * @returns the lerped value
  79991. */
  79992. static Lerp(start: number, end: number, amount: number): number;
  79993. /**
  79994. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  79995. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  79996. * @param start start value
  79997. * @param end target value
  79998. * @param amount amount to lerp between
  79999. * @returns the lerped value
  80000. */
  80001. static LerpAngle(start: number, end: number, amount: number): number;
  80002. /**
  80003. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  80004. * @param a start value
  80005. * @param b target value
  80006. * @param value value between a and b
  80007. * @returns the inverseLerp value
  80008. */
  80009. static InverseLerp(a: number, b: number, value: number): number;
  80010. /**
  80011. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  80012. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  80013. * @param value1 spline value
  80014. * @param tangent1 spline value
  80015. * @param value2 spline value
  80016. * @param tangent2 spline value
  80017. * @param amount input value
  80018. * @returns hermite result
  80019. */
  80020. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  80021. /**
  80022. * Returns a random float number between and min and max values
  80023. * @param min min value of random
  80024. * @param max max value of random
  80025. * @returns random value
  80026. */
  80027. static RandomRange(min: number, max: number): number;
  80028. /**
  80029. * This function returns percentage of a number in a given range.
  80030. *
  80031. * RangeToPercent(40,20,60) will return 0.5 (50%)
  80032. * RangeToPercent(34,0,100) will return 0.34 (34%)
  80033. * @param number to convert to percentage
  80034. * @param min min range
  80035. * @param max max range
  80036. * @returns the percentage
  80037. */
  80038. static RangeToPercent(number: number, min: number, max: number): number;
  80039. /**
  80040. * This function returns number that corresponds to the percentage in a given range.
  80041. *
  80042. * PercentToRange(0.34,0,100) will return 34.
  80043. * @param percent to convert to number
  80044. * @param min min range
  80045. * @param max max range
  80046. * @returns the number
  80047. */
  80048. static PercentToRange(percent: number, min: number, max: number): number;
  80049. /**
  80050. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  80051. * @param angle The angle to normalize in radian.
  80052. * @return The converted angle.
  80053. */
  80054. static NormalizeRadians(angle: number): number;
  80055. }
  80056. }
  80057. declare module BABYLON {
  80058. /**
  80059. * Constant used to convert a value to gamma space
  80060. * @ignorenaming
  80061. */
  80062. export const ToGammaSpace: number;
  80063. /**
  80064. * Constant used to convert a value to linear space
  80065. * @ignorenaming
  80066. */
  80067. export const ToLinearSpace = 2.2;
  80068. /**
  80069. * Constant used to define the minimal number value in Babylon.js
  80070. * @ignorenaming
  80071. */
  80072. let Epsilon: number;
  80073. }
  80074. declare module BABYLON {
  80075. /**
  80076. * Class used to represent a viewport on screen
  80077. */
  80078. export class Viewport {
  80079. /** viewport left coordinate */
  80080. x: number;
  80081. /** viewport top coordinate */
  80082. y: number;
  80083. /**viewport width */
  80084. width: number;
  80085. /** viewport height */
  80086. height: number;
  80087. /**
  80088. * Creates a Viewport object located at (x, y) and sized (width, height)
  80089. * @param x defines viewport left coordinate
  80090. * @param y defines viewport top coordinate
  80091. * @param width defines the viewport width
  80092. * @param height defines the viewport height
  80093. */
  80094. constructor(
  80095. /** viewport left coordinate */
  80096. x: number,
  80097. /** viewport top coordinate */
  80098. y: number,
  80099. /**viewport width */
  80100. width: number,
  80101. /** viewport height */
  80102. height: number);
  80103. /**
  80104. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  80105. * @param renderWidth defines the rendering width
  80106. * @param renderHeight defines the rendering height
  80107. * @returns a new Viewport
  80108. */
  80109. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  80110. /**
  80111. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  80112. * @param renderWidth defines the rendering width
  80113. * @param renderHeight defines the rendering height
  80114. * @param ref defines the target viewport
  80115. * @returns the current viewport
  80116. */
  80117. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  80118. /**
  80119. * Returns a new Viewport copied from the current one
  80120. * @returns a new Viewport
  80121. */
  80122. clone(): Viewport;
  80123. }
  80124. }
  80125. declare module BABYLON {
  80126. /**
  80127. * Class containing a set of static utilities functions for arrays.
  80128. */
  80129. export class ArrayTools {
  80130. /**
  80131. * Returns an array of the given size filled with element built from the given constructor and the paramters
  80132. * @param size the number of element to construct and put in the array
  80133. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  80134. * @returns a new array filled with new objects
  80135. */
  80136. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  80137. }
  80138. }
  80139. declare module BABYLON {
  80140. /**
  80141. * Represents a plane by the equation ax + by + cz + d = 0
  80142. */
  80143. export class Plane {
  80144. private static _TmpMatrix;
  80145. /**
  80146. * Normal of the plane (a,b,c)
  80147. */
  80148. normal: Vector3;
  80149. /**
  80150. * d component of the plane
  80151. */
  80152. d: number;
  80153. /**
  80154. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  80155. * @param a a component of the plane
  80156. * @param b b component of the plane
  80157. * @param c c component of the plane
  80158. * @param d d component of the plane
  80159. */
  80160. constructor(a: number, b: number, c: number, d: number);
  80161. /**
  80162. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  80163. */
  80164. asArray(): number[];
  80165. /**
  80166. * @returns a new plane copied from the current Plane.
  80167. */
  80168. clone(): Plane;
  80169. /**
  80170. * @returns the string "Plane".
  80171. */
  80172. getClassName(): string;
  80173. /**
  80174. * @returns the Plane hash code.
  80175. */
  80176. getHashCode(): number;
  80177. /**
  80178. * Normalize the current Plane in place.
  80179. * @returns the updated Plane.
  80180. */
  80181. normalize(): Plane;
  80182. /**
  80183. * Applies a transformation the plane and returns the result
  80184. * @param transformation the transformation matrix to be applied to the plane
  80185. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  80186. */
  80187. transform(transformation: DeepImmutable<Matrix>): Plane;
  80188. /**
  80189. * Compute the dot product between the point and the plane normal
  80190. * @param point point to calculate the dot product with
  80191. * @returns the dot product (float) of the point coordinates and the plane normal.
  80192. */
  80193. dotCoordinate(point: DeepImmutable<Vector3>): number;
  80194. /**
  80195. * Updates the current Plane from the plane defined by the three given points.
  80196. * @param point1 one of the points used to contruct the plane
  80197. * @param point2 one of the points used to contruct the plane
  80198. * @param point3 one of the points used to contruct the plane
  80199. * @returns the updated Plane.
  80200. */
  80201. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80202. /**
  80203. * Checks if the plane is facing a given direction
  80204. * @param direction the direction to check if the plane is facing
  80205. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  80206. * @returns True is the vector "direction" is the same side than the plane normal.
  80207. */
  80208. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  80209. /**
  80210. * Calculates the distance to a point
  80211. * @param point point to calculate distance to
  80212. * @returns the signed distance (float) from the given point to the Plane.
  80213. */
  80214. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  80215. /**
  80216. * Creates a plane from an array
  80217. * @param array the array to create a plane from
  80218. * @returns a new Plane from the given array.
  80219. */
  80220. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  80221. /**
  80222. * Creates a plane from three points
  80223. * @param point1 point used to create the plane
  80224. * @param point2 point used to create the plane
  80225. * @param point3 point used to create the plane
  80226. * @returns a new Plane defined by the three given points.
  80227. */
  80228. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80229. /**
  80230. * Creates a plane from an origin point and a normal
  80231. * @param origin origin of the plane to be constructed
  80232. * @param normal normal of the plane to be constructed
  80233. * @returns a new Plane the normal vector to this plane at the given origin point.
  80234. * Note : the vector "normal" is updated because normalized.
  80235. */
  80236. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  80237. /**
  80238. * Calculates the distance from a plane and a point
  80239. * @param origin origin of the plane to be constructed
  80240. * @param normal normal of the plane to be constructed
  80241. * @param point point to calculate distance to
  80242. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  80243. */
  80244. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  80245. }
  80246. }
  80247. declare module BABYLON {
  80248. /**
  80249. * Class representing a vector containing 2 coordinates
  80250. */
  80251. export class Vector2 {
  80252. /** defines the first coordinate */
  80253. x: number;
  80254. /** defines the second coordinate */
  80255. y: number;
  80256. /**
  80257. * Creates a new Vector2 from the given x and y coordinates
  80258. * @param x defines the first coordinate
  80259. * @param y defines the second coordinate
  80260. */
  80261. constructor(
  80262. /** defines the first coordinate */
  80263. x?: number,
  80264. /** defines the second coordinate */
  80265. y?: number);
  80266. /**
  80267. * Gets a string with the Vector2 coordinates
  80268. * @returns a string with the Vector2 coordinates
  80269. */
  80270. toString(): string;
  80271. /**
  80272. * Gets class name
  80273. * @returns the string "Vector2"
  80274. */
  80275. getClassName(): string;
  80276. /**
  80277. * Gets current vector hash code
  80278. * @returns the Vector2 hash code as a number
  80279. */
  80280. getHashCode(): number;
  80281. /**
  80282. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  80283. * @param array defines the source array
  80284. * @param index defines the offset in source array
  80285. * @returns the current Vector2
  80286. */
  80287. toArray(array: FloatArray, index?: number): Vector2;
  80288. /**
  80289. * Copy the current vector to an array
  80290. * @returns a new array with 2 elements: the Vector2 coordinates.
  80291. */
  80292. asArray(): number[];
  80293. /**
  80294. * Sets the Vector2 coordinates with the given Vector2 coordinates
  80295. * @param source defines the source Vector2
  80296. * @returns the current updated Vector2
  80297. */
  80298. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  80299. /**
  80300. * Sets the Vector2 coordinates with the given floats
  80301. * @param x defines the first coordinate
  80302. * @param y defines the second coordinate
  80303. * @returns the current updated Vector2
  80304. */
  80305. copyFromFloats(x: number, y: number): Vector2;
  80306. /**
  80307. * Sets the Vector2 coordinates with the given floats
  80308. * @param x defines the first coordinate
  80309. * @param y defines the second coordinate
  80310. * @returns the current updated Vector2
  80311. */
  80312. set(x: number, y: number): Vector2;
  80313. /**
  80314. * Add another vector with the current one
  80315. * @param otherVector defines the other vector
  80316. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  80317. */
  80318. add(otherVector: DeepImmutable<Vector2>): Vector2;
  80319. /**
  80320. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  80321. * @param otherVector defines the other vector
  80322. * @param result defines the target vector
  80323. * @returns the unmodified current Vector2
  80324. */
  80325. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80326. /**
  80327. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  80328. * @param otherVector defines the other vector
  80329. * @returns the current updated Vector2
  80330. */
  80331. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80332. /**
  80333. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  80334. * @param otherVector defines the other vector
  80335. * @returns a new Vector2
  80336. */
  80337. addVector3(otherVector: Vector3): Vector2;
  80338. /**
  80339. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  80340. * @param otherVector defines the other vector
  80341. * @returns a new Vector2
  80342. */
  80343. subtract(otherVector: Vector2): Vector2;
  80344. /**
  80345. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  80346. * @param otherVector defines the other vector
  80347. * @param result defines the target vector
  80348. * @returns the unmodified current Vector2
  80349. */
  80350. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80351. /**
  80352. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  80353. * @param otherVector defines the other vector
  80354. * @returns the current updated Vector2
  80355. */
  80356. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80357. /**
  80358. * Multiplies in place the current Vector2 coordinates by the given ones
  80359. * @param otherVector defines the other vector
  80360. * @returns the current updated Vector2
  80361. */
  80362. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80363. /**
  80364. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  80365. * @param otherVector defines the other vector
  80366. * @returns a new Vector2
  80367. */
  80368. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  80369. /**
  80370. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  80371. * @param otherVector defines the other vector
  80372. * @param result defines the target vector
  80373. * @returns the unmodified current Vector2
  80374. */
  80375. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80376. /**
  80377. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  80378. * @param x defines the first coordinate
  80379. * @param y defines the second coordinate
  80380. * @returns a new Vector2
  80381. */
  80382. multiplyByFloats(x: number, y: number): Vector2;
  80383. /**
  80384. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  80385. * @param otherVector defines the other vector
  80386. * @returns a new Vector2
  80387. */
  80388. divide(otherVector: Vector2): Vector2;
  80389. /**
  80390. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  80391. * @param otherVector defines the other vector
  80392. * @param result defines the target vector
  80393. * @returns the unmodified current Vector2
  80394. */
  80395. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80396. /**
  80397. * Divides the current Vector2 coordinates by the given ones
  80398. * @param otherVector defines the other vector
  80399. * @returns the current updated Vector2
  80400. */
  80401. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80402. /**
  80403. * Gets a new Vector2 with current Vector2 negated coordinates
  80404. * @returns a new Vector2
  80405. */
  80406. negate(): Vector2;
  80407. /**
  80408. * Negate this vector in place
  80409. * @returns this
  80410. */
  80411. negateInPlace(): Vector2;
  80412. /**
  80413. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  80414. * @param result defines the Vector3 object where to store the result
  80415. * @returns the current Vector2
  80416. */
  80417. negateToRef(result: Vector2): Vector2;
  80418. /**
  80419. * Multiply the Vector2 coordinates by scale
  80420. * @param scale defines the scaling factor
  80421. * @returns the current updated Vector2
  80422. */
  80423. scaleInPlace(scale: number): Vector2;
  80424. /**
  80425. * Returns a new Vector2 scaled by "scale" from the current Vector2
  80426. * @param scale defines the scaling factor
  80427. * @returns a new Vector2
  80428. */
  80429. scale(scale: number): Vector2;
  80430. /**
  80431. * Scale the current Vector2 values by a factor to a given Vector2
  80432. * @param scale defines the scale factor
  80433. * @param result defines the Vector2 object where to store the result
  80434. * @returns the unmodified current Vector2
  80435. */
  80436. scaleToRef(scale: number, result: Vector2): Vector2;
  80437. /**
  80438. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  80439. * @param scale defines the scale factor
  80440. * @param result defines the Vector2 object where to store the result
  80441. * @returns the unmodified current Vector2
  80442. */
  80443. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  80444. /**
  80445. * Gets a boolean if two vectors are equals
  80446. * @param otherVector defines the other vector
  80447. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  80448. */
  80449. equals(otherVector: DeepImmutable<Vector2>): boolean;
  80450. /**
  80451. * Gets a boolean if two vectors are equals (using an epsilon value)
  80452. * @param otherVector defines the other vector
  80453. * @param epsilon defines the minimal distance to consider equality
  80454. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  80455. */
  80456. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  80457. /**
  80458. * Gets a new Vector2 from current Vector2 floored values
  80459. * @returns a new Vector2
  80460. */
  80461. floor(): Vector2;
  80462. /**
  80463. * Gets a new Vector2 from current Vector2 floored values
  80464. * @returns a new Vector2
  80465. */
  80466. fract(): Vector2;
  80467. /**
  80468. * Gets the length of the vector
  80469. * @returns the vector length (float)
  80470. */
  80471. length(): number;
  80472. /**
  80473. * Gets the vector squared length
  80474. * @returns the vector squared length (float)
  80475. */
  80476. lengthSquared(): number;
  80477. /**
  80478. * Normalize the vector
  80479. * @returns the current updated Vector2
  80480. */
  80481. normalize(): Vector2;
  80482. /**
  80483. * Gets a new Vector2 copied from the Vector2
  80484. * @returns a new Vector2
  80485. */
  80486. clone(): Vector2;
  80487. /**
  80488. * Gets a new Vector2(0, 0)
  80489. * @returns a new Vector2
  80490. */
  80491. static Zero(): Vector2;
  80492. /**
  80493. * Gets a new Vector2(1, 1)
  80494. * @returns a new Vector2
  80495. */
  80496. static One(): Vector2;
  80497. /**
  80498. * Gets a new Vector2 set from the given index element of the given array
  80499. * @param array defines the data source
  80500. * @param offset defines the offset in the data source
  80501. * @returns a new Vector2
  80502. */
  80503. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  80504. /**
  80505. * Sets "result" from the given index element of the given array
  80506. * @param array defines the data source
  80507. * @param offset defines the offset in the data source
  80508. * @param result defines the target vector
  80509. */
  80510. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  80511. /**
  80512. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  80513. * @param value1 defines 1st point of control
  80514. * @param value2 defines 2nd point of control
  80515. * @param value3 defines 3rd point of control
  80516. * @param value4 defines 4th point of control
  80517. * @param amount defines the interpolation factor
  80518. * @returns a new Vector2
  80519. */
  80520. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  80521. /**
  80522. * 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".
  80523. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  80524. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  80525. * @param value defines the value to clamp
  80526. * @param min defines the lower limit
  80527. * @param max defines the upper limit
  80528. * @returns a new Vector2
  80529. */
  80530. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  80531. /**
  80532. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  80533. * @param value1 defines the 1st control point
  80534. * @param tangent1 defines the outgoing tangent
  80535. * @param value2 defines the 2nd control point
  80536. * @param tangent2 defines the incoming tangent
  80537. * @param amount defines the interpolation factor
  80538. * @returns a new Vector2
  80539. */
  80540. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  80541. /**
  80542. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  80543. * @param start defines the start vector
  80544. * @param end defines the end vector
  80545. * @param amount defines the interpolation factor
  80546. * @returns a new Vector2
  80547. */
  80548. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  80549. /**
  80550. * Gets the dot product of the vector "left" and the vector "right"
  80551. * @param left defines first vector
  80552. * @param right defines second vector
  80553. * @returns the dot product (float)
  80554. */
  80555. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  80556. /**
  80557. * Returns a new Vector2 equal to the normalized given vector
  80558. * @param vector defines the vector to normalize
  80559. * @returns a new Vector2
  80560. */
  80561. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  80562. /**
  80563. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  80564. * @param left defines 1st vector
  80565. * @param right defines 2nd vector
  80566. * @returns a new Vector2
  80567. */
  80568. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  80569. /**
  80570. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  80571. * @param left defines 1st vector
  80572. * @param right defines 2nd vector
  80573. * @returns a new Vector2
  80574. */
  80575. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  80576. /**
  80577. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  80578. * @param vector defines the vector to transform
  80579. * @param transformation defines the matrix to apply
  80580. * @returns a new Vector2
  80581. */
  80582. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  80583. /**
  80584. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  80585. * @param vector defines the vector to transform
  80586. * @param transformation defines the matrix to apply
  80587. * @param result defines the target vector
  80588. */
  80589. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  80590. /**
  80591. * Determines if a given vector is included in a triangle
  80592. * @param p defines the vector to test
  80593. * @param p0 defines 1st triangle point
  80594. * @param p1 defines 2nd triangle point
  80595. * @param p2 defines 3rd triangle point
  80596. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  80597. */
  80598. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  80599. /**
  80600. * Gets the distance between the vectors "value1" and "value2"
  80601. * @param value1 defines first vector
  80602. * @param value2 defines second vector
  80603. * @returns the distance between vectors
  80604. */
  80605. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  80606. /**
  80607. * Returns the squared distance between the vectors "value1" and "value2"
  80608. * @param value1 defines first vector
  80609. * @param value2 defines second vector
  80610. * @returns the squared distance between vectors
  80611. */
  80612. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  80613. /**
  80614. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  80615. * @param value1 defines first vector
  80616. * @param value2 defines second vector
  80617. * @returns a new Vector2
  80618. */
  80619. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  80620. /**
  80621. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  80622. * @param p defines the middle point
  80623. * @param segA defines one point of the segment
  80624. * @param segB defines the other point of the segment
  80625. * @returns the shortest distance
  80626. */
  80627. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  80628. }
  80629. /**
  80630. * Class used to store (x,y,z) vector representation
  80631. * A Vector3 is the main object used in 3D geometry
  80632. * It can represent etiher the coordinates of a point the space, either a direction
  80633. * Reminder: js uses a left handed forward facing system
  80634. */
  80635. export class Vector3 {
  80636. private static _UpReadOnly;
  80637. private static _ZeroReadOnly;
  80638. /** @hidden */
  80639. _x: number;
  80640. /** @hidden */
  80641. _y: number;
  80642. /** @hidden */
  80643. _z: number;
  80644. /** @hidden */
  80645. _isDirty: boolean;
  80646. /** Gets or sets the x coordinate */
  80647. get x(): number;
  80648. set x(value: number);
  80649. /** Gets or sets the y coordinate */
  80650. get y(): number;
  80651. set y(value: number);
  80652. /** Gets or sets the z coordinate */
  80653. get z(): number;
  80654. set z(value: number);
  80655. /**
  80656. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  80657. * @param x defines the first coordinates (on X axis)
  80658. * @param y defines the second coordinates (on Y axis)
  80659. * @param z defines the third coordinates (on Z axis)
  80660. */
  80661. constructor(x?: number, y?: number, z?: number);
  80662. /**
  80663. * Creates a string representation of the Vector3
  80664. * @returns a string with the Vector3 coordinates.
  80665. */
  80666. toString(): string;
  80667. /**
  80668. * Gets the class name
  80669. * @returns the string "Vector3"
  80670. */
  80671. getClassName(): string;
  80672. /**
  80673. * Creates the Vector3 hash code
  80674. * @returns a number which tends to be unique between Vector3 instances
  80675. */
  80676. getHashCode(): number;
  80677. /**
  80678. * Creates an array containing three elements : the coordinates of the Vector3
  80679. * @returns a new array of numbers
  80680. */
  80681. asArray(): number[];
  80682. /**
  80683. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  80684. * @param array defines the destination array
  80685. * @param index defines the offset in the destination array
  80686. * @returns the current Vector3
  80687. */
  80688. toArray(array: FloatArray, index?: number): Vector3;
  80689. /**
  80690. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  80691. * @returns a new Quaternion object, computed from the Vector3 coordinates
  80692. */
  80693. toQuaternion(): Quaternion;
  80694. /**
  80695. * Adds the given vector to the current Vector3
  80696. * @param otherVector defines the second operand
  80697. * @returns the current updated Vector3
  80698. */
  80699. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80700. /**
  80701. * Adds the given coordinates to the current Vector3
  80702. * @param x defines the x coordinate of the operand
  80703. * @param y defines the y coordinate of the operand
  80704. * @param z defines the z coordinate of the operand
  80705. * @returns the current updated Vector3
  80706. */
  80707. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80708. /**
  80709. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  80710. * @param otherVector defines the second operand
  80711. * @returns the resulting Vector3
  80712. */
  80713. add(otherVector: DeepImmutable<Vector3>): Vector3;
  80714. /**
  80715. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  80716. * @param otherVector defines the second operand
  80717. * @param result defines the Vector3 object where to store the result
  80718. * @returns the current Vector3
  80719. */
  80720. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80721. /**
  80722. * Subtract the given vector from the current Vector3
  80723. * @param otherVector defines the second operand
  80724. * @returns the current updated Vector3
  80725. */
  80726. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80727. /**
  80728. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  80729. * @param otherVector defines the second operand
  80730. * @returns the resulting Vector3
  80731. */
  80732. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  80733. /**
  80734. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  80735. * @param otherVector defines the second operand
  80736. * @param result defines the Vector3 object where to store the result
  80737. * @returns the current Vector3
  80738. */
  80739. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80740. /**
  80741. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  80742. * @param x defines the x coordinate of the operand
  80743. * @param y defines the y coordinate of the operand
  80744. * @param z defines the z coordinate of the operand
  80745. * @returns the resulting Vector3
  80746. */
  80747. subtractFromFloats(x: number, y: number, z: number): Vector3;
  80748. /**
  80749. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  80750. * @param x defines the x coordinate of the operand
  80751. * @param y defines the y coordinate of the operand
  80752. * @param z defines the z coordinate of the operand
  80753. * @param result defines the Vector3 object where to store the result
  80754. * @returns the current Vector3
  80755. */
  80756. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  80757. /**
  80758. * Gets a new Vector3 set with the current Vector3 negated coordinates
  80759. * @returns a new Vector3
  80760. */
  80761. negate(): Vector3;
  80762. /**
  80763. * Negate this vector in place
  80764. * @returns this
  80765. */
  80766. negateInPlace(): Vector3;
  80767. /**
  80768. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  80769. * @param result defines the Vector3 object where to store the result
  80770. * @returns the current Vector3
  80771. */
  80772. negateToRef(result: Vector3): Vector3;
  80773. /**
  80774. * Multiplies the Vector3 coordinates by the float "scale"
  80775. * @param scale defines the multiplier factor
  80776. * @returns the current updated Vector3
  80777. */
  80778. scaleInPlace(scale: number): Vector3;
  80779. /**
  80780. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  80781. * @param scale defines the multiplier factor
  80782. * @returns a new Vector3
  80783. */
  80784. scale(scale: number): Vector3;
  80785. /**
  80786. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  80787. * @param scale defines the multiplier factor
  80788. * @param result defines the Vector3 object where to store the result
  80789. * @returns the current Vector3
  80790. */
  80791. scaleToRef(scale: number, result: Vector3): Vector3;
  80792. /**
  80793. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  80794. * @param scale defines the scale factor
  80795. * @param result defines the Vector3 object where to store the result
  80796. * @returns the unmodified current Vector3
  80797. */
  80798. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  80799. /**
  80800. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  80801. * @param origin defines the origin of the projection ray
  80802. * @param plane defines the plane to project to
  80803. * @returns the projected vector3
  80804. */
  80805. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  80806. /**
  80807. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  80808. * @param origin defines the origin of the projection ray
  80809. * @param plane defines the plane to project to
  80810. * @param result defines the Vector3 where to store the result
  80811. */
  80812. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  80813. /**
  80814. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  80815. * @param otherVector defines the second operand
  80816. * @returns true if both vectors are equals
  80817. */
  80818. equals(otherVector: DeepImmutable<Vector3>): boolean;
  80819. /**
  80820. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  80821. * @param otherVector defines the second operand
  80822. * @param epsilon defines the minimal distance to define values as equals
  80823. * @returns true if both vectors are distant less than epsilon
  80824. */
  80825. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  80826. /**
  80827. * Returns true if the current Vector3 coordinates equals the given floats
  80828. * @param x defines the x coordinate of the operand
  80829. * @param y defines the y coordinate of the operand
  80830. * @param z defines the z coordinate of the operand
  80831. * @returns true if both vectors are equals
  80832. */
  80833. equalsToFloats(x: number, y: number, z: number): boolean;
  80834. /**
  80835. * Multiplies the current Vector3 coordinates by the given ones
  80836. * @param otherVector defines the second operand
  80837. * @returns the current updated Vector3
  80838. */
  80839. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80840. /**
  80841. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  80842. * @param otherVector defines the second operand
  80843. * @returns the new Vector3
  80844. */
  80845. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  80846. /**
  80847. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  80848. * @param otherVector defines the second operand
  80849. * @param result defines the Vector3 object where to store the result
  80850. * @returns the current Vector3
  80851. */
  80852. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80853. /**
  80854. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  80855. * @param x defines the x coordinate of the operand
  80856. * @param y defines the y coordinate of the operand
  80857. * @param z defines the z coordinate of the operand
  80858. * @returns the new Vector3
  80859. */
  80860. multiplyByFloats(x: number, y: number, z: number): Vector3;
  80861. /**
  80862. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  80863. * @param otherVector defines the second operand
  80864. * @returns the new Vector3
  80865. */
  80866. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  80867. /**
  80868. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  80869. * @param otherVector defines the second operand
  80870. * @param result defines the Vector3 object where to store the result
  80871. * @returns the current Vector3
  80872. */
  80873. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80874. /**
  80875. * Divides the current Vector3 coordinates by the given ones.
  80876. * @param otherVector defines the second operand
  80877. * @returns the current updated Vector3
  80878. */
  80879. divideInPlace(otherVector: Vector3): Vector3;
  80880. /**
  80881. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  80882. * @param other defines the second operand
  80883. * @returns the current updated Vector3
  80884. */
  80885. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  80886. /**
  80887. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  80888. * @param other defines the second operand
  80889. * @returns the current updated Vector3
  80890. */
  80891. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  80892. /**
  80893. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  80894. * @param x defines the x coordinate of the operand
  80895. * @param y defines the y coordinate of the operand
  80896. * @param z defines the z coordinate of the operand
  80897. * @returns the current updated Vector3
  80898. */
  80899. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80900. /**
  80901. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  80902. * @param x defines the x coordinate of the operand
  80903. * @param y defines the y coordinate of the operand
  80904. * @param z defines the z coordinate of the operand
  80905. * @returns the current updated Vector3
  80906. */
  80907. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80908. /**
  80909. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  80910. * Check if is non uniform within a certain amount of decimal places to account for this
  80911. * @param epsilon the amount the values can differ
  80912. * @returns if the the vector is non uniform to a certain number of decimal places
  80913. */
  80914. isNonUniformWithinEpsilon(epsilon: number): boolean;
  80915. /**
  80916. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  80917. */
  80918. get isNonUniform(): boolean;
  80919. /**
  80920. * Gets a new Vector3 from current Vector3 floored values
  80921. * @returns a new Vector3
  80922. */
  80923. floor(): Vector3;
  80924. /**
  80925. * Gets a new Vector3 from current Vector3 floored values
  80926. * @returns a new Vector3
  80927. */
  80928. fract(): Vector3;
  80929. /**
  80930. * Gets the length of the Vector3
  80931. * @returns the length of the Vector3
  80932. */
  80933. length(): number;
  80934. /**
  80935. * Gets the squared length of the Vector3
  80936. * @returns squared length of the Vector3
  80937. */
  80938. lengthSquared(): number;
  80939. /**
  80940. * Normalize the current Vector3.
  80941. * Please note that this is an in place operation.
  80942. * @returns the current updated Vector3
  80943. */
  80944. normalize(): Vector3;
  80945. /**
  80946. * Reorders the x y z properties of the vector in place
  80947. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  80948. * @returns the current updated vector
  80949. */
  80950. reorderInPlace(order: string): this;
  80951. /**
  80952. * Rotates the vector around 0,0,0 by a quaternion
  80953. * @param quaternion the rotation quaternion
  80954. * @param result vector to store the result
  80955. * @returns the resulting vector
  80956. */
  80957. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  80958. /**
  80959. * Rotates a vector around a given point
  80960. * @param quaternion the rotation quaternion
  80961. * @param point the point to rotate around
  80962. * @param result vector to store the result
  80963. * @returns the resulting vector
  80964. */
  80965. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  80966. /**
  80967. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  80968. * The cross product is then orthogonal to both current and "other"
  80969. * @param other defines the right operand
  80970. * @returns the cross product
  80971. */
  80972. cross(other: Vector3): Vector3;
  80973. /**
  80974. * Normalize the current Vector3 with the given input length.
  80975. * Please note that this is an in place operation.
  80976. * @param len the length of the vector
  80977. * @returns the current updated Vector3
  80978. */
  80979. normalizeFromLength(len: number): Vector3;
  80980. /**
  80981. * Normalize the current Vector3 to a new vector
  80982. * @returns the new Vector3
  80983. */
  80984. normalizeToNew(): Vector3;
  80985. /**
  80986. * Normalize the current Vector3 to the reference
  80987. * @param reference define the Vector3 to update
  80988. * @returns the updated Vector3
  80989. */
  80990. normalizeToRef(reference: Vector3): Vector3;
  80991. /**
  80992. * Creates a new Vector3 copied from the current Vector3
  80993. * @returns the new Vector3
  80994. */
  80995. clone(): Vector3;
  80996. /**
  80997. * Copies the given vector coordinates to the current Vector3 ones
  80998. * @param source defines the source Vector3
  80999. * @returns the current updated Vector3
  81000. */
  81001. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  81002. /**
  81003. * Copies the given floats to the current Vector3 coordinates
  81004. * @param x defines the x coordinate of the operand
  81005. * @param y defines the y coordinate of the operand
  81006. * @param z defines the z coordinate of the operand
  81007. * @returns the current updated Vector3
  81008. */
  81009. copyFromFloats(x: number, y: number, z: number): Vector3;
  81010. /**
  81011. * Copies the given floats to the current Vector3 coordinates
  81012. * @param x defines the x coordinate of the operand
  81013. * @param y defines the y coordinate of the operand
  81014. * @param z defines the z coordinate of the operand
  81015. * @returns the current updated Vector3
  81016. */
  81017. set(x: number, y: number, z: number): Vector3;
  81018. /**
  81019. * Copies the given float to the current Vector3 coordinates
  81020. * @param v defines the x, y and z coordinates of the operand
  81021. * @returns the current updated Vector3
  81022. */
  81023. setAll(v: number): Vector3;
  81024. /**
  81025. * Get the clip factor between two vectors
  81026. * @param vector0 defines the first operand
  81027. * @param vector1 defines the second operand
  81028. * @param axis defines the axis to use
  81029. * @param size defines the size along the axis
  81030. * @returns the clip factor
  81031. */
  81032. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  81033. /**
  81034. * Get angle between two vectors
  81035. * @param vector0 angle between vector0 and vector1
  81036. * @param vector1 angle between vector0 and vector1
  81037. * @param normal direction of the normal
  81038. * @return the angle between vector0 and vector1
  81039. */
  81040. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  81041. /**
  81042. * Returns a new Vector3 set from the index "offset" of the given array
  81043. * @param array defines the source array
  81044. * @param offset defines the offset in the source array
  81045. * @returns the new Vector3
  81046. */
  81047. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  81048. /**
  81049. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  81050. * @param array defines the source array
  81051. * @param offset defines the offset in the source array
  81052. * @returns the new Vector3
  81053. * @deprecated Please use FromArray instead.
  81054. */
  81055. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  81056. /**
  81057. * Sets the given vector "result" with the element values from the index "offset" of the given array
  81058. * @param array defines the source array
  81059. * @param offset defines the offset in the source array
  81060. * @param result defines the Vector3 where to store the result
  81061. */
  81062. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  81063. /**
  81064. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  81065. * @param array defines the source array
  81066. * @param offset defines the offset in the source array
  81067. * @param result defines the Vector3 where to store the result
  81068. * @deprecated Please use FromArrayToRef instead.
  81069. */
  81070. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  81071. /**
  81072. * Sets the given vector "result" with the given floats.
  81073. * @param x defines the x coordinate of the source
  81074. * @param y defines the y coordinate of the source
  81075. * @param z defines the z coordinate of the source
  81076. * @param result defines the Vector3 where to store the result
  81077. */
  81078. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  81079. /**
  81080. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  81081. * @returns a new empty Vector3
  81082. */
  81083. static Zero(): Vector3;
  81084. /**
  81085. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  81086. * @returns a new unit Vector3
  81087. */
  81088. static One(): Vector3;
  81089. /**
  81090. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  81091. * @returns a new up Vector3
  81092. */
  81093. static Up(): Vector3;
  81094. /**
  81095. * Gets a up Vector3 that must not be updated
  81096. */
  81097. static get UpReadOnly(): DeepImmutable<Vector3>;
  81098. /**
  81099. * Gets a zero Vector3 that must not be updated
  81100. */
  81101. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  81102. /**
  81103. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  81104. * @returns a new down Vector3
  81105. */
  81106. static Down(): Vector3;
  81107. /**
  81108. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  81109. * @param rightHandedSystem is the scene right-handed (negative z)
  81110. * @returns a new forward Vector3
  81111. */
  81112. static Forward(rightHandedSystem?: boolean): Vector3;
  81113. /**
  81114. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  81115. * @param rightHandedSystem is the scene right-handed (negative-z)
  81116. * @returns a new forward Vector3
  81117. */
  81118. static Backward(rightHandedSystem?: boolean): Vector3;
  81119. /**
  81120. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  81121. * @returns a new right Vector3
  81122. */
  81123. static Right(): Vector3;
  81124. /**
  81125. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  81126. * @returns a new left Vector3
  81127. */
  81128. static Left(): Vector3;
  81129. /**
  81130. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  81131. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  81132. * @param vector defines the Vector3 to transform
  81133. * @param transformation defines the transformation matrix
  81134. * @returns the transformed Vector3
  81135. */
  81136. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  81137. /**
  81138. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  81139. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  81140. * @param vector defines the Vector3 to transform
  81141. * @param transformation defines the transformation matrix
  81142. * @param result defines the Vector3 where to store the result
  81143. */
  81144. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81145. /**
  81146. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  81147. * This method computes tranformed coordinates only, not transformed direction vectors
  81148. * @param x define the x coordinate of the source vector
  81149. * @param y define the y coordinate of the source vector
  81150. * @param z define the z coordinate of the source vector
  81151. * @param transformation defines the transformation matrix
  81152. * @param result defines the Vector3 where to store the result
  81153. */
  81154. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81155. /**
  81156. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  81157. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81158. * @param vector defines the Vector3 to transform
  81159. * @param transformation defines the transformation matrix
  81160. * @returns the new Vector3
  81161. */
  81162. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  81163. /**
  81164. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  81165. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81166. * @param vector defines the Vector3 to transform
  81167. * @param transformation defines the transformation matrix
  81168. * @param result defines the Vector3 where to store the result
  81169. */
  81170. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81171. /**
  81172. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  81173. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81174. * @param x define the x coordinate of the source vector
  81175. * @param y define the y coordinate of the source vector
  81176. * @param z define the z coordinate of the source vector
  81177. * @param transformation defines the transformation matrix
  81178. * @param result defines the Vector3 where to store the result
  81179. */
  81180. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81181. /**
  81182. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  81183. * @param value1 defines the first control point
  81184. * @param value2 defines the second control point
  81185. * @param value3 defines the third control point
  81186. * @param value4 defines the fourth control point
  81187. * @param amount defines the amount on the spline to use
  81188. * @returns the new Vector3
  81189. */
  81190. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  81191. /**
  81192. * 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"
  81193. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  81194. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  81195. * @param value defines the current value
  81196. * @param min defines the lower range value
  81197. * @param max defines the upper range value
  81198. * @returns the new Vector3
  81199. */
  81200. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  81201. /**
  81202. * 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"
  81203. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  81204. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  81205. * @param value defines the current value
  81206. * @param min defines the lower range value
  81207. * @param max defines the upper range value
  81208. * @param result defines the Vector3 where to store the result
  81209. */
  81210. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  81211. /**
  81212. * Checks if a given vector is inside a specific range
  81213. * @param v defines the vector to test
  81214. * @param min defines the minimum range
  81215. * @param max defines the maximum range
  81216. */
  81217. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  81218. /**
  81219. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  81220. * @param value1 defines the first control point
  81221. * @param tangent1 defines the first tangent vector
  81222. * @param value2 defines the second control point
  81223. * @param tangent2 defines the second tangent vector
  81224. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  81225. * @returns the new Vector3
  81226. */
  81227. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  81228. /**
  81229. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  81230. * @param start defines the start value
  81231. * @param end defines the end value
  81232. * @param amount max defines amount between both (between 0 and 1)
  81233. * @returns the new Vector3
  81234. */
  81235. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  81236. /**
  81237. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  81238. * @param start defines the start value
  81239. * @param end defines the end value
  81240. * @param amount max defines amount between both (between 0 and 1)
  81241. * @param result defines the Vector3 where to store the result
  81242. */
  81243. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  81244. /**
  81245. * Returns the dot product (float) between the vectors "left" and "right"
  81246. * @param left defines the left operand
  81247. * @param right defines the right operand
  81248. * @returns the dot product
  81249. */
  81250. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  81251. /**
  81252. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  81253. * The cross product is then orthogonal to both "left" and "right"
  81254. * @param left defines the left operand
  81255. * @param right defines the right operand
  81256. * @returns the cross product
  81257. */
  81258. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  81259. /**
  81260. * Sets the given vector "result" with the cross product of "left" and "right"
  81261. * The cross product is then orthogonal to both "left" and "right"
  81262. * @param left defines the left operand
  81263. * @param right defines the right operand
  81264. * @param result defines the Vector3 where to store the result
  81265. */
  81266. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  81267. /**
  81268. * Returns a new Vector3 as the normalization of the given vector
  81269. * @param vector defines the Vector3 to normalize
  81270. * @returns the new Vector3
  81271. */
  81272. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  81273. /**
  81274. * Sets the given vector "result" with the normalization of the given first vector
  81275. * @param vector defines the Vector3 to normalize
  81276. * @param result defines the Vector3 where to store the result
  81277. */
  81278. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  81279. /**
  81280. * Project a Vector3 onto screen space
  81281. * @param vector defines the Vector3 to project
  81282. * @param world defines the world matrix to use
  81283. * @param transform defines the transform (view x projection) matrix to use
  81284. * @param viewport defines the screen viewport to use
  81285. * @returns the new Vector3
  81286. */
  81287. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  81288. /** @hidden */
  81289. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  81290. /**
  81291. * Unproject from screen space to object space
  81292. * @param source defines the screen space Vector3 to use
  81293. * @param viewportWidth defines the current width of the viewport
  81294. * @param viewportHeight defines the current height of the viewport
  81295. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81296. * @param transform defines the transform (view x projection) matrix to use
  81297. * @returns the new Vector3
  81298. */
  81299. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  81300. /**
  81301. * Unproject from screen space to object space
  81302. * @param source defines the screen space Vector3 to use
  81303. * @param viewportWidth defines the current width of the viewport
  81304. * @param viewportHeight defines the current height of the viewport
  81305. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81306. * @param view defines the view matrix to use
  81307. * @param projection defines the projection matrix to use
  81308. * @returns the new Vector3
  81309. */
  81310. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  81311. /**
  81312. * Unproject from screen space to object space
  81313. * @param source defines the screen space Vector3 to use
  81314. * @param viewportWidth defines the current width of the viewport
  81315. * @param viewportHeight defines the current height of the viewport
  81316. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81317. * @param view defines the view matrix to use
  81318. * @param projection defines the projection matrix to use
  81319. * @param result defines the Vector3 where to store the result
  81320. */
  81321. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  81322. /**
  81323. * Unproject from screen space to object space
  81324. * @param sourceX defines the screen space x coordinate to use
  81325. * @param sourceY defines the screen space y coordinate to use
  81326. * @param sourceZ defines the screen space z coordinate to use
  81327. * @param viewportWidth defines the current width of the viewport
  81328. * @param viewportHeight defines the current height of the viewport
  81329. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81330. * @param view defines the view matrix to use
  81331. * @param projection defines the projection matrix to use
  81332. * @param result defines the Vector3 where to store the result
  81333. */
  81334. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  81335. /**
  81336. * Gets the minimal coordinate values between two Vector3
  81337. * @param left defines the first operand
  81338. * @param right defines the second operand
  81339. * @returns the new Vector3
  81340. */
  81341. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  81342. /**
  81343. * Gets the maximal coordinate values between two Vector3
  81344. * @param left defines the first operand
  81345. * @param right defines the second operand
  81346. * @returns the new Vector3
  81347. */
  81348. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  81349. /**
  81350. * Returns the distance between the vectors "value1" and "value2"
  81351. * @param value1 defines the first operand
  81352. * @param value2 defines the second operand
  81353. * @returns the distance
  81354. */
  81355. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  81356. /**
  81357. * Returns the squared distance between the vectors "value1" and "value2"
  81358. * @param value1 defines the first operand
  81359. * @param value2 defines the second operand
  81360. * @returns the squared distance
  81361. */
  81362. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  81363. /**
  81364. * Returns a new Vector3 located at the center between "value1" and "value2"
  81365. * @param value1 defines the first operand
  81366. * @param value2 defines the second operand
  81367. * @returns the new Vector3
  81368. */
  81369. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  81370. /**
  81371. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  81372. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  81373. * to something in order to rotate it from its local system to the given target system
  81374. * Note: axis1, axis2 and axis3 are normalized during this operation
  81375. * @param axis1 defines the first axis
  81376. * @param axis2 defines the second axis
  81377. * @param axis3 defines the third axis
  81378. * @returns a new Vector3
  81379. */
  81380. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  81381. /**
  81382. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  81383. * @param axis1 defines the first axis
  81384. * @param axis2 defines the second axis
  81385. * @param axis3 defines the third axis
  81386. * @param ref defines the Vector3 where to store the result
  81387. */
  81388. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  81389. }
  81390. /**
  81391. * Vector4 class created for EulerAngle class conversion to Quaternion
  81392. */
  81393. export class Vector4 {
  81394. /** x value of the vector */
  81395. x: number;
  81396. /** y value of the vector */
  81397. y: number;
  81398. /** z value of the vector */
  81399. z: number;
  81400. /** w value of the vector */
  81401. w: number;
  81402. /**
  81403. * Creates a Vector4 object from the given floats.
  81404. * @param x x value of the vector
  81405. * @param y y value of the vector
  81406. * @param z z value of the vector
  81407. * @param w w value of the vector
  81408. */
  81409. constructor(
  81410. /** x value of the vector */
  81411. x: number,
  81412. /** y value of the vector */
  81413. y: number,
  81414. /** z value of the vector */
  81415. z: number,
  81416. /** w value of the vector */
  81417. w: number);
  81418. /**
  81419. * Returns the string with the Vector4 coordinates.
  81420. * @returns a string containing all the vector values
  81421. */
  81422. toString(): string;
  81423. /**
  81424. * Returns the string "Vector4".
  81425. * @returns "Vector4"
  81426. */
  81427. getClassName(): string;
  81428. /**
  81429. * Returns the Vector4 hash code.
  81430. * @returns a unique hash code
  81431. */
  81432. getHashCode(): number;
  81433. /**
  81434. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  81435. * @returns the resulting array
  81436. */
  81437. asArray(): number[];
  81438. /**
  81439. * Populates the given array from the given index with the Vector4 coordinates.
  81440. * @param array array to populate
  81441. * @param index index of the array to start at (default: 0)
  81442. * @returns the Vector4.
  81443. */
  81444. toArray(array: FloatArray, index?: number): Vector4;
  81445. /**
  81446. * Adds the given vector to the current Vector4.
  81447. * @param otherVector the vector to add
  81448. * @returns the updated Vector4.
  81449. */
  81450. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81451. /**
  81452. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  81453. * @param otherVector the vector to add
  81454. * @returns the resulting vector
  81455. */
  81456. add(otherVector: DeepImmutable<Vector4>): Vector4;
  81457. /**
  81458. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  81459. * @param otherVector the vector to add
  81460. * @param result the vector to store the result
  81461. * @returns the current Vector4.
  81462. */
  81463. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81464. /**
  81465. * Subtract in place the given vector from the current Vector4.
  81466. * @param otherVector the vector to subtract
  81467. * @returns the updated Vector4.
  81468. */
  81469. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81470. /**
  81471. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  81472. * @param otherVector the vector to add
  81473. * @returns the new vector with the result
  81474. */
  81475. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  81476. /**
  81477. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  81478. * @param otherVector the vector to subtract
  81479. * @param result the vector to store the result
  81480. * @returns the current Vector4.
  81481. */
  81482. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81483. /**
  81484. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  81485. */
  81486. /**
  81487. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  81488. * @param x value to subtract
  81489. * @param y value to subtract
  81490. * @param z value to subtract
  81491. * @param w value to subtract
  81492. * @returns new vector containing the result
  81493. */
  81494. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  81495. /**
  81496. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  81497. * @param x value to subtract
  81498. * @param y value to subtract
  81499. * @param z value to subtract
  81500. * @param w value to subtract
  81501. * @param result the vector to store the result in
  81502. * @returns the current Vector4.
  81503. */
  81504. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  81505. /**
  81506. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  81507. * @returns a new vector with the negated values
  81508. */
  81509. negate(): Vector4;
  81510. /**
  81511. * Negate this vector in place
  81512. * @returns this
  81513. */
  81514. negateInPlace(): Vector4;
  81515. /**
  81516. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  81517. * @param result defines the Vector3 object where to store the result
  81518. * @returns the current Vector4
  81519. */
  81520. negateToRef(result: Vector4): Vector4;
  81521. /**
  81522. * Multiplies the current Vector4 coordinates by scale (float).
  81523. * @param scale the number to scale with
  81524. * @returns the updated Vector4.
  81525. */
  81526. scaleInPlace(scale: number): Vector4;
  81527. /**
  81528. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  81529. * @param scale the number to scale with
  81530. * @returns a new vector with the result
  81531. */
  81532. scale(scale: number): Vector4;
  81533. /**
  81534. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  81535. * @param scale the number to scale with
  81536. * @param result a vector to store the result in
  81537. * @returns the current Vector4.
  81538. */
  81539. scaleToRef(scale: number, result: Vector4): Vector4;
  81540. /**
  81541. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  81542. * @param scale defines the scale factor
  81543. * @param result defines the Vector4 object where to store the result
  81544. * @returns the unmodified current Vector4
  81545. */
  81546. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  81547. /**
  81548. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  81549. * @param otherVector the vector to compare against
  81550. * @returns true if they are equal
  81551. */
  81552. equals(otherVector: DeepImmutable<Vector4>): boolean;
  81553. /**
  81554. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  81555. * @param otherVector vector to compare against
  81556. * @param epsilon (Default: very small number)
  81557. * @returns true if they are equal
  81558. */
  81559. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  81560. /**
  81561. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  81562. * @param x x value to compare against
  81563. * @param y y value to compare against
  81564. * @param z z value to compare against
  81565. * @param w w value to compare against
  81566. * @returns true if equal
  81567. */
  81568. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  81569. /**
  81570. * Multiplies in place the current Vector4 by the given one.
  81571. * @param otherVector vector to multiple with
  81572. * @returns the updated Vector4.
  81573. */
  81574. multiplyInPlace(otherVector: Vector4): Vector4;
  81575. /**
  81576. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  81577. * @param otherVector vector to multiple with
  81578. * @returns resulting new vector
  81579. */
  81580. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  81581. /**
  81582. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  81583. * @param otherVector vector to multiple with
  81584. * @param result vector to store the result
  81585. * @returns the current Vector4.
  81586. */
  81587. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81588. /**
  81589. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  81590. * @param x x value multiply with
  81591. * @param y y value multiply with
  81592. * @param z z value multiply with
  81593. * @param w w value multiply with
  81594. * @returns resulting new vector
  81595. */
  81596. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  81597. /**
  81598. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  81599. * @param otherVector vector to devide with
  81600. * @returns resulting new vector
  81601. */
  81602. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  81603. /**
  81604. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  81605. * @param otherVector vector to devide with
  81606. * @param result vector to store the result
  81607. * @returns the current Vector4.
  81608. */
  81609. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81610. /**
  81611. * Divides the current Vector3 coordinates by the given ones.
  81612. * @param otherVector vector to devide with
  81613. * @returns the updated Vector3.
  81614. */
  81615. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81616. /**
  81617. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  81618. * @param other defines the second operand
  81619. * @returns the current updated Vector4
  81620. */
  81621. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  81622. /**
  81623. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  81624. * @param other defines the second operand
  81625. * @returns the current updated Vector4
  81626. */
  81627. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  81628. /**
  81629. * Gets a new Vector4 from current Vector4 floored values
  81630. * @returns a new Vector4
  81631. */
  81632. floor(): Vector4;
  81633. /**
  81634. * Gets a new Vector4 from current Vector3 floored values
  81635. * @returns a new Vector4
  81636. */
  81637. fract(): Vector4;
  81638. /**
  81639. * Returns the Vector4 length (float).
  81640. * @returns the length
  81641. */
  81642. length(): number;
  81643. /**
  81644. * Returns the Vector4 squared length (float).
  81645. * @returns the length squared
  81646. */
  81647. lengthSquared(): number;
  81648. /**
  81649. * Normalizes in place the Vector4.
  81650. * @returns the updated Vector4.
  81651. */
  81652. normalize(): Vector4;
  81653. /**
  81654. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  81655. * @returns this converted to a new vector3
  81656. */
  81657. toVector3(): Vector3;
  81658. /**
  81659. * Returns a new Vector4 copied from the current one.
  81660. * @returns the new cloned vector
  81661. */
  81662. clone(): Vector4;
  81663. /**
  81664. * Updates the current Vector4 with the given one coordinates.
  81665. * @param source the source vector to copy from
  81666. * @returns the updated Vector4.
  81667. */
  81668. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  81669. /**
  81670. * Updates the current Vector4 coordinates with the given floats.
  81671. * @param x float to copy from
  81672. * @param y float to copy from
  81673. * @param z float to copy from
  81674. * @param w float to copy from
  81675. * @returns the updated Vector4.
  81676. */
  81677. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  81678. /**
  81679. * Updates the current Vector4 coordinates with the given floats.
  81680. * @param x float to set from
  81681. * @param y float to set from
  81682. * @param z float to set from
  81683. * @param w float to set from
  81684. * @returns the updated Vector4.
  81685. */
  81686. set(x: number, y: number, z: number, w: number): Vector4;
  81687. /**
  81688. * Copies the given float to the current Vector3 coordinates
  81689. * @param v defines the x, y, z and w coordinates of the operand
  81690. * @returns the current updated Vector3
  81691. */
  81692. setAll(v: number): Vector4;
  81693. /**
  81694. * Returns a new Vector4 set from the starting index of the given array.
  81695. * @param array the array to pull values from
  81696. * @param offset the offset into the array to start at
  81697. * @returns the new vector
  81698. */
  81699. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  81700. /**
  81701. * Updates the given vector "result" from the starting index of the given array.
  81702. * @param array the array to pull values from
  81703. * @param offset the offset into the array to start at
  81704. * @param result the vector to store the result in
  81705. */
  81706. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  81707. /**
  81708. * Updates the given vector "result" from the starting index of the given Float32Array.
  81709. * @param array the array to pull values from
  81710. * @param offset the offset into the array to start at
  81711. * @param result the vector to store the result in
  81712. */
  81713. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  81714. /**
  81715. * Updates the given vector "result" coordinates from the given floats.
  81716. * @param x float to set from
  81717. * @param y float to set from
  81718. * @param z float to set from
  81719. * @param w float to set from
  81720. * @param result the vector to the floats in
  81721. */
  81722. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  81723. /**
  81724. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  81725. * @returns the new vector
  81726. */
  81727. static Zero(): Vector4;
  81728. /**
  81729. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  81730. * @returns the new vector
  81731. */
  81732. static One(): Vector4;
  81733. /**
  81734. * Returns a new normalized Vector4 from the given one.
  81735. * @param vector the vector to normalize
  81736. * @returns the vector
  81737. */
  81738. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  81739. /**
  81740. * Updates the given vector "result" from the normalization of the given one.
  81741. * @param vector the vector to normalize
  81742. * @param result the vector to store the result in
  81743. */
  81744. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  81745. /**
  81746. * Returns a vector with the minimum values from the left and right vectors
  81747. * @param left left vector to minimize
  81748. * @param right right vector to minimize
  81749. * @returns a new vector with the minimum of the left and right vector values
  81750. */
  81751. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  81752. /**
  81753. * Returns a vector with the maximum values from the left and right vectors
  81754. * @param left left vector to maximize
  81755. * @param right right vector to maximize
  81756. * @returns a new vector with the maximum of the left and right vector values
  81757. */
  81758. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  81759. /**
  81760. * Returns the distance (float) between the vectors "value1" and "value2".
  81761. * @param value1 value to calulate the distance between
  81762. * @param value2 value to calulate the distance between
  81763. * @return the distance between the two vectors
  81764. */
  81765. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  81766. /**
  81767. * Returns the squared distance (float) between the vectors "value1" and "value2".
  81768. * @param value1 value to calulate the distance between
  81769. * @param value2 value to calulate the distance between
  81770. * @return the distance between the two vectors squared
  81771. */
  81772. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  81773. /**
  81774. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  81775. * @param value1 value to calulate the center between
  81776. * @param value2 value to calulate the center between
  81777. * @return the center between the two vectors
  81778. */
  81779. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  81780. /**
  81781. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  81782. * This methods computes transformed normalized direction vectors only.
  81783. * @param vector the vector to transform
  81784. * @param transformation the transformation matrix to apply
  81785. * @returns the new vector
  81786. */
  81787. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  81788. /**
  81789. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  81790. * This methods computes transformed normalized direction vectors only.
  81791. * @param vector the vector to transform
  81792. * @param transformation the transformation matrix to apply
  81793. * @param result the vector to store the result in
  81794. */
  81795. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  81796. /**
  81797. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  81798. * This methods computes transformed normalized direction vectors only.
  81799. * @param x value to transform
  81800. * @param y value to transform
  81801. * @param z value to transform
  81802. * @param w value to transform
  81803. * @param transformation the transformation matrix to apply
  81804. * @param result the vector to store the results in
  81805. */
  81806. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  81807. /**
  81808. * Creates a new Vector4 from a Vector3
  81809. * @param source defines the source data
  81810. * @param w defines the 4th component (default is 0)
  81811. * @returns a new Vector4
  81812. */
  81813. static FromVector3(source: Vector3, w?: number): Vector4;
  81814. }
  81815. /**
  81816. * Class used to store quaternion data
  81817. * @see https://en.wikipedia.org/wiki/Quaternion
  81818. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  81819. */
  81820. export class Quaternion {
  81821. /** @hidden */
  81822. _x: number;
  81823. /** @hidden */
  81824. _y: number;
  81825. /** @hidden */
  81826. _z: number;
  81827. /** @hidden */
  81828. _w: number;
  81829. /** @hidden */
  81830. _isDirty: boolean;
  81831. /** Gets or sets the x coordinate */
  81832. get x(): number;
  81833. set x(value: number);
  81834. /** Gets or sets the y coordinate */
  81835. get y(): number;
  81836. set y(value: number);
  81837. /** Gets or sets the z coordinate */
  81838. get z(): number;
  81839. set z(value: number);
  81840. /** Gets or sets the w coordinate */
  81841. get w(): number;
  81842. set w(value: number);
  81843. /**
  81844. * Creates a new Quaternion from the given floats
  81845. * @param x defines the first component (0 by default)
  81846. * @param y defines the second component (0 by default)
  81847. * @param z defines the third component (0 by default)
  81848. * @param w defines the fourth component (1.0 by default)
  81849. */
  81850. constructor(x?: number, y?: number, z?: number, w?: number);
  81851. /**
  81852. * Gets a string representation for the current quaternion
  81853. * @returns a string with the Quaternion coordinates
  81854. */
  81855. toString(): string;
  81856. /**
  81857. * Gets the class name of the quaternion
  81858. * @returns the string "Quaternion"
  81859. */
  81860. getClassName(): string;
  81861. /**
  81862. * Gets a hash code for this quaternion
  81863. * @returns the quaternion hash code
  81864. */
  81865. getHashCode(): number;
  81866. /**
  81867. * Copy the quaternion to an array
  81868. * @returns a new array populated with 4 elements from the quaternion coordinates
  81869. */
  81870. asArray(): number[];
  81871. /**
  81872. * Check if two quaternions are equals
  81873. * @param otherQuaternion defines the second operand
  81874. * @return true if the current quaternion and the given one coordinates are strictly equals
  81875. */
  81876. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  81877. /**
  81878. * Gets a boolean if two quaternions are equals (using an epsilon value)
  81879. * @param otherQuaternion defines the other quaternion
  81880. * @param epsilon defines the minimal distance to consider equality
  81881. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  81882. */
  81883. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  81884. /**
  81885. * Clone the current quaternion
  81886. * @returns a new quaternion copied from the current one
  81887. */
  81888. clone(): Quaternion;
  81889. /**
  81890. * Copy a quaternion to the current one
  81891. * @param other defines the other quaternion
  81892. * @returns the updated current quaternion
  81893. */
  81894. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  81895. /**
  81896. * Updates the current quaternion with the given float coordinates
  81897. * @param x defines the x coordinate
  81898. * @param y defines the y coordinate
  81899. * @param z defines the z coordinate
  81900. * @param w defines the w coordinate
  81901. * @returns the updated current quaternion
  81902. */
  81903. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  81904. /**
  81905. * Updates the current quaternion from the given float coordinates
  81906. * @param x defines the x coordinate
  81907. * @param y defines the y coordinate
  81908. * @param z defines the z coordinate
  81909. * @param w defines the w coordinate
  81910. * @returns the updated current quaternion
  81911. */
  81912. set(x: number, y: number, z: number, w: number): Quaternion;
  81913. /**
  81914. * Adds two quaternions
  81915. * @param other defines the second operand
  81916. * @returns a new quaternion as the addition result of the given one and the current quaternion
  81917. */
  81918. add(other: DeepImmutable<Quaternion>): Quaternion;
  81919. /**
  81920. * Add a quaternion to the current one
  81921. * @param other defines the quaternion to add
  81922. * @returns the current quaternion
  81923. */
  81924. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  81925. /**
  81926. * Subtract two quaternions
  81927. * @param other defines the second operand
  81928. * @returns a new quaternion as the subtraction result of the given one from the current one
  81929. */
  81930. subtract(other: Quaternion): Quaternion;
  81931. /**
  81932. * Multiplies the current quaternion by a scale factor
  81933. * @param value defines the scale factor
  81934. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  81935. */
  81936. scale(value: number): Quaternion;
  81937. /**
  81938. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  81939. * @param scale defines the scale factor
  81940. * @param result defines the Quaternion object where to store the result
  81941. * @returns the unmodified current quaternion
  81942. */
  81943. scaleToRef(scale: number, result: Quaternion): Quaternion;
  81944. /**
  81945. * Multiplies in place the current quaternion by a scale factor
  81946. * @param value defines the scale factor
  81947. * @returns the current modified quaternion
  81948. */
  81949. scaleInPlace(value: number): Quaternion;
  81950. /**
  81951. * Scale the current quaternion values by a factor and add the result to a given quaternion
  81952. * @param scale defines the scale factor
  81953. * @param result defines the Quaternion object where to store the result
  81954. * @returns the unmodified current quaternion
  81955. */
  81956. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  81957. /**
  81958. * Multiplies two quaternions
  81959. * @param q1 defines the second operand
  81960. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  81961. */
  81962. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  81963. /**
  81964. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  81965. * @param q1 defines the second operand
  81966. * @param result defines the target quaternion
  81967. * @returns the current quaternion
  81968. */
  81969. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  81970. /**
  81971. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  81972. * @param q1 defines the second operand
  81973. * @returns the currentupdated quaternion
  81974. */
  81975. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  81976. /**
  81977. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  81978. * @param ref defines the target quaternion
  81979. * @returns the current quaternion
  81980. */
  81981. conjugateToRef(ref: Quaternion): Quaternion;
  81982. /**
  81983. * Conjugates in place (1-q) the current quaternion
  81984. * @returns the current updated quaternion
  81985. */
  81986. conjugateInPlace(): Quaternion;
  81987. /**
  81988. * Conjugates in place (1-q) the current quaternion
  81989. * @returns a new quaternion
  81990. */
  81991. conjugate(): Quaternion;
  81992. /**
  81993. * Gets length of current quaternion
  81994. * @returns the quaternion length (float)
  81995. */
  81996. length(): number;
  81997. /**
  81998. * Normalize in place the current quaternion
  81999. * @returns the current updated quaternion
  82000. */
  82001. normalize(): Quaternion;
  82002. /**
  82003. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  82004. * @param order is a reserved parameter and is ignore for now
  82005. * @returns a new Vector3 containing the Euler angles
  82006. */
  82007. toEulerAngles(order?: string): Vector3;
  82008. /**
  82009. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  82010. * @param result defines the vector which will be filled with the Euler angles
  82011. * @param order is a reserved parameter and is ignore for now
  82012. * @returns the current unchanged quaternion
  82013. */
  82014. toEulerAnglesToRef(result: Vector3): Quaternion;
  82015. /**
  82016. * Updates the given rotation matrix with the current quaternion values
  82017. * @param result defines the target matrix
  82018. * @returns the current unchanged quaternion
  82019. */
  82020. toRotationMatrix(result: Matrix): Quaternion;
  82021. /**
  82022. * Updates the current quaternion from the given rotation matrix values
  82023. * @param matrix defines the source matrix
  82024. * @returns the current updated quaternion
  82025. */
  82026. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  82027. /**
  82028. * Creates a new quaternion from a rotation matrix
  82029. * @param matrix defines the source matrix
  82030. * @returns a new quaternion created from the given rotation matrix values
  82031. */
  82032. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  82033. /**
  82034. * Updates the given quaternion with the given rotation matrix values
  82035. * @param matrix defines the source matrix
  82036. * @param result defines the target quaternion
  82037. */
  82038. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  82039. /**
  82040. * Returns the dot product (float) between the quaternions "left" and "right"
  82041. * @param left defines the left operand
  82042. * @param right defines the right operand
  82043. * @returns the dot product
  82044. */
  82045. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  82046. /**
  82047. * Checks if the two quaternions are close to each other
  82048. * @param quat0 defines the first quaternion to check
  82049. * @param quat1 defines the second quaternion to check
  82050. * @returns true if the two quaternions are close to each other
  82051. */
  82052. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  82053. /**
  82054. * Creates an empty quaternion
  82055. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  82056. */
  82057. static Zero(): Quaternion;
  82058. /**
  82059. * Inverse a given quaternion
  82060. * @param q defines the source quaternion
  82061. * @returns a new quaternion as the inverted current quaternion
  82062. */
  82063. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  82064. /**
  82065. * Inverse a given quaternion
  82066. * @param q defines the source quaternion
  82067. * @param result the quaternion the result will be stored in
  82068. * @returns the result quaternion
  82069. */
  82070. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  82071. /**
  82072. * Creates an identity quaternion
  82073. * @returns the identity quaternion
  82074. */
  82075. static Identity(): Quaternion;
  82076. /**
  82077. * Gets a boolean indicating if the given quaternion is identity
  82078. * @param quaternion defines the quaternion to check
  82079. * @returns true if the quaternion is identity
  82080. */
  82081. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  82082. /**
  82083. * Creates a quaternion from a rotation around an axis
  82084. * @param axis defines the axis to use
  82085. * @param angle defines the angle to use
  82086. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  82087. */
  82088. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  82089. /**
  82090. * Creates a rotation around an axis and stores it into the given quaternion
  82091. * @param axis defines the axis to use
  82092. * @param angle defines the angle to use
  82093. * @param result defines the target quaternion
  82094. * @returns the target quaternion
  82095. */
  82096. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  82097. /**
  82098. * Creates a new quaternion from data stored into an array
  82099. * @param array defines the data source
  82100. * @param offset defines the offset in the source array where the data starts
  82101. * @returns a new quaternion
  82102. */
  82103. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  82104. /**
  82105. * Updates the given quaternion "result" from the starting index of the given array.
  82106. * @param array the array to pull values from
  82107. * @param offset the offset into the array to start at
  82108. * @param result the quaternion to store the result in
  82109. */
  82110. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  82111. /**
  82112. * Create a quaternion from Euler rotation angles
  82113. * @param x Pitch
  82114. * @param y Yaw
  82115. * @param z Roll
  82116. * @returns the new Quaternion
  82117. */
  82118. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  82119. /**
  82120. * Updates a quaternion from Euler rotation angles
  82121. * @param x Pitch
  82122. * @param y Yaw
  82123. * @param z Roll
  82124. * @param result the quaternion to store the result
  82125. * @returns the updated quaternion
  82126. */
  82127. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  82128. /**
  82129. * Create a quaternion from Euler rotation vector
  82130. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  82131. * @returns the new Quaternion
  82132. */
  82133. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  82134. /**
  82135. * Updates a quaternion from Euler rotation vector
  82136. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  82137. * @param result the quaternion to store the result
  82138. * @returns the updated quaternion
  82139. */
  82140. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  82141. /**
  82142. * Creates a new quaternion from the given Euler float angles (y, x, z)
  82143. * @param yaw defines the rotation around Y axis
  82144. * @param pitch defines the rotation around X axis
  82145. * @param roll defines the rotation around Z axis
  82146. * @returns the new quaternion
  82147. */
  82148. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  82149. /**
  82150. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  82151. * @param yaw defines the rotation around Y axis
  82152. * @param pitch defines the rotation around X axis
  82153. * @param roll defines the rotation around Z axis
  82154. * @param result defines the target quaternion
  82155. */
  82156. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  82157. /**
  82158. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  82159. * @param alpha defines the rotation around first axis
  82160. * @param beta defines the rotation around second axis
  82161. * @param gamma defines the rotation around third axis
  82162. * @returns the new quaternion
  82163. */
  82164. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  82165. /**
  82166. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  82167. * @param alpha defines the rotation around first axis
  82168. * @param beta defines the rotation around second axis
  82169. * @param gamma defines the rotation around third axis
  82170. * @param result defines the target quaternion
  82171. */
  82172. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  82173. /**
  82174. * 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)
  82175. * @param axis1 defines the first axis
  82176. * @param axis2 defines the second axis
  82177. * @param axis3 defines the third axis
  82178. * @returns the new quaternion
  82179. */
  82180. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  82181. /**
  82182. * 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
  82183. * @param axis1 defines the first axis
  82184. * @param axis2 defines the second axis
  82185. * @param axis3 defines the third axis
  82186. * @param ref defines the target quaternion
  82187. */
  82188. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  82189. /**
  82190. * Interpolates between two quaternions
  82191. * @param left defines first quaternion
  82192. * @param right defines second quaternion
  82193. * @param amount defines the gradient to use
  82194. * @returns the new interpolated quaternion
  82195. */
  82196. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  82197. /**
  82198. * Interpolates between two quaternions and stores it into a target quaternion
  82199. * @param left defines first quaternion
  82200. * @param right defines second quaternion
  82201. * @param amount defines the gradient to use
  82202. * @param result defines the target quaternion
  82203. */
  82204. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  82205. /**
  82206. * Interpolate between two quaternions using Hermite interpolation
  82207. * @param value1 defines first quaternion
  82208. * @param tangent1 defines the incoming tangent
  82209. * @param value2 defines second quaternion
  82210. * @param tangent2 defines the outgoing tangent
  82211. * @param amount defines the target quaternion
  82212. * @returns the new interpolated quaternion
  82213. */
  82214. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  82215. }
  82216. /**
  82217. * Class used to store matrix data (4x4)
  82218. */
  82219. export class Matrix {
  82220. private static _updateFlagSeed;
  82221. private static _identityReadOnly;
  82222. private _isIdentity;
  82223. private _isIdentityDirty;
  82224. private _isIdentity3x2;
  82225. private _isIdentity3x2Dirty;
  82226. /**
  82227. * Gets the update flag of the matrix which is an unique number for the matrix.
  82228. * It will be incremented every time the matrix data change.
  82229. * You can use it to speed the comparison between two versions of the same matrix.
  82230. */
  82231. updateFlag: number;
  82232. private readonly _m;
  82233. /**
  82234. * Gets the internal data of the matrix
  82235. */
  82236. get m(): DeepImmutable<Float32Array>;
  82237. /** @hidden */
  82238. _markAsUpdated(): void;
  82239. /** @hidden */
  82240. private _updateIdentityStatus;
  82241. /**
  82242. * Creates an empty matrix (filled with zeros)
  82243. */
  82244. constructor();
  82245. /**
  82246. * Check if the current matrix is identity
  82247. * @returns true is the matrix is the identity matrix
  82248. */
  82249. isIdentity(): boolean;
  82250. /**
  82251. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  82252. * @returns true is the matrix is the identity matrix
  82253. */
  82254. isIdentityAs3x2(): boolean;
  82255. /**
  82256. * Gets the determinant of the matrix
  82257. * @returns the matrix determinant
  82258. */
  82259. determinant(): number;
  82260. /**
  82261. * Returns the matrix as a Float32Array
  82262. * @returns the matrix underlying array
  82263. */
  82264. toArray(): DeepImmutable<Float32Array>;
  82265. /**
  82266. * Returns the matrix as a Float32Array
  82267. * @returns the matrix underlying array.
  82268. */
  82269. asArray(): DeepImmutable<Float32Array>;
  82270. /**
  82271. * Inverts the current matrix in place
  82272. * @returns the current inverted matrix
  82273. */
  82274. invert(): Matrix;
  82275. /**
  82276. * Sets all the matrix elements to zero
  82277. * @returns the current matrix
  82278. */
  82279. reset(): Matrix;
  82280. /**
  82281. * Adds the current matrix with a second one
  82282. * @param other defines the matrix to add
  82283. * @returns a new matrix as the addition of the current matrix and the given one
  82284. */
  82285. add(other: DeepImmutable<Matrix>): Matrix;
  82286. /**
  82287. * Sets the given matrix "result" to the addition of the current matrix and the given one
  82288. * @param other defines the matrix to add
  82289. * @param result defines the target matrix
  82290. * @returns the current matrix
  82291. */
  82292. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  82293. /**
  82294. * Adds in place the given matrix to the current matrix
  82295. * @param other defines the second operand
  82296. * @returns the current updated matrix
  82297. */
  82298. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  82299. /**
  82300. * Sets the given matrix to the current inverted Matrix
  82301. * @param other defines the target matrix
  82302. * @returns the unmodified current matrix
  82303. */
  82304. invertToRef(other: Matrix): Matrix;
  82305. /**
  82306. * add a value at the specified position in the current Matrix
  82307. * @param index the index of the value within the matrix. between 0 and 15.
  82308. * @param value the value to be added
  82309. * @returns the current updated matrix
  82310. */
  82311. addAtIndex(index: number, value: number): Matrix;
  82312. /**
  82313. * mutiply the specified position in the current Matrix by a value
  82314. * @param index the index of the value within the matrix. between 0 and 15.
  82315. * @param value the value to be added
  82316. * @returns the current updated matrix
  82317. */
  82318. multiplyAtIndex(index: number, value: number): Matrix;
  82319. /**
  82320. * Inserts the translation vector (using 3 floats) in the current matrix
  82321. * @param x defines the 1st component of the translation
  82322. * @param y defines the 2nd component of the translation
  82323. * @param z defines the 3rd component of the translation
  82324. * @returns the current updated matrix
  82325. */
  82326. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  82327. /**
  82328. * Adds the translation vector (using 3 floats) in the current matrix
  82329. * @param x defines the 1st component of the translation
  82330. * @param y defines the 2nd component of the translation
  82331. * @param z defines the 3rd component of the translation
  82332. * @returns the current updated matrix
  82333. */
  82334. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  82335. /**
  82336. * Inserts the translation vector in the current matrix
  82337. * @param vector3 defines the translation to insert
  82338. * @returns the current updated matrix
  82339. */
  82340. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  82341. /**
  82342. * Gets the translation value of the current matrix
  82343. * @returns a new Vector3 as the extracted translation from the matrix
  82344. */
  82345. getTranslation(): Vector3;
  82346. /**
  82347. * Fill a Vector3 with the extracted translation from the matrix
  82348. * @param result defines the Vector3 where to store the translation
  82349. * @returns the current matrix
  82350. */
  82351. getTranslationToRef(result: Vector3): Matrix;
  82352. /**
  82353. * Remove rotation and scaling part from the matrix
  82354. * @returns the updated matrix
  82355. */
  82356. removeRotationAndScaling(): Matrix;
  82357. /**
  82358. * Multiply two matrices
  82359. * @param other defines the second operand
  82360. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  82361. */
  82362. multiply(other: DeepImmutable<Matrix>): Matrix;
  82363. /**
  82364. * Copy the current matrix from the given one
  82365. * @param other defines the source matrix
  82366. * @returns the current updated matrix
  82367. */
  82368. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  82369. /**
  82370. * Populates the given array from the starting index with the current matrix values
  82371. * @param array defines the target array
  82372. * @param offset defines the offset in the target array where to start storing values
  82373. * @returns the current matrix
  82374. */
  82375. copyToArray(array: Float32Array, offset?: number): Matrix;
  82376. /**
  82377. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  82378. * @param other defines the second operand
  82379. * @param result defines the matrix where to store the multiplication
  82380. * @returns the current matrix
  82381. */
  82382. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  82383. /**
  82384. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  82385. * @param other defines the second operand
  82386. * @param result defines the array where to store the multiplication
  82387. * @param offset defines the offset in the target array where to start storing values
  82388. * @returns the current matrix
  82389. */
  82390. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  82391. /**
  82392. * Check equality between this matrix and a second one
  82393. * @param value defines the second matrix to compare
  82394. * @returns true is the current matrix and the given one values are strictly equal
  82395. */
  82396. equals(value: DeepImmutable<Matrix>): boolean;
  82397. /**
  82398. * Clone the current matrix
  82399. * @returns a new matrix from the current matrix
  82400. */
  82401. clone(): Matrix;
  82402. /**
  82403. * Returns the name of the current matrix class
  82404. * @returns the string "Matrix"
  82405. */
  82406. getClassName(): string;
  82407. /**
  82408. * Gets the hash code of the current matrix
  82409. * @returns the hash code
  82410. */
  82411. getHashCode(): number;
  82412. /**
  82413. * Decomposes the current Matrix into a translation, rotation and scaling components
  82414. * @param scale defines the scale vector3 given as a reference to update
  82415. * @param rotation defines the rotation quaternion given as a reference to update
  82416. * @param translation defines the translation vector3 given as a reference to update
  82417. * @returns true if operation was successful
  82418. */
  82419. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  82420. /**
  82421. * Gets specific row of the matrix
  82422. * @param index defines the number of the row to get
  82423. * @returns the index-th row of the current matrix as a new Vector4
  82424. */
  82425. getRow(index: number): Nullable<Vector4>;
  82426. /**
  82427. * Sets the index-th row of the current matrix to the vector4 values
  82428. * @param index defines the number of the row to set
  82429. * @param row defines the target vector4
  82430. * @returns the updated current matrix
  82431. */
  82432. setRow(index: number, row: Vector4): Matrix;
  82433. /**
  82434. * Compute the transpose of the matrix
  82435. * @returns the new transposed matrix
  82436. */
  82437. transpose(): Matrix;
  82438. /**
  82439. * Compute the transpose of the matrix and store it in a given matrix
  82440. * @param result defines the target matrix
  82441. * @returns the current matrix
  82442. */
  82443. transposeToRef(result: Matrix): Matrix;
  82444. /**
  82445. * Sets the index-th row of the current matrix with the given 4 x float values
  82446. * @param index defines the row index
  82447. * @param x defines the x component to set
  82448. * @param y defines the y component to set
  82449. * @param z defines the z component to set
  82450. * @param w defines the w component to set
  82451. * @returns the updated current matrix
  82452. */
  82453. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  82454. /**
  82455. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  82456. * @param scale defines the scale factor
  82457. * @returns a new matrix
  82458. */
  82459. scale(scale: number): Matrix;
  82460. /**
  82461. * Scale the current matrix values by a factor to a given result matrix
  82462. * @param scale defines the scale factor
  82463. * @param result defines the matrix to store the result
  82464. * @returns the current matrix
  82465. */
  82466. scaleToRef(scale: number, result: Matrix): Matrix;
  82467. /**
  82468. * Scale the current matrix values by a factor and add the result to a given matrix
  82469. * @param scale defines the scale factor
  82470. * @param result defines the Matrix to store the result
  82471. * @returns the current matrix
  82472. */
  82473. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  82474. /**
  82475. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  82476. * @param ref matrix to store the result
  82477. */
  82478. toNormalMatrix(ref: Matrix): void;
  82479. /**
  82480. * Gets only rotation part of the current matrix
  82481. * @returns a new matrix sets to the extracted rotation matrix from the current one
  82482. */
  82483. getRotationMatrix(): Matrix;
  82484. /**
  82485. * Extracts the rotation matrix from the current one and sets it as the given "result"
  82486. * @param result defines the target matrix to store data to
  82487. * @returns the current matrix
  82488. */
  82489. getRotationMatrixToRef(result: Matrix): Matrix;
  82490. /**
  82491. * Toggles model matrix from being right handed to left handed in place and vice versa
  82492. */
  82493. toggleModelMatrixHandInPlace(): void;
  82494. /**
  82495. * Toggles projection matrix from being right handed to left handed in place and vice versa
  82496. */
  82497. toggleProjectionMatrixHandInPlace(): void;
  82498. /**
  82499. * Creates a matrix from an array
  82500. * @param array defines the source array
  82501. * @param offset defines an offset in the source array
  82502. * @returns a new Matrix set from the starting index of the given array
  82503. */
  82504. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  82505. /**
  82506. * Copy the content of an array into a given matrix
  82507. * @param array defines the source array
  82508. * @param offset defines an offset in the source array
  82509. * @param result defines the target matrix
  82510. */
  82511. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  82512. /**
  82513. * Stores an array into a matrix after having multiplied each component by a given factor
  82514. * @param array defines the source array
  82515. * @param offset defines the offset in the source array
  82516. * @param scale defines the scaling factor
  82517. * @param result defines the target matrix
  82518. */
  82519. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  82520. /**
  82521. * Gets an identity matrix that must not be updated
  82522. */
  82523. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  82524. /**
  82525. * Stores a list of values (16) inside a given matrix
  82526. * @param initialM11 defines 1st value of 1st row
  82527. * @param initialM12 defines 2nd value of 1st row
  82528. * @param initialM13 defines 3rd value of 1st row
  82529. * @param initialM14 defines 4th value of 1st row
  82530. * @param initialM21 defines 1st value of 2nd row
  82531. * @param initialM22 defines 2nd value of 2nd row
  82532. * @param initialM23 defines 3rd value of 2nd row
  82533. * @param initialM24 defines 4th value of 2nd row
  82534. * @param initialM31 defines 1st value of 3rd row
  82535. * @param initialM32 defines 2nd value of 3rd row
  82536. * @param initialM33 defines 3rd value of 3rd row
  82537. * @param initialM34 defines 4th value of 3rd row
  82538. * @param initialM41 defines 1st value of 4th row
  82539. * @param initialM42 defines 2nd value of 4th row
  82540. * @param initialM43 defines 3rd value of 4th row
  82541. * @param initialM44 defines 4th value of 4th row
  82542. * @param result defines the target matrix
  82543. */
  82544. 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;
  82545. /**
  82546. * Creates new matrix from a list of values (16)
  82547. * @param initialM11 defines 1st value of 1st row
  82548. * @param initialM12 defines 2nd value of 1st row
  82549. * @param initialM13 defines 3rd value of 1st row
  82550. * @param initialM14 defines 4th value of 1st row
  82551. * @param initialM21 defines 1st value of 2nd row
  82552. * @param initialM22 defines 2nd value of 2nd row
  82553. * @param initialM23 defines 3rd value of 2nd row
  82554. * @param initialM24 defines 4th value of 2nd row
  82555. * @param initialM31 defines 1st value of 3rd row
  82556. * @param initialM32 defines 2nd value of 3rd row
  82557. * @param initialM33 defines 3rd value of 3rd row
  82558. * @param initialM34 defines 4th value of 3rd row
  82559. * @param initialM41 defines 1st value of 4th row
  82560. * @param initialM42 defines 2nd value of 4th row
  82561. * @param initialM43 defines 3rd value of 4th row
  82562. * @param initialM44 defines 4th value of 4th row
  82563. * @returns the new matrix
  82564. */
  82565. 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;
  82566. /**
  82567. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  82568. * @param scale defines the scale vector3
  82569. * @param rotation defines the rotation quaternion
  82570. * @param translation defines the translation vector3
  82571. * @returns a new matrix
  82572. */
  82573. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  82574. /**
  82575. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  82576. * @param scale defines the scale vector3
  82577. * @param rotation defines the rotation quaternion
  82578. * @param translation defines the translation vector3
  82579. * @param result defines the target matrix
  82580. */
  82581. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  82582. /**
  82583. * Creates a new identity matrix
  82584. * @returns a new identity matrix
  82585. */
  82586. static Identity(): Matrix;
  82587. /**
  82588. * Creates a new identity matrix and stores the result in a given matrix
  82589. * @param result defines the target matrix
  82590. */
  82591. static IdentityToRef(result: Matrix): void;
  82592. /**
  82593. * Creates a new zero matrix
  82594. * @returns a new zero matrix
  82595. */
  82596. static Zero(): Matrix;
  82597. /**
  82598. * Creates a new rotation matrix for "angle" radians around the X axis
  82599. * @param angle defines the angle (in radians) to use
  82600. * @return the new matrix
  82601. */
  82602. static RotationX(angle: number): Matrix;
  82603. /**
  82604. * Creates a new matrix as the invert of a given matrix
  82605. * @param source defines the source matrix
  82606. * @returns the new matrix
  82607. */
  82608. static Invert(source: DeepImmutable<Matrix>): Matrix;
  82609. /**
  82610. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  82611. * @param angle defines the angle (in radians) to use
  82612. * @param result defines the target matrix
  82613. */
  82614. static RotationXToRef(angle: number, result: Matrix): void;
  82615. /**
  82616. * Creates a new rotation matrix for "angle" radians around the Y axis
  82617. * @param angle defines the angle (in radians) to use
  82618. * @return the new matrix
  82619. */
  82620. static RotationY(angle: number): Matrix;
  82621. /**
  82622. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  82623. * @param angle defines the angle (in radians) to use
  82624. * @param result defines the target matrix
  82625. */
  82626. static RotationYToRef(angle: number, result: Matrix): void;
  82627. /**
  82628. * Creates a new rotation matrix for "angle" radians around the Z axis
  82629. * @param angle defines the angle (in radians) to use
  82630. * @return the new matrix
  82631. */
  82632. static RotationZ(angle: number): Matrix;
  82633. /**
  82634. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  82635. * @param angle defines the angle (in radians) to use
  82636. * @param result defines the target matrix
  82637. */
  82638. static RotationZToRef(angle: number, result: Matrix): void;
  82639. /**
  82640. * Creates a new rotation matrix for "angle" radians around the given axis
  82641. * @param axis defines the axis to use
  82642. * @param angle defines the angle (in radians) to use
  82643. * @return the new matrix
  82644. */
  82645. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  82646. /**
  82647. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  82648. * @param axis defines the axis to use
  82649. * @param angle defines the angle (in radians) to use
  82650. * @param result defines the target matrix
  82651. */
  82652. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  82653. /**
  82654. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  82655. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  82656. * @param from defines the vector to align
  82657. * @param to defines the vector to align to
  82658. * @param result defines the target matrix
  82659. */
  82660. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  82661. /**
  82662. * Creates a rotation matrix
  82663. * @param yaw defines the yaw angle in radians (Y axis)
  82664. * @param pitch defines the pitch angle in radians (X axis)
  82665. * @param roll defines the roll angle in radians (X axis)
  82666. * @returns the new rotation matrix
  82667. */
  82668. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  82669. /**
  82670. * Creates a rotation matrix and stores it in a given matrix
  82671. * @param yaw defines the yaw angle in radians (Y axis)
  82672. * @param pitch defines the pitch angle in radians (X axis)
  82673. * @param roll defines the roll angle in radians (X axis)
  82674. * @param result defines the target matrix
  82675. */
  82676. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  82677. /**
  82678. * Creates a scaling matrix
  82679. * @param x defines the scale factor on X axis
  82680. * @param y defines the scale factor on Y axis
  82681. * @param z defines the scale factor on Z axis
  82682. * @returns the new matrix
  82683. */
  82684. static Scaling(x: number, y: number, z: number): Matrix;
  82685. /**
  82686. * Creates a scaling matrix and stores it in a given matrix
  82687. * @param x defines the scale factor on X axis
  82688. * @param y defines the scale factor on Y axis
  82689. * @param z defines the scale factor on Z axis
  82690. * @param result defines the target matrix
  82691. */
  82692. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  82693. /**
  82694. * Creates a translation matrix
  82695. * @param x defines the translation on X axis
  82696. * @param y defines the translation on Y axis
  82697. * @param z defines the translationon Z axis
  82698. * @returns the new matrix
  82699. */
  82700. static Translation(x: number, y: number, z: number): Matrix;
  82701. /**
  82702. * Creates a translation matrix and stores it in a given matrix
  82703. * @param x defines the translation on X axis
  82704. * @param y defines the translation on Y axis
  82705. * @param z defines the translationon Z axis
  82706. * @param result defines the target matrix
  82707. */
  82708. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  82709. /**
  82710. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  82711. * @param startValue defines the start value
  82712. * @param endValue defines the end value
  82713. * @param gradient defines the gradient factor
  82714. * @returns the new matrix
  82715. */
  82716. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  82717. /**
  82718. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  82719. * @param startValue defines the start value
  82720. * @param endValue defines the end value
  82721. * @param gradient defines the gradient factor
  82722. * @param result defines the Matrix object where to store data
  82723. */
  82724. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  82725. /**
  82726. * Builds a new matrix whose values are computed by:
  82727. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  82728. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  82729. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  82730. * @param startValue defines the first matrix
  82731. * @param endValue defines the second matrix
  82732. * @param gradient defines the gradient between the two matrices
  82733. * @returns the new matrix
  82734. */
  82735. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  82736. /**
  82737. * Update a matrix to values which are computed by:
  82738. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  82739. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  82740. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  82741. * @param startValue defines the first matrix
  82742. * @param endValue defines the second matrix
  82743. * @param gradient defines the gradient between the two matrices
  82744. * @param result defines the target matrix
  82745. */
  82746. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  82747. /**
  82748. * 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"
  82749. * This function works in left handed mode
  82750. * @param eye defines the final position of the entity
  82751. * @param target defines where the entity should look at
  82752. * @param up defines the up vector for the entity
  82753. * @returns the new matrix
  82754. */
  82755. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  82756. /**
  82757. * 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".
  82758. * This function works in left handed mode
  82759. * @param eye defines the final position of the entity
  82760. * @param target defines where the entity should look at
  82761. * @param up defines the up vector for the entity
  82762. * @param result defines the target matrix
  82763. */
  82764. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  82765. /**
  82766. * 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"
  82767. * This function works in right handed mode
  82768. * @param eye defines the final position of the entity
  82769. * @param target defines where the entity should look at
  82770. * @param up defines the up vector for the entity
  82771. * @returns the new matrix
  82772. */
  82773. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  82774. /**
  82775. * 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".
  82776. * This function works in right handed mode
  82777. * @param eye defines the final position of the entity
  82778. * @param target defines where the entity should look at
  82779. * @param up defines the up vector for the entity
  82780. * @param result defines the target matrix
  82781. */
  82782. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  82783. /**
  82784. * Create a left-handed orthographic projection matrix
  82785. * @param width defines the viewport width
  82786. * @param height defines the viewport height
  82787. * @param znear defines the near clip plane
  82788. * @param zfar defines the far clip plane
  82789. * @returns a new matrix as a left-handed orthographic projection matrix
  82790. */
  82791. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  82792. /**
  82793. * Store a left-handed orthographic projection to a given matrix
  82794. * @param width defines the viewport width
  82795. * @param height defines the viewport height
  82796. * @param znear defines the near clip plane
  82797. * @param zfar defines the far clip plane
  82798. * @param result defines the target matrix
  82799. */
  82800. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  82801. /**
  82802. * Create a left-handed orthographic projection matrix
  82803. * @param left defines the viewport left coordinate
  82804. * @param right defines the viewport right coordinate
  82805. * @param bottom defines the viewport bottom coordinate
  82806. * @param top defines the viewport top coordinate
  82807. * @param znear defines the near clip plane
  82808. * @param zfar defines the far clip plane
  82809. * @returns a new matrix as a left-handed orthographic projection matrix
  82810. */
  82811. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  82812. /**
  82813. * Stores a left-handed orthographic projection into a given matrix
  82814. * @param left defines the viewport left coordinate
  82815. * @param right defines the viewport right coordinate
  82816. * @param bottom defines the viewport bottom coordinate
  82817. * @param top defines the viewport top coordinate
  82818. * @param znear defines the near clip plane
  82819. * @param zfar defines the far clip plane
  82820. * @param result defines the target matrix
  82821. */
  82822. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  82823. /**
  82824. * Creates a right-handed orthographic projection matrix
  82825. * @param left defines the viewport left coordinate
  82826. * @param right defines the viewport right coordinate
  82827. * @param bottom defines the viewport bottom coordinate
  82828. * @param top defines the viewport top coordinate
  82829. * @param znear defines the near clip plane
  82830. * @param zfar defines the far clip plane
  82831. * @returns a new matrix as a right-handed orthographic projection matrix
  82832. */
  82833. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  82834. /**
  82835. * Stores a right-handed orthographic projection into a given matrix
  82836. * @param left defines the viewport left coordinate
  82837. * @param right defines the viewport right coordinate
  82838. * @param bottom defines the viewport bottom coordinate
  82839. * @param top defines the viewport top coordinate
  82840. * @param znear defines the near clip plane
  82841. * @param zfar defines the far clip plane
  82842. * @param result defines the target matrix
  82843. */
  82844. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  82845. /**
  82846. * Creates a left-handed perspective projection matrix
  82847. * @param width defines the viewport width
  82848. * @param height defines the viewport height
  82849. * @param znear defines the near clip plane
  82850. * @param zfar defines the far clip plane
  82851. * @returns a new matrix as a left-handed perspective projection matrix
  82852. */
  82853. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  82854. /**
  82855. * Creates a left-handed perspective projection matrix
  82856. * @param fov defines the horizontal field of view
  82857. * @param aspect defines the aspect ratio
  82858. * @param znear defines the near clip plane
  82859. * @param zfar defines the far clip plane
  82860. * @returns a new matrix as a left-handed perspective projection matrix
  82861. */
  82862. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  82863. /**
  82864. * Stores a left-handed perspective projection into a given matrix
  82865. * @param fov defines the horizontal field of view
  82866. * @param aspect defines the aspect ratio
  82867. * @param znear defines the near clip plane
  82868. * @param zfar defines the far clip plane
  82869. * @param result defines the target matrix
  82870. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82871. */
  82872. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82873. /**
  82874. * Stores a left-handed perspective projection into a given matrix with depth reversed
  82875. * @param fov defines the horizontal field of view
  82876. * @param aspect defines the aspect ratio
  82877. * @param znear defines the near clip plane
  82878. * @param zfar not used as infinity is used as far clip
  82879. * @param result defines the target matrix
  82880. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82881. */
  82882. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82883. /**
  82884. * Creates a right-handed perspective projection matrix
  82885. * @param fov defines the horizontal field of view
  82886. * @param aspect defines the aspect ratio
  82887. * @param znear defines the near clip plane
  82888. * @param zfar defines the far clip plane
  82889. * @returns a new matrix as a right-handed perspective projection matrix
  82890. */
  82891. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  82892. /**
  82893. * Stores a right-handed perspective projection into a given matrix
  82894. * @param fov defines the horizontal field of view
  82895. * @param aspect defines the aspect ratio
  82896. * @param znear defines the near clip plane
  82897. * @param zfar defines the far clip plane
  82898. * @param result defines the target matrix
  82899. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82900. */
  82901. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82902. /**
  82903. * Stores a right-handed perspective projection into a given matrix
  82904. * @param fov defines the horizontal field of view
  82905. * @param aspect defines the aspect ratio
  82906. * @param znear defines the near clip plane
  82907. * @param zfar not used as infinity is used as far clip
  82908. * @param result defines the target matrix
  82909. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82910. */
  82911. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82912. /**
  82913. * Stores a perspective projection for WebVR info a given matrix
  82914. * @param fov defines the field of view
  82915. * @param znear defines the near clip plane
  82916. * @param zfar defines the far clip plane
  82917. * @param result defines the target matrix
  82918. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  82919. */
  82920. static PerspectiveFovWebVRToRef(fov: {
  82921. upDegrees: number;
  82922. downDegrees: number;
  82923. leftDegrees: number;
  82924. rightDegrees: number;
  82925. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  82926. /**
  82927. * Computes a complete transformation matrix
  82928. * @param viewport defines the viewport to use
  82929. * @param world defines the world matrix
  82930. * @param view defines the view matrix
  82931. * @param projection defines the projection matrix
  82932. * @param zmin defines the near clip plane
  82933. * @param zmax defines the far clip plane
  82934. * @returns the transformation matrix
  82935. */
  82936. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  82937. /**
  82938. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  82939. * @param matrix defines the matrix to use
  82940. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  82941. */
  82942. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  82943. /**
  82944. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  82945. * @param matrix defines the matrix to use
  82946. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  82947. */
  82948. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  82949. /**
  82950. * Compute the transpose of a given matrix
  82951. * @param matrix defines the matrix to transpose
  82952. * @returns the new matrix
  82953. */
  82954. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  82955. /**
  82956. * Compute the transpose of a matrix and store it in a target matrix
  82957. * @param matrix defines the matrix to transpose
  82958. * @param result defines the target matrix
  82959. */
  82960. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  82961. /**
  82962. * Computes a reflection matrix from a plane
  82963. * @param plane defines the reflection plane
  82964. * @returns a new matrix
  82965. */
  82966. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  82967. /**
  82968. * Computes a reflection matrix from a plane
  82969. * @param plane defines the reflection plane
  82970. * @param result defines the target matrix
  82971. */
  82972. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  82973. /**
  82974. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  82975. * @param xaxis defines the value of the 1st axis
  82976. * @param yaxis defines the value of the 2nd axis
  82977. * @param zaxis defines the value of the 3rd axis
  82978. * @param result defines the target matrix
  82979. */
  82980. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  82981. /**
  82982. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  82983. * @param quat defines the quaternion to use
  82984. * @param result defines the target matrix
  82985. */
  82986. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  82987. }
  82988. /**
  82989. * @hidden
  82990. */
  82991. export class TmpVectors {
  82992. static Vector2: Vector2[];
  82993. static Vector3: Vector3[];
  82994. static Vector4: Vector4[];
  82995. static Quaternion: Quaternion[];
  82996. static Matrix: Matrix[];
  82997. }
  82998. }
  82999. declare module BABYLON {
  83000. /**
  83001. * Defines potential orientation for back face culling
  83002. */
  83003. export enum Orientation {
  83004. /**
  83005. * Clockwise
  83006. */
  83007. CW = 0,
  83008. /** Counter clockwise */
  83009. CCW = 1
  83010. }
  83011. /** Class used to represent a Bezier curve */
  83012. export class BezierCurve {
  83013. /**
  83014. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  83015. * @param t defines the time
  83016. * @param x1 defines the left coordinate on X axis
  83017. * @param y1 defines the left coordinate on Y axis
  83018. * @param x2 defines the right coordinate on X axis
  83019. * @param y2 defines the right coordinate on Y axis
  83020. * @returns the interpolated value
  83021. */
  83022. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  83023. }
  83024. /**
  83025. * Defines angle representation
  83026. */
  83027. export class Angle {
  83028. private _radians;
  83029. /**
  83030. * Creates an Angle object of "radians" radians (float).
  83031. * @param radians the angle in radians
  83032. */
  83033. constructor(radians: number);
  83034. /**
  83035. * Get value in degrees
  83036. * @returns the Angle value in degrees (float)
  83037. */
  83038. degrees(): number;
  83039. /**
  83040. * Get value in radians
  83041. * @returns the Angle value in radians (float)
  83042. */
  83043. radians(): number;
  83044. /**
  83045. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  83046. * @param a defines first vector
  83047. * @param b defines second vector
  83048. * @returns a new Angle
  83049. */
  83050. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  83051. /**
  83052. * Gets a new Angle object from the given float in radians
  83053. * @param radians defines the angle value in radians
  83054. * @returns a new Angle
  83055. */
  83056. static FromRadians(radians: number): Angle;
  83057. /**
  83058. * Gets a new Angle object from the given float in degrees
  83059. * @param degrees defines the angle value in degrees
  83060. * @returns a new Angle
  83061. */
  83062. static FromDegrees(degrees: number): Angle;
  83063. }
  83064. /**
  83065. * This represents an arc in a 2d space.
  83066. */
  83067. export class Arc2 {
  83068. /** Defines the start point of the arc */
  83069. startPoint: Vector2;
  83070. /** Defines the mid point of the arc */
  83071. midPoint: Vector2;
  83072. /** Defines the end point of the arc */
  83073. endPoint: Vector2;
  83074. /**
  83075. * Defines the center point of the arc.
  83076. */
  83077. centerPoint: Vector2;
  83078. /**
  83079. * Defines the radius of the arc.
  83080. */
  83081. radius: number;
  83082. /**
  83083. * Defines the angle of the arc (from mid point to end point).
  83084. */
  83085. angle: Angle;
  83086. /**
  83087. * Defines the start angle of the arc (from start point to middle point).
  83088. */
  83089. startAngle: Angle;
  83090. /**
  83091. * Defines the orientation of the arc (clock wise/counter clock wise).
  83092. */
  83093. orientation: Orientation;
  83094. /**
  83095. * Creates an Arc object from the three given points : start, middle and end.
  83096. * @param startPoint Defines the start point of the arc
  83097. * @param midPoint Defines the midlle point of the arc
  83098. * @param endPoint Defines the end point of the arc
  83099. */
  83100. constructor(
  83101. /** Defines the start point of the arc */
  83102. startPoint: Vector2,
  83103. /** Defines the mid point of the arc */
  83104. midPoint: Vector2,
  83105. /** Defines the end point of the arc */
  83106. endPoint: Vector2);
  83107. }
  83108. /**
  83109. * Represents a 2D path made up of multiple 2D points
  83110. */
  83111. export class Path2 {
  83112. private _points;
  83113. private _length;
  83114. /**
  83115. * If the path start and end point are the same
  83116. */
  83117. closed: boolean;
  83118. /**
  83119. * Creates a Path2 object from the starting 2D coordinates x and y.
  83120. * @param x the starting points x value
  83121. * @param y the starting points y value
  83122. */
  83123. constructor(x: number, y: number);
  83124. /**
  83125. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  83126. * @param x the added points x value
  83127. * @param y the added points y value
  83128. * @returns the updated Path2.
  83129. */
  83130. addLineTo(x: number, y: number): Path2;
  83131. /**
  83132. * 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.
  83133. * @param midX middle point x value
  83134. * @param midY middle point y value
  83135. * @param endX end point x value
  83136. * @param endY end point y value
  83137. * @param numberOfSegments (default: 36)
  83138. * @returns the updated Path2.
  83139. */
  83140. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  83141. /**
  83142. * Closes the Path2.
  83143. * @returns the Path2.
  83144. */
  83145. close(): Path2;
  83146. /**
  83147. * Gets the sum of the distance between each sequential point in the path
  83148. * @returns the Path2 total length (float).
  83149. */
  83150. length(): number;
  83151. /**
  83152. * Gets the points which construct the path
  83153. * @returns the Path2 internal array of points.
  83154. */
  83155. getPoints(): Vector2[];
  83156. /**
  83157. * Retreives the point at the distance aways from the starting point
  83158. * @param normalizedLengthPosition the length along the path to retreive the point from
  83159. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  83160. */
  83161. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  83162. /**
  83163. * Creates a new path starting from an x and y position
  83164. * @param x starting x value
  83165. * @param y starting y value
  83166. * @returns a new Path2 starting at the coordinates (x, y).
  83167. */
  83168. static StartingAt(x: number, y: number): Path2;
  83169. }
  83170. /**
  83171. * Represents a 3D path made up of multiple 3D points
  83172. */
  83173. export class Path3D {
  83174. /**
  83175. * an array of Vector3, the curve axis of the Path3D
  83176. */
  83177. path: Vector3[];
  83178. private _curve;
  83179. private _distances;
  83180. private _tangents;
  83181. private _normals;
  83182. private _binormals;
  83183. private _raw;
  83184. private _alignTangentsWithPath;
  83185. private readonly _pointAtData;
  83186. /**
  83187. * new Path3D(path, normal, raw)
  83188. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  83189. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  83190. * @param path an array of Vector3, the curve axis of the Path3D
  83191. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  83192. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  83193. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  83194. */
  83195. constructor(
  83196. /**
  83197. * an array of Vector3, the curve axis of the Path3D
  83198. */
  83199. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  83200. /**
  83201. * Returns the Path3D array of successive Vector3 designing its curve.
  83202. * @returns the Path3D array of successive Vector3 designing its curve.
  83203. */
  83204. getCurve(): Vector3[];
  83205. /**
  83206. * Returns the Path3D array of successive Vector3 designing its curve.
  83207. * @returns the Path3D array of successive Vector3 designing its curve.
  83208. */
  83209. getPoints(): Vector3[];
  83210. /**
  83211. * @returns the computed length (float) of the path.
  83212. */
  83213. length(): number;
  83214. /**
  83215. * Returns an array populated with tangent vectors on each Path3D curve point.
  83216. * @returns an array populated with tangent vectors on each Path3D curve point.
  83217. */
  83218. getTangents(): Vector3[];
  83219. /**
  83220. * Returns an array populated with normal vectors on each Path3D curve point.
  83221. * @returns an array populated with normal vectors on each Path3D curve point.
  83222. */
  83223. getNormals(): Vector3[];
  83224. /**
  83225. * Returns an array populated with binormal vectors on each Path3D curve point.
  83226. * @returns an array populated with binormal vectors on each Path3D curve point.
  83227. */
  83228. getBinormals(): Vector3[];
  83229. /**
  83230. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  83231. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  83232. */
  83233. getDistances(): number[];
  83234. /**
  83235. * Returns an interpolated point along this path
  83236. * @param position the position of the point along this path, from 0.0 to 1.0
  83237. * @returns a new Vector3 as the point
  83238. */
  83239. getPointAt(position: number): Vector3;
  83240. /**
  83241. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  83242. * @param position the position of the point along this path, from 0.0 to 1.0
  83243. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  83244. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  83245. */
  83246. getTangentAt(position: number, interpolated?: boolean): Vector3;
  83247. /**
  83248. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  83249. * @param position the position of the point along this path, from 0.0 to 1.0
  83250. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  83251. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  83252. */
  83253. getNormalAt(position: number, interpolated?: boolean): Vector3;
  83254. /**
  83255. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  83256. * @param position the position of the point along this path, from 0.0 to 1.0
  83257. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  83258. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  83259. */
  83260. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  83261. /**
  83262. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  83263. * @param position the position of the point along this path, from 0.0 to 1.0
  83264. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  83265. */
  83266. getDistanceAt(position: number): number;
  83267. /**
  83268. * Returns the array index of the previous point of an interpolated point along this path
  83269. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  83270. * @returns the array index
  83271. */
  83272. getPreviousPointIndexAt(position: number): number;
  83273. /**
  83274. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  83275. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  83276. * @returns the sub position
  83277. */
  83278. getSubPositionAt(position: number): number;
  83279. /**
  83280. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  83281. * @param target the vector of which to get the closest position to
  83282. * @returns the position of the closest virtual point on this path to the target vector
  83283. */
  83284. getClosestPositionTo(target: Vector3): number;
  83285. /**
  83286. * Returns a sub path (slice) of this path
  83287. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  83288. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  83289. * @returns a sub path (slice) of this path
  83290. */
  83291. slice(start?: number, end?: number): Path3D;
  83292. /**
  83293. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  83294. * @param path path which all values are copied into the curves points
  83295. * @param firstNormal which should be projected onto the curve
  83296. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  83297. * @returns the same object updated.
  83298. */
  83299. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  83300. private _compute;
  83301. private _getFirstNonNullVector;
  83302. private _getLastNonNullVector;
  83303. private _normalVector;
  83304. /**
  83305. * Updates the point at data for an interpolated point along this curve
  83306. * @param position the position of the point along this curve, from 0.0 to 1.0
  83307. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  83308. * @returns the (updated) point at data
  83309. */
  83310. private _updatePointAtData;
  83311. /**
  83312. * Updates the point at data from the specified parameters
  83313. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  83314. * @param point the interpolated point
  83315. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  83316. */
  83317. private _setPointAtData;
  83318. /**
  83319. * Updates the point at interpolation matrix for the tangents, normals and binormals
  83320. */
  83321. private _updateInterpolationMatrix;
  83322. }
  83323. /**
  83324. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  83325. * A Curve3 is designed from a series of successive Vector3.
  83326. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  83327. */
  83328. export class Curve3 {
  83329. private _points;
  83330. private _length;
  83331. /**
  83332. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  83333. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  83334. * @param v1 (Vector3) the control point
  83335. * @param v2 (Vector3) the end point of the Quadratic Bezier
  83336. * @param nbPoints (integer) the wanted number of points in the curve
  83337. * @returns the created Curve3
  83338. */
  83339. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  83340. /**
  83341. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  83342. * @param v0 (Vector3) the origin point of the Cubic Bezier
  83343. * @param v1 (Vector3) the first control point
  83344. * @param v2 (Vector3) the second control point
  83345. * @param v3 (Vector3) the end point of the Cubic Bezier
  83346. * @param nbPoints (integer) the wanted number of points in the curve
  83347. * @returns the created Curve3
  83348. */
  83349. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  83350. /**
  83351. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  83352. * @param p1 (Vector3) the origin point of the Hermite Spline
  83353. * @param t1 (Vector3) the tangent vector at the origin point
  83354. * @param p2 (Vector3) the end point of the Hermite Spline
  83355. * @param t2 (Vector3) the tangent vector at the end point
  83356. * @param nbPoints (integer) the wanted number of points in the curve
  83357. * @returns the created Curve3
  83358. */
  83359. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  83360. /**
  83361. * Returns a Curve3 object along a CatmullRom Spline curve :
  83362. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  83363. * @param nbPoints (integer) the wanted number of points between each curve control points
  83364. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  83365. * @returns the created Curve3
  83366. */
  83367. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  83368. /**
  83369. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  83370. * A Curve3 is designed from a series of successive Vector3.
  83371. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  83372. * @param points points which make up the curve
  83373. */
  83374. constructor(points: Vector3[]);
  83375. /**
  83376. * @returns the Curve3 stored array of successive Vector3
  83377. */
  83378. getPoints(): Vector3[];
  83379. /**
  83380. * @returns the computed length (float) of the curve.
  83381. */
  83382. length(): number;
  83383. /**
  83384. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  83385. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  83386. * curveA and curveB keep unchanged.
  83387. * @param curve the curve to continue from this curve
  83388. * @returns the newly constructed curve
  83389. */
  83390. continue(curve: DeepImmutable<Curve3>): Curve3;
  83391. private _computeLength;
  83392. }
  83393. }
  83394. declare module BABYLON {
  83395. /**
  83396. * This represents the main contract an easing function should follow.
  83397. * Easing functions are used throughout the animation system.
  83398. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83399. */
  83400. export interface IEasingFunction {
  83401. /**
  83402. * Given an input gradient between 0 and 1, this returns the corrseponding value
  83403. * of the easing function.
  83404. * The link below provides some of the most common examples of easing functions.
  83405. * @see https://easings.net/
  83406. * @param gradient Defines the value between 0 and 1 we want the easing value for
  83407. * @returns the corresponding value on the curve defined by the easing function
  83408. */
  83409. ease(gradient: number): number;
  83410. }
  83411. /**
  83412. * Base class used for every default easing function.
  83413. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83414. */
  83415. export class EasingFunction implements IEasingFunction {
  83416. /**
  83417. * Interpolation follows the mathematical formula associated with the easing function.
  83418. */
  83419. static readonly EASINGMODE_EASEIN: number;
  83420. /**
  83421. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  83422. */
  83423. static readonly EASINGMODE_EASEOUT: number;
  83424. /**
  83425. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  83426. */
  83427. static readonly EASINGMODE_EASEINOUT: number;
  83428. private _easingMode;
  83429. /**
  83430. * Sets the easing mode of the current function.
  83431. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  83432. */
  83433. setEasingMode(easingMode: number): void;
  83434. /**
  83435. * Gets the current easing mode.
  83436. * @returns the easing mode
  83437. */
  83438. getEasingMode(): number;
  83439. /**
  83440. * @hidden
  83441. */
  83442. easeInCore(gradient: number): number;
  83443. /**
  83444. * Given an input gradient between 0 and 1, this returns the corresponding value
  83445. * of the easing function.
  83446. * @param gradient Defines the value between 0 and 1 we want the easing value for
  83447. * @returns the corresponding value on the curve defined by the easing function
  83448. */
  83449. ease(gradient: number): number;
  83450. }
  83451. /**
  83452. * Easing function with a circle shape (see link below).
  83453. * @see https://easings.net/#easeInCirc
  83454. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83455. */
  83456. export class CircleEase extends EasingFunction implements IEasingFunction {
  83457. /** @hidden */
  83458. easeInCore(gradient: number): number;
  83459. }
  83460. /**
  83461. * Easing function with a ease back shape (see link below).
  83462. * @see https://easings.net/#easeInBack
  83463. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83464. */
  83465. export class BackEase extends EasingFunction implements IEasingFunction {
  83466. /** Defines the amplitude of the function */
  83467. amplitude: number;
  83468. /**
  83469. * Instantiates a back ease easing
  83470. * @see https://easings.net/#easeInBack
  83471. * @param amplitude Defines the amplitude of the function
  83472. */
  83473. constructor(
  83474. /** Defines the amplitude of the function */
  83475. amplitude?: number);
  83476. /** @hidden */
  83477. easeInCore(gradient: number): number;
  83478. }
  83479. /**
  83480. * Easing function with a bouncing shape (see link below).
  83481. * @see https://easings.net/#easeInBounce
  83482. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83483. */
  83484. export class BounceEase extends EasingFunction implements IEasingFunction {
  83485. /** Defines the number of bounces */
  83486. bounces: number;
  83487. /** Defines the amplitude of the bounce */
  83488. bounciness: number;
  83489. /**
  83490. * Instantiates a bounce easing
  83491. * @see https://easings.net/#easeInBounce
  83492. * @param bounces Defines the number of bounces
  83493. * @param bounciness Defines the amplitude of the bounce
  83494. */
  83495. constructor(
  83496. /** Defines the number of bounces */
  83497. bounces?: number,
  83498. /** Defines the amplitude of the bounce */
  83499. bounciness?: number);
  83500. /** @hidden */
  83501. easeInCore(gradient: number): number;
  83502. }
  83503. /**
  83504. * Easing function with a power of 3 shape (see link below).
  83505. * @see https://easings.net/#easeInCubic
  83506. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83507. */
  83508. export class CubicEase extends EasingFunction implements IEasingFunction {
  83509. /** @hidden */
  83510. easeInCore(gradient: number): number;
  83511. }
  83512. /**
  83513. * Easing function with an elastic shape (see link below).
  83514. * @see https://easings.net/#easeInElastic
  83515. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83516. */
  83517. export class ElasticEase extends EasingFunction implements IEasingFunction {
  83518. /** Defines the number of oscillations*/
  83519. oscillations: number;
  83520. /** Defines the amplitude of the oscillations*/
  83521. springiness: number;
  83522. /**
  83523. * Instantiates an elastic easing function
  83524. * @see https://easings.net/#easeInElastic
  83525. * @param oscillations Defines the number of oscillations
  83526. * @param springiness Defines the amplitude of the oscillations
  83527. */
  83528. constructor(
  83529. /** Defines the number of oscillations*/
  83530. oscillations?: number,
  83531. /** Defines the amplitude of the oscillations*/
  83532. springiness?: number);
  83533. /** @hidden */
  83534. easeInCore(gradient: number): number;
  83535. }
  83536. /**
  83537. * Easing function with an exponential shape (see link below).
  83538. * @see https://easings.net/#easeInExpo
  83539. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83540. */
  83541. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  83542. /** Defines the exponent of the function */
  83543. exponent: number;
  83544. /**
  83545. * Instantiates an exponential easing function
  83546. * @see https://easings.net/#easeInExpo
  83547. * @param exponent Defines the exponent of the function
  83548. */
  83549. constructor(
  83550. /** Defines the exponent of the function */
  83551. exponent?: number);
  83552. /** @hidden */
  83553. easeInCore(gradient: number): number;
  83554. }
  83555. /**
  83556. * Easing function with a power shape (see link below).
  83557. * @see https://easings.net/#easeInQuad
  83558. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83559. */
  83560. export class PowerEase extends EasingFunction implements IEasingFunction {
  83561. /** Defines the power of the function */
  83562. power: number;
  83563. /**
  83564. * Instantiates an power base easing function
  83565. * @see https://easings.net/#easeInQuad
  83566. * @param power Defines the power of the function
  83567. */
  83568. constructor(
  83569. /** Defines the power of the function */
  83570. power?: number);
  83571. /** @hidden */
  83572. easeInCore(gradient: number): number;
  83573. }
  83574. /**
  83575. * Easing function with a power of 2 shape (see link below).
  83576. * @see https://easings.net/#easeInQuad
  83577. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83578. */
  83579. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  83580. /** @hidden */
  83581. easeInCore(gradient: number): number;
  83582. }
  83583. /**
  83584. * Easing function with a power of 4 shape (see link below).
  83585. * @see https://easings.net/#easeInQuart
  83586. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83587. */
  83588. export class QuarticEase extends EasingFunction implements IEasingFunction {
  83589. /** @hidden */
  83590. easeInCore(gradient: number): number;
  83591. }
  83592. /**
  83593. * Easing function with a power of 5 shape (see link below).
  83594. * @see https://easings.net/#easeInQuint
  83595. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83596. */
  83597. export class QuinticEase extends EasingFunction implements IEasingFunction {
  83598. /** @hidden */
  83599. easeInCore(gradient: number): number;
  83600. }
  83601. /**
  83602. * Easing function with a sin shape (see link below).
  83603. * @see https://easings.net/#easeInSine
  83604. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83605. */
  83606. export class SineEase extends EasingFunction implements IEasingFunction {
  83607. /** @hidden */
  83608. easeInCore(gradient: number): number;
  83609. }
  83610. /**
  83611. * Easing function with a bezier shape (see link below).
  83612. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  83613. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83614. */
  83615. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  83616. /** Defines the x component of the start tangent in the bezier curve */
  83617. x1: number;
  83618. /** Defines the y component of the start tangent in the bezier curve */
  83619. y1: number;
  83620. /** Defines the x component of the end tangent in the bezier curve */
  83621. x2: number;
  83622. /** Defines the y component of the end tangent in the bezier curve */
  83623. y2: number;
  83624. /**
  83625. * Instantiates a bezier function
  83626. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  83627. * @param x1 Defines the x component of the start tangent in the bezier curve
  83628. * @param y1 Defines the y component of the start tangent in the bezier curve
  83629. * @param x2 Defines the x component of the end tangent in the bezier curve
  83630. * @param y2 Defines the y component of the end tangent in the bezier curve
  83631. */
  83632. constructor(
  83633. /** Defines the x component of the start tangent in the bezier curve */
  83634. x1?: number,
  83635. /** Defines the y component of the start tangent in the bezier curve */
  83636. y1?: number,
  83637. /** Defines the x component of the end tangent in the bezier curve */
  83638. x2?: number,
  83639. /** Defines the y component of the end tangent in the bezier curve */
  83640. y2?: number);
  83641. /** @hidden */
  83642. easeInCore(gradient: number): number;
  83643. }
  83644. }
  83645. declare module BABYLON {
  83646. /**
  83647. * Class used to hold a RBG color
  83648. */
  83649. export class Color3 {
  83650. /**
  83651. * Defines the red component (between 0 and 1, default is 0)
  83652. */
  83653. r: number;
  83654. /**
  83655. * Defines the green component (between 0 and 1, default is 0)
  83656. */
  83657. g: number;
  83658. /**
  83659. * Defines the blue component (between 0 and 1, default is 0)
  83660. */
  83661. b: number;
  83662. /**
  83663. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  83664. * @param r defines the red component (between 0 and 1, default is 0)
  83665. * @param g defines the green component (between 0 and 1, default is 0)
  83666. * @param b defines the blue component (between 0 and 1, default is 0)
  83667. */
  83668. constructor(
  83669. /**
  83670. * Defines the red component (between 0 and 1, default is 0)
  83671. */
  83672. r?: number,
  83673. /**
  83674. * Defines the green component (between 0 and 1, default is 0)
  83675. */
  83676. g?: number,
  83677. /**
  83678. * Defines the blue component (between 0 and 1, default is 0)
  83679. */
  83680. b?: number);
  83681. /**
  83682. * Creates a string with the Color3 current values
  83683. * @returns the string representation of the Color3 object
  83684. */
  83685. toString(): string;
  83686. /**
  83687. * Returns the string "Color3"
  83688. * @returns "Color3"
  83689. */
  83690. getClassName(): string;
  83691. /**
  83692. * Compute the Color3 hash code
  83693. * @returns an unique number that can be used to hash Color3 objects
  83694. */
  83695. getHashCode(): number;
  83696. /**
  83697. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  83698. * @param array defines the array where to store the r,g,b components
  83699. * @param index defines an optional index in the target array to define where to start storing values
  83700. * @returns the current Color3 object
  83701. */
  83702. toArray(array: FloatArray, index?: number): Color3;
  83703. /**
  83704. * Returns a new Color4 object from the current Color3 and the given alpha
  83705. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  83706. * @returns a new Color4 object
  83707. */
  83708. toColor4(alpha?: number): Color4;
  83709. /**
  83710. * Returns a new array populated with 3 numeric elements : red, green and blue values
  83711. * @returns the new array
  83712. */
  83713. asArray(): number[];
  83714. /**
  83715. * Returns the luminance value
  83716. * @returns a float value
  83717. */
  83718. toLuminance(): number;
  83719. /**
  83720. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  83721. * @param otherColor defines the second operand
  83722. * @returns the new Color3 object
  83723. */
  83724. multiply(otherColor: DeepImmutable<Color3>): Color3;
  83725. /**
  83726. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  83727. * @param otherColor defines the second operand
  83728. * @param result defines the Color3 object where to store the result
  83729. * @returns the current Color3
  83730. */
  83731. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83732. /**
  83733. * Determines equality between Color3 objects
  83734. * @param otherColor defines the second operand
  83735. * @returns true if the rgb values are equal to the given ones
  83736. */
  83737. equals(otherColor: DeepImmutable<Color3>): boolean;
  83738. /**
  83739. * Determines equality between the current Color3 object and a set of r,b,g values
  83740. * @param r defines the red component to check
  83741. * @param g defines the green component to check
  83742. * @param b defines the blue component to check
  83743. * @returns true if the rgb values are equal to the given ones
  83744. */
  83745. equalsFloats(r: number, g: number, b: number): boolean;
  83746. /**
  83747. * Multiplies in place each rgb value by scale
  83748. * @param scale defines the scaling factor
  83749. * @returns the updated Color3
  83750. */
  83751. scale(scale: number): Color3;
  83752. /**
  83753. * Multiplies the rgb values by scale and stores the result into "result"
  83754. * @param scale defines the scaling factor
  83755. * @param result defines the Color3 object where to store the result
  83756. * @returns the unmodified current Color3
  83757. */
  83758. scaleToRef(scale: number, result: Color3): Color3;
  83759. /**
  83760. * Scale the current Color3 values by a factor and add the result to a given Color3
  83761. * @param scale defines the scale factor
  83762. * @param result defines color to store the result into
  83763. * @returns the unmodified current Color3
  83764. */
  83765. scaleAndAddToRef(scale: number, result: Color3): Color3;
  83766. /**
  83767. * Clamps the rgb values by the min and max values and stores the result into "result"
  83768. * @param min defines minimum clamping value (default is 0)
  83769. * @param max defines maximum clamping value (default is 1)
  83770. * @param result defines color to store the result into
  83771. * @returns the original Color3
  83772. */
  83773. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  83774. /**
  83775. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  83776. * @param otherColor defines the second operand
  83777. * @returns the new Color3
  83778. */
  83779. add(otherColor: DeepImmutable<Color3>): Color3;
  83780. /**
  83781. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  83782. * @param otherColor defines the second operand
  83783. * @param result defines Color3 object to store the result into
  83784. * @returns the unmodified current Color3
  83785. */
  83786. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83787. /**
  83788. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  83789. * @param otherColor defines the second operand
  83790. * @returns the new Color3
  83791. */
  83792. subtract(otherColor: DeepImmutable<Color3>): Color3;
  83793. /**
  83794. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  83795. * @param otherColor defines the second operand
  83796. * @param result defines Color3 object to store the result into
  83797. * @returns the unmodified current Color3
  83798. */
  83799. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83800. /**
  83801. * Copy the current object
  83802. * @returns a new Color3 copied the current one
  83803. */
  83804. clone(): Color3;
  83805. /**
  83806. * Copies the rgb values from the source in the current Color3
  83807. * @param source defines the source Color3 object
  83808. * @returns the updated Color3 object
  83809. */
  83810. copyFrom(source: DeepImmutable<Color3>): Color3;
  83811. /**
  83812. * Updates the Color3 rgb values from the given floats
  83813. * @param r defines the red component to read from
  83814. * @param g defines the green component to read from
  83815. * @param b defines the blue component to read from
  83816. * @returns the current Color3 object
  83817. */
  83818. copyFromFloats(r: number, g: number, b: number): Color3;
  83819. /**
  83820. * Updates the Color3 rgb values from the given floats
  83821. * @param r defines the red component to read from
  83822. * @param g defines the green component to read from
  83823. * @param b defines the blue component to read from
  83824. * @returns the current Color3 object
  83825. */
  83826. set(r: number, g: number, b: number): Color3;
  83827. /**
  83828. * Compute the Color3 hexadecimal code as a string
  83829. * @returns a string containing the hexadecimal representation of the Color3 object
  83830. */
  83831. toHexString(): string;
  83832. /**
  83833. * Computes a new Color3 converted from the current one to linear space
  83834. * @returns a new Color3 object
  83835. */
  83836. toLinearSpace(): Color3;
  83837. /**
  83838. * Converts current color in rgb space to HSV values
  83839. * @returns a new color3 representing the HSV values
  83840. */
  83841. toHSV(): Color3;
  83842. /**
  83843. * Converts current color in rgb space to HSV values
  83844. * @param result defines the Color3 where to store the HSV values
  83845. */
  83846. toHSVToRef(result: Color3): void;
  83847. /**
  83848. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  83849. * @param convertedColor defines the Color3 object where to store the linear space version
  83850. * @returns the unmodified Color3
  83851. */
  83852. toLinearSpaceToRef(convertedColor: Color3): Color3;
  83853. /**
  83854. * Computes a new Color3 converted from the current one to gamma space
  83855. * @returns a new Color3 object
  83856. */
  83857. toGammaSpace(): Color3;
  83858. /**
  83859. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  83860. * @param convertedColor defines the Color3 object where to store the gamma space version
  83861. * @returns the unmodified Color3
  83862. */
  83863. toGammaSpaceToRef(convertedColor: Color3): Color3;
  83864. private static _BlackReadOnly;
  83865. /**
  83866. * Convert Hue, saturation and value to a Color3 (RGB)
  83867. * @param hue defines the hue
  83868. * @param saturation defines the saturation
  83869. * @param value defines the value
  83870. * @param result defines the Color3 where to store the RGB values
  83871. */
  83872. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  83873. /**
  83874. * Creates a new Color3 from the string containing valid hexadecimal values
  83875. * @param hex defines a string containing valid hexadecimal values
  83876. * @returns a new Color3 object
  83877. */
  83878. static FromHexString(hex: string): Color3;
  83879. /**
  83880. * Creates a new Color3 from the starting index of the given array
  83881. * @param array defines the source array
  83882. * @param offset defines an offset in the source array
  83883. * @returns a new Color3 object
  83884. */
  83885. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  83886. /**
  83887. * Creates a new Color3 from integer values (< 256)
  83888. * @param r defines the red component to read from (value between 0 and 255)
  83889. * @param g defines the green component to read from (value between 0 and 255)
  83890. * @param b defines the blue component to read from (value between 0 and 255)
  83891. * @returns a new Color3 object
  83892. */
  83893. static FromInts(r: number, g: number, b: number): Color3;
  83894. /**
  83895. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  83896. * @param start defines the start Color3 value
  83897. * @param end defines the end Color3 value
  83898. * @param amount defines the gradient value between start and end
  83899. * @returns a new Color3 object
  83900. */
  83901. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  83902. /**
  83903. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  83904. * @param left defines the start value
  83905. * @param right defines the end value
  83906. * @param amount defines the gradient factor
  83907. * @param result defines the Color3 object where to store the result
  83908. */
  83909. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  83910. /**
  83911. * Returns a Color3 value containing a red color
  83912. * @returns a new Color3 object
  83913. */
  83914. static Red(): Color3;
  83915. /**
  83916. * Returns a Color3 value containing a green color
  83917. * @returns a new Color3 object
  83918. */
  83919. static Green(): Color3;
  83920. /**
  83921. * Returns a Color3 value containing a blue color
  83922. * @returns a new Color3 object
  83923. */
  83924. static Blue(): Color3;
  83925. /**
  83926. * Returns a Color3 value containing a black color
  83927. * @returns a new Color3 object
  83928. */
  83929. static Black(): Color3;
  83930. /**
  83931. * Gets a Color3 value containing a black color that must not be updated
  83932. */
  83933. static get BlackReadOnly(): DeepImmutable<Color3>;
  83934. /**
  83935. * Returns a Color3 value containing a white color
  83936. * @returns a new Color3 object
  83937. */
  83938. static White(): Color3;
  83939. /**
  83940. * Returns a Color3 value containing a purple color
  83941. * @returns a new Color3 object
  83942. */
  83943. static Purple(): Color3;
  83944. /**
  83945. * Returns a Color3 value containing a magenta color
  83946. * @returns a new Color3 object
  83947. */
  83948. static Magenta(): Color3;
  83949. /**
  83950. * Returns a Color3 value containing a yellow color
  83951. * @returns a new Color3 object
  83952. */
  83953. static Yellow(): Color3;
  83954. /**
  83955. * Returns a Color3 value containing a gray color
  83956. * @returns a new Color3 object
  83957. */
  83958. static Gray(): Color3;
  83959. /**
  83960. * Returns a Color3 value containing a teal color
  83961. * @returns a new Color3 object
  83962. */
  83963. static Teal(): Color3;
  83964. /**
  83965. * Returns a Color3 value containing a random color
  83966. * @returns a new Color3 object
  83967. */
  83968. static Random(): Color3;
  83969. }
  83970. /**
  83971. * Class used to hold a RBGA color
  83972. */
  83973. export class Color4 {
  83974. /**
  83975. * Defines the red component (between 0 and 1, default is 0)
  83976. */
  83977. r: number;
  83978. /**
  83979. * Defines the green component (between 0 and 1, default is 0)
  83980. */
  83981. g: number;
  83982. /**
  83983. * Defines the blue component (between 0 and 1, default is 0)
  83984. */
  83985. b: number;
  83986. /**
  83987. * Defines the alpha component (between 0 and 1, default is 1)
  83988. */
  83989. a: number;
  83990. /**
  83991. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  83992. * @param r defines the red component (between 0 and 1, default is 0)
  83993. * @param g defines the green component (between 0 and 1, default is 0)
  83994. * @param b defines the blue component (between 0 and 1, default is 0)
  83995. * @param a defines the alpha component (between 0 and 1, default is 1)
  83996. */
  83997. constructor(
  83998. /**
  83999. * Defines the red component (between 0 and 1, default is 0)
  84000. */
  84001. r?: number,
  84002. /**
  84003. * Defines the green component (between 0 and 1, default is 0)
  84004. */
  84005. g?: number,
  84006. /**
  84007. * Defines the blue component (between 0 and 1, default is 0)
  84008. */
  84009. b?: number,
  84010. /**
  84011. * Defines the alpha component (between 0 and 1, default is 1)
  84012. */
  84013. a?: number);
  84014. /**
  84015. * Adds in place the given Color4 values to the current Color4 object
  84016. * @param right defines the second operand
  84017. * @returns the current updated Color4 object
  84018. */
  84019. addInPlace(right: DeepImmutable<Color4>): Color4;
  84020. /**
  84021. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  84022. * @returns the new array
  84023. */
  84024. asArray(): number[];
  84025. /**
  84026. * Stores from the starting index in the given array the Color4 successive values
  84027. * @param array defines the array where to store the r,g,b components
  84028. * @param index defines an optional index in the target array to define where to start storing values
  84029. * @returns the current Color4 object
  84030. */
  84031. toArray(array: number[], index?: number): Color4;
  84032. /**
  84033. * Determines equality between Color4 objects
  84034. * @param otherColor defines the second operand
  84035. * @returns true if the rgba values are equal to the given ones
  84036. */
  84037. equals(otherColor: DeepImmutable<Color4>): boolean;
  84038. /**
  84039. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  84040. * @param right defines the second operand
  84041. * @returns a new Color4 object
  84042. */
  84043. add(right: DeepImmutable<Color4>): Color4;
  84044. /**
  84045. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  84046. * @param right defines the second operand
  84047. * @returns a new Color4 object
  84048. */
  84049. subtract(right: DeepImmutable<Color4>): Color4;
  84050. /**
  84051. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  84052. * @param right defines the second operand
  84053. * @param result defines the Color4 object where to store the result
  84054. * @returns the current Color4 object
  84055. */
  84056. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  84057. /**
  84058. * Creates a new Color4 with the current Color4 values multiplied by scale
  84059. * @param scale defines the scaling factor to apply
  84060. * @returns a new Color4 object
  84061. */
  84062. scale(scale: number): Color4;
  84063. /**
  84064. * Multiplies the current Color4 values by scale and stores the result in "result"
  84065. * @param scale defines the scaling factor to apply
  84066. * @param result defines the Color4 object where to store the result
  84067. * @returns the current unmodified Color4
  84068. */
  84069. scaleToRef(scale: number, result: Color4): Color4;
  84070. /**
  84071. * Scale the current Color4 values by a factor and add the result to a given Color4
  84072. * @param scale defines the scale factor
  84073. * @param result defines the Color4 object where to store the result
  84074. * @returns the unmodified current Color4
  84075. */
  84076. scaleAndAddToRef(scale: number, result: Color4): Color4;
  84077. /**
  84078. * Clamps the rgb values by the min and max values and stores the result into "result"
  84079. * @param min defines minimum clamping value (default is 0)
  84080. * @param max defines maximum clamping value (default is 1)
  84081. * @param result defines color to store the result into.
  84082. * @returns the cuurent Color4
  84083. */
  84084. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  84085. /**
  84086. * Multipy an Color4 value by another and return a new Color4 object
  84087. * @param color defines the Color4 value to multiply by
  84088. * @returns a new Color4 object
  84089. */
  84090. multiply(color: Color4): Color4;
  84091. /**
  84092. * Multipy a Color4 value by another and push the result in a reference value
  84093. * @param color defines the Color4 value to multiply by
  84094. * @param result defines the Color4 to fill the result in
  84095. * @returns the result Color4
  84096. */
  84097. multiplyToRef(color: Color4, result: Color4): Color4;
  84098. /**
  84099. * Creates a string with the Color4 current values
  84100. * @returns the string representation of the Color4 object
  84101. */
  84102. toString(): string;
  84103. /**
  84104. * Returns the string "Color4"
  84105. * @returns "Color4"
  84106. */
  84107. getClassName(): string;
  84108. /**
  84109. * Compute the Color4 hash code
  84110. * @returns an unique number that can be used to hash Color4 objects
  84111. */
  84112. getHashCode(): number;
  84113. /**
  84114. * Creates a new Color4 copied from the current one
  84115. * @returns a new Color4 object
  84116. */
  84117. clone(): Color4;
  84118. /**
  84119. * Copies the given Color4 values into the current one
  84120. * @param source defines the source Color4 object
  84121. * @returns the current updated Color4 object
  84122. */
  84123. copyFrom(source: Color4): Color4;
  84124. /**
  84125. * Copies the given float values into the current one
  84126. * @param r defines the red component to read from
  84127. * @param g defines the green component to read from
  84128. * @param b defines the blue component to read from
  84129. * @param a defines the alpha component to read from
  84130. * @returns the current updated Color4 object
  84131. */
  84132. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  84133. /**
  84134. * Copies the given float values into the current one
  84135. * @param r defines the red component to read from
  84136. * @param g defines the green component to read from
  84137. * @param b defines the blue component to read from
  84138. * @param a defines the alpha component to read from
  84139. * @returns the current updated Color4 object
  84140. */
  84141. set(r: number, g: number, b: number, a: number): Color4;
  84142. /**
  84143. * Compute the Color4 hexadecimal code as a string
  84144. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  84145. * @returns a string containing the hexadecimal representation of the Color4 object
  84146. */
  84147. toHexString(returnAsColor3?: boolean): string;
  84148. /**
  84149. * Computes a new Color4 converted from the current one to linear space
  84150. * @returns a new Color4 object
  84151. */
  84152. toLinearSpace(): Color4;
  84153. /**
  84154. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  84155. * @param convertedColor defines the Color4 object where to store the linear space version
  84156. * @returns the unmodified Color4
  84157. */
  84158. toLinearSpaceToRef(convertedColor: Color4): Color4;
  84159. /**
  84160. * Computes a new Color4 converted from the current one to gamma space
  84161. * @returns a new Color4 object
  84162. */
  84163. toGammaSpace(): Color4;
  84164. /**
  84165. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  84166. * @param convertedColor defines the Color4 object where to store the gamma space version
  84167. * @returns the unmodified Color4
  84168. */
  84169. toGammaSpaceToRef(convertedColor: Color4): Color4;
  84170. /**
  84171. * Creates a new Color4 from the string containing valid hexadecimal values
  84172. * @param hex defines a string containing valid hexadecimal values
  84173. * @returns a new Color4 object
  84174. */
  84175. static FromHexString(hex: string): Color4;
  84176. /**
  84177. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  84178. * @param left defines the start value
  84179. * @param right defines the end value
  84180. * @param amount defines the gradient factor
  84181. * @returns a new Color4 object
  84182. */
  84183. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  84184. /**
  84185. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  84186. * @param left defines the start value
  84187. * @param right defines the end value
  84188. * @param amount defines the gradient factor
  84189. * @param result defines the Color4 object where to store data
  84190. */
  84191. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  84192. /**
  84193. * Creates a new Color4 from a Color3 and an alpha value
  84194. * @param color3 defines the source Color3 to read from
  84195. * @param alpha defines the alpha component (1.0 by default)
  84196. * @returns a new Color4 object
  84197. */
  84198. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  84199. /**
  84200. * Creates a new Color4 from the starting index element of the given array
  84201. * @param array defines the source array to read from
  84202. * @param offset defines the offset in the source array
  84203. * @returns a new Color4 object
  84204. */
  84205. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  84206. /**
  84207. * Creates a new Color3 from integer values (< 256)
  84208. * @param r defines the red component to read from (value between 0 and 255)
  84209. * @param g defines the green component to read from (value between 0 and 255)
  84210. * @param b defines the blue component to read from (value between 0 and 255)
  84211. * @param a defines the alpha component to read from (value between 0 and 255)
  84212. * @returns a new Color3 object
  84213. */
  84214. static FromInts(r: number, g: number, b: number, a: number): Color4;
  84215. /**
  84216. * Check the content of a given array and convert it to an array containing RGBA data
  84217. * If the original array was already containing count * 4 values then it is returned directly
  84218. * @param colors defines the array to check
  84219. * @param count defines the number of RGBA data to expect
  84220. * @returns an array containing count * 4 values (RGBA)
  84221. */
  84222. static CheckColors4(colors: number[], count: number): number[];
  84223. }
  84224. /**
  84225. * @hidden
  84226. */
  84227. export class TmpColors {
  84228. static Color3: Color3[];
  84229. static Color4: Color4[];
  84230. }
  84231. }
  84232. declare module BABYLON {
  84233. /**
  84234. * Defines an interface which represents an animation key frame
  84235. */
  84236. export interface IAnimationKey {
  84237. /**
  84238. * Frame of the key frame
  84239. */
  84240. frame: number;
  84241. /**
  84242. * Value at the specifies key frame
  84243. */
  84244. value: any;
  84245. /**
  84246. * The input tangent for the cubic hermite spline
  84247. */
  84248. inTangent?: any;
  84249. /**
  84250. * The output tangent for the cubic hermite spline
  84251. */
  84252. outTangent?: any;
  84253. /**
  84254. * The animation interpolation type
  84255. */
  84256. interpolation?: AnimationKeyInterpolation;
  84257. }
  84258. /**
  84259. * Enum for the animation key frame interpolation type
  84260. */
  84261. export enum AnimationKeyInterpolation {
  84262. /**
  84263. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  84264. */
  84265. STEP = 1
  84266. }
  84267. }
  84268. declare module BABYLON {
  84269. /**
  84270. * Represents the range of an animation
  84271. */
  84272. export class AnimationRange {
  84273. /**The name of the animation range**/
  84274. name: string;
  84275. /**The starting frame of the animation */
  84276. from: number;
  84277. /**The ending frame of the animation*/
  84278. to: number;
  84279. /**
  84280. * Initializes the range of an animation
  84281. * @param name The name of the animation range
  84282. * @param from The starting frame of the animation
  84283. * @param to The ending frame of the animation
  84284. */
  84285. constructor(
  84286. /**The name of the animation range**/
  84287. name: string,
  84288. /**The starting frame of the animation */
  84289. from: number,
  84290. /**The ending frame of the animation*/
  84291. to: number);
  84292. /**
  84293. * Makes a copy of the animation range
  84294. * @returns A copy of the animation range
  84295. */
  84296. clone(): AnimationRange;
  84297. }
  84298. }
  84299. declare module BABYLON {
  84300. /**
  84301. * Composed of a frame, and an action function
  84302. */
  84303. export class AnimationEvent {
  84304. /** The frame for which the event is triggered **/
  84305. frame: number;
  84306. /** The event to perform when triggered **/
  84307. action: (currentFrame: number) => void;
  84308. /** Specifies if the event should be triggered only once**/
  84309. onlyOnce?: boolean | undefined;
  84310. /**
  84311. * Specifies if the animation event is done
  84312. */
  84313. isDone: boolean;
  84314. /**
  84315. * Initializes the animation event
  84316. * @param frame The frame for which the event is triggered
  84317. * @param action The event to perform when triggered
  84318. * @param onlyOnce Specifies if the event should be triggered only once
  84319. */
  84320. constructor(
  84321. /** The frame for which the event is triggered **/
  84322. frame: number,
  84323. /** The event to perform when triggered **/
  84324. action: (currentFrame: number) => void,
  84325. /** Specifies if the event should be triggered only once**/
  84326. onlyOnce?: boolean | undefined);
  84327. /** @hidden */
  84328. _clone(): AnimationEvent;
  84329. }
  84330. }
  84331. declare module BABYLON {
  84332. /**
  84333. * Interface used to define a behavior
  84334. */
  84335. export interface Behavior<T> {
  84336. /** gets or sets behavior's name */
  84337. name: string;
  84338. /**
  84339. * Function called when the behavior needs to be initialized (after attaching it to a target)
  84340. */
  84341. init(): void;
  84342. /**
  84343. * Called when the behavior is attached to a target
  84344. * @param target defines the target where the behavior is attached to
  84345. */
  84346. attach(target: T): void;
  84347. /**
  84348. * Called when the behavior is detached from its target
  84349. */
  84350. detach(): void;
  84351. }
  84352. /**
  84353. * Interface implemented by classes supporting behaviors
  84354. */
  84355. export interface IBehaviorAware<T> {
  84356. /**
  84357. * Attach a behavior
  84358. * @param behavior defines the behavior to attach
  84359. * @returns the current host
  84360. */
  84361. addBehavior(behavior: Behavior<T>): T;
  84362. /**
  84363. * Remove a behavior from the current object
  84364. * @param behavior defines the behavior to detach
  84365. * @returns the current host
  84366. */
  84367. removeBehavior(behavior: Behavior<T>): T;
  84368. /**
  84369. * Gets a behavior using its name to search
  84370. * @param name defines the name to search
  84371. * @returns the behavior or null if not found
  84372. */
  84373. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  84374. }
  84375. }
  84376. declare module BABYLON {
  84377. /**
  84378. * Defines an array and its length.
  84379. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  84380. */
  84381. export interface ISmartArrayLike<T> {
  84382. /**
  84383. * The data of the array.
  84384. */
  84385. data: Array<T>;
  84386. /**
  84387. * The active length of the array.
  84388. */
  84389. length: number;
  84390. }
  84391. /**
  84392. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  84393. */
  84394. export class SmartArray<T> implements ISmartArrayLike<T> {
  84395. /**
  84396. * The full set of data from the array.
  84397. */
  84398. data: Array<T>;
  84399. /**
  84400. * The active length of the array.
  84401. */
  84402. length: number;
  84403. protected _id: number;
  84404. /**
  84405. * Instantiates a Smart Array.
  84406. * @param capacity defines the default capacity of the array.
  84407. */
  84408. constructor(capacity: number);
  84409. /**
  84410. * Pushes a value at the end of the active data.
  84411. * @param value defines the object to push in the array.
  84412. */
  84413. push(value: T): void;
  84414. /**
  84415. * Iterates over the active data and apply the lambda to them.
  84416. * @param func defines the action to apply on each value.
  84417. */
  84418. forEach(func: (content: T) => void): void;
  84419. /**
  84420. * Sorts the full sets of data.
  84421. * @param compareFn defines the comparison function to apply.
  84422. */
  84423. sort(compareFn: (a: T, b: T) => number): void;
  84424. /**
  84425. * Resets the active data to an empty array.
  84426. */
  84427. reset(): void;
  84428. /**
  84429. * Releases all the data from the array as well as the array.
  84430. */
  84431. dispose(): void;
  84432. /**
  84433. * Concats the active data with a given array.
  84434. * @param array defines the data to concatenate with.
  84435. */
  84436. concat(array: any): void;
  84437. /**
  84438. * Returns the position of a value in the active data.
  84439. * @param value defines the value to find the index for
  84440. * @returns the index if found in the active data otherwise -1
  84441. */
  84442. indexOf(value: T): number;
  84443. /**
  84444. * Returns whether an element is part of the active data.
  84445. * @param value defines the value to look for
  84446. * @returns true if found in the active data otherwise false
  84447. */
  84448. contains(value: T): boolean;
  84449. private static _GlobalId;
  84450. }
  84451. /**
  84452. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  84453. * The data in this array can only be present once
  84454. */
  84455. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  84456. private _duplicateId;
  84457. /**
  84458. * Pushes a value at the end of the active data.
  84459. * THIS DOES NOT PREVENT DUPPLICATE DATA
  84460. * @param value defines the object to push in the array.
  84461. */
  84462. push(value: T): void;
  84463. /**
  84464. * Pushes a value at the end of the active data.
  84465. * If the data is already present, it won t be added again
  84466. * @param value defines the object to push in the array.
  84467. * @returns true if added false if it was already present
  84468. */
  84469. pushNoDuplicate(value: T): boolean;
  84470. /**
  84471. * Resets the active data to an empty array.
  84472. */
  84473. reset(): void;
  84474. /**
  84475. * Concats the active data with a given array.
  84476. * This ensures no dupplicate will be present in the result.
  84477. * @param array defines the data to concatenate with.
  84478. */
  84479. concatWithNoDuplicate(array: any): void;
  84480. }
  84481. }
  84482. declare module BABYLON {
  84483. /**
  84484. * @ignore
  84485. * This is a list of all the different input types that are available in the application.
  84486. * Fo instance: ArcRotateCameraGamepadInput...
  84487. */
  84488. export var CameraInputTypes: {};
  84489. /**
  84490. * This is the contract to implement in order to create a new input class.
  84491. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  84492. */
  84493. export interface ICameraInput<TCamera extends Camera> {
  84494. /**
  84495. * Defines the camera the input is attached to.
  84496. */
  84497. camera: Nullable<TCamera>;
  84498. /**
  84499. * Gets the class name of the current intput.
  84500. * @returns the class name
  84501. */
  84502. getClassName(): string;
  84503. /**
  84504. * Get the friendly name associated with the input class.
  84505. * @returns the input friendly name
  84506. */
  84507. getSimpleName(): string;
  84508. /**
  84509. * Attach the input controls to a specific dom element to get the input from.
  84510. * @param element Defines the element the controls should be listened from
  84511. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84512. */
  84513. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84514. /**
  84515. * Detach the current controls from the specified dom element.
  84516. * @param element Defines the element to stop listening the inputs from
  84517. */
  84518. detachControl(element: Nullable<HTMLElement>): void;
  84519. /**
  84520. * Update the current camera state depending on the inputs that have been used this frame.
  84521. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84522. */
  84523. checkInputs?: () => void;
  84524. }
  84525. /**
  84526. * Represents a map of input types to input instance or input index to input instance.
  84527. */
  84528. export interface CameraInputsMap<TCamera extends Camera> {
  84529. /**
  84530. * Accessor to the input by input type.
  84531. */
  84532. [name: string]: ICameraInput<TCamera>;
  84533. /**
  84534. * Accessor to the input by input index.
  84535. */
  84536. [idx: number]: ICameraInput<TCamera>;
  84537. }
  84538. /**
  84539. * This represents the input manager used within a camera.
  84540. * It helps dealing with all the different kind of input attached to a camera.
  84541. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  84542. */
  84543. export class CameraInputsManager<TCamera extends Camera> {
  84544. /**
  84545. * Defines the list of inputs attahed to the camera.
  84546. */
  84547. attached: CameraInputsMap<TCamera>;
  84548. /**
  84549. * Defines the dom element the camera is collecting inputs from.
  84550. * This is null if the controls have not been attached.
  84551. */
  84552. attachedElement: Nullable<HTMLElement>;
  84553. /**
  84554. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84555. */
  84556. noPreventDefault: boolean;
  84557. /**
  84558. * Defined the camera the input manager belongs to.
  84559. */
  84560. camera: TCamera;
  84561. /**
  84562. * Update the current camera state depending on the inputs that have been used this frame.
  84563. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84564. */
  84565. checkInputs: () => void;
  84566. /**
  84567. * Instantiate a new Camera Input Manager.
  84568. * @param camera Defines the camera the input manager blongs to
  84569. */
  84570. constructor(camera: TCamera);
  84571. /**
  84572. * Add an input method to a camera
  84573. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  84574. * @param input camera input method
  84575. */
  84576. add(input: ICameraInput<TCamera>): void;
  84577. /**
  84578. * Remove a specific input method from a camera
  84579. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  84580. * @param inputToRemove camera input method
  84581. */
  84582. remove(inputToRemove: ICameraInput<TCamera>): void;
  84583. /**
  84584. * Remove a specific input type from a camera
  84585. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  84586. * @param inputType the type of the input to remove
  84587. */
  84588. removeByType(inputType: string): void;
  84589. private _addCheckInputs;
  84590. /**
  84591. * Attach the input controls to the currently attached dom element to listen the events from.
  84592. * @param input Defines the input to attach
  84593. */
  84594. attachInput(input: ICameraInput<TCamera>): void;
  84595. /**
  84596. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  84597. * @param element Defines the dom element to collect the events from
  84598. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84599. */
  84600. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  84601. /**
  84602. * Detach the current manager inputs controls from a specific dom element.
  84603. * @param element Defines the dom element to collect the events from
  84604. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  84605. */
  84606. detachElement(element: HTMLElement, disconnect?: boolean): void;
  84607. /**
  84608. * Rebuild the dynamic inputCheck function from the current list of
  84609. * defined inputs in the manager.
  84610. */
  84611. rebuildInputCheck(): void;
  84612. /**
  84613. * Remove all attached input methods from a camera
  84614. */
  84615. clear(): void;
  84616. /**
  84617. * Serialize the current input manager attached to a camera.
  84618. * This ensures than once parsed,
  84619. * the input associated to the camera will be identical to the current ones
  84620. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  84621. */
  84622. serialize(serializedCamera: any): void;
  84623. /**
  84624. * Parses an input manager serialized JSON to restore the previous list of inputs
  84625. * and states associated to a camera.
  84626. * @param parsedCamera Defines the JSON to parse
  84627. */
  84628. parse(parsedCamera: any): void;
  84629. }
  84630. }
  84631. declare module BABYLON {
  84632. /**
  84633. * Class used to store data that will be store in GPU memory
  84634. */
  84635. export class Buffer {
  84636. private _engine;
  84637. private _buffer;
  84638. /** @hidden */
  84639. _data: Nullable<DataArray>;
  84640. private _updatable;
  84641. private _instanced;
  84642. private _divisor;
  84643. /**
  84644. * Gets the byte stride.
  84645. */
  84646. readonly byteStride: number;
  84647. /**
  84648. * Constructor
  84649. * @param engine the engine
  84650. * @param data the data to use for this buffer
  84651. * @param updatable whether the data is updatable
  84652. * @param stride the stride (optional)
  84653. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  84654. * @param instanced whether the buffer is instanced (optional)
  84655. * @param useBytes set to true if the stride in in bytes (optional)
  84656. * @param divisor sets an optional divisor for instances (1 by default)
  84657. */
  84658. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  84659. /**
  84660. * Create a new VertexBuffer based on the current buffer
  84661. * @param kind defines the vertex buffer kind (position, normal, etc.)
  84662. * @param offset defines offset in the buffer (0 by default)
  84663. * @param size defines the size in floats of attributes (position is 3 for instance)
  84664. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  84665. * @param instanced defines if the vertex buffer contains indexed data
  84666. * @param useBytes defines if the offset and stride are in bytes *
  84667. * @param divisor sets an optional divisor for instances (1 by default)
  84668. * @returns the new vertex buffer
  84669. */
  84670. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  84671. /**
  84672. * Gets a boolean indicating if the Buffer is updatable?
  84673. * @returns true if the buffer is updatable
  84674. */
  84675. isUpdatable(): boolean;
  84676. /**
  84677. * Gets current buffer's data
  84678. * @returns a DataArray or null
  84679. */
  84680. getData(): Nullable<DataArray>;
  84681. /**
  84682. * Gets underlying native buffer
  84683. * @returns underlying native buffer
  84684. */
  84685. getBuffer(): Nullable<DataBuffer>;
  84686. /**
  84687. * Gets the stride in float32 units (i.e. byte stride / 4).
  84688. * May not be an integer if the byte stride is not divisible by 4.
  84689. * @returns the stride in float32 units
  84690. * @deprecated Please use byteStride instead.
  84691. */
  84692. getStrideSize(): number;
  84693. /**
  84694. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  84695. * @param data defines the data to store
  84696. */
  84697. create(data?: Nullable<DataArray>): void;
  84698. /** @hidden */
  84699. _rebuild(): void;
  84700. /**
  84701. * Update current buffer data
  84702. * @param data defines the data to store
  84703. */
  84704. update(data: DataArray): void;
  84705. /**
  84706. * Updates the data directly.
  84707. * @param data the new data
  84708. * @param offset the new offset
  84709. * @param vertexCount the vertex count (optional)
  84710. * @param useBytes set to true if the offset is in bytes
  84711. */
  84712. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  84713. /**
  84714. * Release all resources
  84715. */
  84716. dispose(): void;
  84717. }
  84718. /**
  84719. * Specialized buffer used to store vertex data
  84720. */
  84721. export class VertexBuffer {
  84722. /** @hidden */
  84723. _buffer: Buffer;
  84724. private _kind;
  84725. private _size;
  84726. private _ownsBuffer;
  84727. private _instanced;
  84728. private _instanceDivisor;
  84729. /**
  84730. * The byte type.
  84731. */
  84732. static readonly BYTE: number;
  84733. /**
  84734. * The unsigned byte type.
  84735. */
  84736. static readonly UNSIGNED_BYTE: number;
  84737. /**
  84738. * The short type.
  84739. */
  84740. static readonly SHORT: number;
  84741. /**
  84742. * The unsigned short type.
  84743. */
  84744. static readonly UNSIGNED_SHORT: number;
  84745. /**
  84746. * The integer type.
  84747. */
  84748. static readonly INT: number;
  84749. /**
  84750. * The unsigned integer type.
  84751. */
  84752. static readonly UNSIGNED_INT: number;
  84753. /**
  84754. * The float type.
  84755. */
  84756. static readonly FLOAT: number;
  84757. /**
  84758. * Gets or sets the instance divisor when in instanced mode
  84759. */
  84760. get instanceDivisor(): number;
  84761. set instanceDivisor(value: number);
  84762. /**
  84763. * Gets the byte stride.
  84764. */
  84765. readonly byteStride: number;
  84766. /**
  84767. * Gets the byte offset.
  84768. */
  84769. readonly byteOffset: number;
  84770. /**
  84771. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  84772. */
  84773. readonly normalized: boolean;
  84774. /**
  84775. * Gets the data type of each component in the array.
  84776. */
  84777. readonly type: number;
  84778. /**
  84779. * Constructor
  84780. * @param engine the engine
  84781. * @param data the data to use for this vertex buffer
  84782. * @param kind the vertex buffer kind
  84783. * @param updatable whether the data is updatable
  84784. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  84785. * @param stride the stride (optional)
  84786. * @param instanced whether the buffer is instanced (optional)
  84787. * @param offset the offset of the data (optional)
  84788. * @param size the number of components (optional)
  84789. * @param type the type of the component (optional)
  84790. * @param normalized whether the data contains normalized data (optional)
  84791. * @param useBytes set to true if stride and offset are in bytes (optional)
  84792. * @param divisor defines the instance divisor to use (1 by default)
  84793. */
  84794. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  84795. /** @hidden */
  84796. _rebuild(): void;
  84797. /**
  84798. * Returns the kind of the VertexBuffer (string)
  84799. * @returns a string
  84800. */
  84801. getKind(): string;
  84802. /**
  84803. * Gets a boolean indicating if the VertexBuffer is updatable?
  84804. * @returns true if the buffer is updatable
  84805. */
  84806. isUpdatable(): boolean;
  84807. /**
  84808. * Gets current buffer's data
  84809. * @returns a DataArray or null
  84810. */
  84811. getData(): Nullable<DataArray>;
  84812. /**
  84813. * Gets underlying native buffer
  84814. * @returns underlying native buffer
  84815. */
  84816. getBuffer(): Nullable<DataBuffer>;
  84817. /**
  84818. * Gets the stride in float32 units (i.e. byte stride / 4).
  84819. * May not be an integer if the byte stride is not divisible by 4.
  84820. * @returns the stride in float32 units
  84821. * @deprecated Please use byteStride instead.
  84822. */
  84823. getStrideSize(): number;
  84824. /**
  84825. * Returns the offset as a multiple of the type byte length.
  84826. * @returns the offset in bytes
  84827. * @deprecated Please use byteOffset instead.
  84828. */
  84829. getOffset(): number;
  84830. /**
  84831. * Returns the number of components per vertex attribute (integer)
  84832. * @returns the size in float
  84833. */
  84834. getSize(): number;
  84835. /**
  84836. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  84837. * @returns true if this buffer is instanced
  84838. */
  84839. getIsInstanced(): boolean;
  84840. /**
  84841. * Returns the instancing divisor, zero for non-instanced (integer).
  84842. * @returns a number
  84843. */
  84844. getInstanceDivisor(): number;
  84845. /**
  84846. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  84847. * @param data defines the data to store
  84848. */
  84849. create(data?: DataArray): void;
  84850. /**
  84851. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  84852. * This function will create a new buffer if the current one is not updatable
  84853. * @param data defines the data to store
  84854. */
  84855. update(data: DataArray): void;
  84856. /**
  84857. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  84858. * Returns the directly updated WebGLBuffer.
  84859. * @param data the new data
  84860. * @param offset the new offset
  84861. * @param useBytes set to true if the offset is in bytes
  84862. */
  84863. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  84864. /**
  84865. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  84866. */
  84867. dispose(): void;
  84868. /**
  84869. * Enumerates each value of this vertex buffer as numbers.
  84870. * @param count the number of values to enumerate
  84871. * @param callback the callback function called for each value
  84872. */
  84873. forEach(count: number, callback: (value: number, index: number) => void): void;
  84874. /**
  84875. * Positions
  84876. */
  84877. static readonly PositionKind: string;
  84878. /**
  84879. * Normals
  84880. */
  84881. static readonly NormalKind: string;
  84882. /**
  84883. * Tangents
  84884. */
  84885. static readonly TangentKind: string;
  84886. /**
  84887. * Texture coordinates
  84888. */
  84889. static readonly UVKind: string;
  84890. /**
  84891. * Texture coordinates 2
  84892. */
  84893. static readonly UV2Kind: string;
  84894. /**
  84895. * Texture coordinates 3
  84896. */
  84897. static readonly UV3Kind: string;
  84898. /**
  84899. * Texture coordinates 4
  84900. */
  84901. static readonly UV4Kind: string;
  84902. /**
  84903. * Texture coordinates 5
  84904. */
  84905. static readonly UV5Kind: string;
  84906. /**
  84907. * Texture coordinates 6
  84908. */
  84909. static readonly UV6Kind: string;
  84910. /**
  84911. * Colors
  84912. */
  84913. static readonly ColorKind: string;
  84914. /**
  84915. * Matrix indices (for bones)
  84916. */
  84917. static readonly MatricesIndicesKind: string;
  84918. /**
  84919. * Matrix weights (for bones)
  84920. */
  84921. static readonly MatricesWeightsKind: string;
  84922. /**
  84923. * Additional matrix indices (for bones)
  84924. */
  84925. static readonly MatricesIndicesExtraKind: string;
  84926. /**
  84927. * Additional matrix weights (for bones)
  84928. */
  84929. static readonly MatricesWeightsExtraKind: string;
  84930. /**
  84931. * Deduces the stride given a kind.
  84932. * @param kind The kind string to deduce
  84933. * @returns The deduced stride
  84934. */
  84935. static DeduceStride(kind: string): number;
  84936. /**
  84937. * Gets the byte length of the given type.
  84938. * @param type the type
  84939. * @returns the number of bytes
  84940. */
  84941. static GetTypeByteLength(type: number): number;
  84942. /**
  84943. * Enumerates each value of the given parameters as numbers.
  84944. * @param data the data to enumerate
  84945. * @param byteOffset the byte offset of the data
  84946. * @param byteStride the byte stride of the data
  84947. * @param componentCount the number of components per element
  84948. * @param componentType the type of the component
  84949. * @param count the number of values to enumerate
  84950. * @param normalized whether the data is normalized
  84951. * @param callback the callback function called for each value
  84952. */
  84953. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  84954. private static _GetFloatValue;
  84955. }
  84956. }
  84957. declare module BABYLON {
  84958. /**
  84959. * @hidden
  84960. */
  84961. export class IntersectionInfo {
  84962. bu: Nullable<number>;
  84963. bv: Nullable<number>;
  84964. distance: number;
  84965. faceId: number;
  84966. subMeshId: number;
  84967. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  84968. }
  84969. }
  84970. declare module BABYLON {
  84971. /**
  84972. * Class used to store bounding sphere information
  84973. */
  84974. export class BoundingSphere {
  84975. /**
  84976. * Gets the center of the bounding sphere in local space
  84977. */
  84978. readonly center: Vector3;
  84979. /**
  84980. * Radius of the bounding sphere in local space
  84981. */
  84982. radius: number;
  84983. /**
  84984. * Gets the center of the bounding sphere in world space
  84985. */
  84986. readonly centerWorld: Vector3;
  84987. /**
  84988. * Radius of the bounding sphere in world space
  84989. */
  84990. radiusWorld: number;
  84991. /**
  84992. * Gets the minimum vector in local space
  84993. */
  84994. readonly minimum: Vector3;
  84995. /**
  84996. * Gets the maximum vector in local space
  84997. */
  84998. readonly maximum: Vector3;
  84999. private _worldMatrix;
  85000. private static readonly TmpVector3;
  85001. /**
  85002. * Creates a new bounding sphere
  85003. * @param min defines the minimum vector (in local space)
  85004. * @param max defines the maximum vector (in local space)
  85005. * @param worldMatrix defines the new world matrix
  85006. */
  85007. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85008. /**
  85009. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  85010. * @param min defines the new minimum vector (in local space)
  85011. * @param max defines the new maximum vector (in local space)
  85012. * @param worldMatrix defines the new world matrix
  85013. */
  85014. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85015. /**
  85016. * Scale the current bounding sphere by applying a scale factor
  85017. * @param factor defines the scale factor to apply
  85018. * @returns the current bounding box
  85019. */
  85020. scale(factor: number): BoundingSphere;
  85021. /**
  85022. * Gets the world matrix of the bounding box
  85023. * @returns a matrix
  85024. */
  85025. getWorldMatrix(): DeepImmutable<Matrix>;
  85026. /** @hidden */
  85027. _update(worldMatrix: DeepImmutable<Matrix>): void;
  85028. /**
  85029. * Tests if the bounding sphere is intersecting the frustum planes
  85030. * @param frustumPlanes defines the frustum planes to test
  85031. * @returns true if there is an intersection
  85032. */
  85033. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85034. /**
  85035. * Tests if the bounding sphere center is in between the frustum planes.
  85036. * Used for optimistic fast inclusion.
  85037. * @param frustumPlanes defines the frustum planes to test
  85038. * @returns true if the sphere center is in between the frustum planes
  85039. */
  85040. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85041. /**
  85042. * Tests if a point is inside the bounding sphere
  85043. * @param point defines the point to test
  85044. * @returns true if the point is inside the bounding sphere
  85045. */
  85046. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85047. /**
  85048. * Checks if two sphere intersct
  85049. * @param sphere0 sphere 0
  85050. * @param sphere1 sphere 1
  85051. * @returns true if the speres intersect
  85052. */
  85053. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  85054. }
  85055. }
  85056. declare module BABYLON {
  85057. /**
  85058. * Class used to store bounding box information
  85059. */
  85060. export class BoundingBox implements ICullable {
  85061. /**
  85062. * Gets the 8 vectors representing the bounding box in local space
  85063. */
  85064. readonly vectors: Vector3[];
  85065. /**
  85066. * Gets the center of the bounding box in local space
  85067. */
  85068. readonly center: Vector3;
  85069. /**
  85070. * Gets the center of the bounding box in world space
  85071. */
  85072. readonly centerWorld: Vector3;
  85073. /**
  85074. * Gets the extend size in local space
  85075. */
  85076. readonly extendSize: Vector3;
  85077. /**
  85078. * Gets the extend size in world space
  85079. */
  85080. readonly extendSizeWorld: Vector3;
  85081. /**
  85082. * Gets the OBB (object bounding box) directions
  85083. */
  85084. readonly directions: Vector3[];
  85085. /**
  85086. * Gets the 8 vectors representing the bounding box in world space
  85087. */
  85088. readonly vectorsWorld: Vector3[];
  85089. /**
  85090. * Gets the minimum vector in world space
  85091. */
  85092. readonly minimumWorld: Vector3;
  85093. /**
  85094. * Gets the maximum vector in world space
  85095. */
  85096. readonly maximumWorld: Vector3;
  85097. /**
  85098. * Gets the minimum vector in local space
  85099. */
  85100. readonly minimum: Vector3;
  85101. /**
  85102. * Gets the maximum vector in local space
  85103. */
  85104. readonly maximum: Vector3;
  85105. private _worldMatrix;
  85106. private static readonly TmpVector3;
  85107. /**
  85108. * @hidden
  85109. */
  85110. _tag: number;
  85111. /**
  85112. * Creates a new bounding box
  85113. * @param min defines the minimum vector (in local space)
  85114. * @param max defines the maximum vector (in local space)
  85115. * @param worldMatrix defines the new world matrix
  85116. */
  85117. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85118. /**
  85119. * Recreates the entire bounding box from scratch as if we call the constructor in place
  85120. * @param min defines the new minimum vector (in local space)
  85121. * @param max defines the new maximum vector (in local space)
  85122. * @param worldMatrix defines the new world matrix
  85123. */
  85124. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85125. /**
  85126. * Scale the current bounding box by applying a scale factor
  85127. * @param factor defines the scale factor to apply
  85128. * @returns the current bounding box
  85129. */
  85130. scale(factor: number): BoundingBox;
  85131. /**
  85132. * Gets the world matrix of the bounding box
  85133. * @returns a matrix
  85134. */
  85135. getWorldMatrix(): DeepImmutable<Matrix>;
  85136. /** @hidden */
  85137. _update(world: DeepImmutable<Matrix>): void;
  85138. /**
  85139. * Tests if the bounding box is intersecting the frustum planes
  85140. * @param frustumPlanes defines the frustum planes to test
  85141. * @returns true if there is an intersection
  85142. */
  85143. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85144. /**
  85145. * Tests if the bounding box is entirely inside the frustum planes
  85146. * @param frustumPlanes defines the frustum planes to test
  85147. * @returns true if there is an inclusion
  85148. */
  85149. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85150. /**
  85151. * Tests if a point is inside the bounding box
  85152. * @param point defines the point to test
  85153. * @returns true if the point is inside the bounding box
  85154. */
  85155. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85156. /**
  85157. * Tests if the bounding box intersects with a bounding sphere
  85158. * @param sphere defines the sphere to test
  85159. * @returns true if there is an intersection
  85160. */
  85161. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  85162. /**
  85163. * Tests if the bounding box intersects with a box defined by a min and max vectors
  85164. * @param min defines the min vector to use
  85165. * @param max defines the max vector to use
  85166. * @returns true if there is an intersection
  85167. */
  85168. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  85169. /**
  85170. * Tests if two bounding boxes are intersections
  85171. * @param box0 defines the first box to test
  85172. * @param box1 defines the second box to test
  85173. * @returns true if there is an intersection
  85174. */
  85175. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  85176. /**
  85177. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  85178. * @param minPoint defines the minimum vector of the bounding box
  85179. * @param maxPoint defines the maximum vector of the bounding box
  85180. * @param sphereCenter defines the sphere center
  85181. * @param sphereRadius defines the sphere radius
  85182. * @returns true if there is an intersection
  85183. */
  85184. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  85185. /**
  85186. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  85187. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  85188. * @param frustumPlanes defines the frustum planes to test
  85189. * @return true if there is an inclusion
  85190. */
  85191. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85192. /**
  85193. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  85194. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  85195. * @param frustumPlanes defines the frustum planes to test
  85196. * @return true if there is an intersection
  85197. */
  85198. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85199. }
  85200. }
  85201. declare module BABYLON {
  85202. /** @hidden */
  85203. export class Collider {
  85204. /** Define if a collision was found */
  85205. collisionFound: boolean;
  85206. /**
  85207. * Define last intersection point in local space
  85208. */
  85209. intersectionPoint: Vector3;
  85210. /**
  85211. * Define last collided mesh
  85212. */
  85213. collidedMesh: Nullable<AbstractMesh>;
  85214. private _collisionPoint;
  85215. private _planeIntersectionPoint;
  85216. private _tempVector;
  85217. private _tempVector2;
  85218. private _tempVector3;
  85219. private _tempVector4;
  85220. private _edge;
  85221. private _baseToVertex;
  85222. private _destinationPoint;
  85223. private _slidePlaneNormal;
  85224. private _displacementVector;
  85225. /** @hidden */
  85226. _radius: Vector3;
  85227. /** @hidden */
  85228. _retry: number;
  85229. private _velocity;
  85230. private _basePoint;
  85231. private _epsilon;
  85232. /** @hidden */
  85233. _velocityWorldLength: number;
  85234. /** @hidden */
  85235. _basePointWorld: Vector3;
  85236. private _velocityWorld;
  85237. private _normalizedVelocity;
  85238. /** @hidden */
  85239. _initialVelocity: Vector3;
  85240. /** @hidden */
  85241. _initialPosition: Vector3;
  85242. private _nearestDistance;
  85243. private _collisionMask;
  85244. get collisionMask(): number;
  85245. set collisionMask(mask: number);
  85246. /**
  85247. * Gets the plane normal used to compute the sliding response (in local space)
  85248. */
  85249. get slidePlaneNormal(): Vector3;
  85250. /** @hidden */
  85251. _initialize(source: Vector3, dir: Vector3, e: number): void;
  85252. /** @hidden */
  85253. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  85254. /** @hidden */
  85255. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  85256. /** @hidden */
  85257. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  85258. /** @hidden */
  85259. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  85260. /** @hidden */
  85261. _getResponse(pos: Vector3, vel: Vector3): void;
  85262. }
  85263. }
  85264. declare module BABYLON {
  85265. /**
  85266. * Interface for cullable objects
  85267. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  85268. */
  85269. export interface ICullable {
  85270. /**
  85271. * Checks if the object or part of the object is in the frustum
  85272. * @param frustumPlanes Camera near/planes
  85273. * @returns true if the object is in frustum otherwise false
  85274. */
  85275. isInFrustum(frustumPlanes: Plane[]): boolean;
  85276. /**
  85277. * Checks if a cullable object (mesh...) is in the camera frustum
  85278. * Unlike isInFrustum this cheks the full bounding box
  85279. * @param frustumPlanes Camera near/planes
  85280. * @returns true if the object is in frustum otherwise false
  85281. */
  85282. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85283. }
  85284. /**
  85285. * Info for a bounding data of a mesh
  85286. */
  85287. export class BoundingInfo implements ICullable {
  85288. /**
  85289. * Bounding box for the mesh
  85290. */
  85291. readonly boundingBox: BoundingBox;
  85292. /**
  85293. * Bounding sphere for the mesh
  85294. */
  85295. readonly boundingSphere: BoundingSphere;
  85296. private _isLocked;
  85297. private static readonly TmpVector3;
  85298. /**
  85299. * Constructs bounding info
  85300. * @param minimum min vector of the bounding box/sphere
  85301. * @param maximum max vector of the bounding box/sphere
  85302. * @param worldMatrix defines the new world matrix
  85303. */
  85304. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85305. /**
  85306. * Recreates the entire bounding info from scratch as if we call the constructor in place
  85307. * @param min defines the new minimum vector (in local space)
  85308. * @param max defines the new maximum vector (in local space)
  85309. * @param worldMatrix defines the new world matrix
  85310. */
  85311. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85312. /**
  85313. * min vector of the bounding box/sphere
  85314. */
  85315. get minimum(): Vector3;
  85316. /**
  85317. * max vector of the bounding box/sphere
  85318. */
  85319. get maximum(): Vector3;
  85320. /**
  85321. * If the info is locked and won't be updated to avoid perf overhead
  85322. */
  85323. get isLocked(): boolean;
  85324. set isLocked(value: boolean);
  85325. /**
  85326. * Updates the bounding sphere and box
  85327. * @param world world matrix to be used to update
  85328. */
  85329. update(world: DeepImmutable<Matrix>): void;
  85330. /**
  85331. * Recreate the bounding info to be centered around a specific point given a specific extend.
  85332. * @param center New center of the bounding info
  85333. * @param extend New extend of the bounding info
  85334. * @returns the current bounding info
  85335. */
  85336. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  85337. /**
  85338. * Scale the current bounding info by applying a scale factor
  85339. * @param factor defines the scale factor to apply
  85340. * @returns the current bounding info
  85341. */
  85342. scale(factor: number): BoundingInfo;
  85343. /**
  85344. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  85345. * @param frustumPlanes defines the frustum to test
  85346. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  85347. * @returns true if the bounding info is in the frustum planes
  85348. */
  85349. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  85350. /**
  85351. * Gets the world distance between the min and max points of the bounding box
  85352. */
  85353. get diagonalLength(): number;
  85354. /**
  85355. * Checks if a cullable object (mesh...) is in the camera frustum
  85356. * Unlike isInFrustum this cheks the full bounding box
  85357. * @param frustumPlanes Camera near/planes
  85358. * @returns true if the object is in frustum otherwise false
  85359. */
  85360. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85361. /** @hidden */
  85362. _checkCollision(collider: Collider): boolean;
  85363. /**
  85364. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  85365. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  85366. * @param point the point to check intersection with
  85367. * @returns if the point intersects
  85368. */
  85369. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85370. /**
  85371. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  85372. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  85373. * @param boundingInfo the bounding info to check intersection with
  85374. * @param precise if the intersection should be done using OBB
  85375. * @returns if the bounding info intersects
  85376. */
  85377. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  85378. }
  85379. }
  85380. declare module BABYLON {
  85381. /**
  85382. * Extracts minimum and maximum values from a list of indexed positions
  85383. * @param positions defines the positions to use
  85384. * @param indices defines the indices to the positions
  85385. * @param indexStart defines the start index
  85386. * @param indexCount defines the end index
  85387. * @param bias defines bias value to add to the result
  85388. * @return minimum and maximum values
  85389. */
  85390. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  85391. minimum: Vector3;
  85392. maximum: Vector3;
  85393. };
  85394. /**
  85395. * Extracts minimum and maximum values from a list of positions
  85396. * @param positions defines the positions to use
  85397. * @param start defines the start index in the positions array
  85398. * @param count defines the number of positions to handle
  85399. * @param bias defines bias value to add to the result
  85400. * @param stride defines the stride size to use (distance between two positions in the positions array)
  85401. * @return minimum and maximum values
  85402. */
  85403. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  85404. minimum: Vector3;
  85405. maximum: Vector3;
  85406. };
  85407. }
  85408. declare module BABYLON {
  85409. /** @hidden */
  85410. export class WebGLDataBuffer extends DataBuffer {
  85411. private _buffer;
  85412. constructor(resource: WebGLBuffer);
  85413. get underlyingResource(): any;
  85414. }
  85415. }
  85416. declare module BABYLON {
  85417. /** @hidden */
  85418. export class WebGLPipelineContext implements IPipelineContext {
  85419. engine: ThinEngine;
  85420. program: Nullable<WebGLProgram>;
  85421. context?: WebGLRenderingContext;
  85422. vertexShader?: WebGLShader;
  85423. fragmentShader?: WebGLShader;
  85424. isParallelCompiled: boolean;
  85425. onCompiled?: () => void;
  85426. transformFeedback?: WebGLTransformFeedback | null;
  85427. vertexCompilationError: Nullable<string>;
  85428. fragmentCompilationError: Nullable<string>;
  85429. programLinkError: Nullable<string>;
  85430. programValidationError: Nullable<string>;
  85431. get isAsync(): boolean;
  85432. get isReady(): boolean;
  85433. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  85434. _getVertexShaderCode(): string | null;
  85435. _getFragmentShaderCode(): string | null;
  85436. }
  85437. }
  85438. declare module BABYLON {
  85439. interface ThinEngine {
  85440. /**
  85441. * Create an uniform buffer
  85442. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85443. * @param elements defines the content of the uniform buffer
  85444. * @returns the webGL uniform buffer
  85445. */
  85446. createUniformBuffer(elements: FloatArray): DataBuffer;
  85447. /**
  85448. * Create a dynamic uniform buffer
  85449. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85450. * @param elements defines the content of the uniform buffer
  85451. * @returns the webGL uniform buffer
  85452. */
  85453. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  85454. /**
  85455. * Update an existing uniform buffer
  85456. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85457. * @param uniformBuffer defines the target uniform buffer
  85458. * @param elements defines the content to update
  85459. * @param offset defines the offset in the uniform buffer where update should start
  85460. * @param count defines the size of the data to update
  85461. */
  85462. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  85463. /**
  85464. * Bind an uniform buffer to the current webGL context
  85465. * @param buffer defines the buffer to bind
  85466. */
  85467. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  85468. /**
  85469. * Bind a buffer to the current webGL context at a given location
  85470. * @param buffer defines the buffer to bind
  85471. * @param location defines the index where to bind the buffer
  85472. */
  85473. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  85474. /**
  85475. * Bind a specific block at a given index in a specific shader program
  85476. * @param pipelineContext defines the pipeline context to use
  85477. * @param blockName defines the block name
  85478. * @param index defines the index where to bind the block
  85479. */
  85480. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  85481. }
  85482. }
  85483. declare module BABYLON {
  85484. /**
  85485. * Uniform buffer objects.
  85486. *
  85487. * Handles blocks of uniform on the GPU.
  85488. *
  85489. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85490. *
  85491. * For more information, please refer to :
  85492. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85493. */
  85494. export class UniformBuffer {
  85495. private _engine;
  85496. private _buffer;
  85497. private _data;
  85498. private _bufferData;
  85499. private _dynamic?;
  85500. private _uniformLocations;
  85501. private _uniformSizes;
  85502. private _uniformLocationPointer;
  85503. private _needSync;
  85504. private _noUBO;
  85505. private _currentEffect;
  85506. /** @hidden */
  85507. _alreadyBound: boolean;
  85508. private static _MAX_UNIFORM_SIZE;
  85509. private static _tempBuffer;
  85510. /**
  85511. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  85512. * This is dynamic to allow compat with webgl 1 and 2.
  85513. * You will need to pass the name of the uniform as well as the value.
  85514. */
  85515. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  85516. /**
  85517. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  85518. * This is dynamic to allow compat with webgl 1 and 2.
  85519. * You will need to pass the name of the uniform as well as the value.
  85520. */
  85521. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  85522. /**
  85523. * Lambda to Update a single float in a uniform buffer.
  85524. * This is dynamic to allow compat with webgl 1 and 2.
  85525. * You will need to pass the name of the uniform as well as the value.
  85526. */
  85527. updateFloat: (name: string, x: number) => void;
  85528. /**
  85529. * Lambda to Update a vec2 of float in a uniform buffer.
  85530. * This is dynamic to allow compat with webgl 1 and 2.
  85531. * You will need to pass the name of the uniform as well as the value.
  85532. */
  85533. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  85534. /**
  85535. * Lambda to Update a vec3 of float in a uniform buffer.
  85536. * This is dynamic to allow compat with webgl 1 and 2.
  85537. * You will need to pass the name of the uniform as well as the value.
  85538. */
  85539. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  85540. /**
  85541. * Lambda to Update a vec4 of float in a uniform buffer.
  85542. * This is dynamic to allow compat with webgl 1 and 2.
  85543. * You will need to pass the name of the uniform as well as the value.
  85544. */
  85545. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  85546. /**
  85547. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  85548. * This is dynamic to allow compat with webgl 1 and 2.
  85549. * You will need to pass the name of the uniform as well as the value.
  85550. */
  85551. updateMatrix: (name: string, mat: Matrix) => void;
  85552. /**
  85553. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  85554. * This is dynamic to allow compat with webgl 1 and 2.
  85555. * You will need to pass the name of the uniform as well as the value.
  85556. */
  85557. updateVector3: (name: string, vector: Vector3) => void;
  85558. /**
  85559. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  85560. * This is dynamic to allow compat with webgl 1 and 2.
  85561. * You will need to pass the name of the uniform as well as the value.
  85562. */
  85563. updateVector4: (name: string, vector: Vector4) => void;
  85564. /**
  85565. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  85566. * This is dynamic to allow compat with webgl 1 and 2.
  85567. * You will need to pass the name of the uniform as well as the value.
  85568. */
  85569. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  85570. /**
  85571. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  85572. * This is dynamic to allow compat with webgl 1 and 2.
  85573. * You will need to pass the name of the uniform as well as the value.
  85574. */
  85575. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  85576. /**
  85577. * Instantiates a new Uniform buffer objects.
  85578. *
  85579. * Handles blocks of uniform on the GPU.
  85580. *
  85581. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85582. *
  85583. * For more information, please refer to :
  85584. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85585. * @param engine Define the engine the buffer is associated with
  85586. * @param data Define the data contained in the buffer
  85587. * @param dynamic Define if the buffer is updatable
  85588. */
  85589. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  85590. /**
  85591. * Indicates if the buffer is using the WebGL2 UBO implementation,
  85592. * or just falling back on setUniformXXX calls.
  85593. */
  85594. get useUbo(): boolean;
  85595. /**
  85596. * Indicates if the WebGL underlying uniform buffer is in sync
  85597. * with the javascript cache data.
  85598. */
  85599. get isSync(): boolean;
  85600. /**
  85601. * Indicates if the WebGL underlying uniform buffer is dynamic.
  85602. * Also, a dynamic UniformBuffer will disable cache verification and always
  85603. * update the underlying WebGL uniform buffer to the GPU.
  85604. * @returns if Dynamic, otherwise false
  85605. */
  85606. isDynamic(): boolean;
  85607. /**
  85608. * The data cache on JS side.
  85609. * @returns the underlying data as a float array
  85610. */
  85611. getData(): Float32Array;
  85612. /**
  85613. * The underlying WebGL Uniform buffer.
  85614. * @returns the webgl buffer
  85615. */
  85616. getBuffer(): Nullable<DataBuffer>;
  85617. /**
  85618. * std140 layout specifies how to align data within an UBO structure.
  85619. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  85620. * for specs.
  85621. */
  85622. private _fillAlignment;
  85623. /**
  85624. * Adds an uniform in the buffer.
  85625. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  85626. * for the layout to be correct !
  85627. * @param name Name of the uniform, as used in the uniform block in the shader.
  85628. * @param size Data size, or data directly.
  85629. */
  85630. addUniform(name: string, size: number | number[]): void;
  85631. /**
  85632. * Adds a Matrix 4x4 to the uniform buffer.
  85633. * @param name Name of the uniform, as used in the uniform block in the shader.
  85634. * @param mat A 4x4 matrix.
  85635. */
  85636. addMatrix(name: string, mat: Matrix): void;
  85637. /**
  85638. * Adds a vec2 to the uniform buffer.
  85639. * @param name Name of the uniform, as used in the uniform block in the shader.
  85640. * @param x Define the x component value of the vec2
  85641. * @param y Define the y component value of the vec2
  85642. */
  85643. addFloat2(name: string, x: number, y: number): void;
  85644. /**
  85645. * Adds a vec3 to the uniform buffer.
  85646. * @param name Name of the uniform, as used in the uniform block in the shader.
  85647. * @param x Define the x component value of the vec3
  85648. * @param y Define the y component value of the vec3
  85649. * @param z Define the z component value of the vec3
  85650. */
  85651. addFloat3(name: string, x: number, y: number, z: number): void;
  85652. /**
  85653. * Adds a vec3 to the uniform buffer.
  85654. * @param name Name of the uniform, as used in the uniform block in the shader.
  85655. * @param color Define the vec3 from a Color
  85656. */
  85657. addColor3(name: string, color: Color3): void;
  85658. /**
  85659. * Adds a vec4 to the uniform buffer.
  85660. * @param name Name of the uniform, as used in the uniform block in the shader.
  85661. * @param color Define the rgb components from a Color
  85662. * @param alpha Define the a component of the vec4
  85663. */
  85664. addColor4(name: string, color: Color3, alpha: number): void;
  85665. /**
  85666. * Adds a vec3 to the uniform buffer.
  85667. * @param name Name of the uniform, as used in the uniform block in the shader.
  85668. * @param vector Define the vec3 components from a Vector
  85669. */
  85670. addVector3(name: string, vector: Vector3): void;
  85671. /**
  85672. * Adds a Matrix 3x3 to the uniform buffer.
  85673. * @param name Name of the uniform, as used in the uniform block in the shader.
  85674. */
  85675. addMatrix3x3(name: string): void;
  85676. /**
  85677. * Adds a Matrix 2x2 to the uniform buffer.
  85678. * @param name Name of the uniform, as used in the uniform block in the shader.
  85679. */
  85680. addMatrix2x2(name: string): void;
  85681. /**
  85682. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  85683. */
  85684. create(): void;
  85685. /** @hidden */
  85686. _rebuild(): void;
  85687. /**
  85688. * Updates the WebGL Uniform Buffer on the GPU.
  85689. * If the `dynamic` flag is set to true, no cache comparison is done.
  85690. * Otherwise, the buffer will be updated only if the cache differs.
  85691. */
  85692. update(): void;
  85693. /**
  85694. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  85695. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85696. * @param data Define the flattened data
  85697. * @param size Define the size of the data.
  85698. */
  85699. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  85700. private _valueCache;
  85701. private _cacheMatrix;
  85702. private _updateMatrix3x3ForUniform;
  85703. private _updateMatrix3x3ForEffect;
  85704. private _updateMatrix2x2ForEffect;
  85705. private _updateMatrix2x2ForUniform;
  85706. private _updateFloatForEffect;
  85707. private _updateFloatForUniform;
  85708. private _updateFloat2ForEffect;
  85709. private _updateFloat2ForUniform;
  85710. private _updateFloat3ForEffect;
  85711. private _updateFloat3ForUniform;
  85712. private _updateFloat4ForEffect;
  85713. private _updateFloat4ForUniform;
  85714. private _updateMatrixForEffect;
  85715. private _updateMatrixForUniform;
  85716. private _updateVector3ForEffect;
  85717. private _updateVector3ForUniform;
  85718. private _updateVector4ForEffect;
  85719. private _updateVector4ForUniform;
  85720. private _updateColor3ForEffect;
  85721. private _updateColor3ForUniform;
  85722. private _updateColor4ForEffect;
  85723. private _updateColor4ForUniform;
  85724. /**
  85725. * Sets a sampler uniform on the effect.
  85726. * @param name Define the name of the sampler.
  85727. * @param texture Define the texture to set in the sampler
  85728. */
  85729. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  85730. /**
  85731. * Directly updates the value of the uniform in the cache AND on the GPU.
  85732. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85733. * @param data Define the flattened data
  85734. */
  85735. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  85736. /**
  85737. * Binds this uniform buffer to an effect.
  85738. * @param effect Define the effect to bind the buffer to
  85739. * @param name Name of the uniform block in the shader.
  85740. */
  85741. bindToEffect(effect: Effect, name: string): void;
  85742. /**
  85743. * Disposes the uniform buffer.
  85744. */
  85745. dispose(): void;
  85746. }
  85747. }
  85748. declare module BABYLON {
  85749. /**
  85750. * Enum that determines the text-wrapping mode to use.
  85751. */
  85752. export enum InspectableType {
  85753. /**
  85754. * Checkbox for booleans
  85755. */
  85756. Checkbox = 0,
  85757. /**
  85758. * Sliders for numbers
  85759. */
  85760. Slider = 1,
  85761. /**
  85762. * Vector3
  85763. */
  85764. Vector3 = 2,
  85765. /**
  85766. * Quaternions
  85767. */
  85768. Quaternion = 3,
  85769. /**
  85770. * Color3
  85771. */
  85772. Color3 = 4,
  85773. /**
  85774. * String
  85775. */
  85776. String = 5
  85777. }
  85778. /**
  85779. * Interface used to define custom inspectable properties.
  85780. * This interface is used by the inspector to display custom property grids
  85781. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85782. */
  85783. export interface IInspectable {
  85784. /**
  85785. * Gets the label to display
  85786. */
  85787. label: string;
  85788. /**
  85789. * Gets the name of the property to edit
  85790. */
  85791. propertyName: string;
  85792. /**
  85793. * Gets the type of the editor to use
  85794. */
  85795. type: InspectableType;
  85796. /**
  85797. * Gets the minimum value of the property when using in "slider" mode
  85798. */
  85799. min?: number;
  85800. /**
  85801. * Gets the maximum value of the property when using in "slider" mode
  85802. */
  85803. max?: number;
  85804. /**
  85805. * Gets the setp to use when using in "slider" mode
  85806. */
  85807. step?: number;
  85808. }
  85809. }
  85810. declare module BABYLON {
  85811. /**
  85812. * Class used to provide helper for timing
  85813. */
  85814. export class TimingTools {
  85815. /**
  85816. * Polyfill for setImmediate
  85817. * @param action defines the action to execute after the current execution block
  85818. */
  85819. static SetImmediate(action: () => void): void;
  85820. }
  85821. }
  85822. declare module BABYLON {
  85823. /**
  85824. * Class used to enable instatition of objects by class name
  85825. */
  85826. export class InstantiationTools {
  85827. /**
  85828. * Use this object to register external classes like custom textures or material
  85829. * to allow the laoders to instantiate them
  85830. */
  85831. static RegisteredExternalClasses: {
  85832. [key: string]: Object;
  85833. };
  85834. /**
  85835. * Tries to instantiate a new object from a given class name
  85836. * @param className defines the class name to instantiate
  85837. * @returns the new object or null if the system was not able to do the instantiation
  85838. */
  85839. static Instantiate(className: string): any;
  85840. }
  85841. }
  85842. declare module BABYLON {
  85843. /**
  85844. * Define options used to create a depth texture
  85845. */
  85846. export class DepthTextureCreationOptions {
  85847. /** Specifies whether or not a stencil should be allocated in the texture */
  85848. generateStencil?: boolean;
  85849. /** Specifies whether or not bilinear filtering is enable on the texture */
  85850. bilinearFiltering?: boolean;
  85851. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  85852. comparisonFunction?: number;
  85853. /** Specifies if the created texture is a cube texture */
  85854. isCube?: boolean;
  85855. }
  85856. }
  85857. declare module BABYLON {
  85858. interface ThinEngine {
  85859. /**
  85860. * Creates a depth stencil cube texture.
  85861. * This is only available in WebGL 2.
  85862. * @param size The size of face edge in the cube texture.
  85863. * @param options The options defining the cube texture.
  85864. * @returns The cube texture
  85865. */
  85866. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  85867. /**
  85868. * Creates a cube texture
  85869. * @param rootUrl defines the url where the files to load is located
  85870. * @param scene defines the current scene
  85871. * @param files defines the list of files to load (1 per face)
  85872. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85873. * @param onLoad defines an optional callback raised when the texture is loaded
  85874. * @param onError defines an optional callback raised if there is an issue to load the texture
  85875. * @param format defines the format of the data
  85876. * @param forcedExtension defines the extension to use to pick the right loader
  85877. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85878. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85879. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85880. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  85881. * @returns the cube texture as an InternalTexture
  85882. */
  85883. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  85884. /**
  85885. * Creates a cube texture
  85886. * @param rootUrl defines the url where the files to load is located
  85887. * @param scene defines the current scene
  85888. * @param files defines the list of files to load (1 per face)
  85889. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85890. * @param onLoad defines an optional callback raised when the texture is loaded
  85891. * @param onError defines an optional callback raised if there is an issue to load the texture
  85892. * @param format defines the format of the data
  85893. * @param forcedExtension defines the extension to use to pick the right loader
  85894. * @returns the cube texture as an InternalTexture
  85895. */
  85896. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  85897. /**
  85898. * Creates a cube texture
  85899. * @param rootUrl defines the url where the files to load is located
  85900. * @param scene defines the current scene
  85901. * @param files defines the list of files to load (1 per face)
  85902. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85903. * @param onLoad defines an optional callback raised when the texture is loaded
  85904. * @param onError defines an optional callback raised if there is an issue to load the texture
  85905. * @param format defines the format of the data
  85906. * @param forcedExtension defines the extension to use to pick the right loader
  85907. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85908. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85909. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85910. * @returns the cube texture as an InternalTexture
  85911. */
  85912. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  85913. /** @hidden */
  85914. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  85915. /** @hidden */
  85916. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  85917. /** @hidden */
  85918. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  85919. /** @hidden */
  85920. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  85921. /**
  85922. * @hidden
  85923. */
  85924. _setCubeMapTextureParams(loadMipmap: boolean): void;
  85925. }
  85926. }
  85927. declare module BABYLON {
  85928. /**
  85929. * Class for creating a cube texture
  85930. */
  85931. export class CubeTexture extends BaseTexture {
  85932. private _delayedOnLoad;
  85933. /**
  85934. * Observable triggered once the texture has been loaded.
  85935. */
  85936. onLoadObservable: Observable<CubeTexture>;
  85937. /**
  85938. * The url of the texture
  85939. */
  85940. url: string;
  85941. /**
  85942. * Gets or sets the center of the bounding box associated with the cube texture.
  85943. * It must define where the camera used to render the texture was set
  85944. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  85945. */
  85946. boundingBoxPosition: Vector3;
  85947. private _boundingBoxSize;
  85948. /**
  85949. * Gets or sets the size of the bounding box associated with the cube texture
  85950. * When defined, the cubemap will switch to local mode
  85951. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  85952. * @example https://www.babylonjs-playground.com/#RNASML
  85953. */
  85954. set boundingBoxSize(value: Vector3);
  85955. /**
  85956. * Returns the bounding box size
  85957. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  85958. */
  85959. get boundingBoxSize(): Vector3;
  85960. protected _rotationY: number;
  85961. /**
  85962. * Sets texture matrix rotation angle around Y axis in radians.
  85963. */
  85964. set rotationY(value: number);
  85965. /**
  85966. * Gets texture matrix rotation angle around Y axis radians.
  85967. */
  85968. get rotationY(): number;
  85969. /**
  85970. * Are mip maps generated for this texture or not.
  85971. */
  85972. get noMipmap(): boolean;
  85973. private _noMipmap;
  85974. private _files;
  85975. protected _forcedExtension: Nullable<string>;
  85976. private _extensions;
  85977. private _textureMatrix;
  85978. private _format;
  85979. private _createPolynomials;
  85980. /**
  85981. * Creates a cube texture from an array of image urls
  85982. * @param files defines an array of image urls
  85983. * @param scene defines the hosting scene
  85984. * @param noMipmap specifies if mip maps are not used
  85985. * @returns a cube texture
  85986. */
  85987. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  85988. /**
  85989. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  85990. * @param url defines the url of the prefiltered texture
  85991. * @param scene defines the scene the texture is attached to
  85992. * @param forcedExtension defines the extension of the file if different from the url
  85993. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  85994. * @return the prefiltered texture
  85995. */
  85996. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  85997. /**
  85998. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  85999. * as prefiltered data.
  86000. * @param rootUrl defines the url of the texture or the root name of the six images
  86001. * @param null defines the scene or engine the texture is attached to
  86002. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  86003. * @param noMipmap defines if mipmaps should be created or not
  86004. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  86005. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  86006. * @param onError defines a callback triggered in case of error during load
  86007. * @param format defines the internal format to use for the texture once loaded
  86008. * @param prefiltered defines whether or not the texture is created from prefiltered data
  86009. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  86010. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  86011. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86012. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86013. * @return the cube texture
  86014. */
  86015. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  86016. /**
  86017. * Get the current class name of the texture useful for serialization or dynamic coding.
  86018. * @returns "CubeTexture"
  86019. */
  86020. getClassName(): string;
  86021. /**
  86022. * Update the url (and optional buffer) of this texture if url was null during construction.
  86023. * @param url the url of the texture
  86024. * @param forcedExtension defines the extension to use
  86025. * @param onLoad callback called when the texture is loaded (defaults to null)
  86026. * @param prefiltered Defines whether the updated texture is prefiltered or not
  86027. */
  86028. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  86029. /**
  86030. * Delays loading of the cube texture
  86031. * @param forcedExtension defines the extension to use
  86032. */
  86033. delayLoad(forcedExtension?: string): void;
  86034. /**
  86035. * Returns the reflection texture matrix
  86036. * @returns the reflection texture matrix
  86037. */
  86038. getReflectionTextureMatrix(): Matrix;
  86039. /**
  86040. * Sets the reflection texture matrix
  86041. * @param value Reflection texture matrix
  86042. */
  86043. setReflectionTextureMatrix(value: Matrix): void;
  86044. /**
  86045. * Parses text to create a cube texture
  86046. * @param parsedTexture define the serialized text to read from
  86047. * @param scene defines the hosting scene
  86048. * @param rootUrl defines the root url of the cube texture
  86049. * @returns a cube texture
  86050. */
  86051. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  86052. /**
  86053. * Makes a clone, or deep copy, of the cube texture
  86054. * @returns a new cube texture
  86055. */
  86056. clone(): CubeTexture;
  86057. }
  86058. }
  86059. declare module BABYLON {
  86060. /**
  86061. * Manages the defines for the Material
  86062. */
  86063. export class MaterialDefines {
  86064. /** @hidden */
  86065. protected _keys: string[];
  86066. private _isDirty;
  86067. /** @hidden */
  86068. _renderId: number;
  86069. /** @hidden */
  86070. _areLightsDirty: boolean;
  86071. /** @hidden */
  86072. _areLightsDisposed: boolean;
  86073. /** @hidden */
  86074. _areAttributesDirty: boolean;
  86075. /** @hidden */
  86076. _areTexturesDirty: boolean;
  86077. /** @hidden */
  86078. _areFresnelDirty: boolean;
  86079. /** @hidden */
  86080. _areMiscDirty: boolean;
  86081. /** @hidden */
  86082. _areImageProcessingDirty: boolean;
  86083. /** @hidden */
  86084. _normals: boolean;
  86085. /** @hidden */
  86086. _uvs: boolean;
  86087. /** @hidden */
  86088. _needNormals: boolean;
  86089. /** @hidden */
  86090. _needUVs: boolean;
  86091. [id: string]: any;
  86092. /**
  86093. * Specifies if the material needs to be re-calculated
  86094. */
  86095. get isDirty(): boolean;
  86096. /**
  86097. * Marks the material to indicate that it has been re-calculated
  86098. */
  86099. markAsProcessed(): void;
  86100. /**
  86101. * Marks the material to indicate that it needs to be re-calculated
  86102. */
  86103. markAsUnprocessed(): void;
  86104. /**
  86105. * Marks the material to indicate all of its defines need to be re-calculated
  86106. */
  86107. markAllAsDirty(): void;
  86108. /**
  86109. * Marks the material to indicate that image processing needs to be re-calculated
  86110. */
  86111. markAsImageProcessingDirty(): void;
  86112. /**
  86113. * Marks the material to indicate the lights need to be re-calculated
  86114. * @param disposed Defines whether the light is dirty due to dispose or not
  86115. */
  86116. markAsLightDirty(disposed?: boolean): void;
  86117. /**
  86118. * Marks the attribute state as changed
  86119. */
  86120. markAsAttributesDirty(): void;
  86121. /**
  86122. * Marks the texture state as changed
  86123. */
  86124. markAsTexturesDirty(): void;
  86125. /**
  86126. * Marks the fresnel state as changed
  86127. */
  86128. markAsFresnelDirty(): void;
  86129. /**
  86130. * Marks the misc state as changed
  86131. */
  86132. markAsMiscDirty(): void;
  86133. /**
  86134. * Rebuilds the material defines
  86135. */
  86136. rebuild(): void;
  86137. /**
  86138. * Specifies if two material defines are equal
  86139. * @param other - A material define instance to compare to
  86140. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  86141. */
  86142. isEqual(other: MaterialDefines): boolean;
  86143. /**
  86144. * Clones this instance's defines to another instance
  86145. * @param other - material defines to clone values to
  86146. */
  86147. cloneTo(other: MaterialDefines): void;
  86148. /**
  86149. * Resets the material define values
  86150. */
  86151. reset(): void;
  86152. /**
  86153. * Converts the material define values to a string
  86154. * @returns - String of material define information
  86155. */
  86156. toString(): string;
  86157. }
  86158. }
  86159. declare module BABYLON {
  86160. /**
  86161. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  86162. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  86163. * 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;
  86164. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  86165. */
  86166. export class ColorCurves {
  86167. private _dirty;
  86168. private _tempColor;
  86169. private _globalCurve;
  86170. private _highlightsCurve;
  86171. private _midtonesCurve;
  86172. private _shadowsCurve;
  86173. private _positiveCurve;
  86174. private _negativeCurve;
  86175. private _globalHue;
  86176. private _globalDensity;
  86177. private _globalSaturation;
  86178. private _globalExposure;
  86179. /**
  86180. * Gets the global Hue value.
  86181. * 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).
  86182. */
  86183. get globalHue(): number;
  86184. /**
  86185. * Sets the global Hue value.
  86186. * 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).
  86187. */
  86188. set globalHue(value: number);
  86189. /**
  86190. * Gets the global Density value.
  86191. * 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.
  86192. * Values less than zero provide a filter of opposite hue.
  86193. */
  86194. get globalDensity(): number;
  86195. /**
  86196. * Sets the global Density value.
  86197. * 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.
  86198. * Values less than zero provide a filter of opposite hue.
  86199. */
  86200. set globalDensity(value: number);
  86201. /**
  86202. * Gets the global Saturation value.
  86203. * 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.
  86204. */
  86205. get globalSaturation(): number;
  86206. /**
  86207. * Sets the global Saturation value.
  86208. * 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.
  86209. */
  86210. set globalSaturation(value: number);
  86211. /**
  86212. * Gets the global Exposure value.
  86213. * 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.
  86214. */
  86215. get globalExposure(): number;
  86216. /**
  86217. * Sets the global Exposure value.
  86218. * 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.
  86219. */
  86220. set globalExposure(value: number);
  86221. private _highlightsHue;
  86222. private _highlightsDensity;
  86223. private _highlightsSaturation;
  86224. private _highlightsExposure;
  86225. /**
  86226. * Gets the highlights Hue value.
  86227. * 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).
  86228. */
  86229. get highlightsHue(): number;
  86230. /**
  86231. * Sets the highlights Hue value.
  86232. * 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).
  86233. */
  86234. set highlightsHue(value: number);
  86235. /**
  86236. * Gets the highlights Density value.
  86237. * 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.
  86238. * Values less than zero provide a filter of opposite hue.
  86239. */
  86240. get highlightsDensity(): number;
  86241. /**
  86242. * Sets the highlights Density value.
  86243. * 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.
  86244. * Values less than zero provide a filter of opposite hue.
  86245. */
  86246. set highlightsDensity(value: number);
  86247. /**
  86248. * Gets the highlights Saturation value.
  86249. * 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.
  86250. */
  86251. get highlightsSaturation(): number;
  86252. /**
  86253. * Sets the highlights Saturation value.
  86254. * 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.
  86255. */
  86256. set highlightsSaturation(value: number);
  86257. /**
  86258. * Gets the highlights Exposure value.
  86259. * 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.
  86260. */
  86261. get highlightsExposure(): number;
  86262. /**
  86263. * Sets the highlights Exposure value.
  86264. * 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.
  86265. */
  86266. set highlightsExposure(value: number);
  86267. private _midtonesHue;
  86268. private _midtonesDensity;
  86269. private _midtonesSaturation;
  86270. private _midtonesExposure;
  86271. /**
  86272. * Gets the midtones Hue value.
  86273. * 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).
  86274. */
  86275. get midtonesHue(): number;
  86276. /**
  86277. * Sets the midtones Hue value.
  86278. * 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).
  86279. */
  86280. set midtonesHue(value: number);
  86281. /**
  86282. * Gets the midtones Density value.
  86283. * 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.
  86284. * Values less than zero provide a filter of opposite hue.
  86285. */
  86286. get midtonesDensity(): number;
  86287. /**
  86288. * Sets the midtones Density value.
  86289. * 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.
  86290. * Values less than zero provide a filter of opposite hue.
  86291. */
  86292. set midtonesDensity(value: number);
  86293. /**
  86294. * Gets the midtones Saturation value.
  86295. * 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.
  86296. */
  86297. get midtonesSaturation(): number;
  86298. /**
  86299. * Sets the midtones Saturation value.
  86300. * 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.
  86301. */
  86302. set midtonesSaturation(value: number);
  86303. /**
  86304. * Gets the midtones Exposure value.
  86305. * 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.
  86306. */
  86307. get midtonesExposure(): number;
  86308. /**
  86309. * Sets the midtones Exposure value.
  86310. * 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.
  86311. */
  86312. set midtonesExposure(value: number);
  86313. private _shadowsHue;
  86314. private _shadowsDensity;
  86315. private _shadowsSaturation;
  86316. private _shadowsExposure;
  86317. /**
  86318. * Gets the shadows Hue value.
  86319. * 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).
  86320. */
  86321. get shadowsHue(): number;
  86322. /**
  86323. * Sets the shadows Hue value.
  86324. * 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).
  86325. */
  86326. set shadowsHue(value: number);
  86327. /**
  86328. * Gets the shadows Density value.
  86329. * 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.
  86330. * Values less than zero provide a filter of opposite hue.
  86331. */
  86332. get shadowsDensity(): number;
  86333. /**
  86334. * Sets the shadows Density value.
  86335. * 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.
  86336. * Values less than zero provide a filter of opposite hue.
  86337. */
  86338. set shadowsDensity(value: number);
  86339. /**
  86340. * Gets the shadows Saturation value.
  86341. * 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.
  86342. */
  86343. get shadowsSaturation(): number;
  86344. /**
  86345. * Sets the shadows Saturation value.
  86346. * 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.
  86347. */
  86348. set shadowsSaturation(value: number);
  86349. /**
  86350. * Gets the shadows Exposure value.
  86351. * 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.
  86352. */
  86353. get shadowsExposure(): number;
  86354. /**
  86355. * Sets the shadows Exposure value.
  86356. * 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.
  86357. */
  86358. set shadowsExposure(value: number);
  86359. /**
  86360. * Returns the class name
  86361. * @returns The class name
  86362. */
  86363. getClassName(): string;
  86364. /**
  86365. * Binds the color curves to the shader.
  86366. * @param colorCurves The color curve to bind
  86367. * @param effect The effect to bind to
  86368. * @param positiveUniform The positive uniform shader parameter
  86369. * @param neutralUniform The neutral uniform shader parameter
  86370. * @param negativeUniform The negative uniform shader parameter
  86371. */
  86372. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  86373. /**
  86374. * Prepare the list of uniforms associated with the ColorCurves effects.
  86375. * @param uniformsList The list of uniforms used in the effect
  86376. */
  86377. static PrepareUniforms(uniformsList: string[]): void;
  86378. /**
  86379. * Returns color grading data based on a hue, density, saturation and exposure value.
  86380. * @param filterHue The hue of the color filter.
  86381. * @param filterDensity The density of the color filter.
  86382. * @param saturation The saturation.
  86383. * @param exposure The exposure.
  86384. * @param result The result data container.
  86385. */
  86386. private getColorGradingDataToRef;
  86387. /**
  86388. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  86389. * @param value The input slider value in range [-100,100].
  86390. * @returns Adjusted value.
  86391. */
  86392. private static applyColorGradingSliderNonlinear;
  86393. /**
  86394. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  86395. * @param hue The hue (H) input.
  86396. * @param saturation The saturation (S) input.
  86397. * @param brightness The brightness (B) input.
  86398. * @result An RGBA color represented as Vector4.
  86399. */
  86400. private static fromHSBToRef;
  86401. /**
  86402. * Returns a value clamped between min and max
  86403. * @param value The value to clamp
  86404. * @param min The minimum of value
  86405. * @param max The maximum of value
  86406. * @returns The clamped value.
  86407. */
  86408. private static clamp;
  86409. /**
  86410. * Clones the current color curve instance.
  86411. * @return The cloned curves
  86412. */
  86413. clone(): ColorCurves;
  86414. /**
  86415. * Serializes the current color curve instance to a json representation.
  86416. * @return a JSON representation
  86417. */
  86418. serialize(): any;
  86419. /**
  86420. * Parses the color curve from a json representation.
  86421. * @param source the JSON source to parse
  86422. * @return The parsed curves
  86423. */
  86424. static Parse(source: any): ColorCurves;
  86425. }
  86426. }
  86427. declare module BABYLON {
  86428. /**
  86429. * Interface to follow in your material defines to integrate easily the
  86430. * Image proccessing functions.
  86431. * @hidden
  86432. */
  86433. export interface IImageProcessingConfigurationDefines {
  86434. IMAGEPROCESSING: boolean;
  86435. VIGNETTE: boolean;
  86436. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86437. VIGNETTEBLENDMODEOPAQUE: boolean;
  86438. TONEMAPPING: boolean;
  86439. TONEMAPPING_ACES: boolean;
  86440. CONTRAST: boolean;
  86441. EXPOSURE: boolean;
  86442. COLORCURVES: boolean;
  86443. COLORGRADING: boolean;
  86444. COLORGRADING3D: boolean;
  86445. SAMPLER3DGREENDEPTH: boolean;
  86446. SAMPLER3DBGRMAP: boolean;
  86447. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86448. }
  86449. /**
  86450. * @hidden
  86451. */
  86452. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  86453. IMAGEPROCESSING: boolean;
  86454. VIGNETTE: boolean;
  86455. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86456. VIGNETTEBLENDMODEOPAQUE: boolean;
  86457. TONEMAPPING: boolean;
  86458. TONEMAPPING_ACES: boolean;
  86459. CONTRAST: boolean;
  86460. COLORCURVES: boolean;
  86461. COLORGRADING: boolean;
  86462. COLORGRADING3D: boolean;
  86463. SAMPLER3DGREENDEPTH: boolean;
  86464. SAMPLER3DBGRMAP: boolean;
  86465. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86466. EXPOSURE: boolean;
  86467. constructor();
  86468. }
  86469. /**
  86470. * This groups together the common properties used for image processing either in direct forward pass
  86471. * or through post processing effect depending on the use of the image processing pipeline in your scene
  86472. * or not.
  86473. */
  86474. export class ImageProcessingConfiguration {
  86475. /**
  86476. * Default tone mapping applied in BabylonJS.
  86477. */
  86478. static readonly TONEMAPPING_STANDARD: number;
  86479. /**
  86480. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  86481. * to other engines rendering to increase portability.
  86482. */
  86483. static readonly TONEMAPPING_ACES: number;
  86484. /**
  86485. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  86486. */
  86487. colorCurves: Nullable<ColorCurves>;
  86488. private _colorCurvesEnabled;
  86489. /**
  86490. * Gets wether the color curves effect is enabled.
  86491. */
  86492. get colorCurvesEnabled(): boolean;
  86493. /**
  86494. * Sets wether the color curves effect is enabled.
  86495. */
  86496. set colorCurvesEnabled(value: boolean);
  86497. private _colorGradingTexture;
  86498. /**
  86499. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86500. */
  86501. get colorGradingTexture(): Nullable<BaseTexture>;
  86502. /**
  86503. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86504. */
  86505. set colorGradingTexture(value: Nullable<BaseTexture>);
  86506. private _colorGradingEnabled;
  86507. /**
  86508. * Gets wether the color grading effect is enabled.
  86509. */
  86510. get colorGradingEnabled(): boolean;
  86511. /**
  86512. * Sets wether the color grading effect is enabled.
  86513. */
  86514. set colorGradingEnabled(value: boolean);
  86515. private _colorGradingWithGreenDepth;
  86516. /**
  86517. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  86518. */
  86519. get colorGradingWithGreenDepth(): boolean;
  86520. /**
  86521. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  86522. */
  86523. set colorGradingWithGreenDepth(value: boolean);
  86524. private _colorGradingBGR;
  86525. /**
  86526. * Gets wether the color grading texture contains BGR values.
  86527. */
  86528. get colorGradingBGR(): boolean;
  86529. /**
  86530. * Sets wether the color grading texture contains BGR values.
  86531. */
  86532. set colorGradingBGR(value: boolean);
  86533. /** @hidden */
  86534. _exposure: number;
  86535. /**
  86536. * Gets the Exposure used in the effect.
  86537. */
  86538. get exposure(): number;
  86539. /**
  86540. * Sets the Exposure used in the effect.
  86541. */
  86542. set exposure(value: number);
  86543. private _toneMappingEnabled;
  86544. /**
  86545. * Gets wether the tone mapping effect is enabled.
  86546. */
  86547. get toneMappingEnabled(): boolean;
  86548. /**
  86549. * Sets wether the tone mapping effect is enabled.
  86550. */
  86551. set toneMappingEnabled(value: boolean);
  86552. private _toneMappingType;
  86553. /**
  86554. * Gets the type of tone mapping effect.
  86555. */
  86556. get toneMappingType(): number;
  86557. /**
  86558. * Sets the type of tone mapping effect used in BabylonJS.
  86559. */
  86560. set toneMappingType(value: number);
  86561. protected _contrast: number;
  86562. /**
  86563. * Gets the contrast used in the effect.
  86564. */
  86565. get contrast(): number;
  86566. /**
  86567. * Sets the contrast used in the effect.
  86568. */
  86569. set contrast(value: number);
  86570. /**
  86571. * Vignette stretch size.
  86572. */
  86573. vignetteStretch: number;
  86574. /**
  86575. * Vignette centre X Offset.
  86576. */
  86577. vignetteCentreX: number;
  86578. /**
  86579. * Vignette centre Y Offset.
  86580. */
  86581. vignetteCentreY: number;
  86582. /**
  86583. * Vignette weight or intensity of the vignette effect.
  86584. */
  86585. vignetteWeight: number;
  86586. /**
  86587. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  86588. * if vignetteEnabled is set to true.
  86589. */
  86590. vignetteColor: Color4;
  86591. /**
  86592. * Camera field of view used by the Vignette effect.
  86593. */
  86594. vignetteCameraFov: number;
  86595. private _vignetteBlendMode;
  86596. /**
  86597. * Gets the vignette blend mode allowing different kind of effect.
  86598. */
  86599. get vignetteBlendMode(): number;
  86600. /**
  86601. * Sets the vignette blend mode allowing different kind of effect.
  86602. */
  86603. set vignetteBlendMode(value: number);
  86604. private _vignetteEnabled;
  86605. /**
  86606. * Gets wether the vignette effect is enabled.
  86607. */
  86608. get vignetteEnabled(): boolean;
  86609. /**
  86610. * Sets wether the vignette effect is enabled.
  86611. */
  86612. set vignetteEnabled(value: boolean);
  86613. private _applyByPostProcess;
  86614. /**
  86615. * Gets wether the image processing is applied through a post process or not.
  86616. */
  86617. get applyByPostProcess(): boolean;
  86618. /**
  86619. * Sets wether the image processing is applied through a post process or not.
  86620. */
  86621. set applyByPostProcess(value: boolean);
  86622. private _isEnabled;
  86623. /**
  86624. * Gets wether the image processing is enabled or not.
  86625. */
  86626. get isEnabled(): boolean;
  86627. /**
  86628. * Sets wether the image processing is enabled or not.
  86629. */
  86630. set isEnabled(value: boolean);
  86631. /**
  86632. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  86633. */
  86634. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  86635. /**
  86636. * Method called each time the image processing information changes requires to recompile the effect.
  86637. */
  86638. protected _updateParameters(): void;
  86639. /**
  86640. * Gets the current class name.
  86641. * @return "ImageProcessingConfiguration"
  86642. */
  86643. getClassName(): string;
  86644. /**
  86645. * Prepare the list of uniforms associated with the Image Processing effects.
  86646. * @param uniforms The list of uniforms used in the effect
  86647. * @param defines the list of defines currently in use
  86648. */
  86649. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  86650. /**
  86651. * Prepare the list of samplers associated with the Image Processing effects.
  86652. * @param samplersList The list of uniforms used in the effect
  86653. * @param defines the list of defines currently in use
  86654. */
  86655. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  86656. /**
  86657. * Prepare the list of defines associated to the shader.
  86658. * @param defines the list of defines to complete
  86659. * @param forPostProcess Define if we are currently in post process mode or not
  86660. */
  86661. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  86662. /**
  86663. * Returns true if all the image processing information are ready.
  86664. * @returns True if ready, otherwise, false
  86665. */
  86666. isReady(): boolean;
  86667. /**
  86668. * Binds the image processing to the shader.
  86669. * @param effect The effect to bind to
  86670. * @param overrideAspectRatio Override the aspect ratio of the effect
  86671. */
  86672. bind(effect: Effect, overrideAspectRatio?: number): void;
  86673. /**
  86674. * Clones the current image processing instance.
  86675. * @return The cloned image processing
  86676. */
  86677. clone(): ImageProcessingConfiguration;
  86678. /**
  86679. * Serializes the current image processing instance to a json representation.
  86680. * @return a JSON representation
  86681. */
  86682. serialize(): any;
  86683. /**
  86684. * Parses the image processing from a json representation.
  86685. * @param source the JSON source to parse
  86686. * @return The parsed image processing
  86687. */
  86688. static Parse(source: any): ImageProcessingConfiguration;
  86689. private static _VIGNETTEMODE_MULTIPLY;
  86690. private static _VIGNETTEMODE_OPAQUE;
  86691. /**
  86692. * Used to apply the vignette as a mix with the pixel color.
  86693. */
  86694. static get VIGNETTEMODE_MULTIPLY(): number;
  86695. /**
  86696. * Used to apply the vignette as a replacement of the pixel color.
  86697. */
  86698. static get VIGNETTEMODE_OPAQUE(): number;
  86699. }
  86700. }
  86701. declare module BABYLON {
  86702. /** @hidden */
  86703. export var postprocessVertexShader: {
  86704. name: string;
  86705. shader: string;
  86706. };
  86707. }
  86708. declare module BABYLON {
  86709. interface ThinEngine {
  86710. /**
  86711. * Creates a new render target texture
  86712. * @param size defines the size of the texture
  86713. * @param options defines the options used to create the texture
  86714. * @returns a new render target texture stored in an InternalTexture
  86715. */
  86716. createRenderTargetTexture(size: number | {
  86717. width: number;
  86718. height: number;
  86719. layers?: number;
  86720. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  86721. /**
  86722. * Creates a depth stencil texture.
  86723. * This is only available in WebGL 2 or with the depth texture extension available.
  86724. * @param size The size of face edge in the texture.
  86725. * @param options The options defining the texture.
  86726. * @returns The texture
  86727. */
  86728. createDepthStencilTexture(size: number | {
  86729. width: number;
  86730. height: number;
  86731. layers?: number;
  86732. }, options: DepthTextureCreationOptions): InternalTexture;
  86733. /** @hidden */
  86734. _createDepthStencilTexture(size: number | {
  86735. width: number;
  86736. height: number;
  86737. layers?: number;
  86738. }, options: DepthTextureCreationOptions): InternalTexture;
  86739. }
  86740. }
  86741. declare module BABYLON {
  86742. /**
  86743. * Defines the kind of connection point for node based material
  86744. */
  86745. export enum NodeMaterialBlockConnectionPointTypes {
  86746. /** Float */
  86747. Float = 1,
  86748. /** Int */
  86749. Int = 2,
  86750. /** Vector2 */
  86751. Vector2 = 4,
  86752. /** Vector3 */
  86753. Vector3 = 8,
  86754. /** Vector4 */
  86755. Vector4 = 16,
  86756. /** Color3 */
  86757. Color3 = 32,
  86758. /** Color4 */
  86759. Color4 = 64,
  86760. /** Matrix */
  86761. Matrix = 128,
  86762. /** Custom object */
  86763. Object = 256,
  86764. /** Detect type based on connection */
  86765. AutoDetect = 1024,
  86766. /** Output type that will be defined by input type */
  86767. BasedOnInput = 2048
  86768. }
  86769. }
  86770. declare module BABYLON {
  86771. /**
  86772. * Enum used to define the target of a block
  86773. */
  86774. export enum NodeMaterialBlockTargets {
  86775. /** Vertex shader */
  86776. Vertex = 1,
  86777. /** Fragment shader */
  86778. Fragment = 2,
  86779. /** Neutral */
  86780. Neutral = 4,
  86781. /** Vertex and Fragment */
  86782. VertexAndFragment = 3
  86783. }
  86784. }
  86785. declare module BABYLON {
  86786. /**
  86787. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  86788. */
  86789. export enum NodeMaterialBlockConnectionPointMode {
  86790. /** Value is an uniform */
  86791. Uniform = 0,
  86792. /** Value is a mesh attribute */
  86793. Attribute = 1,
  86794. /** Value is a varying between vertex and fragment shaders */
  86795. Varying = 2,
  86796. /** Mode is undefined */
  86797. Undefined = 3
  86798. }
  86799. }
  86800. declare module BABYLON {
  86801. /**
  86802. * Enum used to define system values e.g. values automatically provided by the system
  86803. */
  86804. export enum NodeMaterialSystemValues {
  86805. /** World */
  86806. World = 1,
  86807. /** View */
  86808. View = 2,
  86809. /** Projection */
  86810. Projection = 3,
  86811. /** ViewProjection */
  86812. ViewProjection = 4,
  86813. /** WorldView */
  86814. WorldView = 5,
  86815. /** WorldViewProjection */
  86816. WorldViewProjection = 6,
  86817. /** CameraPosition */
  86818. CameraPosition = 7,
  86819. /** Fog Color */
  86820. FogColor = 8,
  86821. /** Delta time */
  86822. DeltaTime = 9
  86823. }
  86824. }
  86825. declare module BABYLON {
  86826. /** Defines supported spaces */
  86827. export enum Space {
  86828. /** Local (object) space */
  86829. LOCAL = 0,
  86830. /** World space */
  86831. WORLD = 1,
  86832. /** Bone space */
  86833. BONE = 2
  86834. }
  86835. /** Defines the 3 main axes */
  86836. export class Axis {
  86837. /** X axis */
  86838. static X: Vector3;
  86839. /** Y axis */
  86840. static Y: Vector3;
  86841. /** Z axis */
  86842. static Z: Vector3;
  86843. }
  86844. }
  86845. declare module BABYLON {
  86846. /**
  86847. * Represents a camera frustum
  86848. */
  86849. export class Frustum {
  86850. /**
  86851. * Gets the planes representing the frustum
  86852. * @param transform matrix to be applied to the returned planes
  86853. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  86854. */
  86855. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  86856. /**
  86857. * Gets the near frustum plane transformed by the transform matrix
  86858. * @param transform transformation matrix to be applied to the resulting frustum plane
  86859. * @param frustumPlane the resuling frustum plane
  86860. */
  86861. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86862. /**
  86863. * Gets the far frustum plane transformed by the transform matrix
  86864. * @param transform transformation matrix to be applied to the resulting frustum plane
  86865. * @param frustumPlane the resuling frustum plane
  86866. */
  86867. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86868. /**
  86869. * Gets the left frustum plane transformed by the transform matrix
  86870. * @param transform transformation matrix to be applied to the resulting frustum plane
  86871. * @param frustumPlane the resuling frustum plane
  86872. */
  86873. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86874. /**
  86875. * Gets the right frustum plane transformed by the transform matrix
  86876. * @param transform transformation matrix to be applied to the resulting frustum plane
  86877. * @param frustumPlane the resuling frustum plane
  86878. */
  86879. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86880. /**
  86881. * Gets the top frustum plane transformed by the transform matrix
  86882. * @param transform transformation matrix to be applied to the resulting frustum plane
  86883. * @param frustumPlane the resuling frustum plane
  86884. */
  86885. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86886. /**
  86887. * Gets the bottom frustum plane transformed by the transform matrix
  86888. * @param transform transformation matrix to be applied to the resulting frustum plane
  86889. * @param frustumPlane the resuling frustum plane
  86890. */
  86891. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86892. /**
  86893. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  86894. * @param transform transformation matrix to be applied to the resulting frustum planes
  86895. * @param frustumPlanes the resuling frustum planes
  86896. */
  86897. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  86898. }
  86899. }
  86900. declare module BABYLON {
  86901. /**
  86902. * Interface for the size containing width and height
  86903. */
  86904. export interface ISize {
  86905. /**
  86906. * Width
  86907. */
  86908. width: number;
  86909. /**
  86910. * Heighht
  86911. */
  86912. height: number;
  86913. }
  86914. /**
  86915. * Size containing widht and height
  86916. */
  86917. export class Size implements ISize {
  86918. /**
  86919. * Width
  86920. */
  86921. width: number;
  86922. /**
  86923. * Height
  86924. */
  86925. height: number;
  86926. /**
  86927. * Creates a Size object from the given width and height (floats).
  86928. * @param width width of the new size
  86929. * @param height height of the new size
  86930. */
  86931. constructor(width: number, height: number);
  86932. /**
  86933. * Returns a string with the Size width and height
  86934. * @returns a string with the Size width and height
  86935. */
  86936. toString(): string;
  86937. /**
  86938. * "Size"
  86939. * @returns the string "Size"
  86940. */
  86941. getClassName(): string;
  86942. /**
  86943. * Returns the Size hash code.
  86944. * @returns a hash code for a unique width and height
  86945. */
  86946. getHashCode(): number;
  86947. /**
  86948. * Updates the current size from the given one.
  86949. * @param src the given size
  86950. */
  86951. copyFrom(src: Size): void;
  86952. /**
  86953. * Updates in place the current Size from the given floats.
  86954. * @param width width of the new size
  86955. * @param height height of the new size
  86956. * @returns the updated Size.
  86957. */
  86958. copyFromFloats(width: number, height: number): Size;
  86959. /**
  86960. * Updates in place the current Size from the given floats.
  86961. * @param width width to set
  86962. * @param height height to set
  86963. * @returns the updated Size.
  86964. */
  86965. set(width: number, height: number): Size;
  86966. /**
  86967. * Multiplies the width and height by numbers
  86968. * @param w factor to multiple the width by
  86969. * @param h factor to multiple the height by
  86970. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  86971. */
  86972. multiplyByFloats(w: number, h: number): Size;
  86973. /**
  86974. * Clones the size
  86975. * @returns a new Size copied from the given one.
  86976. */
  86977. clone(): Size;
  86978. /**
  86979. * True if the current Size and the given one width and height are strictly equal.
  86980. * @param other the other size to compare against
  86981. * @returns True if the current Size and the given one width and height are strictly equal.
  86982. */
  86983. equals(other: Size): boolean;
  86984. /**
  86985. * The surface of the Size : width * height (float).
  86986. */
  86987. get surface(): number;
  86988. /**
  86989. * Create a new size of zero
  86990. * @returns a new Size set to (0.0, 0.0)
  86991. */
  86992. static Zero(): Size;
  86993. /**
  86994. * Sums the width and height of two sizes
  86995. * @param otherSize size to add to this size
  86996. * @returns a new Size set as the addition result of the current Size and the given one.
  86997. */
  86998. add(otherSize: Size): Size;
  86999. /**
  87000. * Subtracts the width and height of two
  87001. * @param otherSize size to subtract to this size
  87002. * @returns a new Size set as the subtraction result of the given one from the current Size.
  87003. */
  87004. subtract(otherSize: Size): Size;
  87005. /**
  87006. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  87007. * @param start starting size to lerp between
  87008. * @param end end size to lerp between
  87009. * @param amount amount to lerp between the start and end values
  87010. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  87011. */
  87012. static Lerp(start: Size, end: Size, amount: number): Size;
  87013. }
  87014. }
  87015. declare module BABYLON {
  87016. /**
  87017. * Contains position and normal vectors for a vertex
  87018. */
  87019. export class PositionNormalVertex {
  87020. /** the position of the vertex (defaut: 0,0,0) */
  87021. position: Vector3;
  87022. /** the normal of the vertex (defaut: 0,1,0) */
  87023. normal: Vector3;
  87024. /**
  87025. * Creates a PositionNormalVertex
  87026. * @param position the position of the vertex (defaut: 0,0,0)
  87027. * @param normal the normal of the vertex (defaut: 0,1,0)
  87028. */
  87029. constructor(
  87030. /** the position of the vertex (defaut: 0,0,0) */
  87031. position?: Vector3,
  87032. /** the normal of the vertex (defaut: 0,1,0) */
  87033. normal?: Vector3);
  87034. /**
  87035. * Clones the PositionNormalVertex
  87036. * @returns the cloned PositionNormalVertex
  87037. */
  87038. clone(): PositionNormalVertex;
  87039. }
  87040. /**
  87041. * Contains position, normal and uv vectors for a vertex
  87042. */
  87043. export class PositionNormalTextureVertex {
  87044. /** the position of the vertex (defaut: 0,0,0) */
  87045. position: Vector3;
  87046. /** the normal of the vertex (defaut: 0,1,0) */
  87047. normal: Vector3;
  87048. /** the uv of the vertex (default: 0,0) */
  87049. uv: Vector2;
  87050. /**
  87051. * Creates a PositionNormalTextureVertex
  87052. * @param position the position of the vertex (defaut: 0,0,0)
  87053. * @param normal the normal of the vertex (defaut: 0,1,0)
  87054. * @param uv the uv of the vertex (default: 0,0)
  87055. */
  87056. constructor(
  87057. /** the position of the vertex (defaut: 0,0,0) */
  87058. position?: Vector3,
  87059. /** the normal of the vertex (defaut: 0,1,0) */
  87060. normal?: Vector3,
  87061. /** the uv of the vertex (default: 0,0) */
  87062. uv?: Vector2);
  87063. /**
  87064. * Clones the PositionNormalTextureVertex
  87065. * @returns the cloned PositionNormalTextureVertex
  87066. */
  87067. clone(): PositionNormalTextureVertex;
  87068. }
  87069. }
  87070. declare module BABYLON {
  87071. /**
  87072. * Enum defining the type of animations supported by InputBlock
  87073. */
  87074. export enum AnimatedInputBlockTypes {
  87075. /** No animation */
  87076. None = 0,
  87077. /** Time based animation. Will only work for floats */
  87078. Time = 1
  87079. }
  87080. }
  87081. declare module BABYLON {
  87082. /**
  87083. * Interface describing all the common properties and methods a shadow light needs to implement.
  87084. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  87085. * as well as binding the different shadow properties to the effects.
  87086. */
  87087. export interface IShadowLight extends Light {
  87088. /**
  87089. * The light id in the scene (used in scene.findLighById for instance)
  87090. */
  87091. id: string;
  87092. /**
  87093. * The position the shdow will be casted from.
  87094. */
  87095. position: Vector3;
  87096. /**
  87097. * In 2d mode (needCube being false), the direction used to cast the shadow.
  87098. */
  87099. direction: Vector3;
  87100. /**
  87101. * The transformed position. Position of the light in world space taking parenting in account.
  87102. */
  87103. transformedPosition: Vector3;
  87104. /**
  87105. * The transformed direction. Direction of the light in world space taking parenting in account.
  87106. */
  87107. transformedDirection: Vector3;
  87108. /**
  87109. * The friendly name of the light in the scene.
  87110. */
  87111. name: string;
  87112. /**
  87113. * Defines the shadow projection clipping minimum z value.
  87114. */
  87115. shadowMinZ: number;
  87116. /**
  87117. * Defines the shadow projection clipping maximum z value.
  87118. */
  87119. shadowMaxZ: number;
  87120. /**
  87121. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  87122. * @returns true if the information has been computed, false if it does not need to (no parenting)
  87123. */
  87124. computeTransformedInformation(): boolean;
  87125. /**
  87126. * Gets the scene the light belongs to.
  87127. * @returns The scene
  87128. */
  87129. getScene(): Scene;
  87130. /**
  87131. * Callback defining a custom Projection Matrix Builder.
  87132. * This can be used to override the default projection matrix computation.
  87133. */
  87134. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  87135. /**
  87136. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  87137. * @param matrix The materix to updated with the projection information
  87138. * @param viewMatrix The transform matrix of the light
  87139. * @param renderList The list of mesh to render in the map
  87140. * @returns The current light
  87141. */
  87142. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  87143. /**
  87144. * Gets the current depth scale used in ESM.
  87145. * @returns The scale
  87146. */
  87147. getDepthScale(): number;
  87148. /**
  87149. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  87150. * @returns true if a cube texture needs to be use
  87151. */
  87152. needCube(): boolean;
  87153. /**
  87154. * Detects if the projection matrix requires to be recomputed this frame.
  87155. * @returns true if it requires to be recomputed otherwise, false.
  87156. */
  87157. needProjectionMatrixCompute(): boolean;
  87158. /**
  87159. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  87160. */
  87161. forceProjectionMatrixCompute(): void;
  87162. /**
  87163. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  87164. * @param faceIndex The index of the face we are computed the direction to generate shadow
  87165. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  87166. */
  87167. getShadowDirection(faceIndex?: number): Vector3;
  87168. /**
  87169. * Gets the minZ used for shadow according to both the scene and the light.
  87170. * @param activeCamera The camera we are returning the min for
  87171. * @returns the depth min z
  87172. */
  87173. getDepthMinZ(activeCamera: Camera): number;
  87174. /**
  87175. * Gets the maxZ used for shadow according to both the scene and the light.
  87176. * @param activeCamera The camera we are returning the max for
  87177. * @returns the depth max z
  87178. */
  87179. getDepthMaxZ(activeCamera: Camera): number;
  87180. }
  87181. /**
  87182. * Base implementation IShadowLight
  87183. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  87184. */
  87185. export abstract class ShadowLight extends Light implements IShadowLight {
  87186. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  87187. protected _position: Vector3;
  87188. protected _setPosition(value: Vector3): void;
  87189. /**
  87190. * Sets the position the shadow will be casted from. Also use as the light position for both
  87191. * point and spot lights.
  87192. */
  87193. get position(): Vector3;
  87194. /**
  87195. * Sets the position the shadow will be casted from. Also use as the light position for both
  87196. * point and spot lights.
  87197. */
  87198. set position(value: Vector3);
  87199. protected _direction: Vector3;
  87200. protected _setDirection(value: Vector3): void;
  87201. /**
  87202. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  87203. * Also use as the light direction on spot and directional lights.
  87204. */
  87205. get direction(): Vector3;
  87206. /**
  87207. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  87208. * Also use as the light direction on spot and directional lights.
  87209. */
  87210. set direction(value: Vector3);
  87211. protected _shadowMinZ: number;
  87212. /**
  87213. * Gets the shadow projection clipping minimum z value.
  87214. */
  87215. get shadowMinZ(): number;
  87216. /**
  87217. * Sets the shadow projection clipping minimum z value.
  87218. */
  87219. set shadowMinZ(value: number);
  87220. protected _shadowMaxZ: number;
  87221. /**
  87222. * Sets the shadow projection clipping maximum z value.
  87223. */
  87224. get shadowMaxZ(): number;
  87225. /**
  87226. * Gets the shadow projection clipping maximum z value.
  87227. */
  87228. set shadowMaxZ(value: number);
  87229. /**
  87230. * Callback defining a custom Projection Matrix Builder.
  87231. * This can be used to override the default projection matrix computation.
  87232. */
  87233. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  87234. /**
  87235. * The transformed position. Position of the light in world space taking parenting in account.
  87236. */
  87237. transformedPosition: Vector3;
  87238. /**
  87239. * The transformed direction. Direction of the light in world space taking parenting in account.
  87240. */
  87241. transformedDirection: Vector3;
  87242. private _needProjectionMatrixCompute;
  87243. /**
  87244. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  87245. * @returns true if the information has been computed, false if it does not need to (no parenting)
  87246. */
  87247. computeTransformedInformation(): boolean;
  87248. /**
  87249. * Return the depth scale used for the shadow map.
  87250. * @returns the depth scale.
  87251. */
  87252. getDepthScale(): number;
  87253. /**
  87254. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  87255. * @param faceIndex The index of the face we are computed the direction to generate shadow
  87256. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  87257. */
  87258. getShadowDirection(faceIndex?: number): Vector3;
  87259. /**
  87260. * Returns the ShadowLight absolute position in the World.
  87261. * @returns the position vector in world space
  87262. */
  87263. getAbsolutePosition(): Vector3;
  87264. /**
  87265. * Sets the ShadowLight direction toward the passed target.
  87266. * @param target The point to target in local space
  87267. * @returns the updated ShadowLight direction
  87268. */
  87269. setDirectionToTarget(target: Vector3): Vector3;
  87270. /**
  87271. * Returns the light rotation in euler definition.
  87272. * @returns the x y z rotation in local space.
  87273. */
  87274. getRotation(): Vector3;
  87275. /**
  87276. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  87277. * @returns true if a cube texture needs to be use
  87278. */
  87279. needCube(): boolean;
  87280. /**
  87281. * Detects if the projection matrix requires to be recomputed this frame.
  87282. * @returns true if it requires to be recomputed otherwise, false.
  87283. */
  87284. needProjectionMatrixCompute(): boolean;
  87285. /**
  87286. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  87287. */
  87288. forceProjectionMatrixCompute(): void;
  87289. /** @hidden */
  87290. _initCache(): void;
  87291. /** @hidden */
  87292. _isSynchronized(): boolean;
  87293. /**
  87294. * Computes the world matrix of the node
  87295. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87296. * @returns the world matrix
  87297. */
  87298. computeWorldMatrix(force?: boolean): Matrix;
  87299. /**
  87300. * Gets the minZ used for shadow according to both the scene and the light.
  87301. * @param activeCamera The camera we are returning the min for
  87302. * @returns the depth min z
  87303. */
  87304. getDepthMinZ(activeCamera: Camera): number;
  87305. /**
  87306. * Gets the maxZ used for shadow according to both the scene and the light.
  87307. * @param activeCamera The camera we are returning the max for
  87308. * @returns the depth max z
  87309. */
  87310. getDepthMaxZ(activeCamera: Camera): number;
  87311. /**
  87312. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  87313. * @param matrix The materix to updated with the projection information
  87314. * @param viewMatrix The transform matrix of the light
  87315. * @param renderList The list of mesh to render in the map
  87316. * @returns The current light
  87317. */
  87318. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  87319. }
  87320. }
  87321. declare module BABYLON {
  87322. /** @hidden */
  87323. export var packingFunctions: {
  87324. name: string;
  87325. shader: string;
  87326. };
  87327. }
  87328. declare module BABYLON {
  87329. /** @hidden */
  87330. export var bayerDitherFunctions: {
  87331. name: string;
  87332. shader: string;
  87333. };
  87334. }
  87335. declare module BABYLON {
  87336. /** @hidden */
  87337. export var shadowMapFragmentDeclaration: {
  87338. name: string;
  87339. shader: string;
  87340. };
  87341. }
  87342. declare module BABYLON {
  87343. /** @hidden */
  87344. export var clipPlaneFragmentDeclaration: {
  87345. name: string;
  87346. shader: string;
  87347. };
  87348. }
  87349. declare module BABYLON {
  87350. /** @hidden */
  87351. export var clipPlaneFragment: {
  87352. name: string;
  87353. shader: string;
  87354. };
  87355. }
  87356. declare module BABYLON {
  87357. /** @hidden */
  87358. export var shadowMapFragment: {
  87359. name: string;
  87360. shader: string;
  87361. };
  87362. }
  87363. declare module BABYLON {
  87364. /** @hidden */
  87365. export var shadowMapPixelShader: {
  87366. name: string;
  87367. shader: string;
  87368. };
  87369. }
  87370. declare module BABYLON {
  87371. /** @hidden */
  87372. export var bonesDeclaration: {
  87373. name: string;
  87374. shader: string;
  87375. };
  87376. }
  87377. declare module BABYLON {
  87378. /** @hidden */
  87379. export var morphTargetsVertexGlobalDeclaration: {
  87380. name: string;
  87381. shader: string;
  87382. };
  87383. }
  87384. declare module BABYLON {
  87385. /** @hidden */
  87386. export var morphTargetsVertexDeclaration: {
  87387. name: string;
  87388. shader: string;
  87389. };
  87390. }
  87391. declare module BABYLON {
  87392. /** @hidden */
  87393. export var instancesDeclaration: {
  87394. name: string;
  87395. shader: string;
  87396. };
  87397. }
  87398. declare module BABYLON {
  87399. /** @hidden */
  87400. export var helperFunctions: {
  87401. name: string;
  87402. shader: string;
  87403. };
  87404. }
  87405. declare module BABYLON {
  87406. /** @hidden */
  87407. export var shadowMapVertexDeclaration: {
  87408. name: string;
  87409. shader: string;
  87410. };
  87411. }
  87412. declare module BABYLON {
  87413. /** @hidden */
  87414. export var clipPlaneVertexDeclaration: {
  87415. name: string;
  87416. shader: string;
  87417. };
  87418. }
  87419. declare module BABYLON {
  87420. /** @hidden */
  87421. export var morphTargetsVertex: {
  87422. name: string;
  87423. shader: string;
  87424. };
  87425. }
  87426. declare module BABYLON {
  87427. /** @hidden */
  87428. export var instancesVertex: {
  87429. name: string;
  87430. shader: string;
  87431. };
  87432. }
  87433. declare module BABYLON {
  87434. /** @hidden */
  87435. export var bonesVertex: {
  87436. name: string;
  87437. shader: string;
  87438. };
  87439. }
  87440. declare module BABYLON {
  87441. /** @hidden */
  87442. export var shadowMapVertexNormalBias: {
  87443. name: string;
  87444. shader: string;
  87445. };
  87446. }
  87447. declare module BABYLON {
  87448. /** @hidden */
  87449. export var shadowMapVertexMetric: {
  87450. name: string;
  87451. shader: string;
  87452. };
  87453. }
  87454. declare module BABYLON {
  87455. /** @hidden */
  87456. export var clipPlaneVertex: {
  87457. name: string;
  87458. shader: string;
  87459. };
  87460. }
  87461. declare module BABYLON {
  87462. /** @hidden */
  87463. export var shadowMapVertexShader: {
  87464. name: string;
  87465. shader: string;
  87466. };
  87467. }
  87468. declare module BABYLON {
  87469. /** @hidden */
  87470. export var depthBoxBlurPixelShader: {
  87471. name: string;
  87472. shader: string;
  87473. };
  87474. }
  87475. declare module BABYLON {
  87476. /** @hidden */
  87477. export var shadowMapFragmentSoftTransparentShadow: {
  87478. name: string;
  87479. shader: string;
  87480. };
  87481. }
  87482. declare module BABYLON {
  87483. /**
  87484. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  87485. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  87486. */
  87487. export class EffectFallbacks implements IEffectFallbacks {
  87488. private _defines;
  87489. private _currentRank;
  87490. private _maxRank;
  87491. private _mesh;
  87492. /**
  87493. * Removes the fallback from the bound mesh.
  87494. */
  87495. unBindMesh(): void;
  87496. /**
  87497. * Adds a fallback on the specified property.
  87498. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87499. * @param define The name of the define in the shader
  87500. */
  87501. addFallback(rank: number, define: string): void;
  87502. /**
  87503. * Sets the mesh to use CPU skinning when needing to fallback.
  87504. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87505. * @param mesh The mesh to use the fallbacks.
  87506. */
  87507. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  87508. /**
  87509. * Checks to see if more fallbacks are still availible.
  87510. */
  87511. get hasMoreFallbacks(): boolean;
  87512. /**
  87513. * Removes the defines that should be removed when falling back.
  87514. * @param currentDefines defines the current define statements for the shader.
  87515. * @param effect defines the current effect we try to compile
  87516. * @returns The resulting defines with defines of the current rank removed.
  87517. */
  87518. reduce(currentDefines: string, effect: Effect): string;
  87519. }
  87520. }
  87521. declare module BABYLON {
  87522. /**
  87523. * Interface used to define Action
  87524. */
  87525. export interface IAction {
  87526. /**
  87527. * Trigger for the action
  87528. */
  87529. trigger: number;
  87530. /** Options of the trigger */
  87531. triggerOptions: any;
  87532. /**
  87533. * Gets the trigger parameters
  87534. * @returns the trigger parameters
  87535. */
  87536. getTriggerParameter(): any;
  87537. /**
  87538. * Internal only - executes current action event
  87539. * @hidden
  87540. */
  87541. _executeCurrent(evt?: ActionEvent): void;
  87542. /**
  87543. * Serialize placeholder for child classes
  87544. * @param parent of child
  87545. * @returns the serialized object
  87546. */
  87547. serialize(parent: any): any;
  87548. /**
  87549. * Internal only
  87550. * @hidden
  87551. */
  87552. _prepare(): void;
  87553. /**
  87554. * Internal only - manager for action
  87555. * @hidden
  87556. */
  87557. _actionManager: AbstractActionManager;
  87558. /**
  87559. * Adds action to chain of actions, may be a DoNothingAction
  87560. * @param action defines the next action to execute
  87561. * @returns The action passed in
  87562. * @see https://www.babylonjs-playground.com/#1T30HR#0
  87563. */
  87564. then(action: IAction): IAction;
  87565. }
  87566. /**
  87567. * The action to be carried out following a trigger
  87568. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  87569. */
  87570. export class Action implements IAction {
  87571. /** the trigger, with or without parameters, for the action */
  87572. triggerOptions: any;
  87573. /**
  87574. * Trigger for the action
  87575. */
  87576. trigger: number;
  87577. /**
  87578. * Internal only - manager for action
  87579. * @hidden
  87580. */
  87581. _actionManager: ActionManager;
  87582. private _nextActiveAction;
  87583. private _child;
  87584. private _condition?;
  87585. private _triggerParameter;
  87586. /**
  87587. * An event triggered prior to action being executed.
  87588. */
  87589. onBeforeExecuteObservable: Observable<Action>;
  87590. /**
  87591. * Creates a new Action
  87592. * @param triggerOptions the trigger, with or without parameters, for the action
  87593. * @param condition an optional determinant of action
  87594. */
  87595. constructor(
  87596. /** the trigger, with or without parameters, for the action */
  87597. triggerOptions: any, condition?: Condition);
  87598. /**
  87599. * Internal only
  87600. * @hidden
  87601. */
  87602. _prepare(): void;
  87603. /**
  87604. * Gets the trigger parameters
  87605. * @returns the trigger parameters
  87606. */
  87607. getTriggerParameter(): any;
  87608. /**
  87609. * Internal only - executes current action event
  87610. * @hidden
  87611. */
  87612. _executeCurrent(evt?: ActionEvent): void;
  87613. /**
  87614. * Execute placeholder for child classes
  87615. * @param evt optional action event
  87616. */
  87617. execute(evt?: ActionEvent): void;
  87618. /**
  87619. * Skips to next active action
  87620. */
  87621. skipToNextActiveAction(): void;
  87622. /**
  87623. * Adds action to chain of actions, may be a DoNothingAction
  87624. * @param action defines the next action to execute
  87625. * @returns The action passed in
  87626. * @see https://www.babylonjs-playground.com/#1T30HR#0
  87627. */
  87628. then(action: Action): Action;
  87629. /**
  87630. * Internal only
  87631. * @hidden
  87632. */
  87633. _getProperty(propertyPath: string): string;
  87634. /**
  87635. * Internal only
  87636. * @hidden
  87637. */
  87638. _getEffectiveTarget(target: any, propertyPath: string): any;
  87639. /**
  87640. * Serialize placeholder for child classes
  87641. * @param parent of child
  87642. * @returns the serialized object
  87643. */
  87644. serialize(parent: any): any;
  87645. /**
  87646. * Internal only called by serialize
  87647. * @hidden
  87648. */
  87649. protected _serialize(serializedAction: any, parent?: any): any;
  87650. /**
  87651. * Internal only
  87652. * @hidden
  87653. */
  87654. static _SerializeValueAsString: (value: any) => string;
  87655. /**
  87656. * Internal only
  87657. * @hidden
  87658. */
  87659. static _GetTargetProperty: (target: Scene | Node) => {
  87660. name: string;
  87661. targetType: string;
  87662. value: string;
  87663. };
  87664. }
  87665. }
  87666. declare module BABYLON {
  87667. /**
  87668. * A Condition applied to an Action
  87669. */
  87670. export class Condition {
  87671. /**
  87672. * Internal only - manager for action
  87673. * @hidden
  87674. */
  87675. _actionManager: ActionManager;
  87676. /**
  87677. * Internal only
  87678. * @hidden
  87679. */
  87680. _evaluationId: number;
  87681. /**
  87682. * Internal only
  87683. * @hidden
  87684. */
  87685. _currentResult: boolean;
  87686. /**
  87687. * Creates a new Condition
  87688. * @param actionManager the manager of the action the condition is applied to
  87689. */
  87690. constructor(actionManager: ActionManager);
  87691. /**
  87692. * Check if the current condition is valid
  87693. * @returns a boolean
  87694. */
  87695. isValid(): boolean;
  87696. /**
  87697. * Internal only
  87698. * @hidden
  87699. */
  87700. _getProperty(propertyPath: string): string;
  87701. /**
  87702. * Internal only
  87703. * @hidden
  87704. */
  87705. _getEffectiveTarget(target: any, propertyPath: string): any;
  87706. /**
  87707. * Serialize placeholder for child classes
  87708. * @returns the serialized object
  87709. */
  87710. serialize(): any;
  87711. /**
  87712. * Internal only
  87713. * @hidden
  87714. */
  87715. protected _serialize(serializedCondition: any): any;
  87716. }
  87717. /**
  87718. * Defines specific conditional operators as extensions of Condition
  87719. */
  87720. export class ValueCondition extends Condition {
  87721. /** path to specify the property of the target the conditional operator uses */
  87722. propertyPath: string;
  87723. /** the value compared by the conditional operator against the current value of the property */
  87724. value: any;
  87725. /** the conditional operator, default ValueCondition.IsEqual */
  87726. operator: number;
  87727. /**
  87728. * Internal only
  87729. * @hidden
  87730. */
  87731. private static _IsEqual;
  87732. /**
  87733. * Internal only
  87734. * @hidden
  87735. */
  87736. private static _IsDifferent;
  87737. /**
  87738. * Internal only
  87739. * @hidden
  87740. */
  87741. private static _IsGreater;
  87742. /**
  87743. * Internal only
  87744. * @hidden
  87745. */
  87746. private static _IsLesser;
  87747. /**
  87748. * returns the number for IsEqual
  87749. */
  87750. static get IsEqual(): number;
  87751. /**
  87752. * Returns the number for IsDifferent
  87753. */
  87754. static get IsDifferent(): number;
  87755. /**
  87756. * Returns the number for IsGreater
  87757. */
  87758. static get IsGreater(): number;
  87759. /**
  87760. * Returns the number for IsLesser
  87761. */
  87762. static get IsLesser(): number;
  87763. /**
  87764. * Internal only The action manager for the condition
  87765. * @hidden
  87766. */
  87767. _actionManager: ActionManager;
  87768. /**
  87769. * Internal only
  87770. * @hidden
  87771. */
  87772. private _target;
  87773. /**
  87774. * Internal only
  87775. * @hidden
  87776. */
  87777. private _effectiveTarget;
  87778. /**
  87779. * Internal only
  87780. * @hidden
  87781. */
  87782. private _property;
  87783. /**
  87784. * Creates a new ValueCondition
  87785. * @param actionManager manager for the action the condition applies to
  87786. * @param target for the action
  87787. * @param propertyPath path to specify the property of the target the conditional operator uses
  87788. * @param value the value compared by the conditional operator against the current value of the property
  87789. * @param operator the conditional operator, default ValueCondition.IsEqual
  87790. */
  87791. constructor(actionManager: ActionManager, target: any,
  87792. /** path to specify the property of the target the conditional operator uses */
  87793. propertyPath: string,
  87794. /** the value compared by the conditional operator against the current value of the property */
  87795. value: any,
  87796. /** the conditional operator, default ValueCondition.IsEqual */
  87797. operator?: number);
  87798. /**
  87799. * Compares the given value with the property value for the specified conditional operator
  87800. * @returns the result of the comparison
  87801. */
  87802. isValid(): boolean;
  87803. /**
  87804. * Serialize the ValueCondition into a JSON compatible object
  87805. * @returns serialization object
  87806. */
  87807. serialize(): any;
  87808. /**
  87809. * Gets the name of the conditional operator for the ValueCondition
  87810. * @param operator the conditional operator
  87811. * @returns the name
  87812. */
  87813. static GetOperatorName(operator: number): string;
  87814. }
  87815. /**
  87816. * Defines a predicate condition as an extension of Condition
  87817. */
  87818. export class PredicateCondition extends Condition {
  87819. /** defines the predicate function used to validate the condition */
  87820. predicate: () => boolean;
  87821. /**
  87822. * Internal only - manager for action
  87823. * @hidden
  87824. */
  87825. _actionManager: ActionManager;
  87826. /**
  87827. * Creates a new PredicateCondition
  87828. * @param actionManager manager for the action the condition applies to
  87829. * @param predicate defines the predicate function used to validate the condition
  87830. */
  87831. constructor(actionManager: ActionManager,
  87832. /** defines the predicate function used to validate the condition */
  87833. predicate: () => boolean);
  87834. /**
  87835. * @returns the validity of the predicate condition
  87836. */
  87837. isValid(): boolean;
  87838. }
  87839. /**
  87840. * Defines a state condition as an extension of Condition
  87841. */
  87842. export class StateCondition extends Condition {
  87843. /** Value to compare with target state */
  87844. value: string;
  87845. /**
  87846. * Internal only - manager for action
  87847. * @hidden
  87848. */
  87849. _actionManager: ActionManager;
  87850. /**
  87851. * Internal only
  87852. * @hidden
  87853. */
  87854. private _target;
  87855. /**
  87856. * Creates a new StateCondition
  87857. * @param actionManager manager for the action the condition applies to
  87858. * @param target of the condition
  87859. * @param value to compare with target state
  87860. */
  87861. constructor(actionManager: ActionManager, target: any,
  87862. /** Value to compare with target state */
  87863. value: string);
  87864. /**
  87865. * Gets a boolean indicating if the current condition is met
  87866. * @returns the validity of the state
  87867. */
  87868. isValid(): boolean;
  87869. /**
  87870. * Serialize the StateCondition into a JSON compatible object
  87871. * @returns serialization object
  87872. */
  87873. serialize(): any;
  87874. }
  87875. }
  87876. declare module BABYLON {
  87877. /**
  87878. * This defines an action responsible to toggle a boolean once triggered.
  87879. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  87880. */
  87881. export class SwitchBooleanAction extends Action {
  87882. /**
  87883. * The path to the boolean property in the target object
  87884. */
  87885. propertyPath: string;
  87886. private _target;
  87887. private _effectiveTarget;
  87888. private _property;
  87889. /**
  87890. * Instantiate the action
  87891. * @param triggerOptions defines the trigger options
  87892. * @param target defines the object containing the boolean
  87893. * @param propertyPath defines the path to the boolean property in the target object
  87894. * @param condition defines the trigger related conditions
  87895. */
  87896. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  87897. /** @hidden */
  87898. _prepare(): void;
  87899. /**
  87900. * Execute the action toggle the boolean value.
  87901. */
  87902. execute(): void;
  87903. /**
  87904. * Serializes the actions and its related information.
  87905. * @param parent defines the object to serialize in
  87906. * @returns the serialized object
  87907. */
  87908. serialize(parent: any): any;
  87909. }
  87910. /**
  87911. * This defines an action responsible to set a the state field of the target
  87912. * to a desired value once triggered.
  87913. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  87914. */
  87915. export class SetStateAction extends Action {
  87916. /**
  87917. * The value to store in the state field.
  87918. */
  87919. value: string;
  87920. private _target;
  87921. /**
  87922. * Instantiate the action
  87923. * @param triggerOptions defines the trigger options
  87924. * @param target defines the object containing the state property
  87925. * @param value defines the value to store in the state field
  87926. * @param condition defines the trigger related conditions
  87927. */
  87928. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  87929. /**
  87930. * Execute the action and store the value on the target state property.
  87931. */
  87932. execute(): void;
  87933. /**
  87934. * Serializes the actions and its related information.
  87935. * @param parent defines the object to serialize in
  87936. * @returns the serialized object
  87937. */
  87938. serialize(parent: any): any;
  87939. }
  87940. /**
  87941. * This defines an action responsible to set a property of the target
  87942. * to a desired value once triggered.
  87943. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  87944. */
  87945. export class SetValueAction extends Action {
  87946. /**
  87947. * The path of the property to set in the target.
  87948. */
  87949. propertyPath: string;
  87950. /**
  87951. * The value to set in the property
  87952. */
  87953. value: any;
  87954. private _target;
  87955. private _effectiveTarget;
  87956. private _property;
  87957. /**
  87958. * Instantiate the action
  87959. * @param triggerOptions defines the trigger options
  87960. * @param target defines the object containing the property
  87961. * @param propertyPath defines the path of the property to set in the target
  87962. * @param value defines the value to set in the property
  87963. * @param condition defines the trigger related conditions
  87964. */
  87965. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  87966. /** @hidden */
  87967. _prepare(): void;
  87968. /**
  87969. * Execute the action and set the targetted property to the desired value.
  87970. */
  87971. execute(): void;
  87972. /**
  87973. * Serializes the actions and its related information.
  87974. * @param parent defines the object to serialize in
  87975. * @returns the serialized object
  87976. */
  87977. serialize(parent: any): any;
  87978. }
  87979. /**
  87980. * This defines an action responsible to increment the target value
  87981. * to a desired value once triggered.
  87982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  87983. */
  87984. export class IncrementValueAction extends Action {
  87985. /**
  87986. * The path of the property to increment in the target.
  87987. */
  87988. propertyPath: string;
  87989. /**
  87990. * The value we should increment the property by.
  87991. */
  87992. value: any;
  87993. private _target;
  87994. private _effectiveTarget;
  87995. private _property;
  87996. /**
  87997. * Instantiate the action
  87998. * @param triggerOptions defines the trigger options
  87999. * @param target defines the object containing the property
  88000. * @param propertyPath defines the path of the property to increment in the target
  88001. * @param value defines the value value we should increment the property by
  88002. * @param condition defines the trigger related conditions
  88003. */
  88004. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  88005. /** @hidden */
  88006. _prepare(): void;
  88007. /**
  88008. * Execute the action and increment the target of the value amount.
  88009. */
  88010. execute(): void;
  88011. /**
  88012. * Serializes the actions and its related information.
  88013. * @param parent defines the object to serialize in
  88014. * @returns the serialized object
  88015. */
  88016. serialize(parent: any): any;
  88017. }
  88018. /**
  88019. * This defines an action responsible to start an animation once triggered.
  88020. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88021. */
  88022. export class PlayAnimationAction extends Action {
  88023. /**
  88024. * Where the animation should start (animation frame)
  88025. */
  88026. from: number;
  88027. /**
  88028. * Where the animation should stop (animation frame)
  88029. */
  88030. to: number;
  88031. /**
  88032. * Define if the animation should loop or stop after the first play.
  88033. */
  88034. loop?: boolean;
  88035. private _target;
  88036. /**
  88037. * Instantiate the action
  88038. * @param triggerOptions defines the trigger options
  88039. * @param target defines the target animation or animation name
  88040. * @param from defines from where the animation should start (animation frame)
  88041. * @param end defines where the animation should stop (animation frame)
  88042. * @param loop defines if the animation should loop or stop after the first play
  88043. * @param condition defines the trigger related conditions
  88044. */
  88045. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  88046. /** @hidden */
  88047. _prepare(): void;
  88048. /**
  88049. * Execute the action and play the animation.
  88050. */
  88051. execute(): void;
  88052. /**
  88053. * Serializes the actions and its related information.
  88054. * @param parent defines the object to serialize in
  88055. * @returns the serialized object
  88056. */
  88057. serialize(parent: any): any;
  88058. }
  88059. /**
  88060. * This defines an action responsible to stop an animation once triggered.
  88061. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88062. */
  88063. export class StopAnimationAction extends Action {
  88064. private _target;
  88065. /**
  88066. * Instantiate the action
  88067. * @param triggerOptions defines the trigger options
  88068. * @param target defines the target animation or animation name
  88069. * @param condition defines the trigger related conditions
  88070. */
  88071. constructor(triggerOptions: any, target: any, condition?: Condition);
  88072. /** @hidden */
  88073. _prepare(): void;
  88074. /**
  88075. * Execute the action and stop the animation.
  88076. */
  88077. execute(): void;
  88078. /**
  88079. * Serializes the actions and its related information.
  88080. * @param parent defines the object to serialize in
  88081. * @returns the serialized object
  88082. */
  88083. serialize(parent: any): any;
  88084. }
  88085. /**
  88086. * This defines an action responsible that does nothing once triggered.
  88087. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88088. */
  88089. export class DoNothingAction extends Action {
  88090. /**
  88091. * Instantiate the action
  88092. * @param triggerOptions defines the trigger options
  88093. * @param condition defines the trigger related conditions
  88094. */
  88095. constructor(triggerOptions?: any, condition?: Condition);
  88096. /**
  88097. * Execute the action and do nothing.
  88098. */
  88099. execute(): void;
  88100. /**
  88101. * Serializes the actions and its related information.
  88102. * @param parent defines the object to serialize in
  88103. * @returns the serialized object
  88104. */
  88105. serialize(parent: any): any;
  88106. }
  88107. /**
  88108. * This defines an action responsible to trigger several actions once triggered.
  88109. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88110. */
  88111. export class CombineAction extends Action {
  88112. /**
  88113. * The list of aggregated animations to run.
  88114. */
  88115. children: Action[];
  88116. /**
  88117. * Instantiate the action
  88118. * @param triggerOptions defines the trigger options
  88119. * @param children defines the list of aggregated animations to run
  88120. * @param condition defines the trigger related conditions
  88121. */
  88122. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  88123. /** @hidden */
  88124. _prepare(): void;
  88125. /**
  88126. * Execute the action and executes all the aggregated actions.
  88127. */
  88128. execute(evt: ActionEvent): void;
  88129. /**
  88130. * Serializes the actions and its related information.
  88131. * @param parent defines the object to serialize in
  88132. * @returns the serialized object
  88133. */
  88134. serialize(parent: any): any;
  88135. }
  88136. /**
  88137. * This defines an action responsible to run code (external event) once triggered.
  88138. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88139. */
  88140. export class ExecuteCodeAction extends Action {
  88141. /**
  88142. * The callback function to run.
  88143. */
  88144. func: (evt: ActionEvent) => void;
  88145. /**
  88146. * Instantiate the action
  88147. * @param triggerOptions defines the trigger options
  88148. * @param func defines the callback function to run
  88149. * @param condition defines the trigger related conditions
  88150. */
  88151. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  88152. /**
  88153. * Execute the action and run the attached code.
  88154. */
  88155. execute(evt: ActionEvent): void;
  88156. }
  88157. /**
  88158. * This defines an action responsible to set the parent property of the target once triggered.
  88159. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88160. */
  88161. export class SetParentAction extends Action {
  88162. private _parent;
  88163. private _target;
  88164. /**
  88165. * Instantiate the action
  88166. * @param triggerOptions defines the trigger options
  88167. * @param target defines the target containing the parent property
  88168. * @param parent defines from where the animation should start (animation frame)
  88169. * @param condition defines the trigger related conditions
  88170. */
  88171. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  88172. /** @hidden */
  88173. _prepare(): void;
  88174. /**
  88175. * Execute the action and set the parent property.
  88176. */
  88177. execute(): void;
  88178. /**
  88179. * Serializes the actions and its related information.
  88180. * @param parent defines the object to serialize in
  88181. * @returns the serialized object
  88182. */
  88183. serialize(parent: any): any;
  88184. }
  88185. }
  88186. declare module BABYLON {
  88187. /**
  88188. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  88189. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  88190. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88191. */
  88192. export class ActionManager extends AbstractActionManager {
  88193. /**
  88194. * Nothing
  88195. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88196. */
  88197. static readonly NothingTrigger: number;
  88198. /**
  88199. * On pick
  88200. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88201. */
  88202. static readonly OnPickTrigger: number;
  88203. /**
  88204. * On left pick
  88205. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88206. */
  88207. static readonly OnLeftPickTrigger: number;
  88208. /**
  88209. * On right pick
  88210. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88211. */
  88212. static readonly OnRightPickTrigger: number;
  88213. /**
  88214. * On center pick
  88215. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88216. */
  88217. static readonly OnCenterPickTrigger: number;
  88218. /**
  88219. * On pick down
  88220. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88221. */
  88222. static readonly OnPickDownTrigger: number;
  88223. /**
  88224. * On double pick
  88225. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88226. */
  88227. static readonly OnDoublePickTrigger: number;
  88228. /**
  88229. * On pick up
  88230. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88231. */
  88232. static readonly OnPickUpTrigger: number;
  88233. /**
  88234. * On pick out.
  88235. * This trigger will only be raised if you also declared a OnPickDown
  88236. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88237. */
  88238. static readonly OnPickOutTrigger: number;
  88239. /**
  88240. * On long press
  88241. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88242. */
  88243. static readonly OnLongPressTrigger: number;
  88244. /**
  88245. * On pointer over
  88246. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88247. */
  88248. static readonly OnPointerOverTrigger: number;
  88249. /**
  88250. * On pointer out
  88251. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88252. */
  88253. static readonly OnPointerOutTrigger: number;
  88254. /**
  88255. * On every frame
  88256. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88257. */
  88258. static readonly OnEveryFrameTrigger: number;
  88259. /**
  88260. * On intersection enter
  88261. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88262. */
  88263. static readonly OnIntersectionEnterTrigger: number;
  88264. /**
  88265. * On intersection exit
  88266. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88267. */
  88268. static readonly OnIntersectionExitTrigger: number;
  88269. /**
  88270. * On key down
  88271. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88272. */
  88273. static readonly OnKeyDownTrigger: number;
  88274. /**
  88275. * On key up
  88276. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88277. */
  88278. static readonly OnKeyUpTrigger: number;
  88279. private _scene;
  88280. /**
  88281. * Creates a new action manager
  88282. * @param scene defines the hosting scene
  88283. */
  88284. constructor(scene: Scene);
  88285. /**
  88286. * Releases all associated resources
  88287. */
  88288. dispose(): void;
  88289. /**
  88290. * Gets hosting scene
  88291. * @returns the hosting scene
  88292. */
  88293. getScene(): Scene;
  88294. /**
  88295. * Does this action manager handles actions of any of the given triggers
  88296. * @param triggers defines the triggers to be tested
  88297. * @return a boolean indicating whether one (or more) of the triggers is handled
  88298. */
  88299. hasSpecificTriggers(triggers: number[]): boolean;
  88300. /**
  88301. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  88302. * speed.
  88303. * @param triggerA defines the trigger to be tested
  88304. * @param triggerB defines the trigger to be tested
  88305. * @return a boolean indicating whether one (or more) of the triggers is handled
  88306. */
  88307. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  88308. /**
  88309. * Does this action manager handles actions of a given trigger
  88310. * @param trigger defines the trigger to be tested
  88311. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  88312. * @return whether the trigger is handled
  88313. */
  88314. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  88315. /**
  88316. * Does this action manager has pointer triggers
  88317. */
  88318. get hasPointerTriggers(): boolean;
  88319. /**
  88320. * Does this action manager has pick triggers
  88321. */
  88322. get hasPickTriggers(): boolean;
  88323. /**
  88324. * Registers an action to this action manager
  88325. * @param action defines the action to be registered
  88326. * @return the action amended (prepared) after registration
  88327. */
  88328. registerAction(action: IAction): Nullable<IAction>;
  88329. /**
  88330. * Unregisters an action to this action manager
  88331. * @param action defines the action to be unregistered
  88332. * @return a boolean indicating whether the action has been unregistered
  88333. */
  88334. unregisterAction(action: IAction): Boolean;
  88335. /**
  88336. * Process a specific trigger
  88337. * @param trigger defines the trigger to process
  88338. * @param evt defines the event details to be processed
  88339. */
  88340. processTrigger(trigger: number, evt?: IActionEvent): void;
  88341. /** @hidden */
  88342. _getEffectiveTarget(target: any, propertyPath: string): any;
  88343. /** @hidden */
  88344. _getProperty(propertyPath: string): string;
  88345. /**
  88346. * Serialize this manager to a JSON object
  88347. * @param name defines the property name to store this manager
  88348. * @returns a JSON representation of this manager
  88349. */
  88350. serialize(name: string): any;
  88351. /**
  88352. * Creates a new ActionManager from a JSON data
  88353. * @param parsedActions defines the JSON data to read from
  88354. * @param object defines the hosting mesh
  88355. * @param scene defines the hosting scene
  88356. */
  88357. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  88358. /**
  88359. * Get a trigger name by index
  88360. * @param trigger defines the trigger index
  88361. * @returns a trigger name
  88362. */
  88363. static GetTriggerName(trigger: number): string;
  88364. }
  88365. }
  88366. declare module BABYLON {
  88367. /**
  88368. * Class used to represent a sprite
  88369. * @see https://doc.babylonjs.com/babylon101/sprites
  88370. */
  88371. export class Sprite implements IAnimatable {
  88372. /** defines the name */
  88373. name: string;
  88374. /** Gets or sets the current world position */
  88375. position: Vector3;
  88376. /** Gets or sets the main color */
  88377. color: Color4;
  88378. /** Gets or sets the width */
  88379. width: number;
  88380. /** Gets or sets the height */
  88381. height: number;
  88382. /** Gets or sets rotation angle */
  88383. angle: number;
  88384. /** Gets or sets the cell index in the sprite sheet */
  88385. cellIndex: number;
  88386. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  88387. cellRef: string;
  88388. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  88389. invertU: boolean;
  88390. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  88391. invertV: boolean;
  88392. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  88393. disposeWhenFinishedAnimating: boolean;
  88394. /** Gets the list of attached animations */
  88395. animations: Nullable<Array<Animation>>;
  88396. /** Gets or sets a boolean indicating if the sprite can be picked */
  88397. isPickable: boolean;
  88398. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  88399. useAlphaForPicking: boolean;
  88400. /** @hidden */
  88401. _xOffset: number;
  88402. /** @hidden */
  88403. _yOffset: number;
  88404. /** @hidden */
  88405. _xSize: number;
  88406. /** @hidden */
  88407. _ySize: number;
  88408. /**
  88409. * Gets or sets the associated action manager
  88410. */
  88411. actionManager: Nullable<ActionManager>;
  88412. /**
  88413. * An event triggered when the control has been disposed
  88414. */
  88415. onDisposeObservable: Observable<Sprite>;
  88416. private _animationStarted;
  88417. private _loopAnimation;
  88418. private _fromIndex;
  88419. private _toIndex;
  88420. private _delay;
  88421. private _direction;
  88422. private _manager;
  88423. private _time;
  88424. private _onAnimationEnd;
  88425. /**
  88426. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  88427. */
  88428. isVisible: boolean;
  88429. /**
  88430. * Gets or sets the sprite size
  88431. */
  88432. get size(): number;
  88433. set size(value: number);
  88434. /**
  88435. * Returns a boolean indicating if the animation is started
  88436. */
  88437. get animationStarted(): boolean;
  88438. /**
  88439. * Gets or sets the unique id of the sprite
  88440. */
  88441. uniqueId: number;
  88442. /**
  88443. * Gets the manager of this sprite
  88444. */
  88445. get manager(): ISpriteManager;
  88446. /**
  88447. * Creates a new Sprite
  88448. * @param name defines the name
  88449. * @param manager defines the manager
  88450. */
  88451. constructor(
  88452. /** defines the name */
  88453. name: string, manager: ISpriteManager);
  88454. /**
  88455. * Returns the string "Sprite"
  88456. * @returns "Sprite"
  88457. */
  88458. getClassName(): string;
  88459. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  88460. get fromIndex(): number;
  88461. set fromIndex(value: number);
  88462. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  88463. get toIndex(): number;
  88464. set toIndex(value: number);
  88465. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  88466. get loopAnimation(): boolean;
  88467. set loopAnimation(value: boolean);
  88468. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  88469. get delay(): number;
  88470. set delay(value: number);
  88471. /**
  88472. * Starts an animation
  88473. * @param from defines the initial key
  88474. * @param to defines the end key
  88475. * @param loop defines if the animation must loop
  88476. * @param delay defines the start delay (in ms)
  88477. * @param onAnimationEnd defines a callback to call when animation ends
  88478. */
  88479. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  88480. /** Stops current animation (if any) */
  88481. stopAnimation(): void;
  88482. /** @hidden */
  88483. _animate(deltaTime: number): void;
  88484. /** Release associated resources */
  88485. dispose(): void;
  88486. /**
  88487. * Serializes the sprite to a JSON object
  88488. * @returns the JSON object
  88489. */
  88490. serialize(): any;
  88491. /**
  88492. * Parses a JSON object to create a new sprite
  88493. * @param parsedSprite The JSON object to parse
  88494. * @param manager defines the hosting manager
  88495. * @returns the new sprite
  88496. */
  88497. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  88498. }
  88499. }
  88500. declare module BABYLON {
  88501. /**
  88502. * Information about the result of picking within a scene
  88503. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  88504. */
  88505. export class PickingInfo {
  88506. /** @hidden */
  88507. _pickingUnavailable: boolean;
  88508. /**
  88509. * If the pick collided with an object
  88510. */
  88511. hit: boolean;
  88512. /**
  88513. * Distance away where the pick collided
  88514. */
  88515. distance: number;
  88516. /**
  88517. * The location of pick collision
  88518. */
  88519. pickedPoint: Nullable<Vector3>;
  88520. /**
  88521. * The mesh corresponding the the pick collision
  88522. */
  88523. pickedMesh: Nullable<AbstractMesh>;
  88524. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  88525. bu: number;
  88526. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  88527. bv: number;
  88528. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  88529. faceId: number;
  88530. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  88531. subMeshFaceId: number;
  88532. /** Id of the the submesh that was picked */
  88533. subMeshId: number;
  88534. /** If a sprite was picked, this will be the sprite the pick collided with */
  88535. pickedSprite: Nullable<Sprite>;
  88536. /**
  88537. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  88538. */
  88539. originMesh: Nullable<AbstractMesh>;
  88540. /**
  88541. * The ray that was used to perform the picking.
  88542. */
  88543. ray: Nullable<Ray>;
  88544. /**
  88545. * Gets the normal correspodning to the face the pick collided with
  88546. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  88547. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  88548. * @returns The normal correspodning to the face the pick collided with
  88549. */
  88550. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  88551. /**
  88552. * Gets the texture coordinates of where the pick occured
  88553. * @returns the vector containing the coordnates of the texture
  88554. */
  88555. getTextureCoordinates(): Nullable<Vector2>;
  88556. }
  88557. }
  88558. declare module BABYLON {
  88559. /**
  88560. * Class representing a ray with position and direction
  88561. */
  88562. export class Ray {
  88563. /** origin point */
  88564. origin: Vector3;
  88565. /** direction */
  88566. direction: Vector3;
  88567. /** length of the ray */
  88568. length: number;
  88569. private static readonly TmpVector3;
  88570. private _tmpRay;
  88571. /**
  88572. * Creates a new ray
  88573. * @param origin origin point
  88574. * @param direction direction
  88575. * @param length length of the ray
  88576. */
  88577. constructor(
  88578. /** origin point */
  88579. origin: Vector3,
  88580. /** direction */
  88581. direction: Vector3,
  88582. /** length of the ray */
  88583. length?: number);
  88584. /**
  88585. * Checks if the ray intersects a box
  88586. * This does not account for the ray lenght by design to improve perfs.
  88587. * @param minimum bound of the box
  88588. * @param maximum bound of the box
  88589. * @param intersectionTreshold extra extend to be added to the box in all direction
  88590. * @returns if the box was hit
  88591. */
  88592. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  88593. /**
  88594. * Checks if the ray intersects a box
  88595. * This does not account for the ray lenght by design to improve perfs.
  88596. * @param box the bounding box to check
  88597. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  88598. * @returns if the box was hit
  88599. */
  88600. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  88601. /**
  88602. * If the ray hits a sphere
  88603. * @param sphere the bounding sphere to check
  88604. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  88605. * @returns true if it hits the sphere
  88606. */
  88607. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  88608. /**
  88609. * If the ray hits a triange
  88610. * @param vertex0 triangle vertex
  88611. * @param vertex1 triangle vertex
  88612. * @param vertex2 triangle vertex
  88613. * @returns intersection information if hit
  88614. */
  88615. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  88616. /**
  88617. * Checks if ray intersects a plane
  88618. * @param plane the plane to check
  88619. * @returns the distance away it was hit
  88620. */
  88621. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  88622. /**
  88623. * Calculate the intercept of a ray on a given axis
  88624. * @param axis to check 'x' | 'y' | 'z'
  88625. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  88626. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  88627. */
  88628. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  88629. /**
  88630. * Checks if ray intersects a mesh
  88631. * @param mesh the mesh to check
  88632. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88633. * @returns picking info of the intersecton
  88634. */
  88635. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  88636. /**
  88637. * Checks if ray intersects a mesh
  88638. * @param meshes the meshes to check
  88639. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88640. * @param results array to store result in
  88641. * @returns Array of picking infos
  88642. */
  88643. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  88644. private _comparePickingInfo;
  88645. private static smallnum;
  88646. private static rayl;
  88647. /**
  88648. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  88649. * @param sega the first point of the segment to test the intersection against
  88650. * @param segb the second point of the segment to test the intersection against
  88651. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  88652. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  88653. */
  88654. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  88655. /**
  88656. * Update the ray from viewport position
  88657. * @param x position
  88658. * @param y y position
  88659. * @param viewportWidth viewport width
  88660. * @param viewportHeight viewport height
  88661. * @param world world matrix
  88662. * @param view view matrix
  88663. * @param projection projection matrix
  88664. * @returns this ray updated
  88665. */
  88666. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  88667. /**
  88668. * Creates a ray with origin and direction of 0,0,0
  88669. * @returns the new ray
  88670. */
  88671. static Zero(): Ray;
  88672. /**
  88673. * Creates a new ray from screen space and viewport
  88674. * @param x position
  88675. * @param y y position
  88676. * @param viewportWidth viewport width
  88677. * @param viewportHeight viewport height
  88678. * @param world world matrix
  88679. * @param view view matrix
  88680. * @param projection projection matrix
  88681. * @returns new ray
  88682. */
  88683. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  88684. /**
  88685. * 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
  88686. * transformed to the given world matrix.
  88687. * @param origin The origin point
  88688. * @param end The end point
  88689. * @param world a matrix to transform the ray to. Default is the identity matrix.
  88690. * @returns the new ray
  88691. */
  88692. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  88693. /**
  88694. * Transforms a ray by a matrix
  88695. * @param ray ray to transform
  88696. * @param matrix matrix to apply
  88697. * @returns the resulting new ray
  88698. */
  88699. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  88700. /**
  88701. * Transforms a ray by a matrix
  88702. * @param ray ray to transform
  88703. * @param matrix matrix to apply
  88704. * @param result ray to store result in
  88705. */
  88706. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  88707. /**
  88708. * Unproject a ray from screen space to object space
  88709. * @param sourceX defines the screen space x coordinate to use
  88710. * @param sourceY defines the screen space y coordinate to use
  88711. * @param viewportWidth defines the current width of the viewport
  88712. * @param viewportHeight defines the current height of the viewport
  88713. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  88714. * @param view defines the view matrix to use
  88715. * @param projection defines the projection matrix to use
  88716. */
  88717. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  88718. }
  88719. /**
  88720. * Type used to define predicate used to select faces when a mesh intersection is detected
  88721. */
  88722. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  88723. interface Scene {
  88724. /** @hidden */
  88725. _tempPickingRay: Nullable<Ray>;
  88726. /** @hidden */
  88727. _cachedRayForTransform: Ray;
  88728. /** @hidden */
  88729. _pickWithRayInverseMatrix: Matrix;
  88730. /** @hidden */
  88731. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  88732. /** @hidden */
  88733. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  88734. }
  88735. }
  88736. declare module BABYLON {
  88737. /**
  88738. * Groups all the scene component constants in one place to ease maintenance.
  88739. * @hidden
  88740. */
  88741. export class SceneComponentConstants {
  88742. static readonly NAME_EFFECTLAYER: string;
  88743. static readonly NAME_LAYER: string;
  88744. static readonly NAME_LENSFLARESYSTEM: string;
  88745. static readonly NAME_BOUNDINGBOXRENDERER: string;
  88746. static readonly NAME_PARTICLESYSTEM: string;
  88747. static readonly NAME_GAMEPAD: string;
  88748. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  88749. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  88750. static readonly NAME_PREPASSRENDERER: string;
  88751. static readonly NAME_DEPTHRENDERER: string;
  88752. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  88753. static readonly NAME_SPRITE: string;
  88754. static readonly NAME_OUTLINERENDERER: string;
  88755. static readonly NAME_PROCEDURALTEXTURE: string;
  88756. static readonly NAME_SHADOWGENERATOR: string;
  88757. static readonly NAME_OCTREE: string;
  88758. static readonly NAME_PHYSICSENGINE: string;
  88759. static readonly NAME_AUDIO: string;
  88760. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  88761. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  88762. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  88763. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  88764. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  88765. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  88766. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  88767. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  88768. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  88769. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  88770. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  88771. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  88772. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  88773. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  88774. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  88775. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  88776. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  88777. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  88778. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  88779. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  88780. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  88781. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  88782. static readonly STEP_AFTERRENDER_AUDIO: number;
  88783. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  88784. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  88785. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  88786. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  88787. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  88788. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  88789. static readonly STEP_POINTERMOVE_SPRITE: number;
  88790. static readonly STEP_POINTERDOWN_SPRITE: number;
  88791. static readonly STEP_POINTERUP_SPRITE: number;
  88792. }
  88793. /**
  88794. * This represents a scene component.
  88795. *
  88796. * This is used to decouple the dependency the scene is having on the different workloads like
  88797. * layers, post processes...
  88798. */
  88799. export interface ISceneComponent {
  88800. /**
  88801. * The name of the component. Each component must have a unique name.
  88802. */
  88803. name: string;
  88804. /**
  88805. * The scene the component belongs to.
  88806. */
  88807. scene: Scene;
  88808. /**
  88809. * Register the component to one instance of a scene.
  88810. */
  88811. register(): void;
  88812. /**
  88813. * Rebuilds the elements related to this component in case of
  88814. * context lost for instance.
  88815. */
  88816. rebuild(): void;
  88817. /**
  88818. * Disposes the component and the associated ressources.
  88819. */
  88820. dispose(): void;
  88821. }
  88822. /**
  88823. * This represents a SERIALIZABLE scene component.
  88824. *
  88825. * This extends Scene Component to add Serialization methods on top.
  88826. */
  88827. export interface ISceneSerializableComponent extends ISceneComponent {
  88828. /**
  88829. * Adds all the elements from the container to the scene
  88830. * @param container the container holding the elements
  88831. */
  88832. addFromContainer(container: AbstractScene): void;
  88833. /**
  88834. * Removes all the elements in the container from the scene
  88835. * @param container contains the elements to remove
  88836. * @param dispose if the removed element should be disposed (default: false)
  88837. */
  88838. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  88839. /**
  88840. * Serializes the component data to the specified json object
  88841. * @param serializationObject The object to serialize to
  88842. */
  88843. serialize(serializationObject: any): void;
  88844. }
  88845. /**
  88846. * Strong typing of a Mesh related stage step action
  88847. */
  88848. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  88849. /**
  88850. * Strong typing of a Evaluate Sub Mesh related stage step action
  88851. */
  88852. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  88853. /**
  88854. * Strong typing of a Active Mesh related stage step action
  88855. */
  88856. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  88857. /**
  88858. * Strong typing of a Camera related stage step action
  88859. */
  88860. export type CameraStageAction = (camera: Camera) => void;
  88861. /**
  88862. * Strong typing of a Camera Frame buffer related stage step action
  88863. */
  88864. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  88865. /**
  88866. * Strong typing of a Render Target related stage step action
  88867. */
  88868. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  88869. /**
  88870. * Strong typing of a RenderingGroup related stage step action
  88871. */
  88872. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  88873. /**
  88874. * Strong typing of a Mesh Render related stage step action
  88875. */
  88876. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  88877. /**
  88878. * Strong typing of a simple stage step action
  88879. */
  88880. export type SimpleStageAction = () => void;
  88881. /**
  88882. * Strong typing of a render target action.
  88883. */
  88884. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  88885. /**
  88886. * Strong typing of a pointer move action.
  88887. */
  88888. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  88889. /**
  88890. * Strong typing of a pointer up/down action.
  88891. */
  88892. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  88893. /**
  88894. * Representation of a stage in the scene (Basically a list of ordered steps)
  88895. * @hidden
  88896. */
  88897. export class Stage<T extends Function> extends Array<{
  88898. index: number;
  88899. component: ISceneComponent;
  88900. action: T;
  88901. }> {
  88902. /**
  88903. * Hide ctor from the rest of the world.
  88904. * @param items The items to add.
  88905. */
  88906. private constructor();
  88907. /**
  88908. * Creates a new Stage.
  88909. * @returns A new instance of a Stage
  88910. */
  88911. static Create<T extends Function>(): Stage<T>;
  88912. /**
  88913. * Registers a step in an ordered way in the targeted stage.
  88914. * @param index Defines the position to register the step in
  88915. * @param component Defines the component attached to the step
  88916. * @param action Defines the action to launch during the step
  88917. */
  88918. registerStep(index: number, component: ISceneComponent, action: T): void;
  88919. /**
  88920. * Clears all the steps from the stage.
  88921. */
  88922. clear(): void;
  88923. }
  88924. }
  88925. declare module BABYLON {
  88926. interface Scene {
  88927. /** @hidden */
  88928. _pointerOverSprite: Nullable<Sprite>;
  88929. /** @hidden */
  88930. _pickedDownSprite: Nullable<Sprite>;
  88931. /** @hidden */
  88932. _tempSpritePickingRay: Nullable<Ray>;
  88933. /**
  88934. * All of the sprite managers added to this scene
  88935. * @see https://doc.babylonjs.com/babylon101/sprites
  88936. */
  88937. spriteManagers: Array<ISpriteManager>;
  88938. /**
  88939. * An event triggered when sprites rendering is about to start
  88940. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  88941. */
  88942. onBeforeSpritesRenderingObservable: Observable<Scene>;
  88943. /**
  88944. * An event triggered when sprites rendering is done
  88945. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  88946. */
  88947. onAfterSpritesRenderingObservable: Observable<Scene>;
  88948. /** @hidden */
  88949. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88950. /** Launch a ray to try to pick a sprite in the scene
  88951. * @param x position on screen
  88952. * @param y position on screen
  88953. * @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
  88954. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88955. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  88956. * @returns a PickingInfo
  88957. */
  88958. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88959. /** Use the given ray to pick a sprite in the scene
  88960. * @param ray The ray (in world space) to use to pick meshes
  88961. * @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
  88962. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88963. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  88964. * @returns a PickingInfo
  88965. */
  88966. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88967. /** @hidden */
  88968. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88969. /** Launch a ray to try to pick sprites in the scene
  88970. * @param x position on screen
  88971. * @param y position on screen
  88972. * @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
  88973. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  88974. * @returns a PickingInfo array
  88975. */
  88976. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88977. /** Use the given ray to pick sprites in the scene
  88978. * @param ray The ray (in world space) to use to pick meshes
  88979. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  88980. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  88981. * @returns a PickingInfo array
  88982. */
  88983. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88984. /**
  88985. * Force the sprite under the pointer
  88986. * @param sprite defines the sprite to use
  88987. */
  88988. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  88989. /**
  88990. * Gets the sprite under the pointer
  88991. * @returns a Sprite or null if no sprite is under the pointer
  88992. */
  88993. getPointerOverSprite(): Nullable<Sprite>;
  88994. }
  88995. /**
  88996. * Defines the sprite scene component responsible to manage sprites
  88997. * in a given scene.
  88998. */
  88999. export class SpriteSceneComponent implements ISceneComponent {
  89000. /**
  89001. * The component name helpfull to identify the component in the list of scene components.
  89002. */
  89003. readonly name: string;
  89004. /**
  89005. * The scene the component belongs to.
  89006. */
  89007. scene: Scene;
  89008. /** @hidden */
  89009. private _spritePredicate;
  89010. /**
  89011. * Creates a new instance of the component for the given scene
  89012. * @param scene Defines the scene to register the component in
  89013. */
  89014. constructor(scene: Scene);
  89015. /**
  89016. * Registers the component in a given scene
  89017. */
  89018. register(): void;
  89019. /**
  89020. * Rebuilds the elements related to this component in case of
  89021. * context lost for instance.
  89022. */
  89023. rebuild(): void;
  89024. /**
  89025. * Disposes the component and the associated ressources.
  89026. */
  89027. dispose(): void;
  89028. private _pickSpriteButKeepRay;
  89029. private _pointerMove;
  89030. private _pointerDown;
  89031. private _pointerUp;
  89032. }
  89033. }
  89034. declare module BABYLON {
  89035. /** @hidden */
  89036. export var fogFragmentDeclaration: {
  89037. name: string;
  89038. shader: string;
  89039. };
  89040. }
  89041. declare module BABYLON {
  89042. /** @hidden */
  89043. export var fogFragment: {
  89044. name: string;
  89045. shader: string;
  89046. };
  89047. }
  89048. declare module BABYLON {
  89049. /** @hidden */
  89050. export var spritesPixelShader: {
  89051. name: string;
  89052. shader: string;
  89053. };
  89054. }
  89055. declare module BABYLON {
  89056. /** @hidden */
  89057. export var fogVertexDeclaration: {
  89058. name: string;
  89059. shader: string;
  89060. };
  89061. }
  89062. declare module BABYLON {
  89063. /** @hidden */
  89064. export var spritesVertexShader: {
  89065. name: string;
  89066. shader: string;
  89067. };
  89068. }
  89069. declare module BABYLON {
  89070. /**
  89071. * Defines the minimum interface to fullfil in order to be a sprite manager.
  89072. */
  89073. export interface ISpriteManager extends IDisposable {
  89074. /**
  89075. * Gets manager's name
  89076. */
  89077. name: string;
  89078. /**
  89079. * Restricts the camera to viewing objects with the same layerMask.
  89080. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  89081. */
  89082. layerMask: number;
  89083. /**
  89084. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  89085. */
  89086. isPickable: boolean;
  89087. /**
  89088. * Gets the hosting scene
  89089. */
  89090. scene: Scene;
  89091. /**
  89092. * Specifies the rendering group id for this mesh (0 by default)
  89093. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  89094. */
  89095. renderingGroupId: number;
  89096. /**
  89097. * Defines the list of sprites managed by the manager.
  89098. */
  89099. sprites: Array<Sprite>;
  89100. /**
  89101. * Gets or sets the spritesheet texture
  89102. */
  89103. texture: Texture;
  89104. /** Defines the default width of a cell in the spritesheet */
  89105. cellWidth: number;
  89106. /** Defines the default height of a cell in the spritesheet */
  89107. cellHeight: number;
  89108. /**
  89109. * Tests the intersection of a sprite with a specific ray.
  89110. * @param ray The ray we are sending to test the collision
  89111. * @param camera The camera space we are sending rays in
  89112. * @param predicate A predicate allowing excluding sprites from the list of object to test
  89113. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89114. * @returns picking info or null.
  89115. */
  89116. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89117. /**
  89118. * Intersects the sprites with a ray
  89119. * @param ray defines the ray to intersect with
  89120. * @param camera defines the current active camera
  89121. * @param predicate defines a predicate used to select candidate sprites
  89122. * @returns null if no hit or a PickingInfo array
  89123. */
  89124. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  89125. /**
  89126. * Renders the list of sprites on screen.
  89127. */
  89128. render(): void;
  89129. }
  89130. /**
  89131. * Class used to manage multiple sprites on the same spritesheet
  89132. * @see https://doc.babylonjs.com/babylon101/sprites
  89133. */
  89134. export class SpriteManager implements ISpriteManager {
  89135. /** defines the manager's name */
  89136. name: string;
  89137. /** Define the Url to load snippets */
  89138. static SnippetUrl: string;
  89139. /** Snippet ID if the manager was created from the snippet server */
  89140. snippetId: string;
  89141. /** Gets the list of sprites */
  89142. sprites: Sprite[];
  89143. /** Gets or sets the rendering group id (0 by default) */
  89144. renderingGroupId: number;
  89145. /** Gets or sets camera layer mask */
  89146. layerMask: number;
  89147. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  89148. fogEnabled: boolean;
  89149. /** Gets or sets a boolean indicating if the sprites are pickable */
  89150. isPickable: boolean;
  89151. /** Defines the default width of a cell in the spritesheet */
  89152. cellWidth: number;
  89153. /** Defines the default height of a cell in the spritesheet */
  89154. cellHeight: number;
  89155. /** Associative array from JSON sprite data file */
  89156. private _cellData;
  89157. /** Array of sprite names from JSON sprite data file */
  89158. private _spriteMap;
  89159. /** True when packed cell data from JSON file is ready*/
  89160. private _packedAndReady;
  89161. private _textureContent;
  89162. /**
  89163. * An event triggered when the manager is disposed.
  89164. */
  89165. onDisposeObservable: Observable<SpriteManager>;
  89166. private _onDisposeObserver;
  89167. /**
  89168. * Callback called when the manager is disposed
  89169. */
  89170. set onDispose(callback: () => void);
  89171. private _capacity;
  89172. private _fromPacked;
  89173. private _spriteTexture;
  89174. private _epsilon;
  89175. private _scene;
  89176. private _vertexData;
  89177. private _buffer;
  89178. private _vertexBuffers;
  89179. private _indexBuffer;
  89180. private _effectBase;
  89181. private _effectFog;
  89182. /**
  89183. * Gets or sets the unique id of the sprite
  89184. */
  89185. uniqueId: number;
  89186. /**
  89187. * Gets the array of sprites
  89188. */
  89189. get children(): Sprite[];
  89190. /**
  89191. * Gets the hosting scene
  89192. */
  89193. get scene(): Scene;
  89194. /**
  89195. * Gets the capacity of the manager
  89196. */
  89197. get capacity(): number;
  89198. /**
  89199. * Gets or sets the spritesheet texture
  89200. */
  89201. get texture(): Texture;
  89202. set texture(value: Texture);
  89203. private _blendMode;
  89204. /**
  89205. * Blend mode use to render the particle, it can be any of
  89206. * the static Constants.ALPHA_x properties provided in this class.
  89207. * Default value is Constants.ALPHA_COMBINE
  89208. */
  89209. get blendMode(): number;
  89210. set blendMode(blendMode: number);
  89211. /** Disables writing to the depth buffer when rendering the sprites.
  89212. * It can be handy to disable depth writing when using textures without alpha channel
  89213. * and setting some specific blend modes.
  89214. */
  89215. disableDepthWrite: boolean;
  89216. /**
  89217. * Creates a new sprite manager
  89218. * @param name defines the manager's name
  89219. * @param imgUrl defines the sprite sheet url
  89220. * @param capacity defines the maximum allowed number of sprites
  89221. * @param cellSize defines the size of a sprite cell
  89222. * @param scene defines the hosting scene
  89223. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  89224. * @param samplingMode defines the smapling mode to use with spritesheet
  89225. * @param fromPacked set to false; do not alter
  89226. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  89227. */
  89228. constructor(
  89229. /** defines the manager's name */
  89230. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  89231. /**
  89232. * Returns the string "SpriteManager"
  89233. * @returns "SpriteManager"
  89234. */
  89235. getClassName(): string;
  89236. private _makePacked;
  89237. private _appendSpriteVertex;
  89238. private _checkTextureAlpha;
  89239. /**
  89240. * Intersects the sprites with a ray
  89241. * @param ray defines the ray to intersect with
  89242. * @param camera defines the current active camera
  89243. * @param predicate defines a predicate used to select candidate sprites
  89244. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  89245. * @returns null if no hit or a PickingInfo
  89246. */
  89247. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89248. /**
  89249. * Intersects the sprites with a ray
  89250. * @param ray defines the ray to intersect with
  89251. * @param camera defines the current active camera
  89252. * @param predicate defines a predicate used to select candidate sprites
  89253. * @returns null if no hit or a PickingInfo array
  89254. */
  89255. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  89256. /**
  89257. * Render all child sprites
  89258. */
  89259. render(): void;
  89260. /**
  89261. * Release associated resources
  89262. */
  89263. dispose(): void;
  89264. /**
  89265. * Serializes the sprite manager to a JSON object
  89266. * @param serializeTexture defines if the texture must be serialized as well
  89267. * @returns the JSON object
  89268. */
  89269. serialize(serializeTexture?: boolean): any;
  89270. /**
  89271. * Parses a JSON object to create a new sprite manager.
  89272. * @param parsedManager The JSON object to parse
  89273. * @param scene The scene to create the sprite managerin
  89274. * @param rootUrl The root url to use to load external dependencies like texture
  89275. * @returns the new sprite manager
  89276. */
  89277. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  89278. /**
  89279. * Creates a sprite manager from a snippet saved in a remote file
  89280. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  89281. * @param url defines the url to load from
  89282. * @param scene defines the hosting scene
  89283. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  89284. * @returns a promise that will resolve to the new sprite manager
  89285. */
  89286. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  89287. /**
  89288. * Creates a sprite manager from a snippet saved by the sprite editor
  89289. * @param snippetId defines the snippet to load
  89290. * @param scene defines the hosting scene
  89291. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  89292. * @returns a promise that will resolve to the new sprite manager
  89293. */
  89294. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  89295. }
  89296. }
  89297. declare module BABYLON {
  89298. /** Interface used by value gradients (color, factor, ...) */
  89299. export interface IValueGradient {
  89300. /**
  89301. * Gets or sets the gradient value (between 0 and 1)
  89302. */
  89303. gradient: number;
  89304. }
  89305. /** Class used to store color4 gradient */
  89306. export class ColorGradient implements IValueGradient {
  89307. /**
  89308. * Gets or sets the gradient value (between 0 and 1)
  89309. */
  89310. gradient: number;
  89311. /**
  89312. * Gets or sets first associated color
  89313. */
  89314. color1: Color4;
  89315. /**
  89316. * Gets or sets second associated color
  89317. */
  89318. color2?: Color4 | undefined;
  89319. /**
  89320. * Creates a new color4 gradient
  89321. * @param gradient gets or sets the gradient value (between 0 and 1)
  89322. * @param color1 gets or sets first associated color
  89323. * @param color2 gets or sets first second color
  89324. */
  89325. constructor(
  89326. /**
  89327. * Gets or sets the gradient value (between 0 and 1)
  89328. */
  89329. gradient: number,
  89330. /**
  89331. * Gets or sets first associated color
  89332. */
  89333. color1: Color4,
  89334. /**
  89335. * Gets or sets second associated color
  89336. */
  89337. color2?: Color4 | undefined);
  89338. /**
  89339. * Will get a color picked randomly between color1 and color2.
  89340. * If color2 is undefined then color1 will be used
  89341. * @param result defines the target Color4 to store the result in
  89342. */
  89343. getColorToRef(result: Color4): void;
  89344. }
  89345. /** Class used to store color 3 gradient */
  89346. export class Color3Gradient implements IValueGradient {
  89347. /**
  89348. * Gets or sets the gradient value (between 0 and 1)
  89349. */
  89350. gradient: number;
  89351. /**
  89352. * Gets or sets the associated color
  89353. */
  89354. color: Color3;
  89355. /**
  89356. * Creates a new color3 gradient
  89357. * @param gradient gets or sets the gradient value (between 0 and 1)
  89358. * @param color gets or sets associated color
  89359. */
  89360. constructor(
  89361. /**
  89362. * Gets or sets the gradient value (between 0 and 1)
  89363. */
  89364. gradient: number,
  89365. /**
  89366. * Gets or sets the associated color
  89367. */
  89368. color: Color3);
  89369. }
  89370. /** Class used to store factor gradient */
  89371. export class FactorGradient implements IValueGradient {
  89372. /**
  89373. * Gets or sets the gradient value (between 0 and 1)
  89374. */
  89375. gradient: number;
  89376. /**
  89377. * Gets or sets first associated factor
  89378. */
  89379. factor1: number;
  89380. /**
  89381. * Gets or sets second associated factor
  89382. */
  89383. factor2?: number | undefined;
  89384. /**
  89385. * Creates a new factor gradient
  89386. * @param gradient gets or sets the gradient value (between 0 and 1)
  89387. * @param factor1 gets or sets first associated factor
  89388. * @param factor2 gets or sets second associated factor
  89389. */
  89390. constructor(
  89391. /**
  89392. * Gets or sets the gradient value (between 0 and 1)
  89393. */
  89394. gradient: number,
  89395. /**
  89396. * Gets or sets first associated factor
  89397. */
  89398. factor1: number,
  89399. /**
  89400. * Gets or sets second associated factor
  89401. */
  89402. factor2?: number | undefined);
  89403. /**
  89404. * Will get a number picked randomly between factor1 and factor2.
  89405. * If factor2 is undefined then factor1 will be used
  89406. * @returns the picked number
  89407. */
  89408. getFactor(): number;
  89409. }
  89410. /**
  89411. * Helper used to simplify some generic gradient tasks
  89412. */
  89413. export class GradientHelper {
  89414. /**
  89415. * Gets the current gradient from an array of IValueGradient
  89416. * @param ratio defines the current ratio to get
  89417. * @param gradients defines the array of IValueGradient
  89418. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  89419. */
  89420. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  89421. }
  89422. }
  89423. declare module BABYLON {
  89424. interface ThinEngine {
  89425. /**
  89426. * Creates a raw texture
  89427. * @param data defines the data to store in the texture
  89428. * @param width defines the width of the texture
  89429. * @param height defines the height of the texture
  89430. * @param format defines the format of the data
  89431. * @param generateMipMaps defines if the engine should generate the mip levels
  89432. * @param invertY defines if data must be stored with Y axis inverted
  89433. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  89434. * @param compression defines the compression used (null by default)
  89435. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89436. * @returns the raw texture inside an InternalTexture
  89437. */
  89438. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  89439. /**
  89440. * Update a raw texture
  89441. * @param texture defines the texture to update
  89442. * @param data defines the data to store in the texture
  89443. * @param format defines the format of the data
  89444. * @param invertY defines if data must be stored with Y axis inverted
  89445. */
  89446. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89447. /**
  89448. * Update a raw texture
  89449. * @param texture defines the texture to update
  89450. * @param data defines the data to store in the texture
  89451. * @param format defines the format of the data
  89452. * @param invertY defines if data must be stored with Y axis inverted
  89453. * @param compression defines the compression used (null by default)
  89454. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89455. */
  89456. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  89457. /**
  89458. * Creates a new raw cube texture
  89459. * @param data defines the array of data to use to create each face
  89460. * @param size defines the size of the textures
  89461. * @param format defines the format of the data
  89462. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89463. * @param generateMipMaps defines if the engine should generate the mip levels
  89464. * @param invertY defines if data must be stored with Y axis inverted
  89465. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89466. * @param compression defines the compression used (null by default)
  89467. * @returns the cube texture as an InternalTexture
  89468. */
  89469. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  89470. /**
  89471. * Update a raw cube texture
  89472. * @param texture defines the texture to udpdate
  89473. * @param data defines the data to store
  89474. * @param format defines the data format
  89475. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89476. * @param invertY defines if data must be stored with Y axis inverted
  89477. */
  89478. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  89479. /**
  89480. * Update a raw cube texture
  89481. * @param texture defines the texture to udpdate
  89482. * @param data defines the data to store
  89483. * @param format defines the data format
  89484. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89485. * @param invertY defines if data must be stored with Y axis inverted
  89486. * @param compression defines the compression used (null by default)
  89487. */
  89488. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  89489. /**
  89490. * Update a raw cube texture
  89491. * @param texture defines the texture to udpdate
  89492. * @param data defines the data to store
  89493. * @param format defines the data format
  89494. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89495. * @param invertY defines if data must be stored with Y axis inverted
  89496. * @param compression defines the compression used (null by default)
  89497. * @param level defines which level of the texture to update
  89498. */
  89499. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  89500. /**
  89501. * Creates a new raw cube texture from a specified url
  89502. * @param url defines the url where the data is located
  89503. * @param scene defines the current scene
  89504. * @param size defines the size of the textures
  89505. * @param format defines the format of the data
  89506. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89507. * @param noMipmap defines if the engine should avoid generating the mip levels
  89508. * @param callback defines a callback used to extract texture data from loaded data
  89509. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  89510. * @param onLoad defines a callback called when texture is loaded
  89511. * @param onError defines a callback called if there is an error
  89512. * @returns the cube texture as an InternalTexture
  89513. */
  89514. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  89515. /**
  89516. * Creates a new raw cube texture from a specified url
  89517. * @param url defines the url where the data is located
  89518. * @param scene defines the current scene
  89519. * @param size defines the size of the textures
  89520. * @param format defines the format of the data
  89521. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89522. * @param noMipmap defines if the engine should avoid generating the mip levels
  89523. * @param callback defines a callback used to extract texture data from loaded data
  89524. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  89525. * @param onLoad defines a callback called when texture is loaded
  89526. * @param onError defines a callback called if there is an error
  89527. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89528. * @param invertY defines if data must be stored with Y axis inverted
  89529. * @returns the cube texture as an InternalTexture
  89530. */
  89531. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  89532. /**
  89533. * Creates a new raw 3D texture
  89534. * @param data defines the data used to create the texture
  89535. * @param width defines the width of the texture
  89536. * @param height defines the height of the texture
  89537. * @param depth defines the depth of the texture
  89538. * @param format defines the format of the texture
  89539. * @param generateMipMaps defines if the engine must generate mip levels
  89540. * @param invertY defines if data must be stored with Y axis inverted
  89541. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89542. * @param compression defines the compressed used (can be null)
  89543. * @param textureType defines the compressed used (can be null)
  89544. * @returns a new raw 3D texture (stored in an InternalTexture)
  89545. */
  89546. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  89547. /**
  89548. * Update a raw 3D texture
  89549. * @param texture defines the texture to update
  89550. * @param data defines the data to store
  89551. * @param format defines the data format
  89552. * @param invertY defines if data must be stored with Y axis inverted
  89553. */
  89554. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89555. /**
  89556. * Update a raw 3D texture
  89557. * @param texture defines the texture to update
  89558. * @param data defines the data to store
  89559. * @param format defines the data format
  89560. * @param invertY defines if data must be stored with Y axis inverted
  89561. * @param compression defines the used compression (can be null)
  89562. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  89563. */
  89564. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  89565. /**
  89566. * Creates a new raw 2D array texture
  89567. * @param data defines the data used to create the texture
  89568. * @param width defines the width of the texture
  89569. * @param height defines the height of the texture
  89570. * @param depth defines the number of layers of the texture
  89571. * @param format defines the format of the texture
  89572. * @param generateMipMaps defines if the engine must generate mip levels
  89573. * @param invertY defines if data must be stored with Y axis inverted
  89574. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89575. * @param compression defines the compressed used (can be null)
  89576. * @param textureType defines the compressed used (can be null)
  89577. * @returns a new raw 2D array texture (stored in an InternalTexture)
  89578. */
  89579. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  89580. /**
  89581. * Update a raw 2D array texture
  89582. * @param texture defines the texture to update
  89583. * @param data defines the data to store
  89584. * @param format defines the data format
  89585. * @param invertY defines if data must be stored with Y axis inverted
  89586. */
  89587. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89588. /**
  89589. * Update a raw 2D array texture
  89590. * @param texture defines the texture to update
  89591. * @param data defines the data to store
  89592. * @param format defines the data format
  89593. * @param invertY defines if data must be stored with Y axis inverted
  89594. * @param compression defines the used compression (can be null)
  89595. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  89596. */
  89597. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  89598. }
  89599. }
  89600. declare module BABYLON {
  89601. /**
  89602. * Raw texture can help creating a texture directly from an array of data.
  89603. * This can be super useful if you either get the data from an uncompressed source or
  89604. * if you wish to create your texture pixel by pixel.
  89605. */
  89606. export class RawTexture extends Texture {
  89607. /**
  89608. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89609. */
  89610. format: number;
  89611. /**
  89612. * Instantiates a new RawTexture.
  89613. * Raw texture can help creating a texture directly from an array of data.
  89614. * This can be super useful if you either get the data from an uncompressed source or
  89615. * if you wish to create your texture pixel by pixel.
  89616. * @param data define the array of data to use to create the texture
  89617. * @param width define the width of the texture
  89618. * @param height define the height of the texture
  89619. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89620. * @param scene define the scene the texture belongs to
  89621. * @param generateMipMaps define whether mip maps should be generated or not
  89622. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89623. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89624. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89625. */
  89626. constructor(data: ArrayBufferView, width: number, height: number,
  89627. /**
  89628. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89629. */
  89630. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  89631. /**
  89632. * Updates the texture underlying data.
  89633. * @param data Define the new data of the texture
  89634. */
  89635. update(data: ArrayBufferView): void;
  89636. /**
  89637. * Creates a luminance texture from some data.
  89638. * @param data Define the texture data
  89639. * @param width Define the width of the texture
  89640. * @param height Define the height of the texture
  89641. * @param scene Define the scene the texture belongs to
  89642. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89643. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89644. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89645. * @returns the luminance texture
  89646. */
  89647. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89648. /**
  89649. * Creates a luminance alpha texture from some data.
  89650. * @param data Define the texture data
  89651. * @param width Define the width of the texture
  89652. * @param height Define the height of the texture
  89653. * @param scene Define the scene the texture belongs to
  89654. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89655. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89656. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89657. * @returns the luminance alpha texture
  89658. */
  89659. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89660. /**
  89661. * Creates an alpha texture from some data.
  89662. * @param data Define the texture data
  89663. * @param width Define the width of the texture
  89664. * @param height Define the height of the texture
  89665. * @param scene Define the scene the texture belongs to
  89666. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89667. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89668. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89669. * @returns the alpha texture
  89670. */
  89671. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89672. /**
  89673. * Creates a RGB texture from some data.
  89674. * @param data Define the texture data
  89675. * @param width Define the width of the texture
  89676. * @param height Define the height of the texture
  89677. * @param scene Define the scene the texture belongs to
  89678. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89679. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89680. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89681. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89682. * @returns the RGB alpha texture
  89683. */
  89684. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89685. /**
  89686. * Creates a RGBA texture from some data.
  89687. * @param data Define the texture data
  89688. * @param width Define the width of the texture
  89689. * @param height Define the height of the texture
  89690. * @param scene Define the scene the texture belongs to
  89691. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89692. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89693. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89694. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89695. * @returns the RGBA texture
  89696. */
  89697. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89698. /**
  89699. * Creates a R texture from some data.
  89700. * @param data Define the texture data
  89701. * @param width Define the width of the texture
  89702. * @param height Define the height of the texture
  89703. * @param scene Define the scene the texture belongs to
  89704. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89705. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89706. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89707. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89708. * @returns the R texture
  89709. */
  89710. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89711. }
  89712. }
  89713. declare module BABYLON {
  89714. interface AbstractScene {
  89715. /**
  89716. * The list of procedural textures added to the scene
  89717. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89718. */
  89719. proceduralTextures: Array<ProceduralTexture>;
  89720. }
  89721. /**
  89722. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  89723. * in a given scene.
  89724. */
  89725. export class ProceduralTextureSceneComponent implements ISceneComponent {
  89726. /**
  89727. * The component name helpfull to identify the component in the list of scene components.
  89728. */
  89729. readonly name: string;
  89730. /**
  89731. * The scene the component belongs to.
  89732. */
  89733. scene: Scene;
  89734. /**
  89735. * Creates a new instance of the component for the given scene
  89736. * @param scene Defines the scene to register the component in
  89737. */
  89738. constructor(scene: Scene);
  89739. /**
  89740. * Registers the component in a given scene
  89741. */
  89742. register(): void;
  89743. /**
  89744. * Rebuilds the elements related to this component in case of
  89745. * context lost for instance.
  89746. */
  89747. rebuild(): void;
  89748. /**
  89749. * Disposes the component and the associated ressources.
  89750. */
  89751. dispose(): void;
  89752. private _beforeClear;
  89753. }
  89754. }
  89755. declare module BABYLON {
  89756. interface ThinEngine {
  89757. /**
  89758. * Creates a new render target cube texture
  89759. * @param size defines the size of the texture
  89760. * @param options defines the options used to create the texture
  89761. * @returns a new render target cube texture stored in an InternalTexture
  89762. */
  89763. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  89764. }
  89765. }
  89766. declare module BABYLON {
  89767. /** @hidden */
  89768. export var proceduralVertexShader: {
  89769. name: string;
  89770. shader: string;
  89771. };
  89772. }
  89773. declare module BABYLON {
  89774. /**
  89775. * 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.
  89776. * This is the base class of any Procedural texture and contains most of the shareable code.
  89777. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89778. */
  89779. export class ProceduralTexture extends Texture {
  89780. isCube: boolean;
  89781. /**
  89782. * Define if the texture is enabled or not (disabled texture will not render)
  89783. */
  89784. isEnabled: boolean;
  89785. /**
  89786. * Define if the texture must be cleared before rendering (default is true)
  89787. */
  89788. autoClear: boolean;
  89789. /**
  89790. * Callback called when the texture is generated
  89791. */
  89792. onGenerated: () => void;
  89793. /**
  89794. * Event raised when the texture is generated
  89795. */
  89796. onGeneratedObservable: Observable<ProceduralTexture>;
  89797. /** @hidden */
  89798. _generateMipMaps: boolean;
  89799. /** @hidden **/
  89800. _effect: Effect;
  89801. /** @hidden */
  89802. _textures: {
  89803. [key: string]: Texture;
  89804. };
  89805. /** @hidden */
  89806. protected _fallbackTexture: Nullable<Texture>;
  89807. private _size;
  89808. private _currentRefreshId;
  89809. private _frameId;
  89810. private _refreshRate;
  89811. private _vertexBuffers;
  89812. private _indexBuffer;
  89813. private _uniforms;
  89814. private _samplers;
  89815. private _fragment;
  89816. private _floats;
  89817. private _ints;
  89818. private _floatsArrays;
  89819. private _colors3;
  89820. private _colors4;
  89821. private _vectors2;
  89822. private _vectors3;
  89823. private _matrices;
  89824. private _fallbackTextureUsed;
  89825. private _fullEngine;
  89826. private _cachedDefines;
  89827. private _contentUpdateId;
  89828. private _contentData;
  89829. /**
  89830. * Instantiates a new procedural texture.
  89831. * 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.
  89832. * This is the base class of any Procedural texture and contains most of the shareable code.
  89833. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89834. * @param name Define the name of the texture
  89835. * @param size Define the size of the texture to create
  89836. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  89837. * @param scene Define the scene the texture belongs to
  89838. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  89839. * @param generateMipMaps Define if the texture should creates mip maps or not
  89840. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  89841. */
  89842. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  89843. /**
  89844. * The effect that is created when initializing the post process.
  89845. * @returns The created effect corresponding the the postprocess.
  89846. */
  89847. getEffect(): Effect;
  89848. /**
  89849. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  89850. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  89851. */
  89852. getContent(): Nullable<ArrayBufferView>;
  89853. private _createIndexBuffer;
  89854. /** @hidden */
  89855. _rebuild(): void;
  89856. /**
  89857. * Resets the texture in order to recreate its associated resources.
  89858. * This can be called in case of context loss
  89859. */
  89860. reset(): void;
  89861. protected _getDefines(): string;
  89862. /**
  89863. * Is the texture ready to be used ? (rendered at least once)
  89864. * @returns true if ready, otherwise, false.
  89865. */
  89866. isReady(): boolean;
  89867. /**
  89868. * Resets the refresh counter of the texture and start bak from scratch.
  89869. * Could be useful to regenerate the texture if it is setup to render only once.
  89870. */
  89871. resetRefreshCounter(): void;
  89872. /**
  89873. * Set the fragment shader to use in order to render the texture.
  89874. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  89875. */
  89876. setFragment(fragment: any): void;
  89877. /**
  89878. * Define the refresh rate of the texture or the rendering frequency.
  89879. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  89880. */
  89881. get refreshRate(): number;
  89882. set refreshRate(value: number);
  89883. /** @hidden */
  89884. _shouldRender(): boolean;
  89885. /**
  89886. * Get the size the texture is rendering at.
  89887. * @returns the size (texture is always squared)
  89888. */
  89889. getRenderSize(): number;
  89890. /**
  89891. * Resize the texture to new value.
  89892. * @param size Define the new size the texture should have
  89893. * @param generateMipMaps Define whether the new texture should create mip maps
  89894. */
  89895. resize(size: number, generateMipMaps: boolean): void;
  89896. private _checkUniform;
  89897. /**
  89898. * Set a texture in the shader program used to render.
  89899. * @param name Define the name of the uniform samplers as defined in the shader
  89900. * @param texture Define the texture to bind to this sampler
  89901. * @return the texture itself allowing "fluent" like uniform updates
  89902. */
  89903. setTexture(name: string, texture: Texture): ProceduralTexture;
  89904. /**
  89905. * Set a float in the shader.
  89906. * @param name Define the name of the uniform as defined in the shader
  89907. * @param value Define the value to give to the uniform
  89908. * @return the texture itself allowing "fluent" like uniform updates
  89909. */
  89910. setFloat(name: string, value: number): ProceduralTexture;
  89911. /**
  89912. * Set a int in the shader.
  89913. * @param name Define the name of the uniform as defined in the shader
  89914. * @param value Define the value to give to the uniform
  89915. * @return the texture itself allowing "fluent" like uniform updates
  89916. */
  89917. setInt(name: string, value: number): ProceduralTexture;
  89918. /**
  89919. * Set an array of floats in the shader.
  89920. * @param name Define the name of the uniform as defined in the shader
  89921. * @param value Define the value to give to the uniform
  89922. * @return the texture itself allowing "fluent" like uniform updates
  89923. */
  89924. setFloats(name: string, value: number[]): ProceduralTexture;
  89925. /**
  89926. * Set a vec3 in the shader from a Color3.
  89927. * @param name Define the name of the uniform as defined in the shader
  89928. * @param value Define the value to give to the uniform
  89929. * @return the texture itself allowing "fluent" like uniform updates
  89930. */
  89931. setColor3(name: string, value: Color3): ProceduralTexture;
  89932. /**
  89933. * Set a vec4 in the shader from a Color4.
  89934. * @param name Define the name of the uniform as defined in the shader
  89935. * @param value Define the value to give to the uniform
  89936. * @return the texture itself allowing "fluent" like uniform updates
  89937. */
  89938. setColor4(name: string, value: Color4): ProceduralTexture;
  89939. /**
  89940. * Set a vec2 in the shader from a Vector2.
  89941. * @param name Define the name of the uniform as defined in the shader
  89942. * @param value Define the value to give to the uniform
  89943. * @return the texture itself allowing "fluent" like uniform updates
  89944. */
  89945. setVector2(name: string, value: Vector2): ProceduralTexture;
  89946. /**
  89947. * Set a vec3 in the shader from a Vector3.
  89948. * @param name Define the name of the uniform as defined in the shader
  89949. * @param value Define the value to give to the uniform
  89950. * @return the texture itself allowing "fluent" like uniform updates
  89951. */
  89952. setVector3(name: string, value: Vector3): ProceduralTexture;
  89953. /**
  89954. * Set a mat4 in the shader from a MAtrix.
  89955. * @param name Define the name of the uniform as defined in the shader
  89956. * @param value Define the value to give to the uniform
  89957. * @return the texture itself allowing "fluent" like uniform updates
  89958. */
  89959. setMatrix(name: string, value: Matrix): ProceduralTexture;
  89960. /**
  89961. * Render the texture to its associated render target.
  89962. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  89963. */
  89964. render(useCameraPostProcess?: boolean): void;
  89965. /**
  89966. * Clone the texture.
  89967. * @returns the cloned texture
  89968. */
  89969. clone(): ProceduralTexture;
  89970. /**
  89971. * Dispose the texture and release its asoociated resources.
  89972. */
  89973. dispose(): void;
  89974. }
  89975. }
  89976. declare module BABYLON {
  89977. /**
  89978. * This represents the base class for particle system in Babylon.
  89979. * 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.
  89980. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  89981. * @example https://doc.babylonjs.com/babylon101/particles
  89982. */
  89983. export class BaseParticleSystem {
  89984. /**
  89985. * Source color is added to the destination color without alpha affecting the result
  89986. */
  89987. static BLENDMODE_ONEONE: number;
  89988. /**
  89989. * Blend current color and particle color using particle’s alpha
  89990. */
  89991. static BLENDMODE_STANDARD: number;
  89992. /**
  89993. * Add current color and particle color multiplied by particle’s alpha
  89994. */
  89995. static BLENDMODE_ADD: number;
  89996. /**
  89997. * Multiply current color with particle color
  89998. */
  89999. static BLENDMODE_MULTIPLY: number;
  90000. /**
  90001. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  90002. */
  90003. static BLENDMODE_MULTIPLYADD: number;
  90004. /**
  90005. * List of animations used by the particle system.
  90006. */
  90007. animations: Animation[];
  90008. /**
  90009. * Gets or sets the unique id of the particle system
  90010. */
  90011. uniqueId: number;
  90012. /**
  90013. * The id of the Particle system.
  90014. */
  90015. id: string;
  90016. /**
  90017. * The friendly name of the Particle system.
  90018. */
  90019. name: string;
  90020. /**
  90021. * Snippet ID if the particle system was created from the snippet server
  90022. */
  90023. snippetId: string;
  90024. /**
  90025. * The rendering group used by the Particle system to chose when to render.
  90026. */
  90027. renderingGroupId: number;
  90028. /**
  90029. * The emitter represents the Mesh or position we are attaching the particle system to.
  90030. */
  90031. emitter: Nullable<AbstractMesh | Vector3>;
  90032. /**
  90033. * The maximum number of particles to emit per frame
  90034. */
  90035. emitRate: number;
  90036. /**
  90037. * If you want to launch only a few particles at once, that can be done, as well.
  90038. */
  90039. manualEmitCount: number;
  90040. /**
  90041. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  90042. */
  90043. updateSpeed: number;
  90044. /**
  90045. * The amount of time the particle system is running (depends of the overall update speed).
  90046. */
  90047. targetStopDuration: number;
  90048. /**
  90049. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  90050. */
  90051. disposeOnStop: boolean;
  90052. /**
  90053. * Minimum power of emitting particles.
  90054. */
  90055. minEmitPower: number;
  90056. /**
  90057. * Maximum power of emitting particles.
  90058. */
  90059. maxEmitPower: number;
  90060. /**
  90061. * Minimum life time of emitting particles.
  90062. */
  90063. minLifeTime: number;
  90064. /**
  90065. * Maximum life time of emitting particles.
  90066. */
  90067. maxLifeTime: number;
  90068. /**
  90069. * Minimum Size of emitting particles.
  90070. */
  90071. minSize: number;
  90072. /**
  90073. * Maximum Size of emitting particles.
  90074. */
  90075. maxSize: number;
  90076. /**
  90077. * Minimum scale of emitting particles on X axis.
  90078. */
  90079. minScaleX: number;
  90080. /**
  90081. * Maximum scale of emitting particles on X axis.
  90082. */
  90083. maxScaleX: number;
  90084. /**
  90085. * Minimum scale of emitting particles on Y axis.
  90086. */
  90087. minScaleY: number;
  90088. /**
  90089. * Maximum scale of emitting particles on Y axis.
  90090. */
  90091. maxScaleY: number;
  90092. /**
  90093. * Gets or sets the minimal initial rotation in radians.
  90094. */
  90095. minInitialRotation: number;
  90096. /**
  90097. * Gets or sets the maximal initial rotation in radians.
  90098. */
  90099. maxInitialRotation: number;
  90100. /**
  90101. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  90102. */
  90103. minAngularSpeed: number;
  90104. /**
  90105. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  90106. */
  90107. maxAngularSpeed: number;
  90108. /**
  90109. * The texture used to render each particle. (this can be a spritesheet)
  90110. */
  90111. particleTexture: Nullable<Texture>;
  90112. /**
  90113. * The layer mask we are rendering the particles through.
  90114. */
  90115. layerMask: number;
  90116. /**
  90117. * This can help using your own shader to render the particle system.
  90118. * The according effect will be created
  90119. */
  90120. customShader: any;
  90121. /**
  90122. * By default particle system starts as soon as they are created. This prevents the
  90123. * automatic start to happen and let you decide when to start emitting particles.
  90124. */
  90125. preventAutoStart: boolean;
  90126. private _noiseTexture;
  90127. /**
  90128. * Gets or sets a texture used to add random noise to particle positions
  90129. */
  90130. get noiseTexture(): Nullable<ProceduralTexture>;
  90131. set noiseTexture(value: Nullable<ProceduralTexture>);
  90132. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  90133. noiseStrength: Vector3;
  90134. /**
  90135. * Callback triggered when the particle animation is ending.
  90136. */
  90137. onAnimationEnd: Nullable<() => void>;
  90138. /**
  90139. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  90140. */
  90141. blendMode: number;
  90142. /**
  90143. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  90144. * to override the particles.
  90145. */
  90146. forceDepthWrite: boolean;
  90147. /** 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 */
  90148. preWarmCycles: number;
  90149. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  90150. preWarmStepOffset: number;
  90151. /**
  90152. * 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)
  90153. */
  90154. spriteCellChangeSpeed: number;
  90155. /**
  90156. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  90157. */
  90158. startSpriteCellID: number;
  90159. /**
  90160. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  90161. */
  90162. endSpriteCellID: number;
  90163. /**
  90164. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  90165. */
  90166. spriteCellWidth: number;
  90167. /**
  90168. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  90169. */
  90170. spriteCellHeight: number;
  90171. /**
  90172. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  90173. */
  90174. spriteRandomStartCell: boolean;
  90175. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  90176. translationPivot: Vector2;
  90177. /** @hidden */
  90178. protected _isAnimationSheetEnabled: boolean;
  90179. /**
  90180. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  90181. */
  90182. beginAnimationOnStart: boolean;
  90183. /**
  90184. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  90185. */
  90186. beginAnimationFrom: number;
  90187. /**
  90188. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  90189. */
  90190. beginAnimationTo: number;
  90191. /**
  90192. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  90193. */
  90194. beginAnimationLoop: boolean;
  90195. /**
  90196. * Gets or sets a world offset applied to all particles
  90197. */
  90198. worldOffset: Vector3;
  90199. /**
  90200. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  90201. */
  90202. get isAnimationSheetEnabled(): boolean;
  90203. set isAnimationSheetEnabled(value: boolean);
  90204. /**
  90205. * Get hosting scene
  90206. * @returns the scene
  90207. */
  90208. getScene(): Scene;
  90209. /**
  90210. * You can use gravity if you want to give an orientation to your particles.
  90211. */
  90212. gravity: Vector3;
  90213. protected _colorGradients: Nullable<Array<ColorGradient>>;
  90214. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  90215. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  90216. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  90217. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  90218. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  90219. protected _dragGradients: Nullable<Array<FactorGradient>>;
  90220. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  90221. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  90222. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  90223. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  90224. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  90225. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  90226. /**
  90227. * Defines the delay in milliseconds before starting the system (0 by default)
  90228. */
  90229. startDelay: number;
  90230. /**
  90231. * Gets the current list of drag gradients.
  90232. * You must use addDragGradient and removeDragGradient to udpate this list
  90233. * @returns the list of drag gradients
  90234. */
  90235. getDragGradients(): Nullable<Array<FactorGradient>>;
  90236. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  90237. limitVelocityDamping: number;
  90238. /**
  90239. * Gets the current list of limit velocity gradients.
  90240. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  90241. * @returns the list of limit velocity gradients
  90242. */
  90243. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  90244. /**
  90245. * Gets the current list of color gradients.
  90246. * You must use addColorGradient and removeColorGradient to udpate this list
  90247. * @returns the list of color gradients
  90248. */
  90249. getColorGradients(): Nullable<Array<ColorGradient>>;
  90250. /**
  90251. * Gets the current list of size gradients.
  90252. * You must use addSizeGradient and removeSizeGradient to udpate this list
  90253. * @returns the list of size gradients
  90254. */
  90255. getSizeGradients(): Nullable<Array<FactorGradient>>;
  90256. /**
  90257. * Gets the current list of color remap gradients.
  90258. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  90259. * @returns the list of color remap gradients
  90260. */
  90261. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  90262. /**
  90263. * Gets the current list of alpha remap gradients.
  90264. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  90265. * @returns the list of alpha remap gradients
  90266. */
  90267. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  90268. /**
  90269. * Gets the current list of life time gradients.
  90270. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  90271. * @returns the list of life time gradients
  90272. */
  90273. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  90274. /**
  90275. * Gets the current list of angular speed gradients.
  90276. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  90277. * @returns the list of angular speed gradients
  90278. */
  90279. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  90280. /**
  90281. * Gets the current list of velocity gradients.
  90282. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  90283. * @returns the list of velocity gradients
  90284. */
  90285. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  90286. /**
  90287. * Gets the current list of start size gradients.
  90288. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  90289. * @returns the list of start size gradients
  90290. */
  90291. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  90292. /**
  90293. * Gets the current list of emit rate gradients.
  90294. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  90295. * @returns the list of emit rate gradients
  90296. */
  90297. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  90298. /**
  90299. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90300. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90301. */
  90302. get direction1(): Vector3;
  90303. set direction1(value: Vector3);
  90304. /**
  90305. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90306. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90307. */
  90308. get direction2(): Vector3;
  90309. set direction2(value: Vector3);
  90310. /**
  90311. * 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.
  90312. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90313. */
  90314. get minEmitBox(): Vector3;
  90315. set minEmitBox(value: Vector3);
  90316. /**
  90317. * 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.
  90318. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90319. */
  90320. get maxEmitBox(): Vector3;
  90321. set maxEmitBox(value: Vector3);
  90322. /**
  90323. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  90324. */
  90325. color1: Color4;
  90326. /**
  90327. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  90328. */
  90329. color2: Color4;
  90330. /**
  90331. * Color the particle will have at the end of its lifetime
  90332. */
  90333. colorDead: Color4;
  90334. /**
  90335. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  90336. */
  90337. textureMask: Color4;
  90338. /**
  90339. * The particle emitter type defines the emitter used by the particle system.
  90340. * It can be for example box, sphere, or cone...
  90341. */
  90342. particleEmitterType: IParticleEmitterType;
  90343. /** @hidden */
  90344. _isSubEmitter: boolean;
  90345. /**
  90346. * Gets or sets the billboard mode to use when isBillboardBased = true.
  90347. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  90348. */
  90349. billboardMode: number;
  90350. protected _isBillboardBased: boolean;
  90351. /**
  90352. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  90353. */
  90354. get isBillboardBased(): boolean;
  90355. set isBillboardBased(value: boolean);
  90356. /**
  90357. * The scene the particle system belongs to.
  90358. */
  90359. protected _scene: Scene;
  90360. /**
  90361. * Local cache of defines for image processing.
  90362. */
  90363. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  90364. /**
  90365. * Default configuration related to image processing available in the standard Material.
  90366. */
  90367. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  90368. /**
  90369. * Gets the image processing configuration used either in this material.
  90370. */
  90371. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  90372. /**
  90373. * Sets the Default image processing configuration used either in the this material.
  90374. *
  90375. * If sets to null, the scene one is in use.
  90376. */
  90377. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  90378. /**
  90379. * Attaches a new image processing configuration to the Standard Material.
  90380. * @param configuration
  90381. */
  90382. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  90383. /** @hidden */
  90384. protected _reset(): void;
  90385. /** @hidden */
  90386. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  90387. /**
  90388. * Instantiates a particle system.
  90389. * 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.
  90390. * @param name The name of the particle system
  90391. */
  90392. constructor(name: string);
  90393. /**
  90394. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  90395. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90396. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90397. * @returns the emitter
  90398. */
  90399. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  90400. /**
  90401. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  90402. * @param radius The radius of the hemisphere to emit from
  90403. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90404. * @returns the emitter
  90405. */
  90406. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  90407. /**
  90408. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  90409. * @param radius The radius of the sphere to emit from
  90410. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90411. * @returns the emitter
  90412. */
  90413. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  90414. /**
  90415. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  90416. * @param radius The radius of the sphere to emit from
  90417. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  90418. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  90419. * @returns the emitter
  90420. */
  90421. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  90422. /**
  90423. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  90424. * @param radius The radius of the emission cylinder
  90425. * @param height The height of the emission cylinder
  90426. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  90427. * @param directionRandomizer How much to randomize the particle direction [0-1]
  90428. * @returns the emitter
  90429. */
  90430. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  90431. /**
  90432. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  90433. * @param radius The radius of the cylinder to emit from
  90434. * @param height The height of the emission cylinder
  90435. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90436. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  90437. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  90438. * @returns the emitter
  90439. */
  90440. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  90441. /**
  90442. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  90443. * @param radius The radius of the cone to emit from
  90444. * @param angle The base angle of the cone
  90445. * @returns the emitter
  90446. */
  90447. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  90448. /**
  90449. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  90450. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90451. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90452. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90453. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90454. * @returns the emitter
  90455. */
  90456. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  90457. }
  90458. }
  90459. declare module BABYLON {
  90460. /**
  90461. * Type of sub emitter
  90462. */
  90463. export enum SubEmitterType {
  90464. /**
  90465. * Attached to the particle over it's lifetime
  90466. */
  90467. ATTACHED = 0,
  90468. /**
  90469. * Created when the particle dies
  90470. */
  90471. END = 1
  90472. }
  90473. /**
  90474. * Sub emitter class used to emit particles from an existing particle
  90475. */
  90476. export class SubEmitter {
  90477. /**
  90478. * the particle system to be used by the sub emitter
  90479. */
  90480. particleSystem: ParticleSystem;
  90481. /**
  90482. * Type of the submitter (Default: END)
  90483. */
  90484. type: SubEmitterType;
  90485. /**
  90486. * 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)
  90487. * Note: This only is supported when using an emitter of type Mesh
  90488. */
  90489. inheritDirection: boolean;
  90490. /**
  90491. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  90492. */
  90493. inheritedVelocityAmount: number;
  90494. /**
  90495. * Creates a sub emitter
  90496. * @param particleSystem the particle system to be used by the sub emitter
  90497. */
  90498. constructor(
  90499. /**
  90500. * the particle system to be used by the sub emitter
  90501. */
  90502. particleSystem: ParticleSystem);
  90503. /**
  90504. * Clones the sub emitter
  90505. * @returns the cloned sub emitter
  90506. */
  90507. clone(): SubEmitter;
  90508. /**
  90509. * Serialize current object to a JSON object
  90510. * @returns the serialized object
  90511. */
  90512. serialize(): any;
  90513. /** @hidden */
  90514. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  90515. /**
  90516. * Creates a new SubEmitter from a serialized JSON version
  90517. * @param serializationObject defines the JSON object to read from
  90518. * @param scene defines the hosting scene
  90519. * @param rootUrl defines the rootUrl for data loading
  90520. * @returns a new SubEmitter
  90521. */
  90522. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  90523. /** Release associated resources */
  90524. dispose(): void;
  90525. }
  90526. }
  90527. declare module BABYLON {
  90528. /** @hidden */
  90529. export var imageProcessingDeclaration: {
  90530. name: string;
  90531. shader: string;
  90532. };
  90533. }
  90534. declare module BABYLON {
  90535. /** @hidden */
  90536. export var imageProcessingFunctions: {
  90537. name: string;
  90538. shader: string;
  90539. };
  90540. }
  90541. declare module BABYLON {
  90542. /** @hidden */
  90543. export var particlesPixelShader: {
  90544. name: string;
  90545. shader: string;
  90546. };
  90547. }
  90548. declare module BABYLON {
  90549. /** @hidden */
  90550. export var particlesVertexShader: {
  90551. name: string;
  90552. shader: string;
  90553. };
  90554. }
  90555. declare module BABYLON {
  90556. /**
  90557. * This represents a particle system in Babylon.
  90558. * 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.
  90559. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  90560. * @example https://doc.babylonjs.com/babylon101/particles
  90561. */
  90562. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  90563. /**
  90564. * Billboard mode will only apply to Y axis
  90565. */
  90566. static readonly BILLBOARDMODE_Y: number;
  90567. /**
  90568. * Billboard mode will apply to all axes
  90569. */
  90570. static readonly BILLBOARDMODE_ALL: number;
  90571. /**
  90572. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  90573. */
  90574. static readonly BILLBOARDMODE_STRETCHED: number;
  90575. /**
  90576. * This function can be defined to provide custom update for active particles.
  90577. * This function will be called instead of regular update (age, position, color, etc.).
  90578. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  90579. */
  90580. updateFunction: (particles: Particle[]) => void;
  90581. private _emitterWorldMatrix;
  90582. /**
  90583. * This function can be defined to specify initial direction for every new particle.
  90584. * It by default use the emitterType defined function
  90585. */
  90586. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  90587. /**
  90588. * This function can be defined to specify initial position for every new particle.
  90589. * It by default use the emitterType defined function
  90590. */
  90591. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  90592. /**
  90593. * @hidden
  90594. */
  90595. _inheritedVelocityOffset: Vector3;
  90596. /**
  90597. * An event triggered when the system is disposed
  90598. */
  90599. onDisposeObservable: Observable<IParticleSystem>;
  90600. private _onDisposeObserver;
  90601. /**
  90602. * Sets a callback that will be triggered when the system is disposed
  90603. */
  90604. set onDispose(callback: () => void);
  90605. private _particles;
  90606. private _epsilon;
  90607. private _capacity;
  90608. private _stockParticles;
  90609. private _newPartsExcess;
  90610. private _vertexData;
  90611. private _vertexBuffer;
  90612. private _vertexBuffers;
  90613. private _spriteBuffer;
  90614. private _indexBuffer;
  90615. private _effect;
  90616. private _customEffect;
  90617. private _cachedDefines;
  90618. private _scaledColorStep;
  90619. private _colorDiff;
  90620. private _scaledDirection;
  90621. private _scaledGravity;
  90622. private _currentRenderId;
  90623. private _alive;
  90624. private _useInstancing;
  90625. private _started;
  90626. private _stopped;
  90627. private _actualFrame;
  90628. private _scaledUpdateSpeed;
  90629. private _vertexBufferSize;
  90630. /** @hidden */
  90631. _currentEmitRateGradient: Nullable<FactorGradient>;
  90632. /** @hidden */
  90633. _currentEmitRate1: number;
  90634. /** @hidden */
  90635. _currentEmitRate2: number;
  90636. /** @hidden */
  90637. _currentStartSizeGradient: Nullable<FactorGradient>;
  90638. /** @hidden */
  90639. _currentStartSize1: number;
  90640. /** @hidden */
  90641. _currentStartSize2: number;
  90642. private readonly _rawTextureWidth;
  90643. private _rampGradientsTexture;
  90644. private _useRampGradients;
  90645. /** Gets or sets a boolean indicating that ramp gradients must be used
  90646. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  90647. */
  90648. get useRampGradients(): boolean;
  90649. set useRampGradients(value: boolean);
  90650. /**
  90651. * 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.
  90652. * 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: [])
  90653. */
  90654. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  90655. private _subEmitters;
  90656. /**
  90657. * @hidden
  90658. * If the particle systems emitter should be disposed when the particle system is disposed
  90659. */
  90660. _disposeEmitterOnDispose: boolean;
  90661. /**
  90662. * The current active Sub-systems, this property is used by the root particle system only.
  90663. */
  90664. activeSubSystems: Array<ParticleSystem>;
  90665. /**
  90666. * Specifies if the particles are updated in emitter local space or world space
  90667. */
  90668. isLocal: boolean;
  90669. private _rootParticleSystem;
  90670. /**
  90671. * Gets the current list of active particles
  90672. */
  90673. get particles(): Particle[];
  90674. /**
  90675. * Gets the number of particles active at the same time.
  90676. * @returns The number of active particles.
  90677. */
  90678. getActiveCount(): number;
  90679. /**
  90680. * Returns the string "ParticleSystem"
  90681. * @returns a string containing the class name
  90682. */
  90683. getClassName(): string;
  90684. /**
  90685. * Gets a boolean indicating that the system is stopping
  90686. * @returns true if the system is currently stopping
  90687. */
  90688. isStopping(): boolean;
  90689. /**
  90690. * Gets the custom effect used to render the particles
  90691. * @param blendMode Blend mode for which the effect should be retrieved
  90692. * @returns The effect
  90693. */
  90694. getCustomEffect(blendMode?: number): Nullable<Effect>;
  90695. /**
  90696. * Sets the custom effect used to render the particles
  90697. * @param effect The effect to set
  90698. * @param blendMode Blend mode for which the effect should be set
  90699. */
  90700. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  90701. /** @hidden */
  90702. private _onBeforeDrawParticlesObservable;
  90703. /**
  90704. * Observable that will be called just before the particles are drawn
  90705. */
  90706. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  90707. /**
  90708. * Gets the name of the particle vertex shader
  90709. */
  90710. get vertexShaderName(): string;
  90711. /**
  90712. * Instantiates a particle system.
  90713. * 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.
  90714. * @param name The name of the particle system
  90715. * @param capacity The max number of particles alive at the same time
  90716. * @param scene The scene the particle system belongs to
  90717. * @param customEffect a custom effect used to change the way particles are rendered by default
  90718. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  90719. * @param epsilon Offset used to render the particles
  90720. */
  90721. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  90722. private _addFactorGradient;
  90723. private _removeFactorGradient;
  90724. /**
  90725. * Adds a new life time gradient
  90726. * @param gradient defines the gradient to use (between 0 and 1)
  90727. * @param factor defines the life time factor to affect to the specified gradient
  90728. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90729. * @returns the current particle system
  90730. */
  90731. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90732. /**
  90733. * Remove a specific life time gradient
  90734. * @param gradient defines the gradient to remove
  90735. * @returns the current particle system
  90736. */
  90737. removeLifeTimeGradient(gradient: number): IParticleSystem;
  90738. /**
  90739. * Adds a new size gradient
  90740. * @param gradient defines the gradient to use (between 0 and 1)
  90741. * @param factor defines the size factor to affect to the specified gradient
  90742. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90743. * @returns the current particle system
  90744. */
  90745. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90746. /**
  90747. * Remove a specific size gradient
  90748. * @param gradient defines the gradient to remove
  90749. * @returns the current particle system
  90750. */
  90751. removeSizeGradient(gradient: number): IParticleSystem;
  90752. /**
  90753. * Adds a new color remap gradient
  90754. * @param gradient defines the gradient to use (between 0 and 1)
  90755. * @param min defines the color remap minimal range
  90756. * @param max defines the color remap maximal range
  90757. * @returns the current particle system
  90758. */
  90759. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90760. /**
  90761. * Remove a specific color remap gradient
  90762. * @param gradient defines the gradient to remove
  90763. * @returns the current particle system
  90764. */
  90765. removeColorRemapGradient(gradient: number): IParticleSystem;
  90766. /**
  90767. * Adds a new alpha remap gradient
  90768. * @param gradient defines the gradient to use (between 0 and 1)
  90769. * @param min defines the alpha remap minimal range
  90770. * @param max defines the alpha remap maximal range
  90771. * @returns the current particle system
  90772. */
  90773. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90774. /**
  90775. * Remove a specific alpha remap gradient
  90776. * @param gradient defines the gradient to remove
  90777. * @returns the current particle system
  90778. */
  90779. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  90780. /**
  90781. * Adds a new angular speed gradient
  90782. * @param gradient defines the gradient to use (between 0 and 1)
  90783. * @param factor defines the angular speed to affect to the specified gradient
  90784. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90785. * @returns the current particle system
  90786. */
  90787. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90788. /**
  90789. * Remove a specific angular speed gradient
  90790. * @param gradient defines the gradient to remove
  90791. * @returns the current particle system
  90792. */
  90793. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  90794. /**
  90795. * Adds a new velocity gradient
  90796. * @param gradient defines the gradient to use (between 0 and 1)
  90797. * @param factor defines the velocity to affect to the specified gradient
  90798. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90799. * @returns the current particle system
  90800. */
  90801. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90802. /**
  90803. * Remove a specific velocity gradient
  90804. * @param gradient defines the gradient to remove
  90805. * @returns the current particle system
  90806. */
  90807. removeVelocityGradient(gradient: number): IParticleSystem;
  90808. /**
  90809. * Adds a new limit velocity gradient
  90810. * @param gradient defines the gradient to use (between 0 and 1)
  90811. * @param factor defines the limit velocity value to affect to the specified gradient
  90812. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90813. * @returns the current particle system
  90814. */
  90815. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90816. /**
  90817. * Remove a specific limit velocity gradient
  90818. * @param gradient defines the gradient to remove
  90819. * @returns the current particle system
  90820. */
  90821. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  90822. /**
  90823. * Adds a new drag gradient
  90824. * @param gradient defines the gradient to use (between 0 and 1)
  90825. * @param factor defines the drag value to affect to the specified gradient
  90826. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90827. * @returns the current particle system
  90828. */
  90829. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90830. /**
  90831. * Remove a specific drag gradient
  90832. * @param gradient defines the gradient to remove
  90833. * @returns the current particle system
  90834. */
  90835. removeDragGradient(gradient: number): IParticleSystem;
  90836. /**
  90837. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  90838. * @param gradient defines the gradient to use (between 0 and 1)
  90839. * @param factor defines the emit rate value to affect to the specified gradient
  90840. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90841. * @returns the current particle system
  90842. */
  90843. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90844. /**
  90845. * Remove a specific emit rate gradient
  90846. * @param gradient defines the gradient to remove
  90847. * @returns the current particle system
  90848. */
  90849. removeEmitRateGradient(gradient: number): IParticleSystem;
  90850. /**
  90851. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  90852. * @param gradient defines the gradient to use (between 0 and 1)
  90853. * @param factor defines the start size value to affect to the specified gradient
  90854. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90855. * @returns the current particle system
  90856. */
  90857. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90858. /**
  90859. * Remove a specific start size gradient
  90860. * @param gradient defines the gradient to remove
  90861. * @returns the current particle system
  90862. */
  90863. removeStartSizeGradient(gradient: number): IParticleSystem;
  90864. private _createRampGradientTexture;
  90865. /**
  90866. * Gets the current list of ramp gradients.
  90867. * You must use addRampGradient and removeRampGradient to udpate this list
  90868. * @returns the list of ramp gradients
  90869. */
  90870. getRampGradients(): Nullable<Array<Color3Gradient>>;
  90871. /** Force the system to rebuild all gradients that need to be resync */
  90872. forceRefreshGradients(): void;
  90873. private _syncRampGradientTexture;
  90874. /**
  90875. * Adds a new ramp gradient used to remap particle colors
  90876. * @param gradient defines the gradient to use (between 0 and 1)
  90877. * @param color defines the color to affect to the specified gradient
  90878. * @returns the current particle system
  90879. */
  90880. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  90881. /**
  90882. * Remove a specific ramp gradient
  90883. * @param gradient defines the gradient to remove
  90884. * @returns the current particle system
  90885. */
  90886. removeRampGradient(gradient: number): ParticleSystem;
  90887. /**
  90888. * Adds a new color gradient
  90889. * @param gradient defines the gradient to use (between 0 and 1)
  90890. * @param color1 defines the color to affect to the specified gradient
  90891. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  90892. * @returns this particle system
  90893. */
  90894. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  90895. /**
  90896. * Remove a specific color gradient
  90897. * @param gradient defines the gradient to remove
  90898. * @returns this particle system
  90899. */
  90900. removeColorGradient(gradient: number): IParticleSystem;
  90901. private _fetchR;
  90902. protected _reset(): void;
  90903. private _resetEffect;
  90904. private _createVertexBuffers;
  90905. private _createIndexBuffer;
  90906. /**
  90907. * Gets the maximum number of particles active at the same time.
  90908. * @returns The max number of active particles.
  90909. */
  90910. getCapacity(): number;
  90911. /**
  90912. * Gets whether there are still active particles in the system.
  90913. * @returns True if it is alive, otherwise false.
  90914. */
  90915. isAlive(): boolean;
  90916. /**
  90917. * Gets if the system has been started. (Note: this will still be true after stop is called)
  90918. * @returns True if it has been started, otherwise false.
  90919. */
  90920. isStarted(): boolean;
  90921. private _prepareSubEmitterInternalArray;
  90922. /**
  90923. * Starts the particle system and begins to emit
  90924. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  90925. */
  90926. start(delay?: number): void;
  90927. /**
  90928. * Stops the particle system.
  90929. * @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.
  90930. */
  90931. stop(stopSubEmitters?: boolean): void;
  90932. /**
  90933. * Remove all active particles
  90934. */
  90935. reset(): void;
  90936. /**
  90937. * @hidden (for internal use only)
  90938. */
  90939. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  90940. /**
  90941. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  90942. * Its lifetime will start back at 0.
  90943. */
  90944. recycleParticle: (particle: Particle) => void;
  90945. private _stopSubEmitters;
  90946. private _createParticle;
  90947. private _removeFromRoot;
  90948. private _emitFromParticle;
  90949. private _update;
  90950. /** @hidden */
  90951. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  90952. /** @hidden */
  90953. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  90954. /**
  90955. * Fill the defines array according to the current settings of the particle system
  90956. * @param defines Array to be updated
  90957. * @param blendMode blend mode to take into account when updating the array
  90958. */
  90959. fillDefines(defines: Array<string>, blendMode: number): void;
  90960. /**
  90961. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  90962. * @param uniforms Uniforms array to fill
  90963. * @param attributes Attributes array to fill
  90964. * @param samplers Samplers array to fill
  90965. */
  90966. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  90967. /** @hidden */
  90968. private _getEffect;
  90969. /**
  90970. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  90971. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  90972. */
  90973. animate(preWarmOnly?: boolean): void;
  90974. private _appendParticleVertices;
  90975. /**
  90976. * Rebuilds the particle system.
  90977. */
  90978. rebuild(): void;
  90979. /**
  90980. * Is this system ready to be used/rendered
  90981. * @return true if the system is ready
  90982. */
  90983. isReady(): boolean;
  90984. private _render;
  90985. /**
  90986. * Renders the particle system in its current state.
  90987. * @returns the current number of particles
  90988. */
  90989. render(): number;
  90990. /**
  90991. * Disposes the particle system and free the associated resources
  90992. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  90993. */
  90994. dispose(disposeTexture?: boolean): void;
  90995. /**
  90996. * Clones the particle system.
  90997. * @param name The name of the cloned object
  90998. * @param newEmitter The new emitter to use
  90999. * @returns the cloned particle system
  91000. */
  91001. clone(name: string, newEmitter: any): ParticleSystem;
  91002. /**
  91003. * Serializes the particle system to a JSON object
  91004. * @param serializeTexture defines if the texture must be serialized as well
  91005. * @returns the JSON object
  91006. */
  91007. serialize(serializeTexture?: boolean): any;
  91008. /** @hidden */
  91009. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  91010. /** @hidden */
  91011. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  91012. /**
  91013. * Parses a JSON object to create a particle system.
  91014. * @param parsedParticleSystem The JSON object to parse
  91015. * @param scene The scene to create the particle system in
  91016. * @param rootUrl The root url to use to load external dependencies like texture
  91017. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  91018. * @returns the Parsed particle system
  91019. */
  91020. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  91021. }
  91022. }
  91023. declare module BABYLON {
  91024. /**
  91025. * A particle represents one of the element emitted by a particle system.
  91026. * This is mainly define by its coordinates, direction, velocity and age.
  91027. */
  91028. export class Particle {
  91029. /**
  91030. * The particle system the particle belongs to.
  91031. */
  91032. particleSystem: ParticleSystem;
  91033. private static _Count;
  91034. /**
  91035. * Unique ID of the particle
  91036. */
  91037. id: number;
  91038. /**
  91039. * The world position of the particle in the scene.
  91040. */
  91041. position: Vector3;
  91042. /**
  91043. * The world direction of the particle in the scene.
  91044. */
  91045. direction: Vector3;
  91046. /**
  91047. * The color of the particle.
  91048. */
  91049. color: Color4;
  91050. /**
  91051. * The color change of the particle per step.
  91052. */
  91053. colorStep: Color4;
  91054. /**
  91055. * Defines how long will the life of the particle be.
  91056. */
  91057. lifeTime: number;
  91058. /**
  91059. * The current age of the particle.
  91060. */
  91061. age: number;
  91062. /**
  91063. * The current size of the particle.
  91064. */
  91065. size: number;
  91066. /**
  91067. * The current scale of the particle.
  91068. */
  91069. scale: Vector2;
  91070. /**
  91071. * The current angle of the particle.
  91072. */
  91073. angle: number;
  91074. /**
  91075. * Defines how fast is the angle changing.
  91076. */
  91077. angularSpeed: number;
  91078. /**
  91079. * Defines the cell index used by the particle to be rendered from a sprite.
  91080. */
  91081. cellIndex: number;
  91082. /**
  91083. * The information required to support color remapping
  91084. */
  91085. remapData: Vector4;
  91086. /** @hidden */
  91087. _randomCellOffset?: number;
  91088. /** @hidden */
  91089. _initialDirection: Nullable<Vector3>;
  91090. /** @hidden */
  91091. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  91092. /** @hidden */
  91093. _initialStartSpriteCellID: number;
  91094. /** @hidden */
  91095. _initialEndSpriteCellID: number;
  91096. /** @hidden */
  91097. _currentColorGradient: Nullable<ColorGradient>;
  91098. /** @hidden */
  91099. _currentColor1: Color4;
  91100. /** @hidden */
  91101. _currentColor2: Color4;
  91102. /** @hidden */
  91103. _currentSizeGradient: Nullable<FactorGradient>;
  91104. /** @hidden */
  91105. _currentSize1: number;
  91106. /** @hidden */
  91107. _currentSize2: number;
  91108. /** @hidden */
  91109. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  91110. /** @hidden */
  91111. _currentAngularSpeed1: number;
  91112. /** @hidden */
  91113. _currentAngularSpeed2: number;
  91114. /** @hidden */
  91115. _currentVelocityGradient: Nullable<FactorGradient>;
  91116. /** @hidden */
  91117. _currentVelocity1: number;
  91118. /** @hidden */
  91119. _currentVelocity2: number;
  91120. /** @hidden */
  91121. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  91122. /** @hidden */
  91123. _currentLimitVelocity1: number;
  91124. /** @hidden */
  91125. _currentLimitVelocity2: number;
  91126. /** @hidden */
  91127. _currentDragGradient: Nullable<FactorGradient>;
  91128. /** @hidden */
  91129. _currentDrag1: number;
  91130. /** @hidden */
  91131. _currentDrag2: number;
  91132. /** @hidden */
  91133. _randomNoiseCoordinates1: Vector3;
  91134. /** @hidden */
  91135. _randomNoiseCoordinates2: Vector3;
  91136. /** @hidden */
  91137. _localPosition?: Vector3;
  91138. /**
  91139. * Creates a new instance Particle
  91140. * @param particleSystem the particle system the particle belongs to
  91141. */
  91142. constructor(
  91143. /**
  91144. * The particle system the particle belongs to.
  91145. */
  91146. particleSystem: ParticleSystem);
  91147. private updateCellInfoFromSystem;
  91148. /**
  91149. * Defines how the sprite cell index is updated for the particle
  91150. */
  91151. updateCellIndex(): void;
  91152. /** @hidden */
  91153. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  91154. /** @hidden */
  91155. _inheritParticleInfoToSubEmitters(): void;
  91156. /** @hidden */
  91157. _reset(): void;
  91158. /**
  91159. * Copy the properties of particle to another one.
  91160. * @param other the particle to copy the information to.
  91161. */
  91162. copyTo(other: Particle): void;
  91163. }
  91164. }
  91165. declare module BABYLON {
  91166. /**
  91167. * Particle emitter represents a volume emitting particles.
  91168. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  91169. */
  91170. export interface IParticleEmitterType {
  91171. /**
  91172. * Called by the particle System when the direction is computed for the created particle.
  91173. * @param worldMatrix is the world matrix of the particle system
  91174. * @param directionToUpdate is the direction vector to update with the result
  91175. * @param particle is the particle we are computed the direction for
  91176. * @param isLocal defines if the direction should be set in local space
  91177. */
  91178. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91179. /**
  91180. * Called by the particle System when the position is computed for the created particle.
  91181. * @param worldMatrix is the world matrix of the particle system
  91182. * @param positionToUpdate is the position vector to update with the result
  91183. * @param particle is the particle we are computed the position for
  91184. * @param isLocal defines if the position should be set in local space
  91185. */
  91186. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91187. /**
  91188. * Clones the current emitter and returns a copy of it
  91189. * @returns the new emitter
  91190. */
  91191. clone(): IParticleEmitterType;
  91192. /**
  91193. * Called by the GPUParticleSystem to setup the update shader
  91194. * @param effect defines the update shader
  91195. */
  91196. applyToShader(effect: Effect): void;
  91197. /**
  91198. * Returns a string to use to update the GPU particles update shader
  91199. * @returns the effect defines string
  91200. */
  91201. getEffectDefines(): string;
  91202. /**
  91203. * Returns a string representing the class name
  91204. * @returns a string containing the class name
  91205. */
  91206. getClassName(): string;
  91207. /**
  91208. * Serializes the particle system to a JSON object.
  91209. * @returns the JSON object
  91210. */
  91211. serialize(): any;
  91212. /**
  91213. * Parse properties from a JSON object
  91214. * @param serializationObject defines the JSON object
  91215. * @param scene defines the hosting scene
  91216. */
  91217. parse(serializationObject: any, scene: Scene): void;
  91218. }
  91219. }
  91220. declare module BABYLON {
  91221. /**
  91222. * Particle emitter emitting particles from the inside of a box.
  91223. * It emits the particles randomly between 2 given directions.
  91224. */
  91225. export class BoxParticleEmitter implements IParticleEmitterType {
  91226. /**
  91227. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91228. */
  91229. direction1: Vector3;
  91230. /**
  91231. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91232. */
  91233. direction2: Vector3;
  91234. /**
  91235. * 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.
  91236. */
  91237. minEmitBox: Vector3;
  91238. /**
  91239. * 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.
  91240. */
  91241. maxEmitBox: Vector3;
  91242. /**
  91243. * Creates a new instance BoxParticleEmitter
  91244. */
  91245. constructor();
  91246. /**
  91247. * Called by the particle System when the direction is computed for the created particle.
  91248. * @param worldMatrix is the world matrix of the particle system
  91249. * @param directionToUpdate is the direction vector to update with the result
  91250. * @param particle is the particle we are computed the direction for
  91251. * @param isLocal defines if the direction should be set in local space
  91252. */
  91253. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91254. /**
  91255. * Called by the particle System when the position is computed for the created particle.
  91256. * @param worldMatrix is the world matrix of the particle system
  91257. * @param positionToUpdate is the position vector to update with the result
  91258. * @param particle is the particle we are computed the position for
  91259. * @param isLocal defines if the position should be set in local space
  91260. */
  91261. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91262. /**
  91263. * Clones the current emitter and returns a copy of it
  91264. * @returns the new emitter
  91265. */
  91266. clone(): BoxParticleEmitter;
  91267. /**
  91268. * Called by the GPUParticleSystem to setup the update shader
  91269. * @param effect defines the update shader
  91270. */
  91271. applyToShader(effect: Effect): void;
  91272. /**
  91273. * Returns a string to use to update the GPU particles update shader
  91274. * @returns a string containng the defines string
  91275. */
  91276. getEffectDefines(): string;
  91277. /**
  91278. * Returns the string "BoxParticleEmitter"
  91279. * @returns a string containing the class name
  91280. */
  91281. getClassName(): string;
  91282. /**
  91283. * Serializes the particle system to a JSON object.
  91284. * @returns the JSON object
  91285. */
  91286. serialize(): any;
  91287. /**
  91288. * Parse properties from a JSON object
  91289. * @param serializationObject defines the JSON object
  91290. */
  91291. parse(serializationObject: any): void;
  91292. }
  91293. }
  91294. declare module BABYLON {
  91295. /**
  91296. * Particle emitter emitting particles from the inside of a cone.
  91297. * It emits the particles alongside the cone volume from the base to the particle.
  91298. * The emission direction might be randomized.
  91299. */
  91300. export class ConeParticleEmitter implements IParticleEmitterType {
  91301. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  91302. directionRandomizer: number;
  91303. private _radius;
  91304. private _angle;
  91305. private _height;
  91306. /**
  91307. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  91308. */
  91309. radiusRange: number;
  91310. /**
  91311. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  91312. */
  91313. heightRange: number;
  91314. /**
  91315. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  91316. */
  91317. emitFromSpawnPointOnly: boolean;
  91318. /**
  91319. * Gets or sets the radius of the emission cone
  91320. */
  91321. get radius(): number;
  91322. set radius(value: number);
  91323. /**
  91324. * Gets or sets the angle of the emission cone
  91325. */
  91326. get angle(): number;
  91327. set angle(value: number);
  91328. private _buildHeight;
  91329. /**
  91330. * Creates a new instance ConeParticleEmitter
  91331. * @param radius the radius of the emission cone (1 by default)
  91332. * @param angle the cone base angle (PI by default)
  91333. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  91334. */
  91335. constructor(radius?: number, angle?: number,
  91336. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  91337. directionRandomizer?: number);
  91338. /**
  91339. * Called by the particle System when the direction is computed for the created particle.
  91340. * @param worldMatrix is the world matrix of the particle system
  91341. * @param directionToUpdate is the direction vector to update with the result
  91342. * @param particle is the particle we are computed the direction for
  91343. * @param isLocal defines if the direction should be set in local space
  91344. */
  91345. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91346. /**
  91347. * Called by the particle System when the position is computed for the created particle.
  91348. * @param worldMatrix is the world matrix of the particle system
  91349. * @param positionToUpdate is the position vector to update with the result
  91350. * @param particle is the particle we are computed the position for
  91351. * @param isLocal defines if the position should be set in local space
  91352. */
  91353. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91354. /**
  91355. * Clones the current emitter and returns a copy of it
  91356. * @returns the new emitter
  91357. */
  91358. clone(): ConeParticleEmitter;
  91359. /**
  91360. * Called by the GPUParticleSystem to setup the update shader
  91361. * @param effect defines the update shader
  91362. */
  91363. applyToShader(effect: Effect): void;
  91364. /**
  91365. * Returns a string to use to update the GPU particles update shader
  91366. * @returns a string containng the defines string
  91367. */
  91368. getEffectDefines(): string;
  91369. /**
  91370. * Returns the string "ConeParticleEmitter"
  91371. * @returns a string containing the class name
  91372. */
  91373. getClassName(): string;
  91374. /**
  91375. * Serializes the particle system to a JSON object.
  91376. * @returns the JSON object
  91377. */
  91378. serialize(): any;
  91379. /**
  91380. * Parse properties from a JSON object
  91381. * @param serializationObject defines the JSON object
  91382. */
  91383. parse(serializationObject: any): void;
  91384. }
  91385. }
  91386. declare module BABYLON {
  91387. /**
  91388. * Particle emitter emitting particles from the inside of a cylinder.
  91389. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  91390. */
  91391. export class CylinderParticleEmitter implements IParticleEmitterType {
  91392. /**
  91393. * The radius of the emission cylinder.
  91394. */
  91395. radius: number;
  91396. /**
  91397. * The height of the emission cylinder.
  91398. */
  91399. height: number;
  91400. /**
  91401. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91402. */
  91403. radiusRange: number;
  91404. /**
  91405. * How much to randomize the particle direction [0-1].
  91406. */
  91407. directionRandomizer: number;
  91408. /**
  91409. * Creates a new instance CylinderParticleEmitter
  91410. * @param radius the radius of the emission cylinder (1 by default)
  91411. * @param height the height of the emission cylinder (1 by default)
  91412. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91413. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91414. */
  91415. constructor(
  91416. /**
  91417. * The radius of the emission cylinder.
  91418. */
  91419. radius?: number,
  91420. /**
  91421. * The height of the emission cylinder.
  91422. */
  91423. height?: number,
  91424. /**
  91425. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91426. */
  91427. radiusRange?: number,
  91428. /**
  91429. * How much to randomize the particle direction [0-1].
  91430. */
  91431. directionRandomizer?: number);
  91432. /**
  91433. * Called by the particle System when the direction is computed for the created particle.
  91434. * @param worldMatrix is the world matrix of the particle system
  91435. * @param directionToUpdate is the direction vector to update with the result
  91436. * @param particle is the particle we are computed the direction for
  91437. * @param isLocal defines if the direction should be set in local space
  91438. */
  91439. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91440. /**
  91441. * Called by the particle System when the position is computed for the created particle.
  91442. * @param worldMatrix is the world matrix of the particle system
  91443. * @param positionToUpdate is the position vector to update with the result
  91444. * @param particle is the particle we are computed the position for
  91445. * @param isLocal defines if the position should be set in local space
  91446. */
  91447. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91448. /**
  91449. * Clones the current emitter and returns a copy of it
  91450. * @returns the new emitter
  91451. */
  91452. clone(): CylinderParticleEmitter;
  91453. /**
  91454. * Called by the GPUParticleSystem to setup the update shader
  91455. * @param effect defines the update shader
  91456. */
  91457. applyToShader(effect: Effect): void;
  91458. /**
  91459. * Returns a string to use to update the GPU particles update shader
  91460. * @returns a string containng the defines string
  91461. */
  91462. getEffectDefines(): string;
  91463. /**
  91464. * Returns the string "CylinderParticleEmitter"
  91465. * @returns a string containing the class name
  91466. */
  91467. getClassName(): string;
  91468. /**
  91469. * Serializes the particle system to a JSON object.
  91470. * @returns the JSON object
  91471. */
  91472. serialize(): any;
  91473. /**
  91474. * Parse properties from a JSON object
  91475. * @param serializationObject defines the JSON object
  91476. */
  91477. parse(serializationObject: any): void;
  91478. }
  91479. /**
  91480. * Particle emitter emitting particles from the inside of a cylinder.
  91481. * It emits the particles randomly between two vectors.
  91482. */
  91483. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  91484. /**
  91485. * The min limit of the emission direction.
  91486. */
  91487. direction1: Vector3;
  91488. /**
  91489. * The max limit of the emission direction.
  91490. */
  91491. direction2: Vector3;
  91492. /**
  91493. * Creates a new instance CylinderDirectedParticleEmitter
  91494. * @param radius the radius of the emission cylinder (1 by default)
  91495. * @param height the height of the emission cylinder (1 by default)
  91496. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91497. * @param direction1 the min limit of the emission direction (up vector by default)
  91498. * @param direction2 the max limit of the emission direction (up vector by default)
  91499. */
  91500. constructor(radius?: number, height?: number, radiusRange?: number,
  91501. /**
  91502. * The min limit of the emission direction.
  91503. */
  91504. direction1?: Vector3,
  91505. /**
  91506. * The max limit of the emission direction.
  91507. */
  91508. direction2?: Vector3);
  91509. /**
  91510. * Called by the particle System when the direction is computed for the created particle.
  91511. * @param worldMatrix is the world matrix of the particle system
  91512. * @param directionToUpdate is the direction vector to update with the result
  91513. * @param particle is the particle we are computed the direction for
  91514. */
  91515. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91516. /**
  91517. * Clones the current emitter and returns a copy of it
  91518. * @returns the new emitter
  91519. */
  91520. clone(): CylinderDirectedParticleEmitter;
  91521. /**
  91522. * Called by the GPUParticleSystem to setup the update shader
  91523. * @param effect defines the update shader
  91524. */
  91525. applyToShader(effect: Effect): void;
  91526. /**
  91527. * Returns a string to use to update the GPU particles update shader
  91528. * @returns a string containng the defines string
  91529. */
  91530. getEffectDefines(): string;
  91531. /**
  91532. * Returns the string "CylinderDirectedParticleEmitter"
  91533. * @returns a string containing the class name
  91534. */
  91535. getClassName(): string;
  91536. /**
  91537. * Serializes the particle system to a JSON object.
  91538. * @returns the JSON object
  91539. */
  91540. serialize(): any;
  91541. /**
  91542. * Parse properties from a JSON object
  91543. * @param serializationObject defines the JSON object
  91544. */
  91545. parse(serializationObject: any): void;
  91546. }
  91547. }
  91548. declare module BABYLON {
  91549. /**
  91550. * Particle emitter emitting particles from the inside of a hemisphere.
  91551. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  91552. */
  91553. export class HemisphericParticleEmitter implements IParticleEmitterType {
  91554. /**
  91555. * The radius of the emission hemisphere.
  91556. */
  91557. radius: number;
  91558. /**
  91559. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91560. */
  91561. radiusRange: number;
  91562. /**
  91563. * How much to randomize the particle direction [0-1].
  91564. */
  91565. directionRandomizer: number;
  91566. /**
  91567. * Creates a new instance HemisphericParticleEmitter
  91568. * @param radius the radius of the emission hemisphere (1 by default)
  91569. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91570. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91571. */
  91572. constructor(
  91573. /**
  91574. * The radius of the emission hemisphere.
  91575. */
  91576. radius?: number,
  91577. /**
  91578. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91579. */
  91580. radiusRange?: number,
  91581. /**
  91582. * How much to randomize the particle direction [0-1].
  91583. */
  91584. directionRandomizer?: number);
  91585. /**
  91586. * Called by the particle System when the direction is computed for the created particle.
  91587. * @param worldMatrix is the world matrix of the particle system
  91588. * @param directionToUpdate is the direction vector to update with the result
  91589. * @param particle is the particle we are computed the direction for
  91590. * @param isLocal defines if the direction should be set in local space
  91591. */
  91592. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91593. /**
  91594. * Called by the particle System when the position is computed for the created particle.
  91595. * @param worldMatrix is the world matrix of the particle system
  91596. * @param positionToUpdate is the position vector to update with the result
  91597. * @param particle is the particle we are computed the position for
  91598. * @param isLocal defines if the position should be set in local space
  91599. */
  91600. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91601. /**
  91602. * Clones the current emitter and returns a copy of it
  91603. * @returns the new emitter
  91604. */
  91605. clone(): HemisphericParticleEmitter;
  91606. /**
  91607. * Called by the GPUParticleSystem to setup the update shader
  91608. * @param effect defines the update shader
  91609. */
  91610. applyToShader(effect: Effect): void;
  91611. /**
  91612. * Returns a string to use to update the GPU particles update shader
  91613. * @returns a string containng the defines string
  91614. */
  91615. getEffectDefines(): string;
  91616. /**
  91617. * Returns the string "HemisphericParticleEmitter"
  91618. * @returns a string containing the class name
  91619. */
  91620. getClassName(): string;
  91621. /**
  91622. * Serializes the particle system to a JSON object.
  91623. * @returns the JSON object
  91624. */
  91625. serialize(): any;
  91626. /**
  91627. * Parse properties from a JSON object
  91628. * @param serializationObject defines the JSON object
  91629. */
  91630. parse(serializationObject: any): void;
  91631. }
  91632. }
  91633. declare module BABYLON {
  91634. /**
  91635. * Particle emitter emitting particles from a point.
  91636. * It emits the particles randomly between 2 given directions.
  91637. */
  91638. export class PointParticleEmitter implements IParticleEmitterType {
  91639. /**
  91640. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91641. */
  91642. direction1: Vector3;
  91643. /**
  91644. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91645. */
  91646. direction2: Vector3;
  91647. /**
  91648. * Creates a new instance PointParticleEmitter
  91649. */
  91650. constructor();
  91651. /**
  91652. * Called by the particle System when the direction is computed for the created particle.
  91653. * @param worldMatrix is the world matrix of the particle system
  91654. * @param directionToUpdate is the direction vector to update with the result
  91655. * @param particle is the particle we are computed the direction for
  91656. * @param isLocal defines if the direction should be set in local space
  91657. */
  91658. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91659. /**
  91660. * Called by the particle System when the position is computed for the created particle.
  91661. * @param worldMatrix is the world matrix of the particle system
  91662. * @param positionToUpdate is the position vector to update with the result
  91663. * @param particle is the particle we are computed the position for
  91664. * @param isLocal defines if the position should be set in local space
  91665. */
  91666. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91667. /**
  91668. * Clones the current emitter and returns a copy of it
  91669. * @returns the new emitter
  91670. */
  91671. clone(): PointParticleEmitter;
  91672. /**
  91673. * Called by the GPUParticleSystem to setup the update shader
  91674. * @param effect defines the update shader
  91675. */
  91676. applyToShader(effect: Effect): void;
  91677. /**
  91678. * Returns a string to use to update the GPU particles update shader
  91679. * @returns a string containng the defines string
  91680. */
  91681. getEffectDefines(): string;
  91682. /**
  91683. * Returns the string "PointParticleEmitter"
  91684. * @returns a string containing the class name
  91685. */
  91686. getClassName(): string;
  91687. /**
  91688. * Serializes the particle system to a JSON object.
  91689. * @returns the JSON object
  91690. */
  91691. serialize(): any;
  91692. /**
  91693. * Parse properties from a JSON object
  91694. * @param serializationObject defines the JSON object
  91695. */
  91696. parse(serializationObject: any): void;
  91697. }
  91698. }
  91699. declare module BABYLON {
  91700. /**
  91701. * Particle emitter emitting particles from the inside of a sphere.
  91702. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  91703. */
  91704. export class SphereParticleEmitter implements IParticleEmitterType {
  91705. /**
  91706. * The radius of the emission sphere.
  91707. */
  91708. radius: number;
  91709. /**
  91710. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91711. */
  91712. radiusRange: number;
  91713. /**
  91714. * How much to randomize the particle direction [0-1].
  91715. */
  91716. directionRandomizer: number;
  91717. /**
  91718. * Creates a new instance SphereParticleEmitter
  91719. * @param radius the radius of the emission sphere (1 by default)
  91720. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91721. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91722. */
  91723. constructor(
  91724. /**
  91725. * The radius of the emission sphere.
  91726. */
  91727. radius?: number,
  91728. /**
  91729. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91730. */
  91731. radiusRange?: number,
  91732. /**
  91733. * How much to randomize the particle direction [0-1].
  91734. */
  91735. directionRandomizer?: number);
  91736. /**
  91737. * Called by the particle System when the direction is computed for the created particle.
  91738. * @param worldMatrix is the world matrix of the particle system
  91739. * @param directionToUpdate is the direction vector to update with the result
  91740. * @param particle is the particle we are computed the direction for
  91741. * @param isLocal defines if the direction should be set in local space
  91742. */
  91743. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91744. /**
  91745. * Called by the particle System when the position is computed for the created particle.
  91746. * @param worldMatrix is the world matrix of the particle system
  91747. * @param positionToUpdate is the position vector to update with the result
  91748. * @param particle is the particle we are computed the position for
  91749. * @param isLocal defines if the position should be set in local space
  91750. */
  91751. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91752. /**
  91753. * Clones the current emitter and returns a copy of it
  91754. * @returns the new emitter
  91755. */
  91756. clone(): SphereParticleEmitter;
  91757. /**
  91758. * Called by the GPUParticleSystem to setup the update shader
  91759. * @param effect defines the update shader
  91760. */
  91761. applyToShader(effect: Effect): void;
  91762. /**
  91763. * Returns a string to use to update the GPU particles update shader
  91764. * @returns a string containng the defines string
  91765. */
  91766. getEffectDefines(): string;
  91767. /**
  91768. * Returns the string "SphereParticleEmitter"
  91769. * @returns a string containing the class name
  91770. */
  91771. getClassName(): string;
  91772. /**
  91773. * Serializes the particle system to a JSON object.
  91774. * @returns the JSON object
  91775. */
  91776. serialize(): any;
  91777. /**
  91778. * Parse properties from a JSON object
  91779. * @param serializationObject defines the JSON object
  91780. */
  91781. parse(serializationObject: any): void;
  91782. }
  91783. /**
  91784. * Particle emitter emitting particles from the inside of a sphere.
  91785. * It emits the particles randomly between two vectors.
  91786. */
  91787. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  91788. /**
  91789. * The min limit of the emission direction.
  91790. */
  91791. direction1: Vector3;
  91792. /**
  91793. * The max limit of the emission direction.
  91794. */
  91795. direction2: Vector3;
  91796. /**
  91797. * Creates a new instance SphereDirectedParticleEmitter
  91798. * @param radius the radius of the emission sphere (1 by default)
  91799. * @param direction1 the min limit of the emission direction (up vector by default)
  91800. * @param direction2 the max limit of the emission direction (up vector by default)
  91801. */
  91802. constructor(radius?: number,
  91803. /**
  91804. * The min limit of the emission direction.
  91805. */
  91806. direction1?: Vector3,
  91807. /**
  91808. * The max limit of the emission direction.
  91809. */
  91810. direction2?: Vector3);
  91811. /**
  91812. * Called by the particle System when the direction is computed for the created particle.
  91813. * @param worldMatrix is the world matrix of the particle system
  91814. * @param directionToUpdate is the direction vector to update with the result
  91815. * @param particle is the particle we are computed the direction for
  91816. */
  91817. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91818. /**
  91819. * Clones the current emitter and returns a copy of it
  91820. * @returns the new emitter
  91821. */
  91822. clone(): SphereDirectedParticleEmitter;
  91823. /**
  91824. * Called by the GPUParticleSystem to setup the update shader
  91825. * @param effect defines the update shader
  91826. */
  91827. applyToShader(effect: Effect): void;
  91828. /**
  91829. * Returns a string to use to update the GPU particles update shader
  91830. * @returns a string containng the defines string
  91831. */
  91832. getEffectDefines(): string;
  91833. /**
  91834. * Returns the string "SphereDirectedParticleEmitter"
  91835. * @returns a string containing the class name
  91836. */
  91837. getClassName(): string;
  91838. /**
  91839. * Serializes the particle system to a JSON object.
  91840. * @returns the JSON object
  91841. */
  91842. serialize(): any;
  91843. /**
  91844. * Parse properties from a JSON object
  91845. * @param serializationObject defines the JSON object
  91846. */
  91847. parse(serializationObject: any): void;
  91848. }
  91849. }
  91850. declare module BABYLON {
  91851. /**
  91852. * Particle emitter emitting particles from a custom list of positions.
  91853. */
  91854. export class CustomParticleEmitter implements IParticleEmitterType {
  91855. /**
  91856. * Gets or sets the position generator that will create the inital position of each particle.
  91857. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91858. */
  91859. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  91860. /**
  91861. * Gets or sets the destination generator that will create the final destination of each particle.
  91862. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91863. */
  91864. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  91865. /**
  91866. * Creates a new instance CustomParticleEmitter
  91867. */
  91868. constructor();
  91869. /**
  91870. * Called by the particle System when the direction is computed for the created particle.
  91871. * @param worldMatrix is the world matrix of the particle system
  91872. * @param directionToUpdate is the direction vector to update with the result
  91873. * @param particle is the particle we are computed the direction for
  91874. * @param isLocal defines if the direction should be set in local space
  91875. */
  91876. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91877. /**
  91878. * Called by the particle System when the position is computed for the created particle.
  91879. * @param worldMatrix is the world matrix of the particle system
  91880. * @param positionToUpdate is the position vector to update with the result
  91881. * @param particle is the particle we are computed the position for
  91882. * @param isLocal defines if the position should be set in local space
  91883. */
  91884. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91885. /**
  91886. * Clones the current emitter and returns a copy of it
  91887. * @returns the new emitter
  91888. */
  91889. clone(): CustomParticleEmitter;
  91890. /**
  91891. * Called by the GPUParticleSystem to setup the update shader
  91892. * @param effect defines the update shader
  91893. */
  91894. applyToShader(effect: Effect): void;
  91895. /**
  91896. * Returns a string to use to update the GPU particles update shader
  91897. * @returns a string containng the defines string
  91898. */
  91899. getEffectDefines(): string;
  91900. /**
  91901. * Returns the string "PointParticleEmitter"
  91902. * @returns a string containing the class name
  91903. */
  91904. getClassName(): string;
  91905. /**
  91906. * Serializes the particle system to a JSON object.
  91907. * @returns the JSON object
  91908. */
  91909. serialize(): any;
  91910. /**
  91911. * Parse properties from a JSON object
  91912. * @param serializationObject defines the JSON object
  91913. */
  91914. parse(serializationObject: any): void;
  91915. }
  91916. }
  91917. declare module BABYLON {
  91918. /**
  91919. * Particle emitter emitting particles from the inside of a box.
  91920. * It emits the particles randomly between 2 given directions.
  91921. */
  91922. export class MeshParticleEmitter implements IParticleEmitterType {
  91923. private _indices;
  91924. private _positions;
  91925. private _normals;
  91926. private _storedNormal;
  91927. private _mesh;
  91928. /**
  91929. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91930. */
  91931. direction1: Vector3;
  91932. /**
  91933. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91934. */
  91935. direction2: Vector3;
  91936. /**
  91937. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  91938. */
  91939. useMeshNormalsForDirection: boolean;
  91940. /** Defines the mesh to use as source */
  91941. get mesh(): Nullable<AbstractMesh>;
  91942. set mesh(value: Nullable<AbstractMesh>);
  91943. /**
  91944. * Creates a new instance MeshParticleEmitter
  91945. * @param mesh defines the mesh to use as source
  91946. */
  91947. constructor(mesh?: Nullable<AbstractMesh>);
  91948. /**
  91949. * Called by the particle System when the direction is computed for the created particle.
  91950. * @param worldMatrix is the world matrix of the particle system
  91951. * @param directionToUpdate is the direction vector to update with the result
  91952. * @param particle is the particle we are computed the direction for
  91953. * @param isLocal defines if the direction should be set in local space
  91954. */
  91955. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91956. /**
  91957. * Called by the particle System when the position is computed for the created particle.
  91958. * @param worldMatrix is the world matrix of the particle system
  91959. * @param positionToUpdate is the position vector to update with the result
  91960. * @param particle is the particle we are computed the position for
  91961. * @param isLocal defines if the position should be set in local space
  91962. */
  91963. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91964. /**
  91965. * Clones the current emitter and returns a copy of it
  91966. * @returns the new emitter
  91967. */
  91968. clone(): MeshParticleEmitter;
  91969. /**
  91970. * Called by the GPUParticleSystem to setup the update shader
  91971. * @param effect defines the update shader
  91972. */
  91973. applyToShader(effect: Effect): void;
  91974. /**
  91975. * Returns a string to use to update the GPU particles update shader
  91976. * @returns a string containng the defines string
  91977. */
  91978. getEffectDefines(): string;
  91979. /**
  91980. * Returns the string "BoxParticleEmitter"
  91981. * @returns a string containing the class name
  91982. */
  91983. getClassName(): string;
  91984. /**
  91985. * Serializes the particle system to a JSON object.
  91986. * @returns the JSON object
  91987. */
  91988. serialize(): any;
  91989. /**
  91990. * Parse properties from a JSON object
  91991. * @param serializationObject defines the JSON object
  91992. * @param scene defines the hosting scene
  91993. */
  91994. parse(serializationObject: any, scene: Scene): void;
  91995. }
  91996. }
  91997. declare module BABYLON {
  91998. /**
  91999. * Interface representing a particle system in Babylon.js.
  92000. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  92001. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  92002. */
  92003. export interface IParticleSystem {
  92004. /**
  92005. * List of animations used by the particle system.
  92006. */
  92007. animations: Animation[];
  92008. /**
  92009. * The id of the Particle system.
  92010. */
  92011. id: string;
  92012. /**
  92013. * The name of the Particle system.
  92014. */
  92015. name: string;
  92016. /**
  92017. * The emitter represents the Mesh or position we are attaching the particle system to.
  92018. */
  92019. emitter: Nullable<AbstractMesh | Vector3>;
  92020. /**
  92021. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92022. */
  92023. isBillboardBased: boolean;
  92024. /**
  92025. * The rendering group used by the Particle system to chose when to render.
  92026. */
  92027. renderingGroupId: number;
  92028. /**
  92029. * The layer mask we are rendering the particles through.
  92030. */
  92031. layerMask: number;
  92032. /**
  92033. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92034. */
  92035. updateSpeed: number;
  92036. /**
  92037. * The amount of time the particle system is running (depends of the overall update speed).
  92038. */
  92039. targetStopDuration: number;
  92040. /**
  92041. * The texture used to render each particle. (this can be a spritesheet)
  92042. */
  92043. particleTexture: Nullable<Texture>;
  92044. /**
  92045. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  92046. */
  92047. blendMode: number;
  92048. /**
  92049. * Minimum life time of emitting particles.
  92050. */
  92051. minLifeTime: number;
  92052. /**
  92053. * Maximum life time of emitting particles.
  92054. */
  92055. maxLifeTime: number;
  92056. /**
  92057. * Minimum Size of emitting particles.
  92058. */
  92059. minSize: number;
  92060. /**
  92061. * Maximum Size of emitting particles.
  92062. */
  92063. maxSize: number;
  92064. /**
  92065. * Minimum scale of emitting particles on X axis.
  92066. */
  92067. minScaleX: number;
  92068. /**
  92069. * Maximum scale of emitting particles on X axis.
  92070. */
  92071. maxScaleX: number;
  92072. /**
  92073. * Minimum scale of emitting particles on Y axis.
  92074. */
  92075. minScaleY: number;
  92076. /**
  92077. * Maximum scale of emitting particles on Y axis.
  92078. */
  92079. maxScaleY: number;
  92080. /**
  92081. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  92082. */
  92083. color1: Color4;
  92084. /**
  92085. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  92086. */
  92087. color2: Color4;
  92088. /**
  92089. * Color the particle will have at the end of its lifetime.
  92090. */
  92091. colorDead: Color4;
  92092. /**
  92093. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  92094. */
  92095. emitRate: number;
  92096. /**
  92097. * You can use gravity if you want to give an orientation to your particles.
  92098. */
  92099. gravity: Vector3;
  92100. /**
  92101. * Minimum power of emitting particles.
  92102. */
  92103. minEmitPower: number;
  92104. /**
  92105. * Maximum power of emitting particles.
  92106. */
  92107. maxEmitPower: number;
  92108. /**
  92109. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92110. */
  92111. minAngularSpeed: number;
  92112. /**
  92113. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92114. */
  92115. maxAngularSpeed: number;
  92116. /**
  92117. * Gets or sets the minimal initial rotation in radians.
  92118. */
  92119. minInitialRotation: number;
  92120. /**
  92121. * Gets or sets the maximal initial rotation in radians.
  92122. */
  92123. maxInitialRotation: number;
  92124. /**
  92125. * The particle emitter type defines the emitter used by the particle system.
  92126. * It can be for example box, sphere, or cone...
  92127. */
  92128. particleEmitterType: Nullable<IParticleEmitterType>;
  92129. /**
  92130. * Defines the delay in milliseconds before starting the system (0 by default)
  92131. */
  92132. startDelay: number;
  92133. /**
  92134. * 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
  92135. */
  92136. preWarmCycles: number;
  92137. /**
  92138. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  92139. */
  92140. preWarmStepOffset: number;
  92141. /**
  92142. * 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)
  92143. */
  92144. spriteCellChangeSpeed: number;
  92145. /**
  92146. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92147. */
  92148. startSpriteCellID: number;
  92149. /**
  92150. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92151. */
  92152. endSpriteCellID: number;
  92153. /**
  92154. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92155. */
  92156. spriteCellWidth: number;
  92157. /**
  92158. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92159. */
  92160. spriteCellHeight: number;
  92161. /**
  92162. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92163. */
  92164. spriteRandomStartCell: boolean;
  92165. /**
  92166. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  92167. */
  92168. isAnimationSheetEnabled: boolean;
  92169. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92170. translationPivot: Vector2;
  92171. /**
  92172. * Gets or sets a texture used to add random noise to particle positions
  92173. */
  92174. noiseTexture: Nullable<BaseTexture>;
  92175. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92176. noiseStrength: Vector3;
  92177. /**
  92178. * Gets or sets the billboard mode to use when isBillboardBased = true.
  92179. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  92180. */
  92181. billboardMode: number;
  92182. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92183. limitVelocityDamping: number;
  92184. /**
  92185. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92186. */
  92187. beginAnimationOnStart: boolean;
  92188. /**
  92189. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92190. */
  92191. beginAnimationFrom: number;
  92192. /**
  92193. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92194. */
  92195. beginAnimationTo: number;
  92196. /**
  92197. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92198. */
  92199. beginAnimationLoop: boolean;
  92200. /**
  92201. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92202. */
  92203. disposeOnStop: boolean;
  92204. /**
  92205. * Specifies if the particles are updated in emitter local space or world space
  92206. */
  92207. isLocal: boolean;
  92208. /** Snippet ID if the particle system was created from the snippet server */
  92209. snippetId: string;
  92210. /**
  92211. * Gets the maximum number of particles active at the same time.
  92212. * @returns The max number of active particles.
  92213. */
  92214. getCapacity(): number;
  92215. /**
  92216. * Gets the number of particles active at the same time.
  92217. * @returns The number of active particles.
  92218. */
  92219. getActiveCount(): number;
  92220. /**
  92221. * Gets if the system has been started. (Note: this will still be true after stop is called)
  92222. * @returns True if it has been started, otherwise false.
  92223. */
  92224. isStarted(): boolean;
  92225. /**
  92226. * Animates the particle system for this frame.
  92227. */
  92228. animate(): void;
  92229. /**
  92230. * Renders the particle system in its current state.
  92231. * @returns the current number of particles
  92232. */
  92233. render(): number;
  92234. /**
  92235. * Dispose the particle system and frees its associated resources.
  92236. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  92237. */
  92238. dispose(disposeTexture?: boolean): void;
  92239. /**
  92240. * An event triggered when the system is disposed
  92241. */
  92242. onDisposeObservable: Observable<IParticleSystem>;
  92243. /**
  92244. * Clones the particle system.
  92245. * @param name The name of the cloned object
  92246. * @param newEmitter The new emitter to use
  92247. * @returns the cloned particle system
  92248. */
  92249. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  92250. /**
  92251. * Serializes the particle system to a JSON object
  92252. * @param serializeTexture defines if the texture must be serialized as well
  92253. * @returns the JSON object
  92254. */
  92255. serialize(serializeTexture: boolean): any;
  92256. /**
  92257. * Rebuild the particle system
  92258. */
  92259. rebuild(): void;
  92260. /** Force the system to rebuild all gradients that need to be resync */
  92261. forceRefreshGradients(): void;
  92262. /**
  92263. * Starts the particle system and begins to emit
  92264. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  92265. */
  92266. start(delay?: number): void;
  92267. /**
  92268. * Stops the particle system.
  92269. */
  92270. stop(): void;
  92271. /**
  92272. * Remove all active particles
  92273. */
  92274. reset(): void;
  92275. /**
  92276. * Gets a boolean indicating that the system is stopping
  92277. * @returns true if the system is currently stopping
  92278. */
  92279. isStopping(): boolean;
  92280. /**
  92281. * Is this system ready to be used/rendered
  92282. * @return true if the system is ready
  92283. */
  92284. isReady(): boolean;
  92285. /**
  92286. * Returns the string "ParticleSystem"
  92287. * @returns a string containing the class name
  92288. */
  92289. getClassName(): string;
  92290. /**
  92291. * Gets the custom effect used to render the particles
  92292. * @param blendMode Blend mode for which the effect should be retrieved
  92293. * @returns The effect
  92294. */
  92295. getCustomEffect(blendMode: number): Nullable<Effect>;
  92296. /**
  92297. * Sets the custom effect used to render the particles
  92298. * @param effect The effect to set
  92299. * @param blendMode Blend mode for which the effect should be set
  92300. */
  92301. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  92302. /**
  92303. * Fill the defines array according to the current settings of the particle system
  92304. * @param defines Array to be updated
  92305. * @param blendMode blend mode to take into account when updating the array
  92306. */
  92307. fillDefines(defines: Array<string>, blendMode: number): void;
  92308. /**
  92309. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  92310. * @param uniforms Uniforms array to fill
  92311. * @param attributes Attributes array to fill
  92312. * @param samplers Samplers array to fill
  92313. */
  92314. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  92315. /**
  92316. * Observable that will be called just before the particles are drawn
  92317. */
  92318. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  92319. /**
  92320. * Gets the name of the particle vertex shader
  92321. */
  92322. vertexShaderName: string;
  92323. /**
  92324. * Adds a new color gradient
  92325. * @param gradient defines the gradient to use (between 0 and 1)
  92326. * @param color1 defines the color to affect to the specified gradient
  92327. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  92328. * @returns the current particle system
  92329. */
  92330. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  92331. /**
  92332. * Remove a specific color gradient
  92333. * @param gradient defines the gradient to remove
  92334. * @returns the current particle system
  92335. */
  92336. removeColorGradient(gradient: number): IParticleSystem;
  92337. /**
  92338. * Adds a new size gradient
  92339. * @param gradient defines the gradient to use (between 0 and 1)
  92340. * @param factor defines the size factor to affect to the specified gradient
  92341. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92342. * @returns the current particle system
  92343. */
  92344. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92345. /**
  92346. * Remove a specific size gradient
  92347. * @param gradient defines the gradient to remove
  92348. * @returns the current particle system
  92349. */
  92350. removeSizeGradient(gradient: number): IParticleSystem;
  92351. /**
  92352. * Gets the current list of color gradients.
  92353. * You must use addColorGradient and removeColorGradient to udpate this list
  92354. * @returns the list of color gradients
  92355. */
  92356. getColorGradients(): Nullable<Array<ColorGradient>>;
  92357. /**
  92358. * Gets the current list of size gradients.
  92359. * You must use addSizeGradient and removeSizeGradient to udpate this list
  92360. * @returns the list of size gradients
  92361. */
  92362. getSizeGradients(): Nullable<Array<FactorGradient>>;
  92363. /**
  92364. * Gets the current list of angular speed gradients.
  92365. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  92366. * @returns the list of angular speed gradients
  92367. */
  92368. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  92369. /**
  92370. * Adds a new angular speed gradient
  92371. * @param gradient defines the gradient to use (between 0 and 1)
  92372. * @param factor defines the angular speed to affect to the specified gradient
  92373. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92374. * @returns the current particle system
  92375. */
  92376. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92377. /**
  92378. * Remove a specific angular speed gradient
  92379. * @param gradient defines the gradient to remove
  92380. * @returns the current particle system
  92381. */
  92382. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  92383. /**
  92384. * Gets the current list of velocity gradients.
  92385. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  92386. * @returns the list of velocity gradients
  92387. */
  92388. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  92389. /**
  92390. * Adds a new velocity gradient
  92391. * @param gradient defines the gradient to use (between 0 and 1)
  92392. * @param factor defines the velocity to affect to the specified gradient
  92393. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92394. * @returns the current particle system
  92395. */
  92396. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92397. /**
  92398. * Remove a specific velocity gradient
  92399. * @param gradient defines the gradient to remove
  92400. * @returns the current particle system
  92401. */
  92402. removeVelocityGradient(gradient: number): IParticleSystem;
  92403. /**
  92404. * Gets the current list of limit velocity gradients.
  92405. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92406. * @returns the list of limit velocity gradients
  92407. */
  92408. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92409. /**
  92410. * Adds a new limit velocity gradient
  92411. * @param gradient defines the gradient to use (between 0 and 1)
  92412. * @param factor defines the limit velocity to affect to the specified gradient
  92413. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92414. * @returns the current particle system
  92415. */
  92416. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92417. /**
  92418. * Remove a specific limit velocity gradient
  92419. * @param gradient defines the gradient to remove
  92420. * @returns the current particle system
  92421. */
  92422. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  92423. /**
  92424. * Adds a new drag gradient
  92425. * @param gradient defines the gradient to use (between 0 and 1)
  92426. * @param factor defines the drag to affect to the specified gradient
  92427. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92428. * @returns the current particle system
  92429. */
  92430. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92431. /**
  92432. * Remove a specific drag gradient
  92433. * @param gradient defines the gradient to remove
  92434. * @returns the current particle system
  92435. */
  92436. removeDragGradient(gradient: number): IParticleSystem;
  92437. /**
  92438. * Gets the current list of drag gradients.
  92439. * You must use addDragGradient and removeDragGradient to udpate this list
  92440. * @returns the list of drag gradients
  92441. */
  92442. getDragGradients(): Nullable<Array<FactorGradient>>;
  92443. /**
  92444. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  92445. * @param gradient defines the gradient to use (between 0 and 1)
  92446. * @param factor defines the emit rate to affect to the specified gradient
  92447. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92448. * @returns the current particle system
  92449. */
  92450. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92451. /**
  92452. * Remove a specific emit rate gradient
  92453. * @param gradient defines the gradient to remove
  92454. * @returns the current particle system
  92455. */
  92456. removeEmitRateGradient(gradient: number): IParticleSystem;
  92457. /**
  92458. * Gets the current list of emit rate gradients.
  92459. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  92460. * @returns the list of emit rate gradients
  92461. */
  92462. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  92463. /**
  92464. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  92465. * @param gradient defines the gradient to use (between 0 and 1)
  92466. * @param factor defines the start size to affect to the specified gradient
  92467. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92468. * @returns the current particle system
  92469. */
  92470. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92471. /**
  92472. * Remove a specific start size gradient
  92473. * @param gradient defines the gradient to remove
  92474. * @returns the current particle system
  92475. */
  92476. removeStartSizeGradient(gradient: number): IParticleSystem;
  92477. /**
  92478. * Gets the current list of start size gradients.
  92479. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  92480. * @returns the list of start size gradients
  92481. */
  92482. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  92483. /**
  92484. * Adds a new life time gradient
  92485. * @param gradient defines the gradient to use (between 0 and 1)
  92486. * @param factor defines the life time factor to affect to the specified gradient
  92487. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92488. * @returns the current particle system
  92489. */
  92490. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92491. /**
  92492. * Remove a specific life time gradient
  92493. * @param gradient defines the gradient to remove
  92494. * @returns the current particle system
  92495. */
  92496. removeLifeTimeGradient(gradient: number): IParticleSystem;
  92497. /**
  92498. * Gets the current list of life time gradients.
  92499. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  92500. * @returns the list of life time gradients
  92501. */
  92502. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  92503. /**
  92504. * Gets the current list of color gradients.
  92505. * You must use addColorGradient and removeColorGradient to udpate this list
  92506. * @returns the list of color gradients
  92507. */
  92508. getColorGradients(): Nullable<Array<ColorGradient>>;
  92509. /**
  92510. * Adds a new ramp gradient used to remap particle colors
  92511. * @param gradient defines the gradient to use (between 0 and 1)
  92512. * @param color defines the color to affect to the specified gradient
  92513. * @returns the current particle system
  92514. */
  92515. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  92516. /**
  92517. * Gets the current list of ramp gradients.
  92518. * You must use addRampGradient and removeRampGradient to udpate this list
  92519. * @returns the list of ramp gradients
  92520. */
  92521. getRampGradients(): Nullable<Array<Color3Gradient>>;
  92522. /** Gets or sets a boolean indicating that ramp gradients must be used
  92523. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  92524. */
  92525. useRampGradients: boolean;
  92526. /**
  92527. * Adds a new color remap gradient
  92528. * @param gradient defines the gradient to use (between 0 and 1)
  92529. * @param min defines the color remap minimal range
  92530. * @param max defines the color remap maximal range
  92531. * @returns the current particle system
  92532. */
  92533. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92534. /**
  92535. * Gets the current list of color remap gradients.
  92536. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92537. * @returns the list of color remap gradients
  92538. */
  92539. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92540. /**
  92541. * Adds a new alpha remap gradient
  92542. * @param gradient defines the gradient to use (between 0 and 1)
  92543. * @param min defines the alpha remap minimal range
  92544. * @param max defines the alpha remap maximal range
  92545. * @returns the current particle system
  92546. */
  92547. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92548. /**
  92549. * Gets the current list of alpha remap gradients.
  92550. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92551. * @returns the list of alpha remap gradients
  92552. */
  92553. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92554. /**
  92555. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92556. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92557. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92558. * @returns the emitter
  92559. */
  92560. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92561. /**
  92562. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92563. * @param radius The radius of the hemisphere to emit from
  92564. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92565. * @returns the emitter
  92566. */
  92567. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  92568. /**
  92569. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  92570. * @param radius The radius of the sphere to emit from
  92571. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92572. * @returns the emitter
  92573. */
  92574. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  92575. /**
  92576. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  92577. * @param radius The radius of the sphere to emit from
  92578. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  92579. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  92580. * @returns the emitter
  92581. */
  92582. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92583. /**
  92584. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  92585. * @param radius The radius of the emission cylinder
  92586. * @param height The height of the emission cylinder
  92587. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  92588. * @param directionRandomizer How much to randomize the particle direction [0-1]
  92589. * @returns the emitter
  92590. */
  92591. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  92592. /**
  92593. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92594. * @param radius The radius of the cylinder to emit from
  92595. * @param height The height of the emission cylinder
  92596. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92597. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92598. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92599. * @returns the emitter
  92600. */
  92601. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92602. /**
  92603. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92604. * @param radius The radius of the cone to emit from
  92605. * @param angle The base angle of the cone
  92606. * @returns the emitter
  92607. */
  92608. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  92609. /**
  92610. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92611. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92612. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92613. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92614. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92615. * @returns the emitter
  92616. */
  92617. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92618. /**
  92619. * Get hosting scene
  92620. * @returns the scene
  92621. */
  92622. getScene(): Scene;
  92623. }
  92624. }
  92625. declare module BABYLON {
  92626. /**
  92627. * 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.
  92628. * @see https://doc.babylonjs.com/how_to/transformnode
  92629. */
  92630. export class TransformNode extends Node {
  92631. /**
  92632. * Object will not rotate to face the camera
  92633. */
  92634. static BILLBOARDMODE_NONE: number;
  92635. /**
  92636. * Object will rotate to face the camera but only on the x axis
  92637. */
  92638. static BILLBOARDMODE_X: number;
  92639. /**
  92640. * Object will rotate to face the camera but only on the y axis
  92641. */
  92642. static BILLBOARDMODE_Y: number;
  92643. /**
  92644. * Object will rotate to face the camera but only on the z axis
  92645. */
  92646. static BILLBOARDMODE_Z: number;
  92647. /**
  92648. * Object will rotate to face the camera
  92649. */
  92650. static BILLBOARDMODE_ALL: number;
  92651. /**
  92652. * Object will rotate to face the camera's position instead of orientation
  92653. */
  92654. static BILLBOARDMODE_USE_POSITION: number;
  92655. private static _TmpRotation;
  92656. private static _TmpScaling;
  92657. private static _TmpTranslation;
  92658. private _forward;
  92659. private _forwardInverted;
  92660. private _up;
  92661. private _right;
  92662. private _rightInverted;
  92663. private _position;
  92664. private _rotation;
  92665. private _rotationQuaternion;
  92666. protected _scaling: Vector3;
  92667. protected _isDirty: boolean;
  92668. private _transformToBoneReferal;
  92669. private _isAbsoluteSynced;
  92670. private _billboardMode;
  92671. /**
  92672. * Gets or sets the billboard mode. Default is 0.
  92673. *
  92674. * | Value | Type | Description |
  92675. * | --- | --- | --- |
  92676. * | 0 | BILLBOARDMODE_NONE | |
  92677. * | 1 | BILLBOARDMODE_X | |
  92678. * | 2 | BILLBOARDMODE_Y | |
  92679. * | 4 | BILLBOARDMODE_Z | |
  92680. * | 7 | BILLBOARDMODE_ALL | |
  92681. *
  92682. */
  92683. get billboardMode(): number;
  92684. set billboardMode(value: number);
  92685. private _preserveParentRotationForBillboard;
  92686. /**
  92687. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  92688. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  92689. */
  92690. get preserveParentRotationForBillboard(): boolean;
  92691. set preserveParentRotationForBillboard(value: boolean);
  92692. /**
  92693. * 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
  92694. */
  92695. scalingDeterminant: number;
  92696. private _infiniteDistance;
  92697. /**
  92698. * Gets or sets the distance of the object to max, often used by skybox
  92699. */
  92700. get infiniteDistance(): boolean;
  92701. set infiniteDistance(value: boolean);
  92702. /**
  92703. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  92704. * By default the system will update normals to compensate
  92705. */
  92706. ignoreNonUniformScaling: boolean;
  92707. /**
  92708. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  92709. */
  92710. reIntegrateRotationIntoRotationQuaternion: boolean;
  92711. /** @hidden */
  92712. _poseMatrix: Nullable<Matrix>;
  92713. /** @hidden */
  92714. _localMatrix: Matrix;
  92715. private _usePivotMatrix;
  92716. private _absolutePosition;
  92717. private _absoluteScaling;
  92718. private _absoluteRotationQuaternion;
  92719. private _pivotMatrix;
  92720. private _pivotMatrixInverse;
  92721. protected _postMultiplyPivotMatrix: boolean;
  92722. protected _isWorldMatrixFrozen: boolean;
  92723. /** @hidden */
  92724. _indexInSceneTransformNodesArray: number;
  92725. /**
  92726. * An event triggered after the world matrix is updated
  92727. */
  92728. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  92729. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  92730. /**
  92731. * Gets a string identifying the name of the class
  92732. * @returns "TransformNode" string
  92733. */
  92734. getClassName(): string;
  92735. /**
  92736. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  92737. */
  92738. get position(): Vector3;
  92739. set position(newPosition: Vector3);
  92740. /**
  92741. * 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)).
  92742. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  92743. */
  92744. get rotation(): Vector3;
  92745. set rotation(newRotation: Vector3);
  92746. /**
  92747. * 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)).
  92748. */
  92749. get scaling(): Vector3;
  92750. set scaling(newScaling: Vector3);
  92751. /**
  92752. * 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).
  92753. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  92754. */
  92755. get rotationQuaternion(): Nullable<Quaternion>;
  92756. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  92757. /**
  92758. * The forward direction of that transform in world space.
  92759. */
  92760. get forward(): Vector3;
  92761. /**
  92762. * The up direction of that transform in world space.
  92763. */
  92764. get up(): Vector3;
  92765. /**
  92766. * The right direction of that transform in world space.
  92767. */
  92768. get right(): Vector3;
  92769. /**
  92770. * Copies the parameter passed Matrix into the mesh Pose matrix.
  92771. * @param matrix the matrix to copy the pose from
  92772. * @returns this TransformNode.
  92773. */
  92774. updatePoseMatrix(matrix: Matrix): TransformNode;
  92775. /**
  92776. * Returns the mesh Pose matrix.
  92777. * @returns the pose matrix
  92778. */
  92779. getPoseMatrix(): Matrix;
  92780. /** @hidden */
  92781. _isSynchronized(): boolean;
  92782. /** @hidden */
  92783. _initCache(): void;
  92784. /**
  92785. * Flag the transform node as dirty (Forcing it to update everything)
  92786. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  92787. * @returns this transform node
  92788. */
  92789. markAsDirty(property: string): TransformNode;
  92790. /**
  92791. * Returns the current mesh absolute position.
  92792. * Returns a Vector3.
  92793. */
  92794. get absolutePosition(): Vector3;
  92795. /**
  92796. * Returns the current mesh absolute scaling.
  92797. * Returns a Vector3.
  92798. */
  92799. get absoluteScaling(): Vector3;
  92800. /**
  92801. * Returns the current mesh absolute rotation.
  92802. * Returns a Quaternion.
  92803. */
  92804. get absoluteRotationQuaternion(): Quaternion;
  92805. /**
  92806. * Sets a new matrix to apply before all other transformation
  92807. * @param matrix defines the transform matrix
  92808. * @returns the current TransformNode
  92809. */
  92810. setPreTransformMatrix(matrix: Matrix): TransformNode;
  92811. /**
  92812. * Sets a new pivot matrix to the current node
  92813. * @param matrix defines the new pivot matrix to use
  92814. * @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
  92815. * @returns the current TransformNode
  92816. */
  92817. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  92818. /**
  92819. * Returns the mesh pivot matrix.
  92820. * Default : Identity.
  92821. * @returns the matrix
  92822. */
  92823. getPivotMatrix(): Matrix;
  92824. /**
  92825. * Instantiate (when possible) or clone that node with its hierarchy
  92826. * @param newParent defines the new parent to use for the instance (or clone)
  92827. * @param options defines options to configure how copy is done
  92828. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  92829. * @returns an instance (or a clone) of the current node with its hiearchy
  92830. */
  92831. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  92832. doNotInstantiate: boolean;
  92833. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  92834. /**
  92835. * Prevents the World matrix to be computed any longer
  92836. * @param newWorldMatrix defines an optional matrix to use as world matrix
  92837. * @returns the TransformNode.
  92838. */
  92839. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  92840. /**
  92841. * Allows back the World matrix computation.
  92842. * @returns the TransformNode.
  92843. */
  92844. unfreezeWorldMatrix(): this;
  92845. /**
  92846. * True if the World matrix has been frozen.
  92847. */
  92848. get isWorldMatrixFrozen(): boolean;
  92849. /**
  92850. * Retuns the mesh absolute position in the World.
  92851. * @returns a Vector3.
  92852. */
  92853. getAbsolutePosition(): Vector3;
  92854. /**
  92855. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  92856. * @param absolutePosition the absolute position to set
  92857. * @returns the TransformNode.
  92858. */
  92859. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  92860. /**
  92861. * Sets the mesh position in its local space.
  92862. * @param vector3 the position to set in localspace
  92863. * @returns the TransformNode.
  92864. */
  92865. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  92866. /**
  92867. * Returns the mesh position in the local space from the current World matrix values.
  92868. * @returns a new Vector3.
  92869. */
  92870. getPositionExpressedInLocalSpace(): Vector3;
  92871. /**
  92872. * Translates the mesh along the passed Vector3 in its local space.
  92873. * @param vector3 the distance to translate in localspace
  92874. * @returns the TransformNode.
  92875. */
  92876. locallyTranslate(vector3: Vector3): TransformNode;
  92877. private static _lookAtVectorCache;
  92878. /**
  92879. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  92880. * @param targetPoint the position (must be in same space as current mesh) to look at
  92881. * @param yawCor optional yaw (y-axis) correction in radians
  92882. * @param pitchCor optional pitch (x-axis) correction in radians
  92883. * @param rollCor optional roll (z-axis) correction in radians
  92884. * @param space the choosen space of the target
  92885. * @returns the TransformNode.
  92886. */
  92887. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  92888. /**
  92889. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  92890. * This Vector3 is expressed in the World space.
  92891. * @param localAxis axis to rotate
  92892. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  92893. */
  92894. getDirection(localAxis: Vector3): Vector3;
  92895. /**
  92896. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  92897. * localAxis is expressed in the mesh local space.
  92898. * result is computed in the Wordl space from the mesh World matrix.
  92899. * @param localAxis axis to rotate
  92900. * @param result the resulting transformnode
  92901. * @returns this TransformNode.
  92902. */
  92903. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  92904. /**
  92905. * Sets this transform node rotation to the given local axis.
  92906. * @param localAxis the axis in local space
  92907. * @param yawCor optional yaw (y-axis) correction in radians
  92908. * @param pitchCor optional pitch (x-axis) correction in radians
  92909. * @param rollCor optional roll (z-axis) correction in radians
  92910. * @returns this TransformNode
  92911. */
  92912. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  92913. /**
  92914. * Sets a new pivot point to the current node
  92915. * @param point defines the new pivot point to use
  92916. * @param space defines if the point is in world or local space (local by default)
  92917. * @returns the current TransformNode
  92918. */
  92919. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  92920. /**
  92921. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  92922. * @returns the pivot point
  92923. */
  92924. getPivotPoint(): Vector3;
  92925. /**
  92926. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  92927. * @param result the vector3 to store the result
  92928. * @returns this TransformNode.
  92929. */
  92930. getPivotPointToRef(result: Vector3): TransformNode;
  92931. /**
  92932. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  92933. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  92934. */
  92935. getAbsolutePivotPoint(): Vector3;
  92936. /**
  92937. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  92938. * @param result vector3 to store the result
  92939. * @returns this TransformNode.
  92940. */
  92941. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  92942. /**
  92943. * Defines the passed node as the parent of the current node.
  92944. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  92945. * @see https://doc.babylonjs.com/how_to/parenting
  92946. * @param node the node ot set as the parent
  92947. * @returns this TransformNode.
  92948. */
  92949. setParent(node: Nullable<Node>): TransformNode;
  92950. private _nonUniformScaling;
  92951. /**
  92952. * True if the scaling property of this object is non uniform eg. (1,2,1)
  92953. */
  92954. get nonUniformScaling(): boolean;
  92955. /** @hidden */
  92956. _updateNonUniformScalingState(value: boolean): boolean;
  92957. /**
  92958. * Attach the current TransformNode to another TransformNode associated with a bone
  92959. * @param bone Bone affecting the TransformNode
  92960. * @param affectedTransformNode TransformNode associated with the bone
  92961. * @returns this object
  92962. */
  92963. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  92964. /**
  92965. * Detach the transform node if its associated with a bone
  92966. * @returns this object
  92967. */
  92968. detachFromBone(): TransformNode;
  92969. private static _rotationAxisCache;
  92970. /**
  92971. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  92972. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  92973. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92974. * The passed axis is also normalized.
  92975. * @param axis the axis to rotate around
  92976. * @param amount the amount to rotate in radians
  92977. * @param space Space to rotate in (Default: local)
  92978. * @returns the TransformNode.
  92979. */
  92980. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  92981. /**
  92982. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  92983. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92984. * The passed axis is also normalized. .
  92985. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  92986. * @param point the point to rotate around
  92987. * @param axis the axis to rotate around
  92988. * @param amount the amount to rotate in radians
  92989. * @returns the TransformNode
  92990. */
  92991. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  92992. /**
  92993. * Translates the mesh along the axis vector for the passed distance in the given space.
  92994. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  92995. * @param axis the axis to translate in
  92996. * @param distance the distance to translate
  92997. * @param space Space to rotate in (Default: local)
  92998. * @returns the TransformNode.
  92999. */
  93000. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  93001. /**
  93002. * Adds a rotation step to the mesh current rotation.
  93003. * x, y, z are Euler angles expressed in radians.
  93004. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  93005. * This means this rotation is made in the mesh local space only.
  93006. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  93007. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  93008. * ```javascript
  93009. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  93010. * ```
  93011. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  93012. * 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.
  93013. * @param x Rotation to add
  93014. * @param y Rotation to add
  93015. * @param z Rotation to add
  93016. * @returns the TransformNode.
  93017. */
  93018. addRotation(x: number, y: number, z: number): TransformNode;
  93019. /**
  93020. * @hidden
  93021. */
  93022. protected _getEffectiveParent(): Nullable<Node>;
  93023. /**
  93024. * Computes the world matrix of the node
  93025. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93026. * @returns the world matrix
  93027. */
  93028. computeWorldMatrix(force?: boolean): Matrix;
  93029. /**
  93030. * Resets this nodeTransform's local matrix to Matrix.Identity().
  93031. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  93032. */
  93033. resetLocalMatrix(independentOfChildren?: boolean): void;
  93034. protected _afterComputeWorldMatrix(): void;
  93035. /**
  93036. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  93037. * @param func callback function to add
  93038. *
  93039. * @returns the TransformNode.
  93040. */
  93041. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  93042. /**
  93043. * Removes a registered callback function.
  93044. * @param func callback function to remove
  93045. * @returns the TransformNode.
  93046. */
  93047. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  93048. /**
  93049. * Gets the position of the current mesh in camera space
  93050. * @param camera defines the camera to use
  93051. * @returns a position
  93052. */
  93053. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  93054. /**
  93055. * Returns the distance from the mesh to the active camera
  93056. * @param camera defines the camera to use
  93057. * @returns the distance
  93058. */
  93059. getDistanceToCamera(camera?: Nullable<Camera>): number;
  93060. /**
  93061. * Clone the current transform node
  93062. * @param name Name of the new clone
  93063. * @param newParent New parent for the clone
  93064. * @param doNotCloneChildren Do not clone children hierarchy
  93065. * @returns the new transform node
  93066. */
  93067. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  93068. /**
  93069. * Serializes the objects information.
  93070. * @param currentSerializationObject defines the object to serialize in
  93071. * @returns the serialized object
  93072. */
  93073. serialize(currentSerializationObject?: any): any;
  93074. /**
  93075. * Returns a new TransformNode object parsed from the source provided.
  93076. * @param parsedTransformNode is the source.
  93077. * @param scene the scne the object belongs to
  93078. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  93079. * @returns a new TransformNode object parsed from the source provided.
  93080. */
  93081. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  93082. /**
  93083. * Get all child-transformNodes of this node
  93084. * @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
  93085. * @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
  93086. * @returns an array of TransformNode
  93087. */
  93088. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  93089. /**
  93090. * Releases resources associated with this transform node.
  93091. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93092. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93093. */
  93094. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93095. /**
  93096. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  93097. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  93098. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  93099. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  93100. * @returns the current mesh
  93101. */
  93102. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  93103. private _syncAbsoluteScalingAndRotation;
  93104. }
  93105. }
  93106. declare module BABYLON {
  93107. /**
  93108. * Class used to override all child animations of a given target
  93109. */
  93110. export class AnimationPropertiesOverride {
  93111. /**
  93112. * Gets or sets a value indicating if animation blending must be used
  93113. */
  93114. enableBlending: boolean;
  93115. /**
  93116. * Gets or sets the blending speed to use when enableBlending is true
  93117. */
  93118. blendingSpeed: number;
  93119. /**
  93120. * Gets or sets the default loop mode to use
  93121. */
  93122. loopMode: number;
  93123. }
  93124. }
  93125. declare module BABYLON {
  93126. /**
  93127. * Class used to store bone information
  93128. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93129. */
  93130. export class Bone extends Node {
  93131. /**
  93132. * defines the bone name
  93133. */
  93134. name: string;
  93135. private static _tmpVecs;
  93136. private static _tmpQuat;
  93137. private static _tmpMats;
  93138. /**
  93139. * Gets the list of child bones
  93140. */
  93141. children: Bone[];
  93142. /** Gets the animations associated with this bone */
  93143. animations: Animation[];
  93144. /**
  93145. * Gets or sets bone length
  93146. */
  93147. length: number;
  93148. /**
  93149. * @hidden Internal only
  93150. * Set this value to map this bone to a different index in the transform matrices
  93151. * Set this value to -1 to exclude the bone from the transform matrices
  93152. */
  93153. _index: Nullable<number>;
  93154. private _skeleton;
  93155. private _localMatrix;
  93156. private _restPose;
  93157. private _baseMatrix;
  93158. private _absoluteTransform;
  93159. private _invertedAbsoluteTransform;
  93160. private _parent;
  93161. private _scalingDeterminant;
  93162. private _worldTransform;
  93163. private _localScaling;
  93164. private _localRotation;
  93165. private _localPosition;
  93166. private _needToDecompose;
  93167. private _needToCompose;
  93168. /** @hidden */
  93169. _linkedTransformNode: Nullable<TransformNode>;
  93170. /** @hidden */
  93171. _waitingTransformNodeId: Nullable<string>;
  93172. /** @hidden */
  93173. get _matrix(): Matrix;
  93174. /** @hidden */
  93175. set _matrix(value: Matrix);
  93176. /**
  93177. * Create a new bone
  93178. * @param name defines the bone name
  93179. * @param skeleton defines the parent skeleton
  93180. * @param parentBone defines the parent (can be null if the bone is the root)
  93181. * @param localMatrix defines the local matrix
  93182. * @param restPose defines the rest pose matrix
  93183. * @param baseMatrix defines the base matrix
  93184. * @param index defines index of the bone in the hiearchy
  93185. */
  93186. constructor(
  93187. /**
  93188. * defines the bone name
  93189. */
  93190. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  93191. /**
  93192. * Gets the current object class name.
  93193. * @return the class name
  93194. */
  93195. getClassName(): string;
  93196. /**
  93197. * Gets the parent skeleton
  93198. * @returns a skeleton
  93199. */
  93200. getSkeleton(): Skeleton;
  93201. /**
  93202. * Gets parent bone
  93203. * @returns a bone or null if the bone is the root of the bone hierarchy
  93204. */
  93205. getParent(): Nullable<Bone>;
  93206. /**
  93207. * Returns an array containing the root bones
  93208. * @returns an array containing the root bones
  93209. */
  93210. getChildren(): Array<Bone>;
  93211. /**
  93212. * Gets the node index in matrix array generated for rendering
  93213. * @returns the node index
  93214. */
  93215. getIndex(): number;
  93216. /**
  93217. * Sets the parent bone
  93218. * @param parent defines the parent (can be null if the bone is the root)
  93219. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  93220. */
  93221. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  93222. /**
  93223. * Gets the local matrix
  93224. * @returns a matrix
  93225. */
  93226. getLocalMatrix(): Matrix;
  93227. /**
  93228. * Gets the base matrix (initial matrix which remains unchanged)
  93229. * @returns a matrix
  93230. */
  93231. getBaseMatrix(): Matrix;
  93232. /**
  93233. * Gets the rest pose matrix
  93234. * @returns a matrix
  93235. */
  93236. getRestPose(): Matrix;
  93237. /**
  93238. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  93239. */
  93240. getWorldMatrix(): Matrix;
  93241. /**
  93242. * Sets the local matrix to rest pose matrix
  93243. */
  93244. returnToRest(): void;
  93245. /**
  93246. * Gets the inverse of the absolute transform matrix.
  93247. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  93248. * @returns a matrix
  93249. */
  93250. getInvertedAbsoluteTransform(): Matrix;
  93251. /**
  93252. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  93253. * @returns a matrix
  93254. */
  93255. getAbsoluteTransform(): Matrix;
  93256. /**
  93257. * Links with the given transform node.
  93258. * The local matrix of this bone is copied from the transform node every frame.
  93259. * @param transformNode defines the transform node to link to
  93260. */
  93261. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  93262. /**
  93263. * Gets the node used to drive the bone's transformation
  93264. * @returns a transform node or null
  93265. */
  93266. getTransformNode(): Nullable<TransformNode>;
  93267. /** Gets or sets current position (in local space) */
  93268. get position(): Vector3;
  93269. set position(newPosition: Vector3);
  93270. /** Gets or sets current rotation (in local space) */
  93271. get rotation(): Vector3;
  93272. set rotation(newRotation: Vector3);
  93273. /** Gets or sets current rotation quaternion (in local space) */
  93274. get rotationQuaternion(): Quaternion;
  93275. set rotationQuaternion(newRotation: Quaternion);
  93276. /** Gets or sets current scaling (in local space) */
  93277. get scaling(): Vector3;
  93278. set scaling(newScaling: Vector3);
  93279. /**
  93280. * Gets the animation properties override
  93281. */
  93282. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  93283. private _decompose;
  93284. private _compose;
  93285. /**
  93286. * Update the base and local matrices
  93287. * @param matrix defines the new base or local matrix
  93288. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  93289. * @param updateLocalMatrix defines if the local matrix should be updated
  93290. */
  93291. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  93292. /** @hidden */
  93293. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  93294. /**
  93295. * Flag the bone as dirty (Forcing it to update everything)
  93296. */
  93297. markAsDirty(): void;
  93298. /** @hidden */
  93299. _markAsDirtyAndCompose(): void;
  93300. private _markAsDirtyAndDecompose;
  93301. /**
  93302. * Translate the bone in local or world space
  93303. * @param vec The amount to translate the bone
  93304. * @param space The space that the translation is in
  93305. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93306. */
  93307. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  93308. /**
  93309. * Set the postion of the bone in local or world space
  93310. * @param position The position to set the bone
  93311. * @param space The space that the position is in
  93312. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93313. */
  93314. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  93315. /**
  93316. * Set the absolute position of the bone (world space)
  93317. * @param position The position to set the bone
  93318. * @param mesh The mesh that this bone is attached to
  93319. */
  93320. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  93321. /**
  93322. * Scale the bone on the x, y and z axes (in local space)
  93323. * @param x The amount to scale the bone on the x axis
  93324. * @param y The amount to scale the bone on the y axis
  93325. * @param z The amount to scale the bone on the z axis
  93326. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  93327. */
  93328. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  93329. /**
  93330. * Set the bone scaling in local space
  93331. * @param scale defines the scaling vector
  93332. */
  93333. setScale(scale: Vector3): void;
  93334. /**
  93335. * Gets the current scaling in local space
  93336. * @returns the current scaling vector
  93337. */
  93338. getScale(): Vector3;
  93339. /**
  93340. * Gets the current scaling in local space and stores it in a target vector
  93341. * @param result defines the target vector
  93342. */
  93343. getScaleToRef(result: Vector3): void;
  93344. /**
  93345. * Set the yaw, pitch, and roll of the bone in local or world space
  93346. * @param yaw The rotation of the bone on the y axis
  93347. * @param pitch The rotation of the bone on the x axis
  93348. * @param roll The rotation of the bone on the z axis
  93349. * @param space The space that the axes of rotation are in
  93350. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93351. */
  93352. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  93353. /**
  93354. * Add a rotation to the bone on an axis in local or world space
  93355. * @param axis The axis to rotate the bone on
  93356. * @param amount The amount to rotate the bone
  93357. * @param space The space that the axis is in
  93358. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93359. */
  93360. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  93361. /**
  93362. * Set the rotation of the bone to a particular axis angle in local or world space
  93363. * @param axis The axis to rotate the bone on
  93364. * @param angle The angle that the bone should be rotated to
  93365. * @param space The space that the axis is in
  93366. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93367. */
  93368. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  93369. /**
  93370. * Set the euler rotation of the bone in local of world space
  93371. * @param rotation The euler rotation that the bone should be set to
  93372. * @param space The space that the rotation is in
  93373. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93374. */
  93375. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  93376. /**
  93377. * Set the quaternion rotation of the bone in local of world space
  93378. * @param quat The quaternion rotation that the bone should be set to
  93379. * @param space The space that the rotation is in
  93380. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93381. */
  93382. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  93383. /**
  93384. * Set the rotation matrix of the bone in local of world space
  93385. * @param rotMat The rotation matrix that the bone should be set to
  93386. * @param space The space that the rotation is in
  93387. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93388. */
  93389. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  93390. private _rotateWithMatrix;
  93391. private _getNegativeRotationToRef;
  93392. /**
  93393. * Get the position of the bone in local or world space
  93394. * @param space The space that the returned position is in
  93395. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93396. * @returns The position of the bone
  93397. */
  93398. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  93399. /**
  93400. * Copy the position of the bone to a vector3 in local or world space
  93401. * @param space The space that the returned position is in
  93402. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93403. * @param result The vector3 to copy the position to
  93404. */
  93405. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  93406. /**
  93407. * Get the absolute position of the bone (world space)
  93408. * @param mesh The mesh that this bone is attached to
  93409. * @returns The absolute position of the bone
  93410. */
  93411. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  93412. /**
  93413. * Copy the absolute position of the bone (world space) to the result param
  93414. * @param mesh The mesh that this bone is attached to
  93415. * @param result The vector3 to copy the absolute position to
  93416. */
  93417. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  93418. /**
  93419. * Compute the absolute transforms of this bone and its children
  93420. */
  93421. computeAbsoluteTransforms(): void;
  93422. /**
  93423. * Get the world direction from an axis that is in the local space of the bone
  93424. * @param localAxis The local direction that is used to compute the world direction
  93425. * @param mesh The mesh that this bone is attached to
  93426. * @returns The world direction
  93427. */
  93428. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93429. /**
  93430. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  93431. * @param localAxis The local direction that is used to compute the world direction
  93432. * @param mesh The mesh that this bone is attached to
  93433. * @param result The vector3 that the world direction will be copied to
  93434. */
  93435. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93436. /**
  93437. * Get the euler rotation of the bone in local or world space
  93438. * @param space The space that the rotation should be in
  93439. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93440. * @returns The euler rotation
  93441. */
  93442. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  93443. /**
  93444. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  93445. * @param space The space that the rotation should be in
  93446. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93447. * @param result The vector3 that the rotation should be copied to
  93448. */
  93449. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93450. /**
  93451. * Get the quaternion rotation of the bone in either local or world space
  93452. * @param space The space that the rotation should be in
  93453. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93454. * @returns The quaternion rotation
  93455. */
  93456. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  93457. /**
  93458. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  93459. * @param space The space that the rotation should be in
  93460. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93461. * @param result The quaternion that the rotation should be copied to
  93462. */
  93463. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  93464. /**
  93465. * Get the rotation matrix of the bone in local or world space
  93466. * @param space The space that the rotation should be in
  93467. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93468. * @returns The rotation matrix
  93469. */
  93470. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  93471. /**
  93472. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  93473. * @param space The space that the rotation should be in
  93474. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93475. * @param result The quaternion that the rotation should be copied to
  93476. */
  93477. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  93478. /**
  93479. * Get the world position of a point that is in the local space of the bone
  93480. * @param position The local position
  93481. * @param mesh The mesh that this bone is attached to
  93482. * @returns The world position
  93483. */
  93484. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93485. /**
  93486. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  93487. * @param position The local position
  93488. * @param mesh The mesh that this bone is attached to
  93489. * @param result The vector3 that the world position should be copied to
  93490. */
  93491. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93492. /**
  93493. * Get the local position of a point that is in world space
  93494. * @param position The world position
  93495. * @param mesh The mesh that this bone is attached to
  93496. * @returns The local position
  93497. */
  93498. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93499. /**
  93500. * Get the local position of a point that is in world space and copy it to the result param
  93501. * @param position The world position
  93502. * @param mesh The mesh that this bone is attached to
  93503. * @param result The vector3 that the local position should be copied to
  93504. */
  93505. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93506. }
  93507. }
  93508. declare module BABYLON {
  93509. /**
  93510. * Defines a runtime animation
  93511. */
  93512. export class RuntimeAnimation {
  93513. private _events;
  93514. /**
  93515. * The current frame of the runtime animation
  93516. */
  93517. private _currentFrame;
  93518. /**
  93519. * The animation used by the runtime animation
  93520. */
  93521. private _animation;
  93522. /**
  93523. * The target of the runtime animation
  93524. */
  93525. private _target;
  93526. /**
  93527. * The initiating animatable
  93528. */
  93529. private _host;
  93530. /**
  93531. * The original value of the runtime animation
  93532. */
  93533. private _originalValue;
  93534. /**
  93535. * The original blend value of the runtime animation
  93536. */
  93537. private _originalBlendValue;
  93538. /**
  93539. * The offsets cache of the runtime animation
  93540. */
  93541. private _offsetsCache;
  93542. /**
  93543. * The high limits cache of the runtime animation
  93544. */
  93545. private _highLimitsCache;
  93546. /**
  93547. * Specifies if the runtime animation has been stopped
  93548. */
  93549. private _stopped;
  93550. /**
  93551. * The blending factor of the runtime animation
  93552. */
  93553. private _blendingFactor;
  93554. /**
  93555. * The BabylonJS scene
  93556. */
  93557. private _scene;
  93558. /**
  93559. * The current value of the runtime animation
  93560. */
  93561. private _currentValue;
  93562. /** @hidden */
  93563. _animationState: _IAnimationState;
  93564. /**
  93565. * The active target of the runtime animation
  93566. */
  93567. private _activeTargets;
  93568. private _currentActiveTarget;
  93569. private _directTarget;
  93570. /**
  93571. * The target path of the runtime animation
  93572. */
  93573. private _targetPath;
  93574. /**
  93575. * The weight of the runtime animation
  93576. */
  93577. private _weight;
  93578. /**
  93579. * The ratio offset of the runtime animation
  93580. */
  93581. private _ratioOffset;
  93582. /**
  93583. * The previous delay of the runtime animation
  93584. */
  93585. private _previousDelay;
  93586. /**
  93587. * The previous ratio of the runtime animation
  93588. */
  93589. private _previousRatio;
  93590. private _enableBlending;
  93591. private _keys;
  93592. private _minFrame;
  93593. private _maxFrame;
  93594. private _minValue;
  93595. private _maxValue;
  93596. private _targetIsArray;
  93597. /**
  93598. * Gets the current frame of the runtime animation
  93599. */
  93600. get currentFrame(): number;
  93601. /**
  93602. * Gets the weight of the runtime animation
  93603. */
  93604. get weight(): number;
  93605. /**
  93606. * Gets the current value of the runtime animation
  93607. */
  93608. get currentValue(): any;
  93609. /**
  93610. * Gets the target path of the runtime animation
  93611. */
  93612. get targetPath(): string;
  93613. /**
  93614. * Gets the actual target of the runtime animation
  93615. */
  93616. get target(): any;
  93617. /**
  93618. * Gets the additive state of the runtime animation
  93619. */
  93620. get isAdditive(): boolean;
  93621. /** @hidden */
  93622. _onLoop: () => void;
  93623. /**
  93624. * Create a new RuntimeAnimation object
  93625. * @param target defines the target of the animation
  93626. * @param animation defines the source animation object
  93627. * @param scene defines the hosting scene
  93628. * @param host defines the initiating Animatable
  93629. */
  93630. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  93631. private _preparePath;
  93632. /**
  93633. * Gets the animation from the runtime animation
  93634. */
  93635. get animation(): Animation;
  93636. /**
  93637. * Resets the runtime animation to the beginning
  93638. * @param restoreOriginal defines whether to restore the target property to the original value
  93639. */
  93640. reset(restoreOriginal?: boolean): void;
  93641. /**
  93642. * Specifies if the runtime animation is stopped
  93643. * @returns Boolean specifying if the runtime animation is stopped
  93644. */
  93645. isStopped(): boolean;
  93646. /**
  93647. * Disposes of the runtime animation
  93648. */
  93649. dispose(): void;
  93650. /**
  93651. * Apply the interpolated value to the target
  93652. * @param currentValue defines the value computed by the animation
  93653. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  93654. */
  93655. setValue(currentValue: any, weight: number): void;
  93656. private _getOriginalValues;
  93657. private _setValue;
  93658. /**
  93659. * Gets the loop pmode of the runtime animation
  93660. * @returns Loop Mode
  93661. */
  93662. private _getCorrectLoopMode;
  93663. /**
  93664. * Move the current animation to a given frame
  93665. * @param frame defines the frame to move to
  93666. */
  93667. goToFrame(frame: number): void;
  93668. /**
  93669. * @hidden Internal use only
  93670. */
  93671. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  93672. /**
  93673. * Execute the current animation
  93674. * @param delay defines the delay to add to the current frame
  93675. * @param from defines the lower bound of the animation range
  93676. * @param to defines the upper bound of the animation range
  93677. * @param loop defines if the current animation must loop
  93678. * @param speedRatio defines the current speed ratio
  93679. * @param weight defines the weight of the animation (default is -1 so no weight)
  93680. * @param onLoop optional callback called when animation loops
  93681. * @returns a boolean indicating if the animation is running
  93682. */
  93683. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  93684. }
  93685. }
  93686. declare module BABYLON {
  93687. /**
  93688. * Class used to store an actual running animation
  93689. */
  93690. export class Animatable {
  93691. /** defines the target object */
  93692. target: any;
  93693. /** defines the starting frame number (default is 0) */
  93694. fromFrame: number;
  93695. /** defines the ending frame number (default is 100) */
  93696. toFrame: number;
  93697. /** defines if the animation must loop (default is false) */
  93698. loopAnimation: boolean;
  93699. /** defines a callback to call when animation ends if it is not looping */
  93700. onAnimationEnd?: (() => void) | null | undefined;
  93701. /** defines a callback to call when animation loops */
  93702. onAnimationLoop?: (() => void) | null | undefined;
  93703. /** defines whether the animation should be evaluated additively */
  93704. isAdditive: boolean;
  93705. private _localDelayOffset;
  93706. private _pausedDelay;
  93707. private _runtimeAnimations;
  93708. private _paused;
  93709. private _scene;
  93710. private _speedRatio;
  93711. private _weight;
  93712. private _syncRoot;
  93713. /**
  93714. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  93715. * This will only apply for non looping animation (default is true)
  93716. */
  93717. disposeOnEnd: boolean;
  93718. /**
  93719. * Gets a boolean indicating if the animation has started
  93720. */
  93721. animationStarted: boolean;
  93722. /**
  93723. * Observer raised when the animation ends
  93724. */
  93725. onAnimationEndObservable: Observable<Animatable>;
  93726. /**
  93727. * Observer raised when the animation loops
  93728. */
  93729. onAnimationLoopObservable: Observable<Animatable>;
  93730. /**
  93731. * Gets the root Animatable used to synchronize and normalize animations
  93732. */
  93733. get syncRoot(): Nullable<Animatable>;
  93734. /**
  93735. * Gets the current frame of the first RuntimeAnimation
  93736. * Used to synchronize Animatables
  93737. */
  93738. get masterFrame(): number;
  93739. /**
  93740. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  93741. */
  93742. get weight(): number;
  93743. set weight(value: number);
  93744. /**
  93745. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  93746. */
  93747. get speedRatio(): number;
  93748. set speedRatio(value: number);
  93749. /**
  93750. * Creates a new Animatable
  93751. * @param scene defines the hosting scene
  93752. * @param target defines the target object
  93753. * @param fromFrame defines the starting frame number (default is 0)
  93754. * @param toFrame defines the ending frame number (default is 100)
  93755. * @param loopAnimation defines if the animation must loop (default is false)
  93756. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  93757. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  93758. * @param animations defines a group of animation to add to the new Animatable
  93759. * @param onAnimationLoop defines a callback to call when animation loops
  93760. * @param isAdditive defines whether the animation should be evaluated additively
  93761. */
  93762. constructor(scene: Scene,
  93763. /** defines the target object */
  93764. target: any,
  93765. /** defines the starting frame number (default is 0) */
  93766. fromFrame?: number,
  93767. /** defines the ending frame number (default is 100) */
  93768. toFrame?: number,
  93769. /** defines if the animation must loop (default is false) */
  93770. loopAnimation?: boolean, speedRatio?: number,
  93771. /** defines a callback to call when animation ends if it is not looping */
  93772. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  93773. /** defines a callback to call when animation loops */
  93774. onAnimationLoop?: (() => void) | null | undefined,
  93775. /** defines whether the animation should be evaluated additively */
  93776. isAdditive?: boolean);
  93777. /**
  93778. * Synchronize and normalize current Animatable with a source Animatable
  93779. * This is useful when using animation weights and when animations are not of the same length
  93780. * @param root defines the root Animatable to synchronize with
  93781. * @returns the current Animatable
  93782. */
  93783. syncWith(root: Animatable): Animatable;
  93784. /**
  93785. * Gets the list of runtime animations
  93786. * @returns an array of RuntimeAnimation
  93787. */
  93788. getAnimations(): RuntimeAnimation[];
  93789. /**
  93790. * Adds more animations to the current animatable
  93791. * @param target defines the target of the animations
  93792. * @param animations defines the new animations to add
  93793. */
  93794. appendAnimations(target: any, animations: Animation[]): void;
  93795. /**
  93796. * Gets the source animation for a specific property
  93797. * @param property defines the propertyu to look for
  93798. * @returns null or the source animation for the given property
  93799. */
  93800. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  93801. /**
  93802. * Gets the runtime animation for a specific property
  93803. * @param property defines the propertyu to look for
  93804. * @returns null or the runtime animation for the given property
  93805. */
  93806. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  93807. /**
  93808. * Resets the animatable to its original state
  93809. */
  93810. reset(): void;
  93811. /**
  93812. * Allows the animatable to blend with current running animations
  93813. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  93814. * @param blendingSpeed defines the blending speed to use
  93815. */
  93816. enableBlending(blendingSpeed: number): void;
  93817. /**
  93818. * Disable animation blending
  93819. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  93820. */
  93821. disableBlending(): void;
  93822. /**
  93823. * Jump directly to a given frame
  93824. * @param frame defines the frame to jump to
  93825. */
  93826. goToFrame(frame: number): void;
  93827. /**
  93828. * Pause the animation
  93829. */
  93830. pause(): void;
  93831. /**
  93832. * Restart the animation
  93833. */
  93834. restart(): void;
  93835. private _raiseOnAnimationEnd;
  93836. /**
  93837. * Stop and delete the current animation
  93838. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  93839. * @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)
  93840. */
  93841. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  93842. /**
  93843. * Wait asynchronously for the animation to end
  93844. * @returns a promise which will be fullfilled when the animation ends
  93845. */
  93846. waitAsync(): Promise<Animatable>;
  93847. /** @hidden */
  93848. _animate(delay: number): boolean;
  93849. }
  93850. interface Scene {
  93851. /** @hidden */
  93852. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  93853. /** @hidden */
  93854. _processLateAnimationBindingsForMatrices(holder: {
  93855. totalWeight: number;
  93856. totalAdditiveWeight: number;
  93857. animations: RuntimeAnimation[];
  93858. additiveAnimations: RuntimeAnimation[];
  93859. originalValue: Matrix;
  93860. }): any;
  93861. /** @hidden */
  93862. _processLateAnimationBindingsForQuaternions(holder: {
  93863. totalWeight: number;
  93864. totalAdditiveWeight: number;
  93865. animations: RuntimeAnimation[];
  93866. additiveAnimations: RuntimeAnimation[];
  93867. originalValue: Quaternion;
  93868. }, refQuaternion: Quaternion): Quaternion;
  93869. /** @hidden */
  93870. _processLateAnimationBindings(): void;
  93871. /**
  93872. * Will start the animation sequence of a given target
  93873. * @param target defines the target
  93874. * @param from defines from which frame should animation start
  93875. * @param to defines until which frame should animation run.
  93876. * @param weight defines the weight to apply to the animation (1.0 by default)
  93877. * @param loop defines if the animation loops
  93878. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93879. * @param onAnimationEnd defines the function to be executed when the animation ends
  93880. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93881. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  93882. * @param onAnimationLoop defines the callback to call when an animation loops
  93883. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93884. * @returns the animatable object created for this animation
  93885. */
  93886. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  93887. /**
  93888. * Will start the animation sequence of a given target
  93889. * @param target defines the target
  93890. * @param from defines from which frame should animation start
  93891. * @param to defines until which frame should animation run.
  93892. * @param loop defines if the animation loops
  93893. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93894. * @param onAnimationEnd defines the function to be executed when the animation ends
  93895. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93896. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  93897. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  93898. * @param onAnimationLoop defines the callback to call when an animation loops
  93899. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93900. * @returns the animatable object created for this animation
  93901. */
  93902. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  93903. /**
  93904. * Will start the animation sequence of a given target and its hierarchy
  93905. * @param target defines the target
  93906. * @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.
  93907. * @param from defines from which frame should animation start
  93908. * @param to defines until which frame should animation run.
  93909. * @param loop defines if the animation loops
  93910. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93911. * @param onAnimationEnd defines the function to be executed when the animation ends
  93912. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93913. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  93914. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  93915. * @param onAnimationLoop defines the callback to call when an animation loops
  93916. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93917. * @returns the list of created animatables
  93918. */
  93919. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  93920. /**
  93921. * Begin a new animation on a given node
  93922. * @param target defines the target where the animation will take place
  93923. * @param animations defines the list of animations to start
  93924. * @param from defines the initial value
  93925. * @param to defines the final value
  93926. * @param loop defines if you want animation to loop (off by default)
  93927. * @param speedRatio defines the speed ratio to apply to all animations
  93928. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93929. * @param onAnimationLoop defines the callback to call when an animation loops
  93930. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93931. * @returns the list of created animatables
  93932. */
  93933. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  93934. /**
  93935. * Begin a new animation on a given node and its hierarchy
  93936. * @param target defines the root node where the animation will take place
  93937. * @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.
  93938. * @param animations defines the list of animations to start
  93939. * @param from defines the initial value
  93940. * @param to defines the final value
  93941. * @param loop defines if you want animation to loop (off by default)
  93942. * @param speedRatio defines the speed ratio to apply to all animations
  93943. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93944. * @param onAnimationLoop defines the callback to call when an animation loops
  93945. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93946. * @returns the list of animatables created for all nodes
  93947. */
  93948. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  93949. /**
  93950. * Gets the animatable associated with a specific target
  93951. * @param target defines the target of the animatable
  93952. * @returns the required animatable if found
  93953. */
  93954. getAnimatableByTarget(target: any): Nullable<Animatable>;
  93955. /**
  93956. * Gets all animatables associated with a given target
  93957. * @param target defines the target to look animatables for
  93958. * @returns an array of Animatables
  93959. */
  93960. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  93961. /**
  93962. * Stops and removes all animations that have been applied to the scene
  93963. */
  93964. stopAllAnimations(): void;
  93965. /**
  93966. * Gets the current delta time used by animation engine
  93967. */
  93968. deltaTime: number;
  93969. }
  93970. interface Bone {
  93971. /**
  93972. * Copy an animation range from another bone
  93973. * @param source defines the source bone
  93974. * @param rangeName defines the range name to copy
  93975. * @param frameOffset defines the frame offset
  93976. * @param rescaleAsRequired defines if rescaling must be applied if required
  93977. * @param skelDimensionsRatio defines the scaling ratio
  93978. * @returns true if operation was successful
  93979. */
  93980. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  93981. }
  93982. }
  93983. declare module BABYLON {
  93984. /**
  93985. * Class used to handle skinning animations
  93986. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93987. */
  93988. export class Skeleton implements IAnimatable {
  93989. /** defines the skeleton name */
  93990. name: string;
  93991. /** defines the skeleton Id */
  93992. id: string;
  93993. /**
  93994. * Defines the list of child bones
  93995. */
  93996. bones: Bone[];
  93997. /**
  93998. * Defines an estimate of the dimension of the skeleton at rest
  93999. */
  94000. dimensionsAtRest: Vector3;
  94001. /**
  94002. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  94003. */
  94004. needInitialSkinMatrix: boolean;
  94005. /**
  94006. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  94007. */
  94008. overrideMesh: Nullable<AbstractMesh>;
  94009. /**
  94010. * Gets the list of animations attached to this skeleton
  94011. */
  94012. animations: Array<Animation>;
  94013. private _scene;
  94014. private _isDirty;
  94015. private _transformMatrices;
  94016. private _transformMatrixTexture;
  94017. private _meshesWithPoseMatrix;
  94018. private _animatables;
  94019. private _identity;
  94020. private _synchronizedWithMesh;
  94021. private _ranges;
  94022. private _lastAbsoluteTransformsUpdateId;
  94023. private _canUseTextureForBones;
  94024. private _uniqueId;
  94025. /** @hidden */
  94026. _numBonesWithLinkedTransformNode: number;
  94027. /** @hidden */
  94028. _hasWaitingData: Nullable<boolean>;
  94029. /**
  94030. * Specifies if the skeleton should be serialized
  94031. */
  94032. doNotSerialize: boolean;
  94033. private _useTextureToStoreBoneMatrices;
  94034. /**
  94035. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  94036. * Please note that this option is not available if the hardware does not support it
  94037. */
  94038. get useTextureToStoreBoneMatrices(): boolean;
  94039. set useTextureToStoreBoneMatrices(value: boolean);
  94040. private _animationPropertiesOverride;
  94041. /**
  94042. * Gets or sets the animation properties override
  94043. */
  94044. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  94045. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  94046. /**
  94047. * List of inspectable custom properties (used by the Inspector)
  94048. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94049. */
  94050. inspectableCustomProperties: IInspectable[];
  94051. /**
  94052. * An observable triggered before computing the skeleton's matrices
  94053. */
  94054. onBeforeComputeObservable: Observable<Skeleton>;
  94055. /**
  94056. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  94057. */
  94058. get isUsingTextureForMatrices(): boolean;
  94059. /**
  94060. * Gets the unique ID of this skeleton
  94061. */
  94062. get uniqueId(): number;
  94063. /**
  94064. * Creates a new skeleton
  94065. * @param name defines the skeleton name
  94066. * @param id defines the skeleton Id
  94067. * @param scene defines the hosting scene
  94068. */
  94069. constructor(
  94070. /** defines the skeleton name */
  94071. name: string,
  94072. /** defines the skeleton Id */
  94073. id: string, scene: Scene);
  94074. /**
  94075. * Gets the current object class name.
  94076. * @return the class name
  94077. */
  94078. getClassName(): string;
  94079. /**
  94080. * Returns an array containing the root bones
  94081. * @returns an array containing the root bones
  94082. */
  94083. getChildren(): Array<Bone>;
  94084. /**
  94085. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  94086. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  94087. * @returns a Float32Array containing matrices data
  94088. */
  94089. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  94090. /**
  94091. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  94092. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  94093. * @returns a raw texture containing the data
  94094. */
  94095. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  94096. /**
  94097. * Gets the current hosting scene
  94098. * @returns a scene object
  94099. */
  94100. getScene(): Scene;
  94101. /**
  94102. * Gets a string representing the current skeleton data
  94103. * @param fullDetails defines a boolean indicating if we want a verbose version
  94104. * @returns a string representing the current skeleton data
  94105. */
  94106. toString(fullDetails?: boolean): string;
  94107. /**
  94108. * Get bone's index searching by name
  94109. * @param name defines bone's name to search for
  94110. * @return the indice of the bone. Returns -1 if not found
  94111. */
  94112. getBoneIndexByName(name: string): number;
  94113. /**
  94114. * Creater a new animation range
  94115. * @param name defines the name of the range
  94116. * @param from defines the start key
  94117. * @param to defines the end key
  94118. */
  94119. createAnimationRange(name: string, from: number, to: number): void;
  94120. /**
  94121. * Delete a specific animation range
  94122. * @param name defines the name of the range
  94123. * @param deleteFrames defines if frames must be removed as well
  94124. */
  94125. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  94126. /**
  94127. * Gets a specific animation range
  94128. * @param name defines the name of the range to look for
  94129. * @returns the requested animation range or null if not found
  94130. */
  94131. getAnimationRange(name: string): Nullable<AnimationRange>;
  94132. /**
  94133. * Gets the list of all animation ranges defined on this skeleton
  94134. * @returns an array
  94135. */
  94136. getAnimationRanges(): Nullable<AnimationRange>[];
  94137. /**
  94138. * Copy animation range from a source skeleton.
  94139. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  94140. * @param source defines the source skeleton
  94141. * @param name defines the name of the range to copy
  94142. * @param rescaleAsRequired defines if rescaling must be applied if required
  94143. * @returns true if operation was successful
  94144. */
  94145. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  94146. /**
  94147. * Forces the skeleton to go to rest pose
  94148. */
  94149. returnToRest(): void;
  94150. private _getHighestAnimationFrame;
  94151. /**
  94152. * Begin a specific animation range
  94153. * @param name defines the name of the range to start
  94154. * @param loop defines if looping must be turned on (false by default)
  94155. * @param speedRatio defines the speed ratio to apply (1 by default)
  94156. * @param onAnimationEnd defines a callback which will be called when animation will end
  94157. * @returns a new animatable
  94158. */
  94159. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  94160. /**
  94161. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  94162. * @param skeleton defines the Skeleton containing the animation range to convert
  94163. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  94164. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  94165. * @returns the original skeleton
  94166. */
  94167. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  94168. /** @hidden */
  94169. _markAsDirty(): void;
  94170. /** @hidden */
  94171. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  94172. /** @hidden */
  94173. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  94174. private _computeTransformMatrices;
  94175. /**
  94176. * Build all resources required to render a skeleton
  94177. */
  94178. prepare(): void;
  94179. /**
  94180. * Gets the list of animatables currently running for this skeleton
  94181. * @returns an array of animatables
  94182. */
  94183. getAnimatables(): IAnimatable[];
  94184. /**
  94185. * Clone the current skeleton
  94186. * @param name defines the name of the new skeleton
  94187. * @param id defines the id of the new skeleton
  94188. * @returns the new skeleton
  94189. */
  94190. clone(name: string, id?: string): Skeleton;
  94191. /**
  94192. * Enable animation blending for this skeleton
  94193. * @param blendingSpeed defines the blending speed to apply
  94194. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  94195. */
  94196. enableBlending(blendingSpeed?: number): void;
  94197. /**
  94198. * Releases all resources associated with the current skeleton
  94199. */
  94200. dispose(): void;
  94201. /**
  94202. * Serialize the skeleton in a JSON object
  94203. * @returns a JSON object
  94204. */
  94205. serialize(): any;
  94206. /**
  94207. * Creates a new skeleton from serialized data
  94208. * @param parsedSkeleton defines the serialized data
  94209. * @param scene defines the hosting scene
  94210. * @returns a new skeleton
  94211. */
  94212. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  94213. /**
  94214. * Compute all node absolute transforms
  94215. * @param forceUpdate defines if computation must be done even if cache is up to date
  94216. */
  94217. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  94218. /**
  94219. * Gets the root pose matrix
  94220. * @returns a matrix
  94221. */
  94222. getPoseMatrix(): Nullable<Matrix>;
  94223. /**
  94224. * Sorts bones per internal index
  94225. */
  94226. sortBones(): void;
  94227. private _sortBones;
  94228. }
  94229. }
  94230. declare module BABYLON {
  94231. /**
  94232. * Creates an instance based on a source mesh.
  94233. */
  94234. export class InstancedMesh extends AbstractMesh {
  94235. private _sourceMesh;
  94236. private _currentLOD;
  94237. /** @hidden */
  94238. _indexInSourceMeshInstanceArray: number;
  94239. constructor(name: string, source: Mesh);
  94240. /**
  94241. * Returns the string "InstancedMesh".
  94242. */
  94243. getClassName(): string;
  94244. /** Gets the list of lights affecting that mesh */
  94245. get lightSources(): Light[];
  94246. _resyncLightSources(): void;
  94247. _resyncLightSource(light: Light): void;
  94248. _removeLightSource(light: Light, dispose: boolean): void;
  94249. /**
  94250. * If the source mesh receives shadows
  94251. */
  94252. get receiveShadows(): boolean;
  94253. /**
  94254. * The material of the source mesh
  94255. */
  94256. get material(): Nullable<Material>;
  94257. /**
  94258. * Visibility of the source mesh
  94259. */
  94260. get visibility(): number;
  94261. /**
  94262. * Skeleton of the source mesh
  94263. */
  94264. get skeleton(): Nullable<Skeleton>;
  94265. /**
  94266. * Rendering ground id of the source mesh
  94267. */
  94268. get renderingGroupId(): number;
  94269. set renderingGroupId(value: number);
  94270. /**
  94271. * Returns the total number of vertices (integer).
  94272. */
  94273. getTotalVertices(): number;
  94274. /**
  94275. * Returns a positive integer : the total number of indices in this mesh geometry.
  94276. * @returns the numner of indices or zero if the mesh has no geometry.
  94277. */
  94278. getTotalIndices(): number;
  94279. /**
  94280. * The source mesh of the instance
  94281. */
  94282. get sourceMesh(): Mesh;
  94283. /**
  94284. * Creates a new InstancedMesh object from the mesh model.
  94285. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  94286. * @param name defines the name of the new instance
  94287. * @returns a new InstancedMesh
  94288. */
  94289. createInstance(name: string): InstancedMesh;
  94290. /**
  94291. * Is this node ready to be used/rendered
  94292. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  94293. * @return {boolean} is it ready
  94294. */
  94295. isReady(completeCheck?: boolean): boolean;
  94296. /**
  94297. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  94298. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  94299. * @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.
  94300. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  94301. */
  94302. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  94303. /**
  94304. * Sets the vertex data of the mesh geometry for the requested `kind`.
  94305. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  94306. * The `data` are either a numeric array either a Float32Array.
  94307. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  94308. * 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).
  94309. * Note that a new underlying VertexBuffer object is created each call.
  94310. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  94311. *
  94312. * Possible `kind` values :
  94313. * - VertexBuffer.PositionKind
  94314. * - VertexBuffer.UVKind
  94315. * - VertexBuffer.UV2Kind
  94316. * - VertexBuffer.UV3Kind
  94317. * - VertexBuffer.UV4Kind
  94318. * - VertexBuffer.UV5Kind
  94319. * - VertexBuffer.UV6Kind
  94320. * - VertexBuffer.ColorKind
  94321. * - VertexBuffer.MatricesIndicesKind
  94322. * - VertexBuffer.MatricesIndicesExtraKind
  94323. * - VertexBuffer.MatricesWeightsKind
  94324. * - VertexBuffer.MatricesWeightsExtraKind
  94325. *
  94326. * Returns the Mesh.
  94327. */
  94328. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  94329. /**
  94330. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  94331. * If the mesh has no geometry, it is simply returned as it is.
  94332. * The `data` are either a numeric array either a Float32Array.
  94333. * No new underlying VertexBuffer object is created.
  94334. * 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.
  94335. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  94336. *
  94337. * Possible `kind` values :
  94338. * - VertexBuffer.PositionKind
  94339. * - VertexBuffer.UVKind
  94340. * - VertexBuffer.UV2Kind
  94341. * - VertexBuffer.UV3Kind
  94342. * - VertexBuffer.UV4Kind
  94343. * - VertexBuffer.UV5Kind
  94344. * - VertexBuffer.UV6Kind
  94345. * - VertexBuffer.ColorKind
  94346. * - VertexBuffer.MatricesIndicesKind
  94347. * - VertexBuffer.MatricesIndicesExtraKind
  94348. * - VertexBuffer.MatricesWeightsKind
  94349. * - VertexBuffer.MatricesWeightsExtraKind
  94350. *
  94351. * Returns the Mesh.
  94352. */
  94353. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  94354. /**
  94355. * Sets the mesh indices.
  94356. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  94357. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  94358. * This method creates a new index buffer each call.
  94359. * Returns the Mesh.
  94360. */
  94361. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  94362. /**
  94363. * Boolean : True if the mesh owns the requested kind of data.
  94364. */
  94365. isVerticesDataPresent(kind: string): boolean;
  94366. /**
  94367. * Returns an array of indices (IndicesArray).
  94368. */
  94369. getIndices(): Nullable<IndicesArray>;
  94370. get _positions(): Nullable<Vector3[]>;
  94371. /**
  94372. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  94373. * This means the mesh underlying bounding box and sphere are recomputed.
  94374. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  94375. * @returns the current mesh
  94376. */
  94377. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  94378. /** @hidden */
  94379. _preActivate(): InstancedMesh;
  94380. /** @hidden */
  94381. _activate(renderId: number, intermediateRendering: boolean): boolean;
  94382. /** @hidden */
  94383. _postActivate(): void;
  94384. getWorldMatrix(): Matrix;
  94385. get isAnInstance(): boolean;
  94386. /**
  94387. * Returns the current associated LOD AbstractMesh.
  94388. */
  94389. getLOD(camera: Camera): AbstractMesh;
  94390. /** @hidden */
  94391. _preActivateForIntermediateRendering(renderId: number): Mesh;
  94392. /** @hidden */
  94393. _syncSubMeshes(): InstancedMesh;
  94394. /** @hidden */
  94395. _generatePointsArray(): boolean;
  94396. /**
  94397. * Creates a new InstancedMesh from the current mesh.
  94398. * - name (string) : the cloned mesh name
  94399. * - newParent (optional Node) : the optional Node to parent the clone to.
  94400. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  94401. *
  94402. * Returns the clone.
  94403. */
  94404. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  94405. /**
  94406. * Disposes the InstancedMesh.
  94407. * Returns nothing.
  94408. */
  94409. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94410. }
  94411. interface Mesh {
  94412. /**
  94413. * Register a custom buffer that will be instanced
  94414. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  94415. * @param kind defines the buffer kind
  94416. * @param stride defines the stride in floats
  94417. */
  94418. registerInstancedBuffer(kind: string, stride: number): void;
  94419. /**
  94420. * true to use the edge renderer for all instances of this mesh
  94421. */
  94422. edgesShareWithInstances: boolean;
  94423. /** @hidden */
  94424. _userInstancedBuffersStorage: {
  94425. data: {
  94426. [key: string]: Float32Array;
  94427. };
  94428. sizes: {
  94429. [key: string]: number;
  94430. };
  94431. vertexBuffers: {
  94432. [key: string]: Nullable<VertexBuffer>;
  94433. };
  94434. strides: {
  94435. [key: string]: number;
  94436. };
  94437. };
  94438. }
  94439. interface AbstractMesh {
  94440. /**
  94441. * Object used to store instanced buffers defined by user
  94442. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  94443. */
  94444. instancedBuffers: {
  94445. [key: string]: any;
  94446. };
  94447. }
  94448. }
  94449. declare module BABYLON {
  94450. /**
  94451. * Defines the options associated with the creation of a shader material.
  94452. */
  94453. export interface IShaderMaterialOptions {
  94454. /**
  94455. * Does the material work in alpha blend mode
  94456. */
  94457. needAlphaBlending: boolean;
  94458. /**
  94459. * Does the material work in alpha test mode
  94460. */
  94461. needAlphaTesting: boolean;
  94462. /**
  94463. * The list of attribute names used in the shader
  94464. */
  94465. attributes: string[];
  94466. /**
  94467. * The list of unifrom names used in the shader
  94468. */
  94469. uniforms: string[];
  94470. /**
  94471. * The list of UBO names used in the shader
  94472. */
  94473. uniformBuffers: string[];
  94474. /**
  94475. * The list of sampler names used in the shader
  94476. */
  94477. samplers: string[];
  94478. /**
  94479. * The list of defines used in the shader
  94480. */
  94481. defines: string[];
  94482. }
  94483. /**
  94484. * 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.
  94485. *
  94486. * This returned material effects how the mesh will look based on the code in the shaders.
  94487. *
  94488. * @see https://doc.babylonjs.com/how_to/shader_material
  94489. */
  94490. export class ShaderMaterial extends Material {
  94491. private _shaderPath;
  94492. private _options;
  94493. private _textures;
  94494. private _textureArrays;
  94495. private _floats;
  94496. private _ints;
  94497. private _floatsArrays;
  94498. private _colors3;
  94499. private _colors3Arrays;
  94500. private _colors4;
  94501. private _colors4Arrays;
  94502. private _vectors2;
  94503. private _vectors3;
  94504. private _vectors4;
  94505. private _matrices;
  94506. private _matrixArrays;
  94507. private _matrices3x3;
  94508. private _matrices2x2;
  94509. private _vectors2Arrays;
  94510. private _vectors3Arrays;
  94511. private _vectors4Arrays;
  94512. private _cachedWorldViewMatrix;
  94513. private _cachedWorldViewProjectionMatrix;
  94514. private _renderId;
  94515. private _multiview;
  94516. private _cachedDefines;
  94517. /** Define the Url to load snippets */
  94518. static SnippetUrl: string;
  94519. /** Snippet ID if the material was created from the snippet server */
  94520. snippetId: string;
  94521. /**
  94522. * Instantiate a new shader material.
  94523. * 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.
  94524. * This returned material effects how the mesh will look based on the code in the shaders.
  94525. * @see https://doc.babylonjs.com/how_to/shader_material
  94526. * @param name Define the name of the material in the scene
  94527. * @param scene Define the scene the material belongs to
  94528. * @param shaderPath Defines the route to the shader code in one of three ways:
  94529. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  94530. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  94531. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  94532. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  94533. * @param options Define the options used to create the shader
  94534. */
  94535. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  94536. /**
  94537. * Gets the shader path used to define the shader code
  94538. * It can be modified to trigger a new compilation
  94539. */
  94540. get shaderPath(): any;
  94541. /**
  94542. * Sets the shader path used to define the shader code
  94543. * It can be modified to trigger a new compilation
  94544. */
  94545. set shaderPath(shaderPath: any);
  94546. /**
  94547. * Gets the options used to compile the shader.
  94548. * They can be modified to trigger a new compilation
  94549. */
  94550. get options(): IShaderMaterialOptions;
  94551. /**
  94552. * Gets the current class name of the material e.g. "ShaderMaterial"
  94553. * Mainly use in serialization.
  94554. * @returns the class name
  94555. */
  94556. getClassName(): string;
  94557. /**
  94558. * Specifies if the material will require alpha blending
  94559. * @returns a boolean specifying if alpha blending is needed
  94560. */
  94561. needAlphaBlending(): boolean;
  94562. /**
  94563. * Specifies if this material should be rendered in alpha test mode
  94564. * @returns a boolean specifying if an alpha test is needed.
  94565. */
  94566. needAlphaTesting(): boolean;
  94567. private _checkUniform;
  94568. /**
  94569. * Set a texture in the shader.
  94570. * @param name Define the name of the uniform samplers as defined in the shader
  94571. * @param texture Define the texture to bind to this sampler
  94572. * @return the material itself allowing "fluent" like uniform updates
  94573. */
  94574. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  94575. /**
  94576. * Set a texture array in the shader.
  94577. * @param name Define the name of the uniform sampler array as defined in the shader
  94578. * @param textures Define the list of textures to bind to this sampler
  94579. * @return the material itself allowing "fluent" like uniform updates
  94580. */
  94581. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  94582. /**
  94583. * Set a float in the shader.
  94584. * @param name Define the name of the uniform as defined in the shader
  94585. * @param value Define the value to give to the uniform
  94586. * @return the material itself allowing "fluent" like uniform updates
  94587. */
  94588. setFloat(name: string, value: number): ShaderMaterial;
  94589. /**
  94590. * Set a int in the shader.
  94591. * @param name Define the name of the uniform as defined in the shader
  94592. * @param value Define the value to give to the uniform
  94593. * @return the material itself allowing "fluent" like uniform updates
  94594. */
  94595. setInt(name: string, value: number): ShaderMaterial;
  94596. /**
  94597. * Set an array of floats in the shader.
  94598. * @param name Define the name of the uniform as defined in the shader
  94599. * @param value Define the value to give to the uniform
  94600. * @return the material itself allowing "fluent" like uniform updates
  94601. */
  94602. setFloats(name: string, value: number[]): ShaderMaterial;
  94603. /**
  94604. * Set a vec3 in the shader from a Color3.
  94605. * @param name Define the name of the uniform as defined in the shader
  94606. * @param value Define the value to give to the uniform
  94607. * @return the material itself allowing "fluent" like uniform updates
  94608. */
  94609. setColor3(name: string, value: Color3): ShaderMaterial;
  94610. /**
  94611. * Set a vec3 array in the shader from a Color3 array.
  94612. * @param name Define the name of the uniform as defined in the shader
  94613. * @param value Define the value to give to the uniform
  94614. * @return the material itself allowing "fluent" like uniform updates
  94615. */
  94616. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  94617. /**
  94618. * Set a vec4 in the shader from a Color4.
  94619. * @param name Define the name of the uniform as defined in the shader
  94620. * @param value Define the value to give to the uniform
  94621. * @return the material itself allowing "fluent" like uniform updates
  94622. */
  94623. setColor4(name: string, value: Color4): ShaderMaterial;
  94624. /**
  94625. * Set a vec4 array in the shader from a Color4 array.
  94626. * @param name Define the name of the uniform as defined in the shader
  94627. * @param value Define the value to give to the uniform
  94628. * @return the material itself allowing "fluent" like uniform updates
  94629. */
  94630. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  94631. /**
  94632. * Set a vec2 in the shader from a Vector2.
  94633. * @param name Define the name of the uniform as defined in the shader
  94634. * @param value Define the value to give to the uniform
  94635. * @return the material itself allowing "fluent" like uniform updates
  94636. */
  94637. setVector2(name: string, value: Vector2): ShaderMaterial;
  94638. /**
  94639. * Set a vec3 in the shader from a Vector3.
  94640. * @param name Define the name of the uniform as defined in the shader
  94641. * @param value Define the value to give to the uniform
  94642. * @return the material itself allowing "fluent" like uniform updates
  94643. */
  94644. setVector3(name: string, value: Vector3): ShaderMaterial;
  94645. /**
  94646. * Set a vec4 in the shader from a Vector4.
  94647. * @param name Define the name of the uniform as defined in the shader
  94648. * @param value Define the value to give to the uniform
  94649. * @return the material itself allowing "fluent" like uniform updates
  94650. */
  94651. setVector4(name: string, value: Vector4): ShaderMaterial;
  94652. /**
  94653. * Set a mat4 in the shader from a Matrix.
  94654. * @param name Define the name of the uniform as defined in the shader
  94655. * @param value Define the value to give to the uniform
  94656. * @return the material itself allowing "fluent" like uniform updates
  94657. */
  94658. setMatrix(name: string, value: Matrix): ShaderMaterial;
  94659. /**
  94660. * Set a float32Array in the shader from a matrix array.
  94661. * @param name Define the name of the uniform as defined in the shader
  94662. * @param value Define the value to give to the uniform
  94663. * @return the material itself allowing "fluent" like uniform updates
  94664. */
  94665. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  94666. /**
  94667. * Set a mat3 in the shader from a Float32Array.
  94668. * @param name Define the name of the uniform as defined in the shader
  94669. * @param value Define the value to give to the uniform
  94670. * @return the material itself allowing "fluent" like uniform updates
  94671. */
  94672. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  94673. /**
  94674. * Set a mat2 in the shader from a Float32Array.
  94675. * @param name Define the name of the uniform as defined in the shader
  94676. * @param value Define the value to give to the uniform
  94677. * @return the material itself allowing "fluent" like uniform updates
  94678. */
  94679. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  94680. /**
  94681. * Set a vec2 array in the shader from a number array.
  94682. * @param name Define the name of the uniform as defined in the shader
  94683. * @param value Define the value to give to the uniform
  94684. * @return the material itself allowing "fluent" like uniform updates
  94685. */
  94686. setArray2(name: string, value: number[]): ShaderMaterial;
  94687. /**
  94688. * Set a vec3 array in the shader from a number array.
  94689. * @param name Define the name of the uniform as defined in the shader
  94690. * @param value Define the value to give to the uniform
  94691. * @return the material itself allowing "fluent" like uniform updates
  94692. */
  94693. setArray3(name: string, value: number[]): ShaderMaterial;
  94694. /**
  94695. * Set a vec4 array in the shader from a number array.
  94696. * @param name Define the name of the uniform as defined in the shader
  94697. * @param value Define the value to give to the uniform
  94698. * @return the material itself allowing "fluent" like uniform updates
  94699. */
  94700. setArray4(name: string, value: number[]): ShaderMaterial;
  94701. private _checkCache;
  94702. /**
  94703. * Specifies that the submesh is ready to be used
  94704. * @param mesh defines the mesh to check
  94705. * @param subMesh defines which submesh to check
  94706. * @param useInstances specifies that instances should be used
  94707. * @returns a boolean indicating that the submesh is ready or not
  94708. */
  94709. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  94710. /**
  94711. * Checks if the material is ready to render the requested mesh
  94712. * @param mesh Define the mesh to render
  94713. * @param useInstances Define whether or not the material is used with instances
  94714. * @returns true if ready, otherwise false
  94715. */
  94716. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94717. /**
  94718. * Binds the world matrix to the material
  94719. * @param world defines the world transformation matrix
  94720. * @param effectOverride - If provided, use this effect instead of internal effect
  94721. */
  94722. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  94723. /**
  94724. * Binds the submesh to this material by preparing the effect and shader to draw
  94725. * @param world defines the world transformation matrix
  94726. * @param mesh defines the mesh containing the submesh
  94727. * @param subMesh defines the submesh to bind the material to
  94728. */
  94729. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94730. /**
  94731. * Binds the material to the mesh
  94732. * @param world defines the world transformation matrix
  94733. * @param mesh defines the mesh to bind the material to
  94734. * @param effectOverride - If provided, use this effect instead of internal effect
  94735. */
  94736. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  94737. protected _afterBind(mesh?: Mesh): void;
  94738. /**
  94739. * Gets the active textures from the material
  94740. * @returns an array of textures
  94741. */
  94742. getActiveTextures(): BaseTexture[];
  94743. /**
  94744. * Specifies if the material uses a texture
  94745. * @param texture defines the texture to check against the material
  94746. * @returns a boolean specifying if the material uses the texture
  94747. */
  94748. hasTexture(texture: BaseTexture): boolean;
  94749. /**
  94750. * Makes a duplicate of the material, and gives it a new name
  94751. * @param name defines the new name for the duplicated material
  94752. * @returns the cloned material
  94753. */
  94754. clone(name: string): ShaderMaterial;
  94755. /**
  94756. * Disposes the material
  94757. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94758. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94759. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94760. */
  94761. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94762. /**
  94763. * Serializes this material in a JSON representation
  94764. * @returns the serialized material object
  94765. */
  94766. serialize(): any;
  94767. /**
  94768. * Creates a shader material from parsed shader material data
  94769. * @param source defines the JSON represnetation of the material
  94770. * @param scene defines the hosting scene
  94771. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94772. * @returns a new material
  94773. */
  94774. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  94775. /**
  94776. * Creates a new ShaderMaterial from a snippet saved in a remote file
  94777. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  94778. * @param url defines the url to load from
  94779. * @param scene defines the hosting scene
  94780. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94781. * @returns a promise that will resolve to the new ShaderMaterial
  94782. */
  94783. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  94784. /**
  94785. * Creates a ShaderMaterial from a snippet saved by the Inspector
  94786. * @param snippetId defines the snippet to load
  94787. * @param scene defines the hosting scene
  94788. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94789. * @returns a promise that will resolve to the new ShaderMaterial
  94790. */
  94791. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  94792. }
  94793. }
  94794. declare module BABYLON {
  94795. /** @hidden */
  94796. export var colorPixelShader: {
  94797. name: string;
  94798. shader: string;
  94799. };
  94800. }
  94801. declare module BABYLON {
  94802. /** @hidden */
  94803. export var colorVertexShader: {
  94804. name: string;
  94805. shader: string;
  94806. };
  94807. }
  94808. declare module BABYLON {
  94809. /**
  94810. * Line mesh
  94811. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  94812. */
  94813. export class LinesMesh extends Mesh {
  94814. /**
  94815. * If vertex color should be applied to the mesh
  94816. */
  94817. readonly useVertexColor?: boolean | undefined;
  94818. /**
  94819. * If vertex alpha should be applied to the mesh
  94820. */
  94821. readonly useVertexAlpha?: boolean | undefined;
  94822. /**
  94823. * Color of the line (Default: White)
  94824. */
  94825. color: Color3;
  94826. /**
  94827. * Alpha of the line (Default: 1)
  94828. */
  94829. alpha: number;
  94830. /**
  94831. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  94832. * This margin is expressed in world space coordinates, so its value may vary.
  94833. * Default value is 0.1
  94834. */
  94835. intersectionThreshold: number;
  94836. private _colorShader;
  94837. private color4;
  94838. /**
  94839. * Creates a new LinesMesh
  94840. * @param name defines the name
  94841. * @param scene defines the hosting scene
  94842. * @param parent defines the parent mesh if any
  94843. * @param source defines the optional source LinesMesh used to clone data from
  94844. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  94845. * When false, achieved by calling a clone(), also passing False.
  94846. * This will make creation of children, recursive.
  94847. * @param useVertexColor defines if this LinesMesh supports vertex color
  94848. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  94849. */
  94850. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  94851. /**
  94852. * If vertex color should be applied to the mesh
  94853. */
  94854. useVertexColor?: boolean | undefined,
  94855. /**
  94856. * If vertex alpha should be applied to the mesh
  94857. */
  94858. useVertexAlpha?: boolean | undefined);
  94859. private _addClipPlaneDefine;
  94860. private _removeClipPlaneDefine;
  94861. isReady(): boolean;
  94862. /**
  94863. * Returns the string "LineMesh"
  94864. */
  94865. getClassName(): string;
  94866. /**
  94867. * @hidden
  94868. */
  94869. get material(): Material;
  94870. /**
  94871. * @hidden
  94872. */
  94873. set material(value: Material);
  94874. /**
  94875. * @hidden
  94876. */
  94877. get checkCollisions(): boolean;
  94878. /** @hidden */
  94879. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  94880. /** @hidden */
  94881. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  94882. /**
  94883. * Disposes of the line mesh
  94884. * @param doNotRecurse If children should be disposed
  94885. */
  94886. dispose(doNotRecurse?: boolean): void;
  94887. /**
  94888. * Returns a new LineMesh object cloned from the current one.
  94889. */
  94890. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  94891. /**
  94892. * Creates a new InstancedLinesMesh object from the mesh model.
  94893. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  94894. * @param name defines the name of the new instance
  94895. * @returns a new InstancedLinesMesh
  94896. */
  94897. createInstance(name: string): InstancedLinesMesh;
  94898. }
  94899. /**
  94900. * Creates an instance based on a source LinesMesh
  94901. */
  94902. export class InstancedLinesMesh extends InstancedMesh {
  94903. /**
  94904. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  94905. * This margin is expressed in world space coordinates, so its value may vary.
  94906. * Initilized with the intersectionThreshold value of the source LinesMesh
  94907. */
  94908. intersectionThreshold: number;
  94909. constructor(name: string, source: LinesMesh);
  94910. /**
  94911. * Returns the string "InstancedLinesMesh".
  94912. */
  94913. getClassName(): string;
  94914. }
  94915. }
  94916. declare module BABYLON {
  94917. /** @hidden */
  94918. export var linePixelShader: {
  94919. name: string;
  94920. shader: string;
  94921. };
  94922. }
  94923. declare module BABYLON {
  94924. /** @hidden */
  94925. export var lineVertexShader: {
  94926. name: string;
  94927. shader: string;
  94928. };
  94929. }
  94930. declare module BABYLON {
  94931. interface Scene {
  94932. /** @hidden */
  94933. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  94934. }
  94935. interface AbstractMesh {
  94936. /**
  94937. * Gets the edgesRenderer associated with the mesh
  94938. */
  94939. edgesRenderer: Nullable<EdgesRenderer>;
  94940. }
  94941. interface LinesMesh {
  94942. /**
  94943. * Enables the edge rendering mode on the mesh.
  94944. * This mode makes the mesh edges visible
  94945. * @param epsilon defines the maximal distance between two angles to detect a face
  94946. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94947. * @returns the currentAbstractMesh
  94948. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94949. */
  94950. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  94951. }
  94952. interface InstancedLinesMesh {
  94953. /**
  94954. * Enables the edge rendering mode on the mesh.
  94955. * This mode makes the mesh edges visible
  94956. * @param epsilon defines the maximal distance between two angles to detect a face
  94957. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94958. * @returns the current InstancedLinesMesh
  94959. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94960. */
  94961. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  94962. }
  94963. /**
  94964. * Defines the minimum contract an Edges renderer should follow.
  94965. */
  94966. export interface IEdgesRenderer extends IDisposable {
  94967. /**
  94968. * Gets or sets a boolean indicating if the edgesRenderer is active
  94969. */
  94970. isEnabled: boolean;
  94971. /**
  94972. * Renders the edges of the attached mesh,
  94973. */
  94974. render(): void;
  94975. /**
  94976. * Checks wether or not the edges renderer is ready to render.
  94977. * @return true if ready, otherwise false.
  94978. */
  94979. isReady(): boolean;
  94980. /**
  94981. * List of instances to render in case the source mesh has instances
  94982. */
  94983. customInstances: SmartArray<Matrix>;
  94984. }
  94985. /**
  94986. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  94987. */
  94988. export class EdgesRenderer implements IEdgesRenderer {
  94989. /**
  94990. * Define the size of the edges with an orthographic camera
  94991. */
  94992. edgesWidthScalerForOrthographic: number;
  94993. /**
  94994. * Define the size of the edges with a perspective camera
  94995. */
  94996. edgesWidthScalerForPerspective: number;
  94997. protected _source: AbstractMesh;
  94998. protected _linesPositions: number[];
  94999. protected _linesNormals: number[];
  95000. protected _linesIndices: number[];
  95001. protected _epsilon: number;
  95002. protected _indicesCount: number;
  95003. protected _lineShader: ShaderMaterial;
  95004. protected _ib: DataBuffer;
  95005. protected _buffers: {
  95006. [key: string]: Nullable<VertexBuffer>;
  95007. };
  95008. protected _buffersForInstances: {
  95009. [key: string]: Nullable<VertexBuffer>;
  95010. };
  95011. protected _checkVerticesInsteadOfIndices: boolean;
  95012. private _meshRebuildObserver;
  95013. private _meshDisposeObserver;
  95014. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  95015. isEnabled: boolean;
  95016. /**
  95017. * List of instances to render in case the source mesh has instances
  95018. */
  95019. customInstances: SmartArray<Matrix>;
  95020. private static GetShader;
  95021. /**
  95022. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  95023. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  95024. * @param source Mesh used to create edges
  95025. * @param epsilon sum of angles in adjacency to check for edge
  95026. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  95027. * @param generateEdgesLines - should generate Lines or only prepare resources.
  95028. */
  95029. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  95030. protected _prepareRessources(): void;
  95031. /** @hidden */
  95032. _rebuild(): void;
  95033. /**
  95034. * Releases the required resources for the edges renderer
  95035. */
  95036. dispose(): void;
  95037. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  95038. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  95039. /**
  95040. * Checks if the pair of p0 and p1 is en edge
  95041. * @param faceIndex
  95042. * @param edge
  95043. * @param faceNormals
  95044. * @param p0
  95045. * @param p1
  95046. * @private
  95047. */
  95048. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  95049. /**
  95050. * push line into the position, normal and index buffer
  95051. * @protected
  95052. */
  95053. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  95054. /**
  95055. * Generates lines edges from adjacencjes
  95056. * @private
  95057. */
  95058. _generateEdgesLines(): void;
  95059. /**
  95060. * Checks wether or not the edges renderer is ready to render.
  95061. * @return true if ready, otherwise false.
  95062. */
  95063. isReady(): boolean;
  95064. /**
  95065. * Renders the edges of the attached mesh,
  95066. */
  95067. render(): void;
  95068. }
  95069. /**
  95070. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  95071. */
  95072. export class LineEdgesRenderer extends EdgesRenderer {
  95073. /**
  95074. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  95075. * @param source LineMesh used to generate edges
  95076. * @param epsilon not important (specified angle for edge detection)
  95077. * @param checkVerticesInsteadOfIndices not important for LineMesh
  95078. */
  95079. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  95080. /**
  95081. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  95082. */
  95083. _generateEdgesLines(): void;
  95084. }
  95085. }
  95086. declare module BABYLON {
  95087. /**
  95088. * This represents the object necessary to create a rendering group.
  95089. * This is exclusively used and created by the rendering manager.
  95090. * To modify the behavior, you use the available helpers in your scene or meshes.
  95091. * @hidden
  95092. */
  95093. export class RenderingGroup {
  95094. index: number;
  95095. private static _zeroVector;
  95096. private _scene;
  95097. private _opaqueSubMeshes;
  95098. private _transparentSubMeshes;
  95099. private _alphaTestSubMeshes;
  95100. private _depthOnlySubMeshes;
  95101. private _particleSystems;
  95102. private _spriteManagers;
  95103. private _opaqueSortCompareFn;
  95104. private _alphaTestSortCompareFn;
  95105. private _transparentSortCompareFn;
  95106. private _renderOpaque;
  95107. private _renderAlphaTest;
  95108. private _renderTransparent;
  95109. /** @hidden */
  95110. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  95111. onBeforeTransparentRendering: () => void;
  95112. /**
  95113. * Set the opaque sort comparison function.
  95114. * If null the sub meshes will be render in the order they were created
  95115. */
  95116. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95117. /**
  95118. * Set the alpha test sort comparison function.
  95119. * If null the sub meshes will be render in the order they were created
  95120. */
  95121. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95122. /**
  95123. * Set the transparent sort comparison function.
  95124. * If null the sub meshes will be render in the order they were created
  95125. */
  95126. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95127. /**
  95128. * Creates a new rendering group.
  95129. * @param index The rendering group index
  95130. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  95131. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  95132. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  95133. */
  95134. 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>);
  95135. /**
  95136. * Render all the sub meshes contained in the group.
  95137. * @param customRenderFunction Used to override the default render behaviour of the group.
  95138. * @returns true if rendered some submeshes.
  95139. */
  95140. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  95141. /**
  95142. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  95143. * @param subMeshes The submeshes to render
  95144. */
  95145. private renderOpaqueSorted;
  95146. /**
  95147. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  95148. * @param subMeshes The submeshes to render
  95149. */
  95150. private renderAlphaTestSorted;
  95151. /**
  95152. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  95153. * @param subMeshes The submeshes to render
  95154. */
  95155. private renderTransparentSorted;
  95156. /**
  95157. * Renders the submeshes in a specified order.
  95158. * @param subMeshes The submeshes to sort before render
  95159. * @param sortCompareFn The comparison function use to sort
  95160. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  95161. * @param transparent Specifies to activate blending if true
  95162. */
  95163. private static renderSorted;
  95164. /**
  95165. * Renders the submeshes in the order they were dispatched (no sort applied).
  95166. * @param subMeshes The submeshes to render
  95167. */
  95168. private static renderUnsorted;
  95169. /**
  95170. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95171. * are rendered back to front if in the same alpha index.
  95172. *
  95173. * @param a The first submesh
  95174. * @param b The second submesh
  95175. * @returns The result of the comparison
  95176. */
  95177. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  95178. /**
  95179. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95180. * are rendered back to front.
  95181. *
  95182. * @param a The first submesh
  95183. * @param b The second submesh
  95184. * @returns The result of the comparison
  95185. */
  95186. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  95187. /**
  95188. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95189. * are rendered front to back (prevent overdraw).
  95190. *
  95191. * @param a The first submesh
  95192. * @param b The second submesh
  95193. * @returns The result of the comparison
  95194. */
  95195. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  95196. /**
  95197. * Resets the different lists of submeshes to prepare a new frame.
  95198. */
  95199. prepare(): void;
  95200. dispose(): void;
  95201. /**
  95202. * Inserts the submesh in its correct queue depending on its material.
  95203. * @param subMesh The submesh to dispatch
  95204. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  95205. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  95206. */
  95207. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  95208. dispatchSprites(spriteManager: ISpriteManager): void;
  95209. dispatchParticles(particleSystem: IParticleSystem): void;
  95210. private _renderParticles;
  95211. private _renderSprites;
  95212. }
  95213. }
  95214. declare module BABYLON {
  95215. /**
  95216. * Interface describing the different options available in the rendering manager
  95217. * regarding Auto Clear between groups.
  95218. */
  95219. export interface IRenderingManagerAutoClearSetup {
  95220. /**
  95221. * Defines whether or not autoclear is enable.
  95222. */
  95223. autoClear: boolean;
  95224. /**
  95225. * Defines whether or not to autoclear the depth buffer.
  95226. */
  95227. depth: boolean;
  95228. /**
  95229. * Defines whether or not to autoclear the stencil buffer.
  95230. */
  95231. stencil: boolean;
  95232. }
  95233. /**
  95234. * This class is used by the onRenderingGroupObservable
  95235. */
  95236. export class RenderingGroupInfo {
  95237. /**
  95238. * The Scene that being rendered
  95239. */
  95240. scene: Scene;
  95241. /**
  95242. * The camera currently used for the rendering pass
  95243. */
  95244. camera: Nullable<Camera>;
  95245. /**
  95246. * The ID of the renderingGroup being processed
  95247. */
  95248. renderingGroupId: number;
  95249. }
  95250. /**
  95251. * This is the manager responsible of all the rendering for meshes sprites and particles.
  95252. * It is enable to manage the different groups as well as the different necessary sort functions.
  95253. * This should not be used directly aside of the few static configurations
  95254. */
  95255. export class RenderingManager {
  95256. /**
  95257. * The max id used for rendering groups (not included)
  95258. */
  95259. static MAX_RENDERINGGROUPS: number;
  95260. /**
  95261. * The min id used for rendering groups (included)
  95262. */
  95263. static MIN_RENDERINGGROUPS: number;
  95264. /**
  95265. * Used to globally prevent autoclearing scenes.
  95266. */
  95267. static AUTOCLEAR: boolean;
  95268. /**
  95269. * @hidden
  95270. */
  95271. _useSceneAutoClearSetup: boolean;
  95272. private _scene;
  95273. private _renderingGroups;
  95274. private _depthStencilBufferAlreadyCleaned;
  95275. private _autoClearDepthStencil;
  95276. private _customOpaqueSortCompareFn;
  95277. private _customAlphaTestSortCompareFn;
  95278. private _customTransparentSortCompareFn;
  95279. private _renderingGroupInfo;
  95280. /**
  95281. * Instantiates a new rendering group for a particular scene
  95282. * @param scene Defines the scene the groups belongs to
  95283. */
  95284. constructor(scene: Scene);
  95285. private _clearDepthStencilBuffer;
  95286. /**
  95287. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  95288. * @hidden
  95289. */
  95290. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  95291. /**
  95292. * Resets the different information of the group to prepare a new frame
  95293. * @hidden
  95294. */
  95295. reset(): void;
  95296. /**
  95297. * Dispose and release the group and its associated resources.
  95298. * @hidden
  95299. */
  95300. dispose(): void;
  95301. /**
  95302. * Clear the info related to rendering groups preventing retention points during dispose.
  95303. */
  95304. freeRenderingGroups(): void;
  95305. private _prepareRenderingGroup;
  95306. /**
  95307. * Add a sprite manager to the rendering manager in order to render it this frame.
  95308. * @param spriteManager Define the sprite manager to render
  95309. */
  95310. dispatchSprites(spriteManager: ISpriteManager): void;
  95311. /**
  95312. * Add a particle system to the rendering manager in order to render it this frame.
  95313. * @param particleSystem Define the particle system to render
  95314. */
  95315. dispatchParticles(particleSystem: IParticleSystem): void;
  95316. /**
  95317. * Add a submesh to the manager in order to render it this frame
  95318. * @param subMesh The submesh to dispatch
  95319. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  95320. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  95321. */
  95322. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  95323. /**
  95324. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  95325. * This allowed control for front to back rendering or reversly depending of the special needs.
  95326. *
  95327. * @param renderingGroupId The rendering group id corresponding to its index
  95328. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  95329. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  95330. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  95331. */
  95332. 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;
  95333. /**
  95334. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  95335. *
  95336. * @param renderingGroupId The rendering group id corresponding to its index
  95337. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  95338. * @param depth Automatically clears depth between groups if true and autoClear is true.
  95339. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  95340. */
  95341. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  95342. /**
  95343. * Gets the current auto clear configuration for one rendering group of the rendering
  95344. * manager.
  95345. * @param index the rendering group index to get the information for
  95346. * @returns The auto clear setup for the requested rendering group
  95347. */
  95348. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  95349. }
  95350. }
  95351. declare module BABYLON {
  95352. /**
  95353. * Defines the options associated with the creation of a custom shader for a shadow generator.
  95354. */
  95355. export interface ICustomShaderOptions {
  95356. /**
  95357. * Gets or sets the custom shader name to use
  95358. */
  95359. shaderName: string;
  95360. /**
  95361. * The list of attribute names used in the shader
  95362. */
  95363. attributes?: string[];
  95364. /**
  95365. * The list of unifrom names used in the shader
  95366. */
  95367. uniforms?: string[];
  95368. /**
  95369. * The list of sampler names used in the shader
  95370. */
  95371. samplers?: string[];
  95372. /**
  95373. * The list of defines used in the shader
  95374. */
  95375. defines?: string[];
  95376. }
  95377. /**
  95378. * Interface to implement to create a shadow generator compatible with BJS.
  95379. */
  95380. export interface IShadowGenerator {
  95381. /**
  95382. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  95383. * @returns The render target texture if present otherwise, null
  95384. */
  95385. getShadowMap(): Nullable<RenderTargetTexture>;
  95386. /**
  95387. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  95388. * @param subMesh The submesh we want to render in the shadow map
  95389. * @param useInstances Defines wether will draw in the map using instances
  95390. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  95391. * @returns true if ready otherwise, false
  95392. */
  95393. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  95394. /**
  95395. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  95396. * @param defines Defines of the material we want to update
  95397. * @param lightIndex Index of the light in the enabled light list of the material
  95398. */
  95399. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  95400. /**
  95401. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  95402. * defined in the generator but impacting the effect).
  95403. * It implies the unifroms available on the materials are the standard BJS ones.
  95404. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  95405. * @param effect The effect we are binfing the information for
  95406. */
  95407. bindShadowLight(lightIndex: string, effect: Effect): void;
  95408. /**
  95409. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  95410. * (eq to shadow prjection matrix * light transform matrix)
  95411. * @returns The transform matrix used to create the shadow map
  95412. */
  95413. getTransformMatrix(): Matrix;
  95414. /**
  95415. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  95416. * Cube and 2D textures for instance.
  95417. */
  95418. recreateShadowMap(): void;
  95419. /**
  95420. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95421. * @param onCompiled Callback triggered at the and of the effects compilation
  95422. * @param options Sets of optional options forcing the compilation with different modes
  95423. */
  95424. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  95425. useInstances: boolean;
  95426. }>): void;
  95427. /**
  95428. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95429. * @param options Sets of optional options forcing the compilation with different modes
  95430. * @returns A promise that resolves when the compilation completes
  95431. */
  95432. forceCompilationAsync(options?: Partial<{
  95433. useInstances: boolean;
  95434. }>): Promise<void>;
  95435. /**
  95436. * Serializes the shadow generator setup to a json object.
  95437. * @returns The serialized JSON object
  95438. */
  95439. serialize(): any;
  95440. /**
  95441. * Disposes the Shadow map and related Textures and effects.
  95442. */
  95443. dispose(): void;
  95444. }
  95445. /**
  95446. * Default implementation IShadowGenerator.
  95447. * This is the main object responsible of generating shadows in the framework.
  95448. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  95449. */
  95450. export class ShadowGenerator implements IShadowGenerator {
  95451. /**
  95452. * Name of the shadow generator class
  95453. */
  95454. static CLASSNAME: string;
  95455. /**
  95456. * Shadow generator mode None: no filtering applied.
  95457. */
  95458. static readonly FILTER_NONE: number;
  95459. /**
  95460. * Shadow generator mode ESM: Exponential Shadow Mapping.
  95461. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95462. */
  95463. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  95464. /**
  95465. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  95466. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  95467. */
  95468. static readonly FILTER_POISSONSAMPLING: number;
  95469. /**
  95470. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  95471. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95472. */
  95473. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  95474. /**
  95475. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  95476. * edge artifacts on steep falloff.
  95477. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95478. */
  95479. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  95480. /**
  95481. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  95482. * edge artifacts on steep falloff.
  95483. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95484. */
  95485. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  95486. /**
  95487. * Shadow generator mode PCF: Percentage Closer Filtering
  95488. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  95489. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  95490. */
  95491. static readonly FILTER_PCF: number;
  95492. /**
  95493. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  95494. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  95495. * Contact Hardening
  95496. */
  95497. static readonly FILTER_PCSS: number;
  95498. /**
  95499. * Reserved for PCF and PCSS
  95500. * Highest Quality.
  95501. *
  95502. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  95503. *
  95504. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  95505. */
  95506. static readonly QUALITY_HIGH: number;
  95507. /**
  95508. * Reserved for PCF and PCSS
  95509. * Good tradeoff for quality/perf cross devices
  95510. *
  95511. * Execute PCF on a 3*3 kernel.
  95512. *
  95513. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  95514. */
  95515. static readonly QUALITY_MEDIUM: number;
  95516. /**
  95517. * Reserved for PCF and PCSS
  95518. * The lowest quality but the fastest.
  95519. *
  95520. * Execute PCF on a 1*1 kernel.
  95521. *
  95522. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  95523. */
  95524. static readonly QUALITY_LOW: number;
  95525. /** Gets or sets the custom shader name to use */
  95526. customShaderOptions: ICustomShaderOptions;
  95527. /**
  95528. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  95529. */
  95530. onBeforeShadowMapRenderObservable: Observable<Effect>;
  95531. /**
  95532. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  95533. */
  95534. onAfterShadowMapRenderObservable: Observable<Effect>;
  95535. /**
  95536. * Observable triggered before a mesh is rendered in the shadow map.
  95537. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  95538. */
  95539. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  95540. /**
  95541. * Observable triggered after a mesh is rendered in the shadow map.
  95542. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  95543. */
  95544. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  95545. protected _bias: number;
  95546. /**
  95547. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  95548. */
  95549. get bias(): number;
  95550. /**
  95551. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  95552. */
  95553. set bias(bias: number);
  95554. protected _normalBias: number;
  95555. /**
  95556. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  95557. */
  95558. get normalBias(): number;
  95559. /**
  95560. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  95561. */
  95562. set normalBias(normalBias: number);
  95563. protected _blurBoxOffset: number;
  95564. /**
  95565. * Gets the blur box offset: offset applied during the blur pass.
  95566. * Only useful if useKernelBlur = false
  95567. */
  95568. get blurBoxOffset(): number;
  95569. /**
  95570. * Sets the blur box offset: offset applied during the blur pass.
  95571. * Only useful if useKernelBlur = false
  95572. */
  95573. set blurBoxOffset(value: number);
  95574. protected _blurScale: number;
  95575. /**
  95576. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  95577. * 2 means half of the size.
  95578. */
  95579. get blurScale(): number;
  95580. /**
  95581. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  95582. * 2 means half of the size.
  95583. */
  95584. set blurScale(value: number);
  95585. protected _blurKernel: number;
  95586. /**
  95587. * Gets the blur kernel: kernel size of the blur pass.
  95588. * Only useful if useKernelBlur = true
  95589. */
  95590. get blurKernel(): number;
  95591. /**
  95592. * Sets the blur kernel: kernel size of the blur pass.
  95593. * Only useful if useKernelBlur = true
  95594. */
  95595. set blurKernel(value: number);
  95596. protected _useKernelBlur: boolean;
  95597. /**
  95598. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  95599. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  95600. */
  95601. get useKernelBlur(): boolean;
  95602. /**
  95603. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  95604. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  95605. */
  95606. set useKernelBlur(value: boolean);
  95607. protected _depthScale: number;
  95608. /**
  95609. * Gets the depth scale used in ESM mode.
  95610. */
  95611. get depthScale(): number;
  95612. /**
  95613. * Sets the depth scale used in ESM mode.
  95614. * This can override the scale stored on the light.
  95615. */
  95616. set depthScale(value: number);
  95617. protected _validateFilter(filter: number): number;
  95618. protected _filter: number;
  95619. /**
  95620. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  95621. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  95622. */
  95623. get filter(): number;
  95624. /**
  95625. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  95626. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  95627. */
  95628. set filter(value: number);
  95629. /**
  95630. * Gets if the current filter is set to Poisson Sampling.
  95631. */
  95632. get usePoissonSampling(): boolean;
  95633. /**
  95634. * Sets the current filter to Poisson Sampling.
  95635. */
  95636. set usePoissonSampling(value: boolean);
  95637. /**
  95638. * Gets if the current filter is set to ESM.
  95639. */
  95640. get useExponentialShadowMap(): boolean;
  95641. /**
  95642. * Sets the current filter is to ESM.
  95643. */
  95644. set useExponentialShadowMap(value: boolean);
  95645. /**
  95646. * Gets if the current filter is set to filtered ESM.
  95647. */
  95648. get useBlurExponentialShadowMap(): boolean;
  95649. /**
  95650. * Gets if the current filter is set to filtered ESM.
  95651. */
  95652. set useBlurExponentialShadowMap(value: boolean);
  95653. /**
  95654. * Gets if the current filter is set to "close ESM" (using the inverse of the
  95655. * exponential to prevent steep falloff artifacts).
  95656. */
  95657. get useCloseExponentialShadowMap(): boolean;
  95658. /**
  95659. * Sets the current filter to "close ESM" (using the inverse of the
  95660. * exponential to prevent steep falloff artifacts).
  95661. */
  95662. set useCloseExponentialShadowMap(value: boolean);
  95663. /**
  95664. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  95665. * exponential to prevent steep falloff artifacts).
  95666. */
  95667. get useBlurCloseExponentialShadowMap(): boolean;
  95668. /**
  95669. * Sets the current filter to filtered "close ESM" (using the inverse of the
  95670. * exponential to prevent steep falloff artifacts).
  95671. */
  95672. set useBlurCloseExponentialShadowMap(value: boolean);
  95673. /**
  95674. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  95675. */
  95676. get usePercentageCloserFiltering(): boolean;
  95677. /**
  95678. * Sets the current filter to "PCF" (percentage closer filtering).
  95679. */
  95680. set usePercentageCloserFiltering(value: boolean);
  95681. protected _filteringQuality: number;
  95682. /**
  95683. * Gets the PCF or PCSS Quality.
  95684. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  95685. */
  95686. get filteringQuality(): number;
  95687. /**
  95688. * Sets the PCF or PCSS Quality.
  95689. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  95690. */
  95691. set filteringQuality(filteringQuality: number);
  95692. /**
  95693. * Gets if the current filter is set to "PCSS" (contact hardening).
  95694. */
  95695. get useContactHardeningShadow(): boolean;
  95696. /**
  95697. * Sets the current filter to "PCSS" (contact hardening).
  95698. */
  95699. set useContactHardeningShadow(value: boolean);
  95700. protected _contactHardeningLightSizeUVRatio: number;
  95701. /**
  95702. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  95703. * Using a ratio helps keeping shape stability independently of the map size.
  95704. *
  95705. * It does not account for the light projection as it was having too much
  95706. * instability during the light setup or during light position changes.
  95707. *
  95708. * Only valid if useContactHardeningShadow is true.
  95709. */
  95710. get contactHardeningLightSizeUVRatio(): number;
  95711. /**
  95712. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  95713. * Using a ratio helps keeping shape stability independently of the map size.
  95714. *
  95715. * It does not account for the light projection as it was having too much
  95716. * instability during the light setup or during light position changes.
  95717. *
  95718. * Only valid if useContactHardeningShadow is true.
  95719. */
  95720. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  95721. protected _darkness: number;
  95722. /** Gets or sets the actual darkness of a shadow */
  95723. get darkness(): number;
  95724. set darkness(value: number);
  95725. /**
  95726. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  95727. * 0 means strongest and 1 would means no shadow.
  95728. * @returns the darkness.
  95729. */
  95730. getDarkness(): number;
  95731. /**
  95732. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  95733. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  95734. * @returns the shadow generator allowing fluent coding.
  95735. */
  95736. setDarkness(darkness: number): ShadowGenerator;
  95737. protected _transparencyShadow: boolean;
  95738. /** Gets or sets the ability to have transparent shadow */
  95739. get transparencyShadow(): boolean;
  95740. set transparencyShadow(value: boolean);
  95741. /**
  95742. * Sets the ability to have transparent shadow (boolean).
  95743. * @param transparent True if transparent else False
  95744. * @returns the shadow generator allowing fluent coding
  95745. */
  95746. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  95747. /**
  95748. * Enables or disables shadows with varying strength based on the transparency
  95749. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  95750. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  95751. * mesh.visibility * alphaTexture.a
  95752. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  95753. */
  95754. enableSoftTransparentShadow: boolean;
  95755. protected _shadowMap: Nullable<RenderTargetTexture>;
  95756. protected _shadowMap2: Nullable<RenderTargetTexture>;
  95757. /**
  95758. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  95759. * @returns The render target texture if present otherwise, null
  95760. */
  95761. getShadowMap(): Nullable<RenderTargetTexture>;
  95762. /**
  95763. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  95764. * @returns The render target texture if the shadow map is present otherwise, null
  95765. */
  95766. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  95767. /**
  95768. * Gets the class name of that object
  95769. * @returns "ShadowGenerator"
  95770. */
  95771. getClassName(): string;
  95772. /**
  95773. * Helper function to add a mesh and its descendants to the list of shadow casters.
  95774. * @param mesh Mesh to add
  95775. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  95776. * @returns the Shadow Generator itself
  95777. */
  95778. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  95779. /**
  95780. * Helper function to remove a mesh and its descendants from the list of shadow casters
  95781. * @param mesh Mesh to remove
  95782. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  95783. * @returns the Shadow Generator itself
  95784. */
  95785. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  95786. /**
  95787. * Controls the extent to which the shadows fade out at the edge of the frustum
  95788. */
  95789. frustumEdgeFalloff: number;
  95790. protected _light: IShadowLight;
  95791. /**
  95792. * Returns the associated light object.
  95793. * @returns the light generating the shadow
  95794. */
  95795. getLight(): IShadowLight;
  95796. /**
  95797. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  95798. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  95799. * It might on the other hand introduce peter panning.
  95800. */
  95801. forceBackFacesOnly: boolean;
  95802. protected _scene: Scene;
  95803. protected _lightDirection: Vector3;
  95804. protected _effect: Effect;
  95805. protected _viewMatrix: Matrix;
  95806. protected _projectionMatrix: Matrix;
  95807. protected _transformMatrix: Matrix;
  95808. protected _cachedPosition: Vector3;
  95809. protected _cachedDirection: Vector3;
  95810. protected _cachedDefines: string;
  95811. protected _currentRenderID: number;
  95812. protected _boxBlurPostprocess: Nullable<PostProcess>;
  95813. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  95814. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  95815. protected _blurPostProcesses: PostProcess[];
  95816. protected _mapSize: number;
  95817. protected _currentFaceIndex: number;
  95818. protected _currentFaceIndexCache: number;
  95819. protected _textureType: number;
  95820. protected _defaultTextureMatrix: Matrix;
  95821. protected _storedUniqueId: Nullable<number>;
  95822. /** @hidden */
  95823. static _SceneComponentInitialization: (scene: Scene) => void;
  95824. /**
  95825. * Creates a ShadowGenerator object.
  95826. * A ShadowGenerator is the required tool to use the shadows.
  95827. * Each light casting shadows needs to use its own ShadowGenerator.
  95828. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  95829. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  95830. * @param light The light object generating the shadows.
  95831. * @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.
  95832. */
  95833. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  95834. protected _initializeGenerator(): void;
  95835. protected _createTargetRenderTexture(): void;
  95836. protected _initializeShadowMap(): void;
  95837. protected _initializeBlurRTTAndPostProcesses(): void;
  95838. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  95839. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  95840. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  95841. protected _applyFilterValues(): void;
  95842. /**
  95843. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95844. * @param onCompiled Callback triggered at the and of the effects compilation
  95845. * @param options Sets of optional options forcing the compilation with different modes
  95846. */
  95847. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  95848. useInstances: boolean;
  95849. }>): void;
  95850. /**
  95851. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95852. * @param options Sets of optional options forcing the compilation with different modes
  95853. * @returns A promise that resolves when the compilation completes
  95854. */
  95855. forceCompilationAsync(options?: Partial<{
  95856. useInstances: boolean;
  95857. }>): Promise<void>;
  95858. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  95859. private _prepareShadowDefines;
  95860. /**
  95861. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  95862. * @param subMesh The submesh we want to render in the shadow map
  95863. * @param useInstances Defines wether will draw in the map using instances
  95864. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  95865. * @returns true if ready otherwise, false
  95866. */
  95867. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  95868. /**
  95869. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  95870. * @param defines Defines of the material we want to update
  95871. * @param lightIndex Index of the light in the enabled light list of the material
  95872. */
  95873. prepareDefines(defines: any, lightIndex: number): void;
  95874. /**
  95875. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  95876. * defined in the generator but impacting the effect).
  95877. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  95878. * @param effect The effect we are binfing the information for
  95879. */
  95880. bindShadowLight(lightIndex: string, effect: Effect): void;
  95881. /**
  95882. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  95883. * (eq to shadow prjection matrix * light transform matrix)
  95884. * @returns The transform matrix used to create the shadow map
  95885. */
  95886. getTransformMatrix(): Matrix;
  95887. /**
  95888. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  95889. * Cube and 2D textures for instance.
  95890. */
  95891. recreateShadowMap(): void;
  95892. protected _disposeBlurPostProcesses(): void;
  95893. protected _disposeRTTandPostProcesses(): void;
  95894. /**
  95895. * Disposes the ShadowGenerator.
  95896. * Returns nothing.
  95897. */
  95898. dispose(): void;
  95899. /**
  95900. * Serializes the shadow generator setup to a json object.
  95901. * @returns The serialized JSON object
  95902. */
  95903. serialize(): any;
  95904. /**
  95905. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  95906. * @param parsedShadowGenerator The JSON object to parse
  95907. * @param scene The scene to create the shadow map for
  95908. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  95909. * @returns The parsed shadow generator
  95910. */
  95911. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  95912. }
  95913. }
  95914. declare module BABYLON {
  95915. /**
  95916. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  95917. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  95918. * 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.
  95919. */
  95920. export abstract class Light extends Node {
  95921. /**
  95922. * Falloff Default: light is falling off following the material specification:
  95923. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  95924. */
  95925. static readonly FALLOFF_DEFAULT: number;
  95926. /**
  95927. * Falloff Physical: light is falling off following the inverse squared distance law.
  95928. */
  95929. static readonly FALLOFF_PHYSICAL: number;
  95930. /**
  95931. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  95932. * to enhance interoperability with other engines.
  95933. */
  95934. static readonly FALLOFF_GLTF: number;
  95935. /**
  95936. * Falloff Standard: light is falling off like in the standard material
  95937. * to enhance interoperability with other materials.
  95938. */
  95939. static readonly FALLOFF_STANDARD: number;
  95940. /**
  95941. * If every light affecting the material is in this lightmapMode,
  95942. * material.lightmapTexture adds or multiplies
  95943. * (depends on material.useLightmapAsShadowmap)
  95944. * after every other light calculations.
  95945. */
  95946. static readonly LIGHTMAP_DEFAULT: number;
  95947. /**
  95948. * material.lightmapTexture as only diffuse lighting from this light
  95949. * adds only specular lighting from this light
  95950. * adds dynamic shadows
  95951. */
  95952. static readonly LIGHTMAP_SPECULAR: number;
  95953. /**
  95954. * material.lightmapTexture as only lighting
  95955. * no light calculation from this light
  95956. * only adds dynamic shadows from this light
  95957. */
  95958. static readonly LIGHTMAP_SHADOWSONLY: number;
  95959. /**
  95960. * Each light type uses the default quantity according to its type:
  95961. * point/spot lights use luminous intensity
  95962. * directional lights use illuminance
  95963. */
  95964. static readonly INTENSITYMODE_AUTOMATIC: number;
  95965. /**
  95966. * lumen (lm)
  95967. */
  95968. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  95969. /**
  95970. * candela (lm/sr)
  95971. */
  95972. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  95973. /**
  95974. * lux (lm/m^2)
  95975. */
  95976. static readonly INTENSITYMODE_ILLUMINANCE: number;
  95977. /**
  95978. * nit (cd/m^2)
  95979. */
  95980. static readonly INTENSITYMODE_LUMINANCE: number;
  95981. /**
  95982. * Light type const id of the point light.
  95983. */
  95984. static readonly LIGHTTYPEID_POINTLIGHT: number;
  95985. /**
  95986. * Light type const id of the directional light.
  95987. */
  95988. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  95989. /**
  95990. * Light type const id of the spot light.
  95991. */
  95992. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  95993. /**
  95994. * Light type const id of the hemispheric light.
  95995. */
  95996. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  95997. /**
  95998. * Diffuse gives the basic color to an object.
  95999. */
  96000. diffuse: Color3;
  96001. /**
  96002. * Specular produces a highlight color on an object.
  96003. * Note: This is note affecting PBR materials.
  96004. */
  96005. specular: Color3;
  96006. /**
  96007. * Defines the falloff type for this light. This lets overrriding how punctual light are
  96008. * falling off base on range or angle.
  96009. * This can be set to any values in Light.FALLOFF_x.
  96010. *
  96011. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  96012. * other types of materials.
  96013. */
  96014. falloffType: number;
  96015. /**
  96016. * Strength of the light.
  96017. * Note: By default it is define in the framework own unit.
  96018. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  96019. */
  96020. intensity: number;
  96021. private _range;
  96022. protected _inverseSquaredRange: number;
  96023. /**
  96024. * Defines how far from the source the light is impacting in scene units.
  96025. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  96026. */
  96027. get range(): number;
  96028. /**
  96029. * Defines how far from the source the light is impacting in scene units.
  96030. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  96031. */
  96032. set range(value: number);
  96033. /**
  96034. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  96035. * of light.
  96036. */
  96037. private _photometricScale;
  96038. private _intensityMode;
  96039. /**
  96040. * Gets the photometric scale used to interpret the intensity.
  96041. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  96042. */
  96043. get intensityMode(): number;
  96044. /**
  96045. * Sets the photometric scale used to interpret the intensity.
  96046. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  96047. */
  96048. set intensityMode(value: number);
  96049. private _radius;
  96050. /**
  96051. * Gets the light radius used by PBR Materials to simulate soft area lights.
  96052. */
  96053. get radius(): number;
  96054. /**
  96055. * sets the light radius used by PBR Materials to simulate soft area lights.
  96056. */
  96057. set radius(value: number);
  96058. private _renderPriority;
  96059. /**
  96060. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  96061. * exceeding the number allowed of the materials.
  96062. */
  96063. renderPriority: number;
  96064. private _shadowEnabled;
  96065. /**
  96066. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  96067. * the current shadow generator.
  96068. */
  96069. get shadowEnabled(): boolean;
  96070. /**
  96071. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  96072. * the current shadow generator.
  96073. */
  96074. set shadowEnabled(value: boolean);
  96075. private _includedOnlyMeshes;
  96076. /**
  96077. * Gets the only meshes impacted by this light.
  96078. */
  96079. get includedOnlyMeshes(): AbstractMesh[];
  96080. /**
  96081. * Sets the only meshes impacted by this light.
  96082. */
  96083. set includedOnlyMeshes(value: AbstractMesh[]);
  96084. private _excludedMeshes;
  96085. /**
  96086. * Gets the meshes not impacted by this light.
  96087. */
  96088. get excludedMeshes(): AbstractMesh[];
  96089. /**
  96090. * Sets the meshes not impacted by this light.
  96091. */
  96092. set excludedMeshes(value: AbstractMesh[]);
  96093. private _excludeWithLayerMask;
  96094. /**
  96095. * Gets the layer id use to find what meshes are not impacted by the light.
  96096. * Inactive if 0
  96097. */
  96098. get excludeWithLayerMask(): number;
  96099. /**
  96100. * Sets the layer id use to find what meshes are not impacted by the light.
  96101. * Inactive if 0
  96102. */
  96103. set excludeWithLayerMask(value: number);
  96104. private _includeOnlyWithLayerMask;
  96105. /**
  96106. * Gets the layer id use to find what meshes are impacted by the light.
  96107. * Inactive if 0
  96108. */
  96109. get includeOnlyWithLayerMask(): number;
  96110. /**
  96111. * Sets the layer id use to find what meshes are impacted by the light.
  96112. * Inactive if 0
  96113. */
  96114. set includeOnlyWithLayerMask(value: number);
  96115. private _lightmapMode;
  96116. /**
  96117. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  96118. */
  96119. get lightmapMode(): number;
  96120. /**
  96121. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  96122. */
  96123. set lightmapMode(value: number);
  96124. /**
  96125. * Shadow generator associted to the light.
  96126. * @hidden Internal use only.
  96127. */
  96128. _shadowGenerator: Nullable<IShadowGenerator>;
  96129. /**
  96130. * @hidden Internal use only.
  96131. */
  96132. _excludedMeshesIds: string[];
  96133. /**
  96134. * @hidden Internal use only.
  96135. */
  96136. _includedOnlyMeshesIds: string[];
  96137. /**
  96138. * The current light unifom buffer.
  96139. * @hidden Internal use only.
  96140. */
  96141. _uniformBuffer: UniformBuffer;
  96142. /** @hidden */
  96143. _renderId: number;
  96144. /**
  96145. * Creates a Light object in the scene.
  96146. * Documentation : https://doc.babylonjs.com/babylon101/lights
  96147. * @param name The firendly name of the light
  96148. * @param scene The scene the light belongs too
  96149. */
  96150. constructor(name: string, scene: Scene);
  96151. protected abstract _buildUniformLayout(): void;
  96152. /**
  96153. * Sets the passed Effect "effect" with the Light information.
  96154. * @param effect The effect to update
  96155. * @param lightIndex The index of the light in the effect to update
  96156. * @returns The light
  96157. */
  96158. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  96159. /**
  96160. * Sets the passed Effect "effect" with the Light textures.
  96161. * @param effect The effect to update
  96162. * @param lightIndex The index of the light in the effect to update
  96163. * @returns The light
  96164. */
  96165. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  96166. /**
  96167. * Binds the lights information from the scene to the effect for the given mesh.
  96168. * @param lightIndex Light index
  96169. * @param scene The scene where the light belongs to
  96170. * @param effect The effect we are binding the data to
  96171. * @param useSpecular Defines if specular is supported
  96172. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  96173. */
  96174. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  96175. /**
  96176. * Sets the passed Effect "effect" with the Light information.
  96177. * @param effect The effect to update
  96178. * @param lightDataUniformName The uniform used to store light data (position or direction)
  96179. * @returns The light
  96180. */
  96181. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  96182. /**
  96183. * Returns the string "Light".
  96184. * @returns the class name
  96185. */
  96186. getClassName(): string;
  96187. /** @hidden */
  96188. readonly _isLight: boolean;
  96189. /**
  96190. * Converts the light information to a readable string for debug purpose.
  96191. * @param fullDetails Supports for multiple levels of logging within scene loading
  96192. * @returns the human readable light info
  96193. */
  96194. toString(fullDetails?: boolean): string;
  96195. /** @hidden */
  96196. protected _syncParentEnabledState(): void;
  96197. /**
  96198. * Set the enabled state of this node.
  96199. * @param value - the new enabled state
  96200. */
  96201. setEnabled(value: boolean): void;
  96202. /**
  96203. * Returns the Light associated shadow generator if any.
  96204. * @return the associated shadow generator.
  96205. */
  96206. getShadowGenerator(): Nullable<IShadowGenerator>;
  96207. /**
  96208. * Returns a Vector3, the absolute light position in the World.
  96209. * @returns the world space position of the light
  96210. */
  96211. getAbsolutePosition(): Vector3;
  96212. /**
  96213. * Specifies if the light will affect the passed mesh.
  96214. * @param mesh The mesh to test against the light
  96215. * @return true the mesh is affected otherwise, false.
  96216. */
  96217. canAffectMesh(mesh: AbstractMesh): boolean;
  96218. /**
  96219. * Sort function to order lights for rendering.
  96220. * @param a First Light object to compare to second.
  96221. * @param b Second Light object to compare first.
  96222. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  96223. */
  96224. static CompareLightsPriority(a: Light, b: Light): number;
  96225. /**
  96226. * Releases resources associated with this node.
  96227. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96228. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96229. */
  96230. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96231. /**
  96232. * Returns the light type ID (integer).
  96233. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  96234. */
  96235. getTypeID(): number;
  96236. /**
  96237. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  96238. * @returns the scaled intensity in intensity mode unit
  96239. */
  96240. getScaledIntensity(): number;
  96241. /**
  96242. * Returns a new Light object, named "name", from the current one.
  96243. * @param name The name of the cloned light
  96244. * @param newParent The parent of this light, if it has one
  96245. * @returns the new created light
  96246. */
  96247. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  96248. /**
  96249. * Serializes the current light into a Serialization object.
  96250. * @returns the serialized object.
  96251. */
  96252. serialize(): any;
  96253. /**
  96254. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  96255. * This new light is named "name" and added to the passed scene.
  96256. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  96257. * @param name The friendly name of the light
  96258. * @param scene The scene the new light will belong to
  96259. * @returns the constructor function
  96260. */
  96261. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  96262. /**
  96263. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  96264. * @param parsedLight The JSON representation of the light
  96265. * @param scene The scene to create the parsed light in
  96266. * @returns the created light after parsing
  96267. */
  96268. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  96269. private _hookArrayForExcluded;
  96270. private _hookArrayForIncludedOnly;
  96271. private _resyncMeshes;
  96272. /**
  96273. * Forces the meshes to update their light related information in their rendering used effects
  96274. * @hidden Internal Use Only
  96275. */
  96276. _markMeshesAsLightDirty(): void;
  96277. /**
  96278. * Recomputes the cached photometric scale if needed.
  96279. */
  96280. private _computePhotometricScale;
  96281. /**
  96282. * Returns the Photometric Scale according to the light type and intensity mode.
  96283. */
  96284. private _getPhotometricScale;
  96285. /**
  96286. * Reorder the light in the scene according to their defined priority.
  96287. * @hidden Internal Use Only
  96288. */
  96289. _reorderLightsInScene(): void;
  96290. /**
  96291. * Prepares the list of defines specific to the light type.
  96292. * @param defines the list of defines
  96293. * @param lightIndex defines the index of the light for the effect
  96294. */
  96295. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  96296. }
  96297. }
  96298. declare module BABYLON {
  96299. /**
  96300. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  96301. * This is the base of the follow, arc rotate cameras and Free camera
  96302. * @see https://doc.babylonjs.com/features/cameras
  96303. */
  96304. export class TargetCamera extends Camera {
  96305. private static _RigCamTransformMatrix;
  96306. private static _TargetTransformMatrix;
  96307. private static _TargetFocalPoint;
  96308. private _tmpUpVector;
  96309. private _tmpTargetVector;
  96310. /**
  96311. * Define the current direction the camera is moving to
  96312. */
  96313. cameraDirection: Vector3;
  96314. /**
  96315. * Define the current rotation the camera is rotating to
  96316. */
  96317. cameraRotation: Vector2;
  96318. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  96319. ignoreParentScaling: boolean;
  96320. /**
  96321. * When set, the up vector of the camera will be updated by the rotation of the camera
  96322. */
  96323. updateUpVectorFromRotation: boolean;
  96324. private _tmpQuaternion;
  96325. /**
  96326. * Define the current rotation of the camera
  96327. */
  96328. rotation: Vector3;
  96329. /**
  96330. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  96331. */
  96332. rotationQuaternion: Quaternion;
  96333. /**
  96334. * Define the current speed of the camera
  96335. */
  96336. speed: number;
  96337. /**
  96338. * Add constraint to the camera to prevent it to move freely in all directions and
  96339. * around all axis.
  96340. */
  96341. noRotationConstraint: boolean;
  96342. /**
  96343. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  96344. * panning
  96345. */
  96346. invertRotation: boolean;
  96347. /**
  96348. * Speed multiplier for inverse camera panning
  96349. */
  96350. inverseRotationSpeed: number;
  96351. /**
  96352. * Define the current target of the camera as an object or a position.
  96353. */
  96354. lockedTarget: any;
  96355. /** @hidden */
  96356. _currentTarget: Vector3;
  96357. /** @hidden */
  96358. _initialFocalDistance: number;
  96359. /** @hidden */
  96360. _viewMatrix: Matrix;
  96361. /** @hidden */
  96362. _camMatrix: Matrix;
  96363. /** @hidden */
  96364. _cameraTransformMatrix: Matrix;
  96365. /** @hidden */
  96366. _cameraRotationMatrix: Matrix;
  96367. /** @hidden */
  96368. _referencePoint: Vector3;
  96369. /** @hidden */
  96370. _transformedReferencePoint: Vector3;
  96371. /** @hidden */
  96372. _reset: () => void;
  96373. private _defaultUp;
  96374. /**
  96375. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  96376. * This is the base of the follow, arc rotate cameras and Free camera
  96377. * @see https://doc.babylonjs.com/features/cameras
  96378. * @param name Defines the name of the camera in the scene
  96379. * @param position Defines the start position of the camera in the scene
  96380. * @param scene Defines the scene the camera belongs to
  96381. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  96382. */
  96383. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96384. /**
  96385. * Gets the position in front of the camera at a given distance.
  96386. * @param distance The distance from the camera we want the position to be
  96387. * @returns the position
  96388. */
  96389. getFrontPosition(distance: number): Vector3;
  96390. /** @hidden */
  96391. _getLockedTargetPosition(): Nullable<Vector3>;
  96392. private _storedPosition;
  96393. private _storedRotation;
  96394. private _storedRotationQuaternion;
  96395. /**
  96396. * Store current camera state of the camera (fov, position, rotation, etc..)
  96397. * @returns the camera
  96398. */
  96399. storeState(): Camera;
  96400. /**
  96401. * Restored camera state. You must call storeState() first
  96402. * @returns whether it was successful or not
  96403. * @hidden
  96404. */
  96405. _restoreStateValues(): boolean;
  96406. /** @hidden */
  96407. _initCache(): void;
  96408. /** @hidden */
  96409. _updateCache(ignoreParentClass?: boolean): void;
  96410. /** @hidden */
  96411. _isSynchronizedViewMatrix(): boolean;
  96412. /** @hidden */
  96413. _computeLocalCameraSpeed(): number;
  96414. /**
  96415. * Defines the target the camera should look at.
  96416. * @param target Defines the new target as a Vector or a mesh
  96417. */
  96418. setTarget(target: Vector3): void;
  96419. /**
  96420. * Return the current target position of the camera. This value is expressed in local space.
  96421. * @returns the target position
  96422. */
  96423. getTarget(): Vector3;
  96424. /** @hidden */
  96425. _decideIfNeedsToMove(): boolean;
  96426. /** @hidden */
  96427. _updatePosition(): void;
  96428. /** @hidden */
  96429. _checkInputs(): void;
  96430. protected _updateCameraRotationMatrix(): void;
  96431. /**
  96432. * 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)
  96433. * @returns the current camera
  96434. */
  96435. private _rotateUpVectorWithCameraRotationMatrix;
  96436. private _cachedRotationZ;
  96437. private _cachedQuaternionRotationZ;
  96438. /** @hidden */
  96439. _getViewMatrix(): Matrix;
  96440. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  96441. /**
  96442. * @hidden
  96443. */
  96444. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  96445. /**
  96446. * @hidden
  96447. */
  96448. _updateRigCameras(): void;
  96449. private _getRigCamPositionAndTarget;
  96450. /**
  96451. * Gets the current object class name.
  96452. * @return the class name
  96453. */
  96454. getClassName(): string;
  96455. }
  96456. }
  96457. declare module BABYLON {
  96458. /**
  96459. * Gather the list of keyboard event types as constants.
  96460. */
  96461. export class KeyboardEventTypes {
  96462. /**
  96463. * The keydown event is fired when a key becomes active (pressed).
  96464. */
  96465. static readonly KEYDOWN: number;
  96466. /**
  96467. * The keyup event is fired when a key has been released.
  96468. */
  96469. static readonly KEYUP: number;
  96470. }
  96471. /**
  96472. * This class is used to store keyboard related info for the onKeyboardObservable event.
  96473. */
  96474. export class KeyboardInfo {
  96475. /**
  96476. * Defines the type of event (KeyboardEventTypes)
  96477. */
  96478. type: number;
  96479. /**
  96480. * Defines the related dom event
  96481. */
  96482. event: KeyboardEvent;
  96483. /**
  96484. * Instantiates a new keyboard info.
  96485. * This class is used to store keyboard related info for the onKeyboardObservable event.
  96486. * @param type Defines the type of event (KeyboardEventTypes)
  96487. * @param event Defines the related dom event
  96488. */
  96489. constructor(
  96490. /**
  96491. * Defines the type of event (KeyboardEventTypes)
  96492. */
  96493. type: number,
  96494. /**
  96495. * Defines the related dom event
  96496. */
  96497. event: KeyboardEvent);
  96498. }
  96499. /**
  96500. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  96501. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  96502. */
  96503. export class KeyboardInfoPre extends KeyboardInfo {
  96504. /**
  96505. * Defines the type of event (KeyboardEventTypes)
  96506. */
  96507. type: number;
  96508. /**
  96509. * Defines the related dom event
  96510. */
  96511. event: KeyboardEvent;
  96512. /**
  96513. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  96514. */
  96515. skipOnPointerObservable: boolean;
  96516. /**
  96517. * Instantiates a new keyboard pre info.
  96518. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  96519. * @param type Defines the type of event (KeyboardEventTypes)
  96520. * @param event Defines the related dom event
  96521. */
  96522. constructor(
  96523. /**
  96524. * Defines the type of event (KeyboardEventTypes)
  96525. */
  96526. type: number,
  96527. /**
  96528. * Defines the related dom event
  96529. */
  96530. event: KeyboardEvent);
  96531. }
  96532. }
  96533. declare module BABYLON {
  96534. /**
  96535. * Manage the keyboard inputs to control the movement of a free camera.
  96536. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  96537. */
  96538. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  96539. /**
  96540. * Defines the camera the input is attached to.
  96541. */
  96542. camera: FreeCamera;
  96543. /**
  96544. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  96545. */
  96546. keysUp: number[];
  96547. /**
  96548. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  96549. */
  96550. keysUpward: number[];
  96551. /**
  96552. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  96553. */
  96554. keysDown: number[];
  96555. /**
  96556. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  96557. */
  96558. keysDownward: number[];
  96559. /**
  96560. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  96561. */
  96562. keysLeft: number[];
  96563. /**
  96564. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  96565. */
  96566. keysRight: number[];
  96567. private _keys;
  96568. private _onCanvasBlurObserver;
  96569. private _onKeyboardObserver;
  96570. private _engine;
  96571. private _scene;
  96572. /**
  96573. * Attach the input controls to a specific dom element to get the input from.
  96574. * @param element Defines the element the controls should be listened from
  96575. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96576. */
  96577. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96578. /**
  96579. * Detach the current controls from the specified dom element.
  96580. * @param element Defines the element to stop listening the inputs from
  96581. */
  96582. detachControl(element: Nullable<HTMLElement>): void;
  96583. /**
  96584. * Update the current camera state depending on the inputs that have been used this frame.
  96585. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96586. */
  96587. checkInputs(): void;
  96588. /**
  96589. * Gets the class name of the current intput.
  96590. * @returns the class name
  96591. */
  96592. getClassName(): string;
  96593. /** @hidden */
  96594. _onLostFocus(): void;
  96595. /**
  96596. * Get the friendly name associated with the input class.
  96597. * @returns the input friendly name
  96598. */
  96599. getSimpleName(): string;
  96600. }
  96601. }
  96602. declare module BABYLON {
  96603. /**
  96604. * Gather the list of pointer event types as constants.
  96605. */
  96606. export class PointerEventTypes {
  96607. /**
  96608. * 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.
  96609. */
  96610. static readonly POINTERDOWN: number;
  96611. /**
  96612. * The pointerup event is fired when a pointer is no longer active.
  96613. */
  96614. static readonly POINTERUP: number;
  96615. /**
  96616. * The pointermove event is fired when a pointer changes coordinates.
  96617. */
  96618. static readonly POINTERMOVE: number;
  96619. /**
  96620. * The pointerwheel event is fired when a mouse wheel has been rotated.
  96621. */
  96622. static readonly POINTERWHEEL: number;
  96623. /**
  96624. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  96625. */
  96626. static readonly POINTERPICK: number;
  96627. /**
  96628. * The pointertap event is fired when a the object has been touched and released without drag.
  96629. */
  96630. static readonly POINTERTAP: number;
  96631. /**
  96632. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  96633. */
  96634. static readonly POINTERDOUBLETAP: number;
  96635. }
  96636. /**
  96637. * Base class of pointer info types.
  96638. */
  96639. export class PointerInfoBase {
  96640. /**
  96641. * Defines the type of event (PointerEventTypes)
  96642. */
  96643. type: number;
  96644. /**
  96645. * Defines the related dom event
  96646. */
  96647. event: PointerEvent | MouseWheelEvent;
  96648. /**
  96649. * Instantiates the base class of pointers info.
  96650. * @param type Defines the type of event (PointerEventTypes)
  96651. * @param event Defines the related dom event
  96652. */
  96653. constructor(
  96654. /**
  96655. * Defines the type of event (PointerEventTypes)
  96656. */
  96657. type: number,
  96658. /**
  96659. * Defines the related dom event
  96660. */
  96661. event: PointerEvent | MouseWheelEvent);
  96662. }
  96663. /**
  96664. * This class is used to store pointer related info for the onPrePointerObservable event.
  96665. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  96666. */
  96667. export class PointerInfoPre extends PointerInfoBase {
  96668. /**
  96669. * Ray from a pointer if availible (eg. 6dof controller)
  96670. */
  96671. ray: Nullable<Ray>;
  96672. /**
  96673. * Defines the local position of the pointer on the canvas.
  96674. */
  96675. localPosition: Vector2;
  96676. /**
  96677. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  96678. */
  96679. skipOnPointerObservable: boolean;
  96680. /**
  96681. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  96682. * @param type Defines the type of event (PointerEventTypes)
  96683. * @param event Defines the related dom event
  96684. * @param localX Defines the local x coordinates of the pointer when the event occured
  96685. * @param localY Defines the local y coordinates of the pointer when the event occured
  96686. */
  96687. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  96688. }
  96689. /**
  96690. * This type contains all the data related to a pointer event in Babylon.js.
  96691. * 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.
  96692. */
  96693. export class PointerInfo extends PointerInfoBase {
  96694. /**
  96695. * Defines the picking info associated to the info (if any)\
  96696. */
  96697. pickInfo: Nullable<PickingInfo>;
  96698. /**
  96699. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  96700. * @param type Defines the type of event (PointerEventTypes)
  96701. * @param event Defines the related dom event
  96702. * @param pickInfo Defines the picking info associated to the info (if any)\
  96703. */
  96704. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  96705. /**
  96706. * Defines the picking info associated to the info (if any)\
  96707. */
  96708. pickInfo: Nullable<PickingInfo>);
  96709. }
  96710. /**
  96711. * Data relating to a touch event on the screen.
  96712. */
  96713. export interface PointerTouch {
  96714. /**
  96715. * X coordinate of touch.
  96716. */
  96717. x: number;
  96718. /**
  96719. * Y coordinate of touch.
  96720. */
  96721. y: number;
  96722. /**
  96723. * Id of touch. Unique for each finger.
  96724. */
  96725. pointerId: number;
  96726. /**
  96727. * Event type passed from DOM.
  96728. */
  96729. type: any;
  96730. }
  96731. }
  96732. declare module BABYLON {
  96733. /**
  96734. * Manage the mouse inputs to control the movement of a free camera.
  96735. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  96736. */
  96737. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  96738. /**
  96739. * Define if touch is enabled in the mouse input
  96740. */
  96741. touchEnabled: boolean;
  96742. /**
  96743. * Defines the camera the input is attached to.
  96744. */
  96745. camera: FreeCamera;
  96746. /**
  96747. * Defines the buttons associated with the input to handle camera move.
  96748. */
  96749. buttons: number[];
  96750. /**
  96751. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  96752. */
  96753. angularSensibility: number;
  96754. private _pointerInput;
  96755. private _onMouseMove;
  96756. private _observer;
  96757. private previousPosition;
  96758. /**
  96759. * Observable for when a pointer move event occurs containing the move offset
  96760. */
  96761. onPointerMovedObservable: Observable<{
  96762. offsetX: number;
  96763. offsetY: number;
  96764. }>;
  96765. /**
  96766. * @hidden
  96767. * If the camera should be rotated automatically based on pointer movement
  96768. */
  96769. _allowCameraRotation: boolean;
  96770. /**
  96771. * Manage the mouse inputs to control the movement of a free camera.
  96772. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  96773. * @param touchEnabled Defines if touch is enabled or not
  96774. */
  96775. constructor(
  96776. /**
  96777. * Define if touch is enabled in the mouse input
  96778. */
  96779. touchEnabled?: boolean);
  96780. /**
  96781. * Attach the input controls to a specific dom element to get the input from.
  96782. * @param element Defines the element the controls should be listened from
  96783. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96784. */
  96785. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96786. /**
  96787. * Called on JS contextmenu event.
  96788. * Override this method to provide functionality.
  96789. */
  96790. protected onContextMenu(evt: PointerEvent): void;
  96791. /**
  96792. * Detach the current controls from the specified dom element.
  96793. * @param element Defines the element to stop listening the inputs from
  96794. */
  96795. detachControl(element: Nullable<HTMLElement>): void;
  96796. /**
  96797. * Gets the class name of the current intput.
  96798. * @returns the class name
  96799. */
  96800. getClassName(): string;
  96801. /**
  96802. * Get the friendly name associated with the input class.
  96803. * @returns the input friendly name
  96804. */
  96805. getSimpleName(): string;
  96806. }
  96807. }
  96808. declare module BABYLON {
  96809. /**
  96810. * Manage the touch inputs to control the movement of a free camera.
  96811. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  96812. */
  96813. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  96814. /**
  96815. * Defines the camera the input is attached to.
  96816. */
  96817. camera: FreeCamera;
  96818. /**
  96819. * Defines the touch sensibility for rotation.
  96820. * The higher the faster.
  96821. */
  96822. touchAngularSensibility: number;
  96823. /**
  96824. * Defines the touch sensibility for move.
  96825. * The higher the faster.
  96826. */
  96827. touchMoveSensibility: number;
  96828. private _offsetX;
  96829. private _offsetY;
  96830. private _pointerPressed;
  96831. private _pointerInput;
  96832. private _observer;
  96833. private _onLostFocus;
  96834. /**
  96835. * Attach the input controls to a specific dom element to get the input from.
  96836. * @param element Defines the element the controls should be listened from
  96837. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96838. */
  96839. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96840. /**
  96841. * Detach the current controls from the specified dom element.
  96842. * @param element Defines the element to stop listening the inputs from
  96843. */
  96844. detachControl(element: Nullable<HTMLElement>): void;
  96845. /**
  96846. * Update the current camera state depending on the inputs that have been used this frame.
  96847. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96848. */
  96849. checkInputs(): void;
  96850. /**
  96851. * Gets the class name of the current intput.
  96852. * @returns the class name
  96853. */
  96854. getClassName(): string;
  96855. /**
  96856. * Get the friendly name associated with the input class.
  96857. * @returns the input friendly name
  96858. */
  96859. getSimpleName(): string;
  96860. }
  96861. }
  96862. declare module BABYLON {
  96863. /**
  96864. * Default Inputs manager for the FreeCamera.
  96865. * It groups all the default supported inputs for ease of use.
  96866. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  96867. */
  96868. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  96869. /**
  96870. * @hidden
  96871. */
  96872. _mouseInput: Nullable<FreeCameraMouseInput>;
  96873. /**
  96874. * Instantiates a new FreeCameraInputsManager.
  96875. * @param camera Defines the camera the inputs belong to
  96876. */
  96877. constructor(camera: FreeCamera);
  96878. /**
  96879. * Add keyboard input support to the input manager.
  96880. * @returns the current input manager
  96881. */
  96882. addKeyboard(): FreeCameraInputsManager;
  96883. /**
  96884. * Add mouse input support to the input manager.
  96885. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  96886. * @returns the current input manager
  96887. */
  96888. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  96889. /**
  96890. * Removes the mouse input support from the manager
  96891. * @returns the current input manager
  96892. */
  96893. removeMouse(): FreeCameraInputsManager;
  96894. /**
  96895. * Add touch input support to the input manager.
  96896. * @returns the current input manager
  96897. */
  96898. addTouch(): FreeCameraInputsManager;
  96899. /**
  96900. * Remove all attached input methods from a camera
  96901. */
  96902. clear(): void;
  96903. }
  96904. }
  96905. declare module BABYLON {
  96906. /**
  96907. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  96908. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  96909. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  96910. */
  96911. export class FreeCamera extends TargetCamera {
  96912. /**
  96913. * Define the collision ellipsoid of the camera.
  96914. * This is helpful to simulate a camera body like the player body around the camera
  96915. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  96916. */
  96917. ellipsoid: Vector3;
  96918. /**
  96919. * Define an offset for the position of the ellipsoid around the camera.
  96920. * This can be helpful to determine the center of the body near the gravity center of the body
  96921. * instead of its head.
  96922. */
  96923. ellipsoidOffset: Vector3;
  96924. /**
  96925. * Enable or disable collisions of the camera with the rest of the scene objects.
  96926. */
  96927. checkCollisions: boolean;
  96928. /**
  96929. * Enable or disable gravity on the camera.
  96930. */
  96931. applyGravity: boolean;
  96932. /**
  96933. * Define the input manager associated to the camera.
  96934. */
  96935. inputs: FreeCameraInputsManager;
  96936. /**
  96937. * Gets the input sensibility for a mouse input. (default is 2000.0)
  96938. * Higher values reduce sensitivity.
  96939. */
  96940. get angularSensibility(): number;
  96941. /**
  96942. * Sets the input sensibility for a mouse input. (default is 2000.0)
  96943. * Higher values reduce sensitivity.
  96944. */
  96945. set angularSensibility(value: number);
  96946. /**
  96947. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  96948. */
  96949. get keysUp(): number[];
  96950. set keysUp(value: number[]);
  96951. /**
  96952. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  96953. */
  96954. get keysUpward(): number[];
  96955. set keysUpward(value: number[]);
  96956. /**
  96957. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  96958. */
  96959. get keysDown(): number[];
  96960. set keysDown(value: number[]);
  96961. /**
  96962. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  96963. */
  96964. get keysDownward(): number[];
  96965. set keysDownward(value: number[]);
  96966. /**
  96967. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  96968. */
  96969. get keysLeft(): number[];
  96970. set keysLeft(value: number[]);
  96971. /**
  96972. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  96973. */
  96974. get keysRight(): number[];
  96975. set keysRight(value: number[]);
  96976. /**
  96977. * Event raised when the camera collide with a mesh in the scene.
  96978. */
  96979. onCollide: (collidedMesh: AbstractMesh) => void;
  96980. private _collider;
  96981. private _needMoveForGravity;
  96982. private _oldPosition;
  96983. private _diffPosition;
  96984. private _newPosition;
  96985. /** @hidden */
  96986. _localDirection: Vector3;
  96987. /** @hidden */
  96988. _transformedDirection: Vector3;
  96989. /**
  96990. * Instantiates a Free Camera.
  96991. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  96992. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  96993. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  96994. * @param name Define the name of the camera in the scene
  96995. * @param position Define the start position of the camera in the scene
  96996. * @param scene Define the scene the camera belongs to
  96997. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  96998. */
  96999. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  97000. /**
  97001. * Attached controls to the current camera.
  97002. * @param element Defines the element the controls should be listened from
  97003. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97004. */
  97005. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97006. /**
  97007. * Detach the current controls from the camera.
  97008. * The camera will stop reacting to inputs.
  97009. * @param element Defines the element to stop listening the inputs from
  97010. */
  97011. detachControl(element: HTMLElement): void;
  97012. private _collisionMask;
  97013. /**
  97014. * Define a collision mask to limit the list of object the camera can collide with
  97015. */
  97016. get collisionMask(): number;
  97017. set collisionMask(mask: number);
  97018. /** @hidden */
  97019. _collideWithWorld(displacement: Vector3): void;
  97020. private _onCollisionPositionChange;
  97021. /** @hidden */
  97022. _checkInputs(): void;
  97023. /** @hidden */
  97024. _decideIfNeedsToMove(): boolean;
  97025. /** @hidden */
  97026. _updatePosition(): void;
  97027. /**
  97028. * Destroy the camera and release the current resources hold by it.
  97029. */
  97030. dispose(): void;
  97031. /**
  97032. * Gets the current object class name.
  97033. * @return the class name
  97034. */
  97035. getClassName(): string;
  97036. }
  97037. }
  97038. declare module BABYLON {
  97039. /**
  97040. * Represents a gamepad control stick position
  97041. */
  97042. export class StickValues {
  97043. /**
  97044. * The x component of the control stick
  97045. */
  97046. x: number;
  97047. /**
  97048. * The y component of the control stick
  97049. */
  97050. y: number;
  97051. /**
  97052. * Initializes the gamepad x and y control stick values
  97053. * @param x The x component of the gamepad control stick value
  97054. * @param y The y component of the gamepad control stick value
  97055. */
  97056. constructor(
  97057. /**
  97058. * The x component of the control stick
  97059. */
  97060. x: number,
  97061. /**
  97062. * The y component of the control stick
  97063. */
  97064. y: number);
  97065. }
  97066. /**
  97067. * An interface which manages callbacks for gamepad button changes
  97068. */
  97069. export interface GamepadButtonChanges {
  97070. /**
  97071. * Called when a gamepad has been changed
  97072. */
  97073. changed: boolean;
  97074. /**
  97075. * Called when a gamepad press event has been triggered
  97076. */
  97077. pressChanged: boolean;
  97078. /**
  97079. * Called when a touch event has been triggered
  97080. */
  97081. touchChanged: boolean;
  97082. /**
  97083. * Called when a value has changed
  97084. */
  97085. valueChanged: boolean;
  97086. }
  97087. /**
  97088. * Represents a gamepad
  97089. */
  97090. export class Gamepad {
  97091. /**
  97092. * The id of the gamepad
  97093. */
  97094. id: string;
  97095. /**
  97096. * The index of the gamepad
  97097. */
  97098. index: number;
  97099. /**
  97100. * The browser gamepad
  97101. */
  97102. browserGamepad: any;
  97103. /**
  97104. * Specifies what type of gamepad this represents
  97105. */
  97106. type: number;
  97107. private _leftStick;
  97108. private _rightStick;
  97109. /** @hidden */
  97110. _isConnected: boolean;
  97111. private _leftStickAxisX;
  97112. private _leftStickAxisY;
  97113. private _rightStickAxisX;
  97114. private _rightStickAxisY;
  97115. /**
  97116. * Triggered when the left control stick has been changed
  97117. */
  97118. private _onleftstickchanged;
  97119. /**
  97120. * Triggered when the right control stick has been changed
  97121. */
  97122. private _onrightstickchanged;
  97123. /**
  97124. * Represents a gamepad controller
  97125. */
  97126. static GAMEPAD: number;
  97127. /**
  97128. * Represents a generic controller
  97129. */
  97130. static GENERIC: number;
  97131. /**
  97132. * Represents an XBox controller
  97133. */
  97134. static XBOX: number;
  97135. /**
  97136. * Represents a pose-enabled controller
  97137. */
  97138. static POSE_ENABLED: number;
  97139. /**
  97140. * Represents an Dual Shock controller
  97141. */
  97142. static DUALSHOCK: number;
  97143. /**
  97144. * Specifies whether the left control stick should be Y-inverted
  97145. */
  97146. protected _invertLeftStickY: boolean;
  97147. /**
  97148. * Specifies if the gamepad has been connected
  97149. */
  97150. get isConnected(): boolean;
  97151. /**
  97152. * Initializes the gamepad
  97153. * @param id The id of the gamepad
  97154. * @param index The index of the gamepad
  97155. * @param browserGamepad The browser gamepad
  97156. * @param leftStickX The x component of the left joystick
  97157. * @param leftStickY The y component of the left joystick
  97158. * @param rightStickX The x component of the right joystick
  97159. * @param rightStickY The y component of the right joystick
  97160. */
  97161. constructor(
  97162. /**
  97163. * The id of the gamepad
  97164. */
  97165. id: string,
  97166. /**
  97167. * The index of the gamepad
  97168. */
  97169. index: number,
  97170. /**
  97171. * The browser gamepad
  97172. */
  97173. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  97174. /**
  97175. * Callback triggered when the left joystick has changed
  97176. * @param callback
  97177. */
  97178. onleftstickchanged(callback: (values: StickValues) => void): void;
  97179. /**
  97180. * Callback triggered when the right joystick has changed
  97181. * @param callback
  97182. */
  97183. onrightstickchanged(callback: (values: StickValues) => void): void;
  97184. /**
  97185. * Gets the left joystick
  97186. */
  97187. get leftStick(): StickValues;
  97188. /**
  97189. * Sets the left joystick values
  97190. */
  97191. set leftStick(newValues: StickValues);
  97192. /**
  97193. * Gets the right joystick
  97194. */
  97195. get rightStick(): StickValues;
  97196. /**
  97197. * Sets the right joystick value
  97198. */
  97199. set rightStick(newValues: StickValues);
  97200. /**
  97201. * Updates the gamepad joystick positions
  97202. */
  97203. update(): void;
  97204. /**
  97205. * Disposes the gamepad
  97206. */
  97207. dispose(): void;
  97208. }
  97209. /**
  97210. * Represents a generic gamepad
  97211. */
  97212. export class GenericPad extends Gamepad {
  97213. private _buttons;
  97214. private _onbuttondown;
  97215. private _onbuttonup;
  97216. /**
  97217. * Observable triggered when a button has been pressed
  97218. */
  97219. onButtonDownObservable: Observable<number>;
  97220. /**
  97221. * Observable triggered when a button has been released
  97222. */
  97223. onButtonUpObservable: Observable<number>;
  97224. /**
  97225. * Callback triggered when a button has been pressed
  97226. * @param callback Called when a button has been pressed
  97227. */
  97228. onbuttondown(callback: (buttonPressed: number) => void): void;
  97229. /**
  97230. * Callback triggered when a button has been released
  97231. * @param callback Called when a button has been released
  97232. */
  97233. onbuttonup(callback: (buttonReleased: number) => void): void;
  97234. /**
  97235. * Initializes the generic gamepad
  97236. * @param id The id of the generic gamepad
  97237. * @param index The index of the generic gamepad
  97238. * @param browserGamepad The browser gamepad
  97239. */
  97240. constructor(id: string, index: number, browserGamepad: any);
  97241. private _setButtonValue;
  97242. /**
  97243. * Updates the generic gamepad
  97244. */
  97245. update(): void;
  97246. /**
  97247. * Disposes the generic gamepad
  97248. */
  97249. dispose(): void;
  97250. }
  97251. }
  97252. declare module BABYLON {
  97253. /**
  97254. * Defines the types of pose enabled controllers that are supported
  97255. */
  97256. export enum PoseEnabledControllerType {
  97257. /**
  97258. * HTC Vive
  97259. */
  97260. VIVE = 0,
  97261. /**
  97262. * Oculus Rift
  97263. */
  97264. OCULUS = 1,
  97265. /**
  97266. * Windows mixed reality
  97267. */
  97268. WINDOWS = 2,
  97269. /**
  97270. * Samsung gear VR
  97271. */
  97272. GEAR_VR = 3,
  97273. /**
  97274. * Google Daydream
  97275. */
  97276. DAYDREAM = 4,
  97277. /**
  97278. * Generic
  97279. */
  97280. GENERIC = 5
  97281. }
  97282. /**
  97283. * Defines the MutableGamepadButton interface for the state of a gamepad button
  97284. */
  97285. export interface MutableGamepadButton {
  97286. /**
  97287. * Value of the button/trigger
  97288. */
  97289. value: number;
  97290. /**
  97291. * If the button/trigger is currently touched
  97292. */
  97293. touched: boolean;
  97294. /**
  97295. * If the button/trigger is currently pressed
  97296. */
  97297. pressed: boolean;
  97298. }
  97299. /**
  97300. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  97301. * @hidden
  97302. */
  97303. export interface ExtendedGamepadButton extends GamepadButton {
  97304. /**
  97305. * If the button/trigger is currently pressed
  97306. */
  97307. readonly pressed: boolean;
  97308. /**
  97309. * If the button/trigger is currently touched
  97310. */
  97311. readonly touched: boolean;
  97312. /**
  97313. * Value of the button/trigger
  97314. */
  97315. readonly value: number;
  97316. }
  97317. /** @hidden */
  97318. export interface _GamePadFactory {
  97319. /**
  97320. * Returns whether or not the current gamepad can be created for this type of controller.
  97321. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  97322. * @returns true if it can be created, otherwise false
  97323. */
  97324. canCreate(gamepadInfo: any): boolean;
  97325. /**
  97326. * Creates a new instance of the Gamepad.
  97327. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  97328. * @returns the new gamepad instance
  97329. */
  97330. create(gamepadInfo: any): Gamepad;
  97331. }
  97332. /**
  97333. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  97334. */
  97335. export class PoseEnabledControllerHelper {
  97336. /** @hidden */
  97337. static _ControllerFactories: _GamePadFactory[];
  97338. /** @hidden */
  97339. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  97340. /**
  97341. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  97342. * @param vrGamepad the gamepad to initialized
  97343. * @returns a vr controller of the type the gamepad identified as
  97344. */
  97345. static InitiateController(vrGamepad: any): Gamepad;
  97346. }
  97347. /**
  97348. * Defines the PoseEnabledController object that contains state of a vr capable controller
  97349. */
  97350. export class PoseEnabledController extends Gamepad implements PoseControlled {
  97351. /**
  97352. * If the controller is used in a webXR session
  97353. */
  97354. isXR: boolean;
  97355. private _deviceRoomPosition;
  97356. private _deviceRoomRotationQuaternion;
  97357. /**
  97358. * The device position in babylon space
  97359. */
  97360. devicePosition: Vector3;
  97361. /**
  97362. * The device rotation in babylon space
  97363. */
  97364. deviceRotationQuaternion: Quaternion;
  97365. /**
  97366. * The scale factor of the device in babylon space
  97367. */
  97368. deviceScaleFactor: number;
  97369. /**
  97370. * (Likely devicePosition should be used instead) The device position in its room space
  97371. */
  97372. position: Vector3;
  97373. /**
  97374. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  97375. */
  97376. rotationQuaternion: Quaternion;
  97377. /**
  97378. * The type of controller (Eg. Windows mixed reality)
  97379. */
  97380. controllerType: PoseEnabledControllerType;
  97381. protected _calculatedPosition: Vector3;
  97382. private _calculatedRotation;
  97383. /**
  97384. * The raw pose from the device
  97385. */
  97386. rawPose: DevicePose;
  97387. private _trackPosition;
  97388. private _maxRotationDistFromHeadset;
  97389. private _draggedRoomRotation;
  97390. /**
  97391. * @hidden
  97392. */
  97393. _disableTrackPosition(fixedPosition: Vector3): void;
  97394. /**
  97395. * Internal, the mesh attached to the controller
  97396. * @hidden
  97397. */
  97398. _mesh: Nullable<AbstractMesh>;
  97399. private _poseControlledCamera;
  97400. private _leftHandSystemQuaternion;
  97401. /**
  97402. * Internal, matrix used to convert room space to babylon space
  97403. * @hidden
  97404. */
  97405. _deviceToWorld: Matrix;
  97406. /**
  97407. * Node to be used when casting a ray from the controller
  97408. * @hidden
  97409. */
  97410. _pointingPoseNode: Nullable<TransformNode>;
  97411. /**
  97412. * Name of the child mesh that can be used to cast a ray from the controller
  97413. */
  97414. static readonly POINTING_POSE: string;
  97415. /**
  97416. * Creates a new PoseEnabledController from a gamepad
  97417. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  97418. */
  97419. constructor(browserGamepad: any);
  97420. private _workingMatrix;
  97421. /**
  97422. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  97423. */
  97424. update(): void;
  97425. /**
  97426. * Updates only the pose device and mesh without doing any button event checking
  97427. */
  97428. protected _updatePoseAndMesh(): void;
  97429. /**
  97430. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  97431. * @param poseData raw pose fromthe device
  97432. */
  97433. updateFromDevice(poseData: DevicePose): void;
  97434. /**
  97435. * @hidden
  97436. */
  97437. _meshAttachedObservable: Observable<AbstractMesh>;
  97438. /**
  97439. * Attaches a mesh to the controller
  97440. * @param mesh the mesh to be attached
  97441. */
  97442. attachToMesh(mesh: AbstractMesh): void;
  97443. /**
  97444. * Attaches the controllers mesh to a camera
  97445. * @param camera the camera the mesh should be attached to
  97446. */
  97447. attachToPoseControlledCamera(camera: TargetCamera): void;
  97448. /**
  97449. * Disposes of the controller
  97450. */
  97451. dispose(): void;
  97452. /**
  97453. * The mesh that is attached to the controller
  97454. */
  97455. get mesh(): Nullable<AbstractMesh>;
  97456. /**
  97457. * Gets the ray of the controller in the direction the controller is pointing
  97458. * @param length the length the resulting ray should be
  97459. * @returns a ray in the direction the controller is pointing
  97460. */
  97461. getForwardRay(length?: number): Ray;
  97462. }
  97463. }
  97464. declare module BABYLON {
  97465. /**
  97466. * Defines the WebVRController object that represents controllers tracked in 3D space
  97467. */
  97468. export abstract class WebVRController extends PoseEnabledController {
  97469. /**
  97470. * Internal, the default controller model for the controller
  97471. */
  97472. protected _defaultModel: Nullable<AbstractMesh>;
  97473. /**
  97474. * Fired when the trigger state has changed
  97475. */
  97476. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  97477. /**
  97478. * Fired when the main button state has changed
  97479. */
  97480. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97481. /**
  97482. * Fired when the secondary button state has changed
  97483. */
  97484. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97485. /**
  97486. * Fired when the pad state has changed
  97487. */
  97488. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  97489. /**
  97490. * Fired when controllers stick values have changed
  97491. */
  97492. onPadValuesChangedObservable: Observable<StickValues>;
  97493. /**
  97494. * Array of button availible on the controller
  97495. */
  97496. protected _buttons: Array<MutableGamepadButton>;
  97497. private _onButtonStateChange;
  97498. /**
  97499. * Fired when a controller button's state has changed
  97500. * @param callback the callback containing the button that was modified
  97501. */
  97502. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  97503. /**
  97504. * X and Y axis corresponding to the controllers joystick
  97505. */
  97506. pad: StickValues;
  97507. /**
  97508. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  97509. */
  97510. hand: string;
  97511. /**
  97512. * The default controller model for the controller
  97513. */
  97514. get defaultModel(): Nullable<AbstractMesh>;
  97515. /**
  97516. * Creates a new WebVRController from a gamepad
  97517. * @param vrGamepad the gamepad that the WebVRController should be created from
  97518. */
  97519. constructor(vrGamepad: any);
  97520. /**
  97521. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  97522. */
  97523. update(): void;
  97524. /**
  97525. * Function to be called when a button is modified
  97526. */
  97527. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97528. /**
  97529. * Loads a mesh and attaches it to the controller
  97530. * @param scene the scene the mesh should be added to
  97531. * @param meshLoaded callback for when the mesh has been loaded
  97532. */
  97533. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97534. private _setButtonValue;
  97535. private _changes;
  97536. private _checkChanges;
  97537. /**
  97538. * Disposes of th webVRCOntroller
  97539. */
  97540. dispose(): void;
  97541. }
  97542. }
  97543. declare module BABYLON {
  97544. /**
  97545. * The HemisphericLight simulates the ambient environment light,
  97546. * so the passed direction is the light reflection direction, not the incoming direction.
  97547. */
  97548. export class HemisphericLight extends Light {
  97549. /**
  97550. * The groundColor is the light in the opposite direction to the one specified during creation.
  97551. * 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.
  97552. */
  97553. groundColor: Color3;
  97554. /**
  97555. * The light reflection direction, not the incoming direction.
  97556. */
  97557. direction: Vector3;
  97558. /**
  97559. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  97560. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  97561. * The HemisphericLight can't cast shadows.
  97562. * Documentation : https://doc.babylonjs.com/babylon101/lights
  97563. * @param name The friendly name of the light
  97564. * @param direction The direction of the light reflection
  97565. * @param scene The scene the light belongs to
  97566. */
  97567. constructor(name: string, direction: Vector3, scene: Scene);
  97568. protected _buildUniformLayout(): void;
  97569. /**
  97570. * Returns the string "HemisphericLight".
  97571. * @return The class name
  97572. */
  97573. getClassName(): string;
  97574. /**
  97575. * Sets the HemisphericLight direction towards the passed target (Vector3).
  97576. * Returns the updated direction.
  97577. * @param target The target the direction should point to
  97578. * @return The computed direction
  97579. */
  97580. setDirectionToTarget(target: Vector3): Vector3;
  97581. /**
  97582. * Returns the shadow generator associated to the light.
  97583. * @returns Always null for hemispheric lights because it does not support shadows.
  97584. */
  97585. getShadowGenerator(): Nullable<IShadowGenerator>;
  97586. /**
  97587. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  97588. * @param effect The effect to update
  97589. * @param lightIndex The index of the light in the effect to update
  97590. * @returns The hemispheric light
  97591. */
  97592. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  97593. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  97594. /**
  97595. * Computes the world matrix of the node
  97596. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  97597. * @param useWasUpdatedFlag defines a reserved property
  97598. * @returns the world matrix
  97599. */
  97600. computeWorldMatrix(): Matrix;
  97601. /**
  97602. * Returns the integer 3.
  97603. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  97604. */
  97605. getTypeID(): number;
  97606. /**
  97607. * Prepares the list of defines specific to the light type.
  97608. * @param defines the list of defines
  97609. * @param lightIndex defines the index of the light for the effect
  97610. */
  97611. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  97612. }
  97613. }
  97614. declare module BABYLON {
  97615. /** @hidden */
  97616. export var vrMultiviewToSingleviewPixelShader: {
  97617. name: string;
  97618. shader: string;
  97619. };
  97620. }
  97621. declare module BABYLON {
  97622. /**
  97623. * Renders to multiple views with a single draw call
  97624. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  97625. */
  97626. export class MultiviewRenderTarget extends RenderTargetTexture {
  97627. /**
  97628. * Creates a multiview render target
  97629. * @param scene scene used with the render target
  97630. * @param size the size of the render target (used for each view)
  97631. */
  97632. constructor(scene: Scene, size?: number | {
  97633. width: number;
  97634. height: number;
  97635. } | {
  97636. ratio: number;
  97637. });
  97638. /**
  97639. * @hidden
  97640. * @param faceIndex the face index, if its a cube texture
  97641. */
  97642. _bindFrameBuffer(faceIndex?: number): void;
  97643. /**
  97644. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  97645. * @returns the view count
  97646. */
  97647. getViewCount(): number;
  97648. }
  97649. }
  97650. declare module BABYLON {
  97651. interface Engine {
  97652. /**
  97653. * Creates a new multiview render target
  97654. * @param width defines the width of the texture
  97655. * @param height defines the height of the texture
  97656. * @returns the created multiview texture
  97657. */
  97658. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  97659. /**
  97660. * Binds a multiview framebuffer to be drawn to
  97661. * @param multiviewTexture texture to bind
  97662. */
  97663. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  97664. }
  97665. interface Camera {
  97666. /**
  97667. * @hidden
  97668. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  97669. */
  97670. _useMultiviewToSingleView: boolean;
  97671. /**
  97672. * @hidden
  97673. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  97674. */
  97675. _multiviewTexture: Nullable<RenderTargetTexture>;
  97676. /**
  97677. * @hidden
  97678. * ensures the multiview texture of the camera exists and has the specified width/height
  97679. * @param width height to set on the multiview texture
  97680. * @param height width to set on the multiview texture
  97681. */
  97682. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  97683. }
  97684. interface Scene {
  97685. /** @hidden */
  97686. _transformMatrixR: Matrix;
  97687. /** @hidden */
  97688. _multiviewSceneUbo: Nullable<UniformBuffer>;
  97689. /** @hidden */
  97690. _createMultiviewUbo(): void;
  97691. /** @hidden */
  97692. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  97693. /** @hidden */
  97694. _renderMultiviewToSingleView(camera: Camera): void;
  97695. }
  97696. }
  97697. declare module BABYLON {
  97698. /**
  97699. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  97700. * This will not be used for webXR as it supports displaying texture arrays directly
  97701. */
  97702. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  97703. /**
  97704. * Initializes a VRMultiviewToSingleview
  97705. * @param name name of the post process
  97706. * @param camera camera to be applied to
  97707. * @param scaleFactor scaling factor to the size of the output texture
  97708. */
  97709. constructor(name: string, camera: Camera, scaleFactor: number);
  97710. }
  97711. }
  97712. declare module BABYLON {
  97713. /**
  97714. * Interface used to define additional presentation attributes
  97715. */
  97716. export interface IVRPresentationAttributes {
  97717. /**
  97718. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  97719. */
  97720. highRefreshRate: boolean;
  97721. /**
  97722. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  97723. */
  97724. foveationLevel: number;
  97725. }
  97726. interface Engine {
  97727. /** @hidden */
  97728. _vrDisplay: any;
  97729. /** @hidden */
  97730. _vrSupported: boolean;
  97731. /** @hidden */
  97732. _oldSize: Size;
  97733. /** @hidden */
  97734. _oldHardwareScaleFactor: number;
  97735. /** @hidden */
  97736. _vrExclusivePointerMode: boolean;
  97737. /** @hidden */
  97738. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  97739. /** @hidden */
  97740. _onVRDisplayPointerRestricted: () => void;
  97741. /** @hidden */
  97742. _onVRDisplayPointerUnrestricted: () => void;
  97743. /** @hidden */
  97744. _onVrDisplayConnect: Nullable<(display: any) => void>;
  97745. /** @hidden */
  97746. _onVrDisplayDisconnect: Nullable<() => void>;
  97747. /** @hidden */
  97748. _onVrDisplayPresentChange: Nullable<() => void>;
  97749. /**
  97750. * Observable signaled when VR display mode changes
  97751. */
  97752. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  97753. /**
  97754. * Observable signaled when VR request present is complete
  97755. */
  97756. onVRRequestPresentComplete: Observable<boolean>;
  97757. /**
  97758. * Observable signaled when VR request present starts
  97759. */
  97760. onVRRequestPresentStart: Observable<Engine>;
  97761. /**
  97762. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  97763. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  97764. */
  97765. isInVRExclusivePointerMode: boolean;
  97766. /**
  97767. * Gets a boolean indicating if a webVR device was detected
  97768. * @returns true if a webVR device was detected
  97769. */
  97770. isVRDevicePresent(): boolean;
  97771. /**
  97772. * Gets the current webVR device
  97773. * @returns the current webVR device (or null)
  97774. */
  97775. getVRDevice(): any;
  97776. /**
  97777. * Initializes a webVR display and starts listening to display change events
  97778. * The onVRDisplayChangedObservable will be notified upon these changes
  97779. * @returns A promise containing a VRDisplay and if vr is supported
  97780. */
  97781. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  97782. /** @hidden */
  97783. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  97784. /**
  97785. * Gets or sets the presentation attributes used to configure VR rendering
  97786. */
  97787. vrPresentationAttributes?: IVRPresentationAttributes;
  97788. /**
  97789. * Call this function to switch to webVR mode
  97790. * Will do nothing if webVR is not supported or if there is no webVR device
  97791. * @param options the webvr options provided to the camera. mainly used for multiview
  97792. * @see https://doc.babylonjs.com/how_to/webvr_camera
  97793. */
  97794. enableVR(options: WebVROptions): void;
  97795. /** @hidden */
  97796. _onVRFullScreenTriggered(): void;
  97797. }
  97798. }
  97799. declare module BABYLON {
  97800. /**
  97801. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  97802. * IMPORTANT!! The data is right-hand data.
  97803. * @export
  97804. * @interface DevicePose
  97805. */
  97806. export interface DevicePose {
  97807. /**
  97808. * The position of the device, values in array are [x,y,z].
  97809. */
  97810. readonly position: Nullable<Float32Array>;
  97811. /**
  97812. * The linearVelocity of the device, values in array are [x,y,z].
  97813. */
  97814. readonly linearVelocity: Nullable<Float32Array>;
  97815. /**
  97816. * The linearAcceleration of the device, values in array are [x,y,z].
  97817. */
  97818. readonly linearAcceleration: Nullable<Float32Array>;
  97819. /**
  97820. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  97821. */
  97822. readonly orientation: Nullable<Float32Array>;
  97823. /**
  97824. * The angularVelocity of the device, values in array are [x,y,z].
  97825. */
  97826. readonly angularVelocity: Nullable<Float32Array>;
  97827. /**
  97828. * The angularAcceleration of the device, values in array are [x,y,z].
  97829. */
  97830. readonly angularAcceleration: Nullable<Float32Array>;
  97831. }
  97832. /**
  97833. * Interface representing a pose controlled object in Babylon.
  97834. * A pose controlled object has both regular pose values as well as pose values
  97835. * from an external device such as a VR head mounted display
  97836. */
  97837. export interface PoseControlled {
  97838. /**
  97839. * The position of the object in babylon space.
  97840. */
  97841. position: Vector3;
  97842. /**
  97843. * The rotation quaternion of the object in babylon space.
  97844. */
  97845. rotationQuaternion: Quaternion;
  97846. /**
  97847. * The position of the device in babylon space.
  97848. */
  97849. devicePosition?: Vector3;
  97850. /**
  97851. * The rotation quaternion of the device in babylon space.
  97852. */
  97853. deviceRotationQuaternion: Quaternion;
  97854. /**
  97855. * The raw pose coming from the device.
  97856. */
  97857. rawPose: Nullable<DevicePose>;
  97858. /**
  97859. * The scale of the device to be used when translating from device space to babylon space.
  97860. */
  97861. deviceScaleFactor: number;
  97862. /**
  97863. * Updates the poseControlled values based on the input device pose.
  97864. * @param poseData the pose data to update the object with
  97865. */
  97866. updateFromDevice(poseData: DevicePose): void;
  97867. }
  97868. /**
  97869. * Set of options to customize the webVRCamera
  97870. */
  97871. export interface WebVROptions {
  97872. /**
  97873. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  97874. */
  97875. trackPosition?: boolean;
  97876. /**
  97877. * Sets the scale of the vrDevice in babylon space. (default: 1)
  97878. */
  97879. positionScale?: number;
  97880. /**
  97881. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  97882. */
  97883. displayName?: string;
  97884. /**
  97885. * Should the native controller meshes be initialized. (default: true)
  97886. */
  97887. controllerMeshes?: boolean;
  97888. /**
  97889. * Creating a default HemiLight only on controllers. (default: true)
  97890. */
  97891. defaultLightingOnControllers?: boolean;
  97892. /**
  97893. * If you don't want to use the default VR button of the helper. (default: false)
  97894. */
  97895. useCustomVRButton?: boolean;
  97896. /**
  97897. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  97898. */
  97899. customVRButton?: HTMLButtonElement;
  97900. /**
  97901. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  97902. */
  97903. rayLength?: number;
  97904. /**
  97905. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  97906. */
  97907. defaultHeight?: number;
  97908. /**
  97909. * If multiview should be used if availible (default: false)
  97910. */
  97911. useMultiview?: boolean;
  97912. }
  97913. /**
  97914. * This represents a WebVR camera.
  97915. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  97916. * @example https://doc.babylonjs.com/how_to/webvr_camera
  97917. */
  97918. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  97919. private webVROptions;
  97920. /**
  97921. * @hidden
  97922. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  97923. */
  97924. _vrDevice: any;
  97925. /**
  97926. * The rawPose of the vrDevice.
  97927. */
  97928. rawPose: Nullable<DevicePose>;
  97929. private _onVREnabled;
  97930. private _specsVersion;
  97931. private _attached;
  97932. private _frameData;
  97933. protected _descendants: Array<Node>;
  97934. private _deviceRoomPosition;
  97935. /** @hidden */
  97936. _deviceRoomRotationQuaternion: Quaternion;
  97937. private _standingMatrix;
  97938. /**
  97939. * Represents device position in babylon space.
  97940. */
  97941. devicePosition: Vector3;
  97942. /**
  97943. * Represents device rotation in babylon space.
  97944. */
  97945. deviceRotationQuaternion: Quaternion;
  97946. /**
  97947. * The scale of the device to be used when translating from device space to babylon space.
  97948. */
  97949. deviceScaleFactor: number;
  97950. private _deviceToWorld;
  97951. private _worldToDevice;
  97952. /**
  97953. * References to the webVR controllers for the vrDevice.
  97954. */
  97955. controllers: Array<WebVRController>;
  97956. /**
  97957. * Emits an event when a controller is attached.
  97958. */
  97959. onControllersAttachedObservable: Observable<WebVRController[]>;
  97960. /**
  97961. * Emits an event when a controller's mesh has been loaded;
  97962. */
  97963. onControllerMeshLoadedObservable: Observable<WebVRController>;
  97964. /**
  97965. * Emits an event when the HMD's pose has been updated.
  97966. */
  97967. onPoseUpdatedFromDeviceObservable: Observable<any>;
  97968. private _poseSet;
  97969. /**
  97970. * If the rig cameras be used as parent instead of this camera.
  97971. */
  97972. rigParenting: boolean;
  97973. private _lightOnControllers;
  97974. private _defaultHeight?;
  97975. /**
  97976. * Instantiates a WebVRFreeCamera.
  97977. * @param name The name of the WebVRFreeCamera
  97978. * @param position The starting anchor position for the camera
  97979. * @param scene The scene the camera belongs to
  97980. * @param webVROptions a set of customizable options for the webVRCamera
  97981. */
  97982. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  97983. /**
  97984. * Gets the device distance from the ground in meters.
  97985. * @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.
  97986. */
  97987. deviceDistanceToRoomGround(): number;
  97988. /**
  97989. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  97990. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  97991. */
  97992. useStandingMatrix(callback?: (bool: boolean) => void): void;
  97993. /**
  97994. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  97995. * @returns A promise with a boolean set to if the standing matrix is supported.
  97996. */
  97997. useStandingMatrixAsync(): Promise<boolean>;
  97998. /**
  97999. * Disposes the camera
  98000. */
  98001. dispose(): void;
  98002. /**
  98003. * Gets a vrController by name.
  98004. * @param name The name of the controller to retreive
  98005. * @returns the controller matching the name specified or null if not found
  98006. */
  98007. getControllerByName(name: string): Nullable<WebVRController>;
  98008. private _leftController;
  98009. /**
  98010. * The controller corresponding to the users left hand.
  98011. */
  98012. get leftController(): Nullable<WebVRController>;
  98013. private _rightController;
  98014. /**
  98015. * The controller corresponding to the users right hand.
  98016. */
  98017. get rightController(): Nullable<WebVRController>;
  98018. /**
  98019. * Casts a ray forward from the vrCamera's gaze.
  98020. * @param length Length of the ray (default: 100)
  98021. * @returns the ray corresponding to the gaze
  98022. */
  98023. getForwardRay(length?: number): Ray;
  98024. /**
  98025. * @hidden
  98026. * Updates the camera based on device's frame data
  98027. */
  98028. _checkInputs(): void;
  98029. /**
  98030. * Updates the poseControlled values based on the input device pose.
  98031. * @param poseData Pose coming from the device
  98032. */
  98033. updateFromDevice(poseData: DevicePose): void;
  98034. private _htmlElementAttached;
  98035. private _detachIfAttached;
  98036. /**
  98037. * WebVR's attach control will start broadcasting frames to the device.
  98038. * Note that in certain browsers (chrome for example) this function must be called
  98039. * within a user-interaction callback. Example:
  98040. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  98041. *
  98042. * @param element html element to attach the vrDevice to
  98043. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  98044. */
  98045. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98046. /**
  98047. * Detaches the camera from the html element and disables VR
  98048. *
  98049. * @param element html element to detach from
  98050. */
  98051. detachControl(element: HTMLElement): void;
  98052. /**
  98053. * @returns the name of this class
  98054. */
  98055. getClassName(): string;
  98056. /**
  98057. * Calls resetPose on the vrDisplay
  98058. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  98059. */
  98060. resetToCurrentRotation(): void;
  98061. /**
  98062. * @hidden
  98063. * Updates the rig cameras (left and right eye)
  98064. */
  98065. _updateRigCameras(): void;
  98066. private _workingVector;
  98067. private _oneVector;
  98068. private _workingMatrix;
  98069. private updateCacheCalled;
  98070. private _correctPositionIfNotTrackPosition;
  98071. /**
  98072. * @hidden
  98073. * Updates the cached values of the camera
  98074. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  98075. */
  98076. _updateCache(ignoreParentClass?: boolean): void;
  98077. /**
  98078. * @hidden
  98079. * Get current device position in babylon world
  98080. */
  98081. _computeDevicePosition(): void;
  98082. /**
  98083. * Updates the current device position and rotation in the babylon world
  98084. */
  98085. update(): void;
  98086. /**
  98087. * @hidden
  98088. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  98089. * @returns an identity matrix
  98090. */
  98091. _getViewMatrix(): Matrix;
  98092. private _tmpMatrix;
  98093. /**
  98094. * This function is called by the two RIG cameras.
  98095. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  98096. * @hidden
  98097. */
  98098. _getWebVRViewMatrix(): Matrix;
  98099. /** @hidden */
  98100. _getWebVRProjectionMatrix(): Matrix;
  98101. private _onGamepadConnectedObserver;
  98102. private _onGamepadDisconnectedObserver;
  98103. private _updateCacheWhenTrackingDisabledObserver;
  98104. /**
  98105. * Initializes the controllers and their meshes
  98106. */
  98107. initControllers(): void;
  98108. }
  98109. }
  98110. declare module BABYLON {
  98111. /**
  98112. * "Static Class" containing the most commonly used helper while dealing with material for
  98113. * rendering purpose.
  98114. *
  98115. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  98116. *
  98117. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  98118. */
  98119. export class MaterialHelper {
  98120. /**
  98121. * Bind the current view position to an effect.
  98122. * @param effect The effect to be bound
  98123. * @param scene The scene the eyes position is used from
  98124. * @param variableName name of the shader variable that will hold the eye position
  98125. */
  98126. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  98127. /**
  98128. * Helps preparing the defines values about the UVs in used in the effect.
  98129. * UVs are shared as much as we can accross channels in the shaders.
  98130. * @param texture The texture we are preparing the UVs for
  98131. * @param defines The defines to update
  98132. * @param key The channel key "diffuse", "specular"... used in the shader
  98133. */
  98134. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  98135. /**
  98136. * Binds a texture matrix value to its corrsponding uniform
  98137. * @param texture The texture to bind the matrix for
  98138. * @param uniformBuffer The uniform buffer receivin the data
  98139. * @param key The channel key "diffuse", "specular"... used in the shader
  98140. */
  98141. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  98142. /**
  98143. * Gets the current status of the fog (should it be enabled?)
  98144. * @param mesh defines the mesh to evaluate for fog support
  98145. * @param scene defines the hosting scene
  98146. * @returns true if fog must be enabled
  98147. */
  98148. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  98149. /**
  98150. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  98151. * @param mesh defines the current mesh
  98152. * @param scene defines the current scene
  98153. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  98154. * @param pointsCloud defines if point cloud rendering has to be turned on
  98155. * @param fogEnabled defines if fog has to be turned on
  98156. * @param alphaTest defines if alpha testing has to be turned on
  98157. * @param defines defines the current list of defines
  98158. */
  98159. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  98160. /**
  98161. * Helper used to prepare the list of defines associated with frame values for shader compilation
  98162. * @param scene defines the current scene
  98163. * @param engine defines the current engine
  98164. * @param defines specifies the list of active defines
  98165. * @param useInstances defines if instances have to be turned on
  98166. * @param useClipPlane defines if clip plane have to be turned on
  98167. * @param useInstances defines if instances have to be turned on
  98168. * @param useThinInstances defines if thin instances have to be turned on
  98169. */
  98170. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  98171. /**
  98172. * Prepares the defines for bones
  98173. * @param mesh The mesh containing the geometry data we will draw
  98174. * @param defines The defines to update
  98175. */
  98176. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  98177. /**
  98178. * Prepares the defines for morph targets
  98179. * @param mesh The mesh containing the geometry data we will draw
  98180. * @param defines The defines to update
  98181. */
  98182. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  98183. /**
  98184. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  98185. * @param mesh The mesh containing the geometry data we will draw
  98186. * @param defines The defines to update
  98187. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  98188. * @param useBones Precise whether bones should be used or not (override mesh info)
  98189. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  98190. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  98191. * @returns false if defines are considered not dirty and have not been checked
  98192. */
  98193. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  98194. /**
  98195. * Prepares the defines related to multiview
  98196. * @param scene The scene we are intending to draw
  98197. * @param defines The defines to update
  98198. */
  98199. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  98200. /**
  98201. * Prepares the defines related to the prepass
  98202. * @param scene The scene we are intending to draw
  98203. * @param defines The defines to update
  98204. * @param shouldRenderToMRT Indicates if this material renders to several textures in the prepass
  98205. */
  98206. static PrepareDefinesForPrePass(scene: Scene, defines: any, shouldRenderToMRT: boolean): void;
  98207. /**
  98208. * Prepares the defines related to the light information passed in parameter
  98209. * @param scene The scene we are intending to draw
  98210. * @param mesh The mesh the effect is compiling for
  98211. * @param light The light the effect is compiling for
  98212. * @param lightIndex The index of the light
  98213. * @param defines The defines to update
  98214. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  98215. * @param state Defines the current state regarding what is needed (normals, etc...)
  98216. */
  98217. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  98218. needNormals: boolean;
  98219. needRebuild: boolean;
  98220. shadowEnabled: boolean;
  98221. specularEnabled: boolean;
  98222. lightmapMode: boolean;
  98223. }): void;
  98224. /**
  98225. * Prepares the defines related to the light information passed in parameter
  98226. * @param scene The scene we are intending to draw
  98227. * @param mesh The mesh the effect is compiling for
  98228. * @param defines The defines to update
  98229. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  98230. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  98231. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  98232. * @returns true if normals will be required for the rest of the effect
  98233. */
  98234. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  98235. /**
  98236. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  98237. * @param lightIndex defines the light index
  98238. * @param uniformsList The uniform list
  98239. * @param samplersList The sampler list
  98240. * @param projectedLightTexture defines if projected texture must be used
  98241. * @param uniformBuffersList defines an optional list of uniform buffers
  98242. */
  98243. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  98244. /**
  98245. * Prepares the uniforms and samplers list to be used in the effect
  98246. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  98247. * @param samplersList The sampler list
  98248. * @param defines The defines helping in the list generation
  98249. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  98250. */
  98251. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  98252. /**
  98253. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  98254. * @param defines The defines to update while falling back
  98255. * @param fallbacks The authorized effect fallbacks
  98256. * @param maxSimultaneousLights The maximum number of lights allowed
  98257. * @param rank the current rank of the Effect
  98258. * @returns The newly affected rank
  98259. */
  98260. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  98261. private static _TmpMorphInfluencers;
  98262. /**
  98263. * Prepares the list of attributes required for morph targets according to the effect defines.
  98264. * @param attribs The current list of supported attribs
  98265. * @param mesh The mesh to prepare the morph targets attributes for
  98266. * @param influencers The number of influencers
  98267. */
  98268. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  98269. /**
  98270. * Prepares the list of attributes required for morph targets according to the effect defines.
  98271. * @param attribs The current list of supported attribs
  98272. * @param mesh The mesh to prepare the morph targets attributes for
  98273. * @param defines The current Defines of the effect
  98274. */
  98275. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  98276. /**
  98277. * Prepares the list of attributes required for bones according to the effect defines.
  98278. * @param attribs The current list of supported attribs
  98279. * @param mesh The mesh to prepare the bones attributes for
  98280. * @param defines The current Defines of the effect
  98281. * @param fallbacks The current efffect fallback strategy
  98282. */
  98283. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  98284. /**
  98285. * Check and prepare the list of attributes required for instances according to the effect defines.
  98286. * @param attribs The current list of supported attribs
  98287. * @param defines The current MaterialDefines of the effect
  98288. */
  98289. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  98290. /**
  98291. * Add the list of attributes required for instances to the attribs array.
  98292. * @param attribs The current list of supported attribs
  98293. */
  98294. static PushAttributesForInstances(attribs: string[]): void;
  98295. /**
  98296. * Binds the light information to the effect.
  98297. * @param light The light containing the generator
  98298. * @param effect The effect we are binding the data to
  98299. * @param lightIndex The light index in the effect used to render
  98300. */
  98301. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  98302. /**
  98303. * Binds the lights information from the scene to the effect for the given mesh.
  98304. * @param light Light to bind
  98305. * @param lightIndex Light index
  98306. * @param scene The scene where the light belongs to
  98307. * @param effect The effect we are binding the data to
  98308. * @param useSpecular Defines if specular is supported
  98309. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98310. */
  98311. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  98312. /**
  98313. * Binds the lights information from the scene to the effect for the given mesh.
  98314. * @param scene The scene the lights belongs to
  98315. * @param mesh The mesh we are binding the information to render
  98316. * @param effect The effect we are binding the data to
  98317. * @param defines The generated defines for the effect
  98318. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  98319. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98320. */
  98321. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  98322. private static _tempFogColor;
  98323. /**
  98324. * Binds the fog information from the scene to the effect for the given mesh.
  98325. * @param scene The scene the lights belongs to
  98326. * @param mesh The mesh we are binding the information to render
  98327. * @param effect The effect we are binding the data to
  98328. * @param linearSpace Defines if the fog effect is applied in linear space
  98329. */
  98330. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  98331. /**
  98332. * Binds the bones information from the mesh to the effect.
  98333. * @param mesh The mesh we are binding the information to render
  98334. * @param effect The effect we are binding the data to
  98335. */
  98336. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  98337. /**
  98338. * Binds the morph targets information from the mesh to the effect.
  98339. * @param abstractMesh The mesh we are binding the information to render
  98340. * @param effect The effect we are binding the data to
  98341. */
  98342. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  98343. /**
  98344. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  98345. * @param defines The generated defines used in the effect
  98346. * @param effect The effect we are binding the data to
  98347. * @param scene The scene we are willing to render with logarithmic scale for
  98348. */
  98349. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  98350. /**
  98351. * Binds the clip plane information from the scene to the effect.
  98352. * @param scene The scene the clip plane information are extracted from
  98353. * @param effect The effect we are binding the data to
  98354. */
  98355. static BindClipPlane(effect: Effect, scene: Scene): void;
  98356. }
  98357. }
  98358. declare module BABYLON {
  98359. /**
  98360. * Block used to expose an input value
  98361. */
  98362. export class InputBlock extends NodeMaterialBlock {
  98363. private _mode;
  98364. private _associatedVariableName;
  98365. private _storedValue;
  98366. private _valueCallback;
  98367. private _type;
  98368. private _animationType;
  98369. /** Gets or set a value used to limit the range of float values */
  98370. min: number;
  98371. /** Gets or set a value used to limit the range of float values */
  98372. max: number;
  98373. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  98374. isBoolean: boolean;
  98375. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  98376. matrixMode: number;
  98377. /** @hidden */
  98378. _systemValue: Nullable<NodeMaterialSystemValues>;
  98379. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  98380. visibleInInspector: boolean;
  98381. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  98382. isConstant: boolean;
  98383. /** Gets or sets the group to use to display this block in the Inspector */
  98384. groupInInspector: string;
  98385. /** Gets an observable raised when the value is changed */
  98386. onValueChangedObservable: Observable<InputBlock>;
  98387. /**
  98388. * Gets or sets the connection point type (default is float)
  98389. */
  98390. get type(): NodeMaterialBlockConnectionPointTypes;
  98391. /**
  98392. * Creates a new InputBlock
  98393. * @param name defines the block name
  98394. * @param target defines the target of that block (Vertex by default)
  98395. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  98396. */
  98397. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  98398. /**
  98399. * Gets the output component
  98400. */
  98401. get output(): NodeMaterialConnectionPoint;
  98402. /**
  98403. * Set the source of this connection point to a vertex attribute
  98404. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  98405. * @returns the current connection point
  98406. */
  98407. setAsAttribute(attributeName?: string): InputBlock;
  98408. /**
  98409. * Set the source of this connection point to a system value
  98410. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  98411. * @returns the current connection point
  98412. */
  98413. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  98414. /**
  98415. * Gets or sets the value of that point.
  98416. * Please note that this value will be ignored if valueCallback is defined
  98417. */
  98418. get value(): any;
  98419. set value(value: any);
  98420. /**
  98421. * Gets or sets a callback used to get the value of that point.
  98422. * Please note that setting this value will force the connection point to ignore the value property
  98423. */
  98424. get valueCallback(): () => any;
  98425. set valueCallback(value: () => any);
  98426. /**
  98427. * Gets or sets the associated variable name in the shader
  98428. */
  98429. get associatedVariableName(): string;
  98430. set associatedVariableName(value: string);
  98431. /** Gets or sets the type of animation applied to the input */
  98432. get animationType(): AnimatedInputBlockTypes;
  98433. set animationType(value: AnimatedInputBlockTypes);
  98434. /**
  98435. * Gets a boolean indicating that this connection point not defined yet
  98436. */
  98437. get isUndefined(): boolean;
  98438. /**
  98439. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  98440. * In this case the connection point name must be the name of the uniform to use.
  98441. * Can only be set on inputs
  98442. */
  98443. get isUniform(): boolean;
  98444. set isUniform(value: boolean);
  98445. /**
  98446. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  98447. * In this case the connection point name must be the name of the attribute to use
  98448. * Can only be set on inputs
  98449. */
  98450. get isAttribute(): boolean;
  98451. set isAttribute(value: boolean);
  98452. /**
  98453. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  98454. * Can only be set on exit points
  98455. */
  98456. get isVarying(): boolean;
  98457. set isVarying(value: boolean);
  98458. /**
  98459. * Gets a boolean indicating that the current connection point is a system value
  98460. */
  98461. get isSystemValue(): boolean;
  98462. /**
  98463. * Gets or sets the current well known value or null if not defined as a system value
  98464. */
  98465. get systemValue(): Nullable<NodeMaterialSystemValues>;
  98466. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  98467. /**
  98468. * Gets the current class name
  98469. * @returns the class name
  98470. */
  98471. getClassName(): string;
  98472. /**
  98473. * Animate the input if animationType !== None
  98474. * @param scene defines the rendering scene
  98475. */
  98476. animate(scene: Scene): void;
  98477. private _emitDefine;
  98478. initialize(state: NodeMaterialBuildState): void;
  98479. /**
  98480. * Set the input block to its default value (based on its type)
  98481. */
  98482. setDefaultValue(): void;
  98483. private _emitConstant;
  98484. /** @hidden */
  98485. get _noContextSwitch(): boolean;
  98486. private _emit;
  98487. /** @hidden */
  98488. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  98489. /** @hidden */
  98490. _transmit(effect: Effect, scene: Scene): void;
  98491. protected _buildBlock(state: NodeMaterialBuildState): void;
  98492. protected _dumpPropertiesCode(): string;
  98493. dispose(): void;
  98494. serialize(): any;
  98495. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98496. }
  98497. }
  98498. declare module BABYLON {
  98499. /**
  98500. * Enum used to define the compatibility state between two connection points
  98501. */
  98502. export enum NodeMaterialConnectionPointCompatibilityStates {
  98503. /** Points are compatibles */
  98504. Compatible = 0,
  98505. /** Points are incompatible because of their types */
  98506. TypeIncompatible = 1,
  98507. /** Points are incompatible because of their targets (vertex vs fragment) */
  98508. TargetIncompatible = 2
  98509. }
  98510. /**
  98511. * Defines the direction of a connection point
  98512. */
  98513. export enum NodeMaterialConnectionPointDirection {
  98514. /** Input */
  98515. Input = 0,
  98516. /** Output */
  98517. Output = 1
  98518. }
  98519. /**
  98520. * Defines a connection point for a block
  98521. */
  98522. export class NodeMaterialConnectionPoint {
  98523. /** @hidden */
  98524. _ownerBlock: NodeMaterialBlock;
  98525. /** @hidden */
  98526. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  98527. private _endpoints;
  98528. private _associatedVariableName;
  98529. private _direction;
  98530. /** @hidden */
  98531. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  98532. /** @hidden */
  98533. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  98534. private _type;
  98535. /** @hidden */
  98536. _enforceAssociatedVariableName: boolean;
  98537. /** Gets the direction of the point */
  98538. get direction(): NodeMaterialConnectionPointDirection;
  98539. /** Indicates that this connection point needs dual validation before being connected to another point */
  98540. needDualDirectionValidation: boolean;
  98541. /**
  98542. * Gets or sets the additional types supported by this connection point
  98543. */
  98544. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  98545. /**
  98546. * Gets or sets the additional types excluded by this connection point
  98547. */
  98548. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  98549. /**
  98550. * Observable triggered when this point is connected
  98551. */
  98552. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  98553. /**
  98554. * Gets or sets the associated variable name in the shader
  98555. */
  98556. get associatedVariableName(): string;
  98557. set associatedVariableName(value: string);
  98558. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  98559. get innerType(): NodeMaterialBlockConnectionPointTypes;
  98560. /**
  98561. * Gets or sets the connection point type (default is float)
  98562. */
  98563. get type(): NodeMaterialBlockConnectionPointTypes;
  98564. set type(value: NodeMaterialBlockConnectionPointTypes);
  98565. /**
  98566. * Gets or sets the connection point name
  98567. */
  98568. name: string;
  98569. /**
  98570. * Gets or sets the connection point name
  98571. */
  98572. displayName: string;
  98573. /**
  98574. * Gets or sets a boolean indicating that this connection point can be omitted
  98575. */
  98576. isOptional: boolean;
  98577. /**
  98578. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  98579. */
  98580. isExposedOnFrame: boolean;
  98581. /**
  98582. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  98583. */
  98584. define: string;
  98585. /** @hidden */
  98586. _prioritizeVertex: boolean;
  98587. private _target;
  98588. /** Gets or sets the target of that connection point */
  98589. get target(): NodeMaterialBlockTargets;
  98590. set target(value: NodeMaterialBlockTargets);
  98591. /**
  98592. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  98593. */
  98594. get isConnected(): boolean;
  98595. /**
  98596. * Gets a boolean indicating that the current point is connected to an input block
  98597. */
  98598. get isConnectedToInputBlock(): boolean;
  98599. /**
  98600. * Gets a the connected input block (if any)
  98601. */
  98602. get connectInputBlock(): Nullable<InputBlock>;
  98603. /** Get the other side of the connection (if any) */
  98604. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  98605. /** Get the block that owns this connection point */
  98606. get ownerBlock(): NodeMaterialBlock;
  98607. /** Get the block connected on the other side of this connection (if any) */
  98608. get sourceBlock(): Nullable<NodeMaterialBlock>;
  98609. /** Get the block connected on the endpoints of this connection (if any) */
  98610. get connectedBlocks(): Array<NodeMaterialBlock>;
  98611. /** Gets the list of connected endpoints */
  98612. get endpoints(): NodeMaterialConnectionPoint[];
  98613. /** Gets a boolean indicating if that output point is connected to at least one input */
  98614. get hasEndpoints(): boolean;
  98615. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  98616. get isConnectedInVertexShader(): boolean;
  98617. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  98618. get isConnectedInFragmentShader(): boolean;
  98619. /**
  98620. * Creates a block suitable to be used as an input for this input point.
  98621. * If null is returned, a block based on the point type will be created.
  98622. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  98623. */
  98624. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  98625. /**
  98626. * Creates a new connection point
  98627. * @param name defines the connection point name
  98628. * @param ownerBlock defines the block hosting this connection point
  98629. * @param direction defines the direction of the connection point
  98630. */
  98631. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  98632. /**
  98633. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  98634. * @returns the class name
  98635. */
  98636. getClassName(): string;
  98637. /**
  98638. * Gets a boolean indicating if the current point can be connected to another point
  98639. * @param connectionPoint defines the other connection point
  98640. * @returns a boolean
  98641. */
  98642. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  98643. /**
  98644. * Gets a number indicating if the current point can be connected to another point
  98645. * @param connectionPoint defines the other connection point
  98646. * @returns a number defining the compatibility state
  98647. */
  98648. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  98649. /**
  98650. * Connect this point to another connection point
  98651. * @param connectionPoint defines the other connection point
  98652. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  98653. * @returns the current connection point
  98654. */
  98655. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  98656. /**
  98657. * Disconnect this point from one of his endpoint
  98658. * @param endpoint defines the other connection point
  98659. * @returns the current connection point
  98660. */
  98661. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  98662. /**
  98663. * Serializes this point in a JSON representation
  98664. * @param isInput defines if the connection point is an input (default is true)
  98665. * @returns the serialized point object
  98666. */
  98667. serialize(isInput?: boolean): any;
  98668. /**
  98669. * Release resources
  98670. */
  98671. dispose(): void;
  98672. }
  98673. }
  98674. declare module BABYLON {
  98675. /**
  98676. * Enum used to define the material modes
  98677. */
  98678. export enum NodeMaterialModes {
  98679. /** Regular material */
  98680. Material = 0,
  98681. /** For post process */
  98682. PostProcess = 1,
  98683. /** For particle system */
  98684. Particle = 2
  98685. }
  98686. }
  98687. declare module BABYLON {
  98688. /**
  98689. * Block used to read a texture from a sampler
  98690. */
  98691. export class TextureBlock extends NodeMaterialBlock {
  98692. private _defineName;
  98693. private _linearDefineName;
  98694. private _gammaDefineName;
  98695. private _tempTextureRead;
  98696. private _samplerName;
  98697. private _transformedUVName;
  98698. private _textureTransformName;
  98699. private _textureInfoName;
  98700. private _mainUVName;
  98701. private _mainUVDefineName;
  98702. private _fragmentOnly;
  98703. /**
  98704. * Gets or sets the texture associated with the node
  98705. */
  98706. texture: Nullable<Texture>;
  98707. /**
  98708. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98709. */
  98710. convertToGammaSpace: boolean;
  98711. /**
  98712. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98713. */
  98714. convertToLinearSpace: boolean;
  98715. /**
  98716. * Create a new TextureBlock
  98717. * @param name defines the block name
  98718. */
  98719. constructor(name: string, fragmentOnly?: boolean);
  98720. /**
  98721. * Gets the current class name
  98722. * @returns the class name
  98723. */
  98724. getClassName(): string;
  98725. /**
  98726. * Gets the uv input component
  98727. */
  98728. get uv(): NodeMaterialConnectionPoint;
  98729. /**
  98730. * Gets the rgba output component
  98731. */
  98732. get rgba(): NodeMaterialConnectionPoint;
  98733. /**
  98734. * Gets the rgb output component
  98735. */
  98736. get rgb(): NodeMaterialConnectionPoint;
  98737. /**
  98738. * Gets the r output component
  98739. */
  98740. get r(): NodeMaterialConnectionPoint;
  98741. /**
  98742. * Gets the g output component
  98743. */
  98744. get g(): NodeMaterialConnectionPoint;
  98745. /**
  98746. * Gets the b output component
  98747. */
  98748. get b(): NodeMaterialConnectionPoint;
  98749. /**
  98750. * Gets the a output component
  98751. */
  98752. get a(): NodeMaterialConnectionPoint;
  98753. get target(): NodeMaterialBlockTargets;
  98754. autoConfigure(material: NodeMaterial): void;
  98755. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  98756. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98757. isReady(): boolean;
  98758. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  98759. private get _isMixed();
  98760. private _injectVertexCode;
  98761. private _writeTextureRead;
  98762. private _writeOutput;
  98763. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98764. protected _dumpPropertiesCode(): string;
  98765. serialize(): any;
  98766. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98767. }
  98768. }
  98769. declare module BABYLON {
  98770. /** @hidden */
  98771. export var reflectionFunction: {
  98772. name: string;
  98773. shader: string;
  98774. };
  98775. }
  98776. declare module BABYLON {
  98777. /**
  98778. * Base block used to read a reflection texture from a sampler
  98779. */
  98780. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  98781. /** @hidden */
  98782. _define3DName: string;
  98783. /** @hidden */
  98784. _defineCubicName: string;
  98785. /** @hidden */
  98786. _defineExplicitName: string;
  98787. /** @hidden */
  98788. _defineProjectionName: string;
  98789. /** @hidden */
  98790. _defineLocalCubicName: string;
  98791. /** @hidden */
  98792. _defineSphericalName: string;
  98793. /** @hidden */
  98794. _definePlanarName: string;
  98795. /** @hidden */
  98796. _defineEquirectangularName: string;
  98797. /** @hidden */
  98798. _defineMirroredEquirectangularFixedName: string;
  98799. /** @hidden */
  98800. _defineEquirectangularFixedName: string;
  98801. /** @hidden */
  98802. _defineSkyboxName: string;
  98803. /** @hidden */
  98804. _defineOppositeZ: string;
  98805. /** @hidden */
  98806. _cubeSamplerName: string;
  98807. /** @hidden */
  98808. _2DSamplerName: string;
  98809. protected _positionUVWName: string;
  98810. protected _directionWName: string;
  98811. protected _reflectionVectorName: string;
  98812. /** @hidden */
  98813. _reflectionCoordsName: string;
  98814. /** @hidden */
  98815. _reflectionMatrixName: string;
  98816. protected _reflectionColorName: string;
  98817. /**
  98818. * Gets or sets the texture associated with the node
  98819. */
  98820. texture: Nullable<BaseTexture>;
  98821. /**
  98822. * Create a new ReflectionTextureBaseBlock
  98823. * @param name defines the block name
  98824. */
  98825. constructor(name: string);
  98826. /**
  98827. * Gets the current class name
  98828. * @returns the class name
  98829. */
  98830. getClassName(): string;
  98831. /**
  98832. * Gets the world position input component
  98833. */
  98834. abstract get position(): NodeMaterialConnectionPoint;
  98835. /**
  98836. * Gets the world position input component
  98837. */
  98838. abstract get worldPosition(): NodeMaterialConnectionPoint;
  98839. /**
  98840. * Gets the world normal input component
  98841. */
  98842. abstract get worldNormal(): NodeMaterialConnectionPoint;
  98843. /**
  98844. * Gets the world input component
  98845. */
  98846. abstract get world(): NodeMaterialConnectionPoint;
  98847. /**
  98848. * Gets the camera (or eye) position component
  98849. */
  98850. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  98851. /**
  98852. * Gets the view input component
  98853. */
  98854. abstract get view(): NodeMaterialConnectionPoint;
  98855. protected _getTexture(): Nullable<BaseTexture>;
  98856. autoConfigure(material: NodeMaterial): void;
  98857. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98858. isReady(): boolean;
  98859. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  98860. /**
  98861. * Gets the code to inject in the vertex shader
  98862. * @param state current state of the node material building
  98863. * @returns the shader code
  98864. */
  98865. handleVertexSide(state: NodeMaterialBuildState): string;
  98866. /**
  98867. * Handles the inits for the fragment code path
  98868. * @param state node material build state
  98869. */
  98870. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  98871. /**
  98872. * Generates the reflection coords code for the fragment code path
  98873. * @param worldNormalVarName name of the world normal variable
  98874. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  98875. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  98876. * @returns the shader code
  98877. */
  98878. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  98879. /**
  98880. * Generates the reflection color code for the fragment code path
  98881. * @param lodVarName name of the lod variable
  98882. * @param swizzleLookupTexture swizzle to use for the final color variable
  98883. * @returns the shader code
  98884. */
  98885. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  98886. /**
  98887. * Generates the code corresponding to the connected output points
  98888. * @param state node material build state
  98889. * @param varName name of the variable to output
  98890. * @returns the shader code
  98891. */
  98892. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  98893. protected _buildBlock(state: NodeMaterialBuildState): this;
  98894. protected _dumpPropertiesCode(): string;
  98895. serialize(): any;
  98896. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98897. }
  98898. }
  98899. declare module BABYLON {
  98900. /**
  98901. * Defines a connection point to be used for points with a custom object type
  98902. */
  98903. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  98904. private _blockType;
  98905. private _blockName;
  98906. private _nameForCheking?;
  98907. /**
  98908. * Creates a new connection point
  98909. * @param name defines the connection point name
  98910. * @param ownerBlock defines the block hosting this connection point
  98911. * @param direction defines the direction of the connection point
  98912. */
  98913. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  98914. /**
  98915. * Gets a number indicating if the current point can be connected to another point
  98916. * @param connectionPoint defines the other connection point
  98917. * @returns a number defining the compatibility state
  98918. */
  98919. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  98920. /**
  98921. * Creates a block suitable to be used as an input for this input point.
  98922. * If null is returned, a block based on the point type will be created.
  98923. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  98924. */
  98925. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  98926. }
  98927. }
  98928. declare module BABYLON {
  98929. /**
  98930. * Enum defining the type of properties that can be edited in the property pages in the NME
  98931. */
  98932. export enum PropertyTypeForEdition {
  98933. /** property is a boolean */
  98934. Boolean = 0,
  98935. /** property is a float */
  98936. Float = 1,
  98937. /** property is a Vector2 */
  98938. Vector2 = 2,
  98939. /** property is a list of values */
  98940. List = 3
  98941. }
  98942. /**
  98943. * Interface that defines an option in a variable of type list
  98944. */
  98945. export interface IEditablePropertyListOption {
  98946. /** label of the option */
  98947. "label": string;
  98948. /** value of the option */
  98949. "value": number;
  98950. }
  98951. /**
  98952. * Interface that defines the options available for an editable property
  98953. */
  98954. export interface IEditablePropertyOption {
  98955. /** min value */
  98956. "min"?: number;
  98957. /** max value */
  98958. "max"?: number;
  98959. /** notifiers: indicates which actions to take when the property is changed */
  98960. "notifiers"?: {
  98961. /** the material should be rebuilt */
  98962. "rebuild"?: boolean;
  98963. /** the preview should be updated */
  98964. "update"?: boolean;
  98965. };
  98966. /** list of the options for a variable of type list */
  98967. "options"?: IEditablePropertyListOption[];
  98968. }
  98969. /**
  98970. * Interface that describes an editable property
  98971. */
  98972. export interface IPropertyDescriptionForEdition {
  98973. /** name of the property */
  98974. "propertyName": string;
  98975. /** display name of the property */
  98976. "displayName": string;
  98977. /** type of the property */
  98978. "type": PropertyTypeForEdition;
  98979. /** group of the property - all properties with the same group value will be displayed in a specific section */
  98980. "groupName": string;
  98981. /** options for the property */
  98982. "options": IEditablePropertyOption;
  98983. }
  98984. /**
  98985. * Decorator that flags a property in a node material block as being editable
  98986. */
  98987. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  98988. }
  98989. declare module BABYLON {
  98990. /**
  98991. * Block used to implement the refraction part of the sub surface module of the PBR material
  98992. */
  98993. export class RefractionBlock extends NodeMaterialBlock {
  98994. /** @hidden */
  98995. _define3DName: string;
  98996. /** @hidden */
  98997. _refractionMatrixName: string;
  98998. /** @hidden */
  98999. _defineLODRefractionAlpha: string;
  99000. /** @hidden */
  99001. _defineLinearSpecularRefraction: string;
  99002. /** @hidden */
  99003. _defineOppositeZ: string;
  99004. /** @hidden */
  99005. _cubeSamplerName: string;
  99006. /** @hidden */
  99007. _2DSamplerName: string;
  99008. /** @hidden */
  99009. _vRefractionMicrosurfaceInfosName: string;
  99010. /** @hidden */
  99011. _vRefractionInfosName: string;
  99012. private _scene;
  99013. /**
  99014. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  99015. * Materials half opaque for instance using refraction could benefit from this control.
  99016. */
  99017. linkRefractionWithTransparency: boolean;
  99018. /**
  99019. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  99020. */
  99021. invertRefractionY: boolean;
  99022. /**
  99023. * Gets or sets the texture associated with the node
  99024. */
  99025. texture: Nullable<BaseTexture>;
  99026. /**
  99027. * Create a new RefractionBlock
  99028. * @param name defines the block name
  99029. */
  99030. constructor(name: string);
  99031. /**
  99032. * Gets the current class name
  99033. * @returns the class name
  99034. */
  99035. getClassName(): string;
  99036. /**
  99037. * Gets the intensity input component
  99038. */
  99039. get intensity(): NodeMaterialConnectionPoint;
  99040. /**
  99041. * Gets the index of refraction input component
  99042. */
  99043. get indexOfRefraction(): NodeMaterialConnectionPoint;
  99044. /**
  99045. * Gets the tint at distance input component
  99046. */
  99047. get tintAtDistance(): NodeMaterialConnectionPoint;
  99048. /**
  99049. * Gets the view input component
  99050. */
  99051. get view(): NodeMaterialConnectionPoint;
  99052. /**
  99053. * Gets the refraction object output component
  99054. */
  99055. get refraction(): NodeMaterialConnectionPoint;
  99056. /**
  99057. * Returns true if the block has a texture
  99058. */
  99059. get hasTexture(): boolean;
  99060. protected _getTexture(): Nullable<BaseTexture>;
  99061. autoConfigure(material: NodeMaterial): void;
  99062. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99063. isReady(): boolean;
  99064. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  99065. /**
  99066. * Gets the main code of the block (fragment side)
  99067. * @param state current state of the node material building
  99068. * @returns the shader code
  99069. */
  99070. getCode(state: NodeMaterialBuildState): string;
  99071. protected _buildBlock(state: NodeMaterialBuildState): this;
  99072. protected _dumpPropertiesCode(): string;
  99073. serialize(): any;
  99074. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99075. }
  99076. }
  99077. declare module BABYLON {
  99078. /**
  99079. * Base block used as input for post process
  99080. */
  99081. export class CurrentScreenBlock extends NodeMaterialBlock {
  99082. private _samplerName;
  99083. private _linearDefineName;
  99084. private _gammaDefineName;
  99085. private _mainUVName;
  99086. private _tempTextureRead;
  99087. /**
  99088. * Gets or sets the texture associated with the node
  99089. */
  99090. texture: Nullable<BaseTexture>;
  99091. /**
  99092. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99093. */
  99094. convertToGammaSpace: boolean;
  99095. /**
  99096. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99097. */
  99098. convertToLinearSpace: boolean;
  99099. /**
  99100. * Create a new CurrentScreenBlock
  99101. * @param name defines the block name
  99102. */
  99103. constructor(name: string);
  99104. /**
  99105. * Gets the current class name
  99106. * @returns the class name
  99107. */
  99108. getClassName(): string;
  99109. /**
  99110. * Gets the uv input component
  99111. */
  99112. get uv(): NodeMaterialConnectionPoint;
  99113. /**
  99114. * Gets the rgba output component
  99115. */
  99116. get rgba(): NodeMaterialConnectionPoint;
  99117. /**
  99118. * Gets the rgb output component
  99119. */
  99120. get rgb(): NodeMaterialConnectionPoint;
  99121. /**
  99122. * Gets the r output component
  99123. */
  99124. get r(): NodeMaterialConnectionPoint;
  99125. /**
  99126. * Gets the g output component
  99127. */
  99128. get g(): NodeMaterialConnectionPoint;
  99129. /**
  99130. * Gets the b output component
  99131. */
  99132. get b(): NodeMaterialConnectionPoint;
  99133. /**
  99134. * Gets the a output component
  99135. */
  99136. get a(): NodeMaterialConnectionPoint;
  99137. /**
  99138. * Initialize the block and prepare the context for build
  99139. * @param state defines the state that will be used for the build
  99140. */
  99141. initialize(state: NodeMaterialBuildState): void;
  99142. get target(): NodeMaterialBlockTargets;
  99143. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99144. isReady(): boolean;
  99145. private _injectVertexCode;
  99146. private _writeTextureRead;
  99147. private _writeOutput;
  99148. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99149. serialize(): any;
  99150. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99151. }
  99152. }
  99153. declare module BABYLON {
  99154. /**
  99155. * Base block used for the particle texture
  99156. */
  99157. export class ParticleTextureBlock extends NodeMaterialBlock {
  99158. private _samplerName;
  99159. private _linearDefineName;
  99160. private _gammaDefineName;
  99161. private _tempTextureRead;
  99162. /**
  99163. * Gets or sets the texture associated with the node
  99164. */
  99165. texture: Nullable<BaseTexture>;
  99166. /**
  99167. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99168. */
  99169. convertToGammaSpace: boolean;
  99170. /**
  99171. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99172. */
  99173. convertToLinearSpace: boolean;
  99174. /**
  99175. * Create a new ParticleTextureBlock
  99176. * @param name defines the block name
  99177. */
  99178. constructor(name: string);
  99179. /**
  99180. * Gets the current class name
  99181. * @returns the class name
  99182. */
  99183. getClassName(): string;
  99184. /**
  99185. * Gets the uv input component
  99186. */
  99187. get uv(): NodeMaterialConnectionPoint;
  99188. /**
  99189. * Gets the rgba output component
  99190. */
  99191. get rgba(): NodeMaterialConnectionPoint;
  99192. /**
  99193. * Gets the rgb output component
  99194. */
  99195. get rgb(): NodeMaterialConnectionPoint;
  99196. /**
  99197. * Gets the r output component
  99198. */
  99199. get r(): NodeMaterialConnectionPoint;
  99200. /**
  99201. * Gets the g output component
  99202. */
  99203. get g(): NodeMaterialConnectionPoint;
  99204. /**
  99205. * Gets the b output component
  99206. */
  99207. get b(): NodeMaterialConnectionPoint;
  99208. /**
  99209. * Gets the a output component
  99210. */
  99211. get a(): NodeMaterialConnectionPoint;
  99212. /**
  99213. * Initialize the block and prepare the context for build
  99214. * @param state defines the state that will be used for the build
  99215. */
  99216. initialize(state: NodeMaterialBuildState): void;
  99217. autoConfigure(material: NodeMaterial): void;
  99218. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99219. isReady(): boolean;
  99220. private _writeOutput;
  99221. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99222. serialize(): any;
  99223. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99224. }
  99225. }
  99226. declare module BABYLON {
  99227. /**
  99228. * Class used to store shared data between 2 NodeMaterialBuildState
  99229. */
  99230. export class NodeMaterialBuildStateSharedData {
  99231. /**
  99232. * Gets the list of emitted varyings
  99233. */
  99234. temps: string[];
  99235. /**
  99236. * Gets the list of emitted varyings
  99237. */
  99238. varyings: string[];
  99239. /**
  99240. * Gets the varying declaration string
  99241. */
  99242. varyingDeclaration: string;
  99243. /**
  99244. * Input blocks
  99245. */
  99246. inputBlocks: InputBlock[];
  99247. /**
  99248. * Input blocks
  99249. */
  99250. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  99251. /**
  99252. * Bindable blocks (Blocks that need to set data to the effect)
  99253. */
  99254. bindableBlocks: NodeMaterialBlock[];
  99255. /**
  99256. * List of blocks that can provide a compilation fallback
  99257. */
  99258. blocksWithFallbacks: NodeMaterialBlock[];
  99259. /**
  99260. * List of blocks that can provide a define update
  99261. */
  99262. blocksWithDefines: NodeMaterialBlock[];
  99263. /**
  99264. * List of blocks that can provide a repeatable content
  99265. */
  99266. repeatableContentBlocks: NodeMaterialBlock[];
  99267. /**
  99268. * List of blocks that can provide a dynamic list of uniforms
  99269. */
  99270. dynamicUniformBlocks: NodeMaterialBlock[];
  99271. /**
  99272. * List of blocks that can block the isReady function for the material
  99273. */
  99274. blockingBlocks: NodeMaterialBlock[];
  99275. /**
  99276. * Gets the list of animated inputs
  99277. */
  99278. animatedInputs: InputBlock[];
  99279. /**
  99280. * Build Id used to avoid multiple recompilations
  99281. */
  99282. buildId: number;
  99283. /** List of emitted variables */
  99284. variableNames: {
  99285. [key: string]: number;
  99286. };
  99287. /** List of emitted defines */
  99288. defineNames: {
  99289. [key: string]: number;
  99290. };
  99291. /** Should emit comments? */
  99292. emitComments: boolean;
  99293. /** Emit build activity */
  99294. verbose: boolean;
  99295. /** Gets or sets the hosting scene */
  99296. scene: Scene;
  99297. /**
  99298. * Gets the compilation hints emitted at compilation time
  99299. */
  99300. hints: {
  99301. needWorldViewMatrix: boolean;
  99302. needWorldViewProjectionMatrix: boolean;
  99303. needAlphaBlending: boolean;
  99304. needAlphaTesting: boolean;
  99305. };
  99306. /**
  99307. * List of compilation checks
  99308. */
  99309. checks: {
  99310. emitVertex: boolean;
  99311. emitFragment: boolean;
  99312. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  99313. };
  99314. /**
  99315. * Is vertex program allowed to be empty?
  99316. */
  99317. allowEmptyVertexProgram: boolean;
  99318. /** Creates a new shared data */
  99319. constructor();
  99320. /**
  99321. * Emits console errors and exceptions if there is a failing check
  99322. */
  99323. emitErrors(): void;
  99324. }
  99325. }
  99326. declare module BABYLON {
  99327. /**
  99328. * Class used to store node based material build state
  99329. */
  99330. export class NodeMaterialBuildState {
  99331. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  99332. supportUniformBuffers: boolean;
  99333. /**
  99334. * Gets the list of emitted attributes
  99335. */
  99336. attributes: string[];
  99337. /**
  99338. * Gets the list of emitted uniforms
  99339. */
  99340. uniforms: string[];
  99341. /**
  99342. * Gets the list of emitted constants
  99343. */
  99344. constants: string[];
  99345. /**
  99346. * Gets the list of emitted samplers
  99347. */
  99348. samplers: string[];
  99349. /**
  99350. * Gets the list of emitted functions
  99351. */
  99352. functions: {
  99353. [key: string]: string;
  99354. };
  99355. /**
  99356. * Gets the list of emitted extensions
  99357. */
  99358. extensions: {
  99359. [key: string]: string;
  99360. };
  99361. /**
  99362. * Gets the target of the compilation state
  99363. */
  99364. target: NodeMaterialBlockTargets;
  99365. /**
  99366. * Gets the list of emitted counters
  99367. */
  99368. counters: {
  99369. [key: string]: number;
  99370. };
  99371. /**
  99372. * Shared data between multiple NodeMaterialBuildState instances
  99373. */
  99374. sharedData: NodeMaterialBuildStateSharedData;
  99375. /** @hidden */
  99376. _vertexState: NodeMaterialBuildState;
  99377. /** @hidden */
  99378. _attributeDeclaration: string;
  99379. /** @hidden */
  99380. _uniformDeclaration: string;
  99381. /** @hidden */
  99382. _constantDeclaration: string;
  99383. /** @hidden */
  99384. _samplerDeclaration: string;
  99385. /** @hidden */
  99386. _varyingTransfer: string;
  99387. /** @hidden */
  99388. _injectAtEnd: string;
  99389. private _repeatableContentAnchorIndex;
  99390. /** @hidden */
  99391. _builtCompilationString: string;
  99392. /**
  99393. * Gets the emitted compilation strings
  99394. */
  99395. compilationString: string;
  99396. /**
  99397. * Finalize the compilation strings
  99398. * @param state defines the current compilation state
  99399. */
  99400. finalize(state: NodeMaterialBuildState): void;
  99401. /** @hidden */
  99402. get _repeatableContentAnchor(): string;
  99403. /** @hidden */
  99404. _getFreeVariableName(prefix: string): string;
  99405. /** @hidden */
  99406. _getFreeDefineName(prefix: string): string;
  99407. /** @hidden */
  99408. _excludeVariableName(name: string): void;
  99409. /** @hidden */
  99410. _emit2DSampler(name: string): void;
  99411. /** @hidden */
  99412. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  99413. /** @hidden */
  99414. _emitExtension(name: string, extension: string, define?: string): void;
  99415. /** @hidden */
  99416. _emitFunction(name: string, code: string, comments: string): void;
  99417. /** @hidden */
  99418. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  99419. replaceStrings?: {
  99420. search: RegExp;
  99421. replace: string;
  99422. }[];
  99423. repeatKey?: string;
  99424. }): string;
  99425. /** @hidden */
  99426. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  99427. repeatKey?: string;
  99428. removeAttributes?: boolean;
  99429. removeUniforms?: boolean;
  99430. removeVaryings?: boolean;
  99431. removeIfDef?: boolean;
  99432. replaceStrings?: {
  99433. search: RegExp;
  99434. replace: string;
  99435. }[];
  99436. }, storeKey?: string): void;
  99437. /** @hidden */
  99438. _registerTempVariable(name: string): boolean;
  99439. /** @hidden */
  99440. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  99441. /** @hidden */
  99442. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  99443. /** @hidden */
  99444. _emitFloat(value: number): string;
  99445. }
  99446. }
  99447. declare module BABYLON {
  99448. /**
  99449. * Helper class used to generate session unique ID
  99450. */
  99451. export class UniqueIdGenerator {
  99452. private static _UniqueIdCounter;
  99453. /**
  99454. * Gets an unique (relatively to the current scene) Id
  99455. */
  99456. static get UniqueId(): number;
  99457. }
  99458. }
  99459. declare module BABYLON {
  99460. /**
  99461. * Defines a block that can be used inside a node based material
  99462. */
  99463. export class NodeMaterialBlock {
  99464. private _buildId;
  99465. private _buildTarget;
  99466. private _target;
  99467. private _isFinalMerger;
  99468. private _isInput;
  99469. protected _isUnique: boolean;
  99470. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  99471. inputsAreExclusive: boolean;
  99472. /** @hidden */
  99473. _codeVariableName: string;
  99474. /** @hidden */
  99475. _inputs: NodeMaterialConnectionPoint[];
  99476. /** @hidden */
  99477. _outputs: NodeMaterialConnectionPoint[];
  99478. /** @hidden */
  99479. _preparationId: number;
  99480. /**
  99481. * Gets or sets the name of the block
  99482. */
  99483. name: string;
  99484. /**
  99485. * Gets or sets the unique id of the node
  99486. */
  99487. uniqueId: number;
  99488. /**
  99489. * Gets or sets the comments associated with this block
  99490. */
  99491. comments: string;
  99492. /**
  99493. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  99494. */
  99495. get isUnique(): boolean;
  99496. /**
  99497. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  99498. */
  99499. get isFinalMerger(): boolean;
  99500. /**
  99501. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  99502. */
  99503. get isInput(): boolean;
  99504. /**
  99505. * Gets or sets the build Id
  99506. */
  99507. get buildId(): number;
  99508. set buildId(value: number);
  99509. /**
  99510. * Gets or sets the target of the block
  99511. */
  99512. get target(): NodeMaterialBlockTargets;
  99513. set target(value: NodeMaterialBlockTargets);
  99514. /**
  99515. * Gets the list of input points
  99516. */
  99517. get inputs(): NodeMaterialConnectionPoint[];
  99518. /** Gets the list of output points */
  99519. get outputs(): NodeMaterialConnectionPoint[];
  99520. /**
  99521. * Find an input by its name
  99522. * @param name defines the name of the input to look for
  99523. * @returns the input or null if not found
  99524. */
  99525. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  99526. /**
  99527. * Find an output by its name
  99528. * @param name defines the name of the outputto look for
  99529. * @returns the output or null if not found
  99530. */
  99531. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  99532. /**
  99533. * Creates a new NodeMaterialBlock
  99534. * @param name defines the block name
  99535. * @param target defines the target of that block (Vertex by default)
  99536. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  99537. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  99538. */
  99539. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  99540. /**
  99541. * Initialize the block and prepare the context for build
  99542. * @param state defines the state that will be used for the build
  99543. */
  99544. initialize(state: NodeMaterialBuildState): void;
  99545. /**
  99546. * Bind data to effect. Will only be called for blocks with isBindable === true
  99547. * @param effect defines the effect to bind data to
  99548. * @param nodeMaterial defines the hosting NodeMaterial
  99549. * @param mesh defines the mesh that will be rendered
  99550. * @param subMesh defines the submesh that will be rendered
  99551. */
  99552. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  99553. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  99554. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  99555. protected _writeFloat(value: number): string;
  99556. /**
  99557. * Gets the current class name e.g. "NodeMaterialBlock"
  99558. * @returns the class name
  99559. */
  99560. getClassName(): string;
  99561. /**
  99562. * Register a new input. Must be called inside a block constructor
  99563. * @param name defines the connection point name
  99564. * @param type defines the connection point type
  99565. * @param isOptional defines a boolean indicating that this input can be omitted
  99566. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  99567. * @param point an already created connection point. If not provided, create a new one
  99568. * @returns the current block
  99569. */
  99570. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  99571. /**
  99572. * Register a new output. Must be called inside a block constructor
  99573. * @param name defines the connection point name
  99574. * @param type defines the connection point type
  99575. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  99576. * @param point an already created connection point. If not provided, create a new one
  99577. * @returns the current block
  99578. */
  99579. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  99580. /**
  99581. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  99582. * @param forOutput defines an optional connection point to check compatibility with
  99583. * @returns the first available input or null
  99584. */
  99585. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  99586. /**
  99587. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  99588. * @param forBlock defines an optional block to check compatibility with
  99589. * @returns the first available input or null
  99590. */
  99591. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  99592. /**
  99593. * Gets the sibling of the given output
  99594. * @param current defines the current output
  99595. * @returns the next output in the list or null
  99596. */
  99597. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  99598. /**
  99599. * Connect current block with another block
  99600. * @param other defines the block to connect with
  99601. * @param options define the various options to help pick the right connections
  99602. * @returns the current block
  99603. */
  99604. connectTo(other: NodeMaterialBlock, options?: {
  99605. input?: string;
  99606. output?: string;
  99607. outputSwizzle?: string;
  99608. }): this | undefined;
  99609. protected _buildBlock(state: NodeMaterialBuildState): void;
  99610. /**
  99611. * Add uniforms, samplers and uniform buffers at compilation time
  99612. * @param state defines the state to update
  99613. * @param nodeMaterial defines the node material requesting the update
  99614. * @param defines defines the material defines to update
  99615. * @param uniformBuffers defines the list of uniform buffer names
  99616. */
  99617. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  99618. /**
  99619. * Add potential fallbacks if shader compilation fails
  99620. * @param mesh defines the mesh to be rendered
  99621. * @param fallbacks defines the current prioritized list of fallbacks
  99622. */
  99623. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  99624. /**
  99625. * Initialize defines for shader compilation
  99626. * @param mesh defines the mesh to be rendered
  99627. * @param nodeMaterial defines the node material requesting the update
  99628. * @param defines defines the material defines to update
  99629. * @param useInstances specifies that instances should be used
  99630. */
  99631. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  99632. /**
  99633. * Update defines for shader compilation
  99634. * @param mesh defines the mesh to be rendered
  99635. * @param nodeMaterial defines the node material requesting the update
  99636. * @param defines defines the material defines to update
  99637. * @param useInstances specifies that instances should be used
  99638. * @param subMesh defines which submesh to render
  99639. */
  99640. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  99641. /**
  99642. * Lets the block try to connect some inputs automatically
  99643. * @param material defines the hosting NodeMaterial
  99644. */
  99645. autoConfigure(material: NodeMaterial): void;
  99646. /**
  99647. * Function called when a block is declared as repeatable content generator
  99648. * @param vertexShaderState defines the current compilation state for the vertex shader
  99649. * @param fragmentShaderState defines the current compilation state for the fragment shader
  99650. * @param mesh defines the mesh to be rendered
  99651. * @param defines defines the material defines to update
  99652. */
  99653. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  99654. /**
  99655. * Checks if the block is ready
  99656. * @param mesh defines the mesh to be rendered
  99657. * @param nodeMaterial defines the node material requesting the update
  99658. * @param defines defines the material defines to update
  99659. * @param useInstances specifies that instances should be used
  99660. * @returns true if the block is ready
  99661. */
  99662. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  99663. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  99664. private _processBuild;
  99665. /**
  99666. * Compile the current node and generate the shader code
  99667. * @param state defines the current compilation state (uniforms, samplers, current string)
  99668. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  99669. * @returns true if already built
  99670. */
  99671. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  99672. protected _inputRename(name: string): string;
  99673. protected _outputRename(name: string): string;
  99674. protected _dumpPropertiesCode(): string;
  99675. /** @hidden */
  99676. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  99677. /** @hidden */
  99678. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  99679. /**
  99680. * Clone the current block to a new identical block
  99681. * @param scene defines the hosting scene
  99682. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99683. * @returns a copy of the current block
  99684. */
  99685. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  99686. /**
  99687. * Serializes this block in a JSON representation
  99688. * @returns the serialized block object
  99689. */
  99690. serialize(): any;
  99691. /** @hidden */
  99692. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99693. private _deserializePortDisplayNamesAndExposedOnFrame;
  99694. /**
  99695. * Release resources
  99696. */
  99697. dispose(): void;
  99698. }
  99699. }
  99700. declare module BABYLON {
  99701. /**
  99702. * Base class of materials working in push mode in babylon JS
  99703. * @hidden
  99704. */
  99705. export class PushMaterial extends Material {
  99706. protected _activeEffect: Effect;
  99707. protected _normalMatrix: Matrix;
  99708. constructor(name: string, scene: Scene);
  99709. getEffect(): Effect;
  99710. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99711. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  99712. /**
  99713. * Binds the given world matrix to the active effect
  99714. *
  99715. * @param world the matrix to bind
  99716. */
  99717. bindOnlyWorldMatrix(world: Matrix): void;
  99718. /**
  99719. * Binds the given normal matrix to the active effect
  99720. *
  99721. * @param normalMatrix the matrix to bind
  99722. */
  99723. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99724. bind(world: Matrix, mesh?: Mesh): void;
  99725. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99726. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99727. }
  99728. }
  99729. declare module BABYLON {
  99730. /**
  99731. * Root class for all node material optimizers
  99732. */
  99733. export class NodeMaterialOptimizer {
  99734. /**
  99735. * Function used to optimize a NodeMaterial graph
  99736. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  99737. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  99738. */
  99739. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  99740. }
  99741. }
  99742. declare module BABYLON {
  99743. /**
  99744. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  99745. */
  99746. export class TransformBlock extends NodeMaterialBlock {
  99747. /**
  99748. * Defines the value to use to complement W value to transform it to a Vector4
  99749. */
  99750. complementW: number;
  99751. /**
  99752. * Defines the value to use to complement z value to transform it to a Vector4
  99753. */
  99754. complementZ: number;
  99755. /**
  99756. * Creates a new TransformBlock
  99757. * @param name defines the block name
  99758. */
  99759. constructor(name: string);
  99760. /**
  99761. * Gets the current class name
  99762. * @returns the class name
  99763. */
  99764. getClassName(): string;
  99765. /**
  99766. * Gets the vector input
  99767. */
  99768. get vector(): NodeMaterialConnectionPoint;
  99769. /**
  99770. * Gets the output component
  99771. */
  99772. get output(): NodeMaterialConnectionPoint;
  99773. /**
  99774. * Gets the xyz output component
  99775. */
  99776. get xyz(): NodeMaterialConnectionPoint;
  99777. /**
  99778. * Gets the matrix transform input
  99779. */
  99780. get transform(): NodeMaterialConnectionPoint;
  99781. protected _buildBlock(state: NodeMaterialBuildState): this;
  99782. /**
  99783. * Update defines for shader compilation
  99784. * @param mesh defines the mesh to be rendered
  99785. * @param nodeMaterial defines the node material requesting the update
  99786. * @param defines defines the material defines to update
  99787. * @param useInstances specifies that instances should be used
  99788. * @param subMesh defines which submesh to render
  99789. */
  99790. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  99791. serialize(): any;
  99792. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99793. protected _dumpPropertiesCode(): string;
  99794. }
  99795. }
  99796. declare module BABYLON {
  99797. /**
  99798. * Block used to output the vertex position
  99799. */
  99800. export class VertexOutputBlock extends NodeMaterialBlock {
  99801. /**
  99802. * Creates a new VertexOutputBlock
  99803. * @param name defines the block name
  99804. */
  99805. constructor(name: string);
  99806. /**
  99807. * Gets the current class name
  99808. * @returns the class name
  99809. */
  99810. getClassName(): string;
  99811. /**
  99812. * Gets the vector input component
  99813. */
  99814. get vector(): NodeMaterialConnectionPoint;
  99815. protected _buildBlock(state: NodeMaterialBuildState): this;
  99816. }
  99817. }
  99818. declare module BABYLON {
  99819. /**
  99820. * Block used to output the final color
  99821. */
  99822. export class FragmentOutputBlock extends NodeMaterialBlock {
  99823. /**
  99824. * Create a new FragmentOutputBlock
  99825. * @param name defines the block name
  99826. */
  99827. constructor(name: string);
  99828. /**
  99829. * Gets the current class name
  99830. * @returns the class name
  99831. */
  99832. getClassName(): string;
  99833. /**
  99834. * Gets the rgba input component
  99835. */
  99836. get rgba(): NodeMaterialConnectionPoint;
  99837. /**
  99838. * Gets the rgb input component
  99839. */
  99840. get rgb(): NodeMaterialConnectionPoint;
  99841. /**
  99842. * Gets the a input component
  99843. */
  99844. get a(): NodeMaterialConnectionPoint;
  99845. protected _buildBlock(state: NodeMaterialBuildState): this;
  99846. }
  99847. }
  99848. declare module BABYLON {
  99849. /**
  99850. * Block used for the particle ramp gradient section
  99851. */
  99852. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  99853. /**
  99854. * Create a new ParticleRampGradientBlock
  99855. * @param name defines the block name
  99856. */
  99857. constructor(name: string);
  99858. /**
  99859. * Gets the current class name
  99860. * @returns the class name
  99861. */
  99862. getClassName(): string;
  99863. /**
  99864. * Gets the color input component
  99865. */
  99866. get color(): NodeMaterialConnectionPoint;
  99867. /**
  99868. * Gets the rampColor output component
  99869. */
  99870. get rampColor(): NodeMaterialConnectionPoint;
  99871. /**
  99872. * Initialize the block and prepare the context for build
  99873. * @param state defines the state that will be used for the build
  99874. */
  99875. initialize(state: NodeMaterialBuildState): void;
  99876. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99877. }
  99878. }
  99879. declare module BABYLON {
  99880. /**
  99881. * Block used for the particle blend multiply section
  99882. */
  99883. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  99884. /**
  99885. * Create a new ParticleBlendMultiplyBlock
  99886. * @param name defines the block name
  99887. */
  99888. constructor(name: string);
  99889. /**
  99890. * Gets the current class name
  99891. * @returns the class name
  99892. */
  99893. getClassName(): string;
  99894. /**
  99895. * Gets the color input component
  99896. */
  99897. get color(): NodeMaterialConnectionPoint;
  99898. /**
  99899. * Gets the alphaTexture input component
  99900. */
  99901. get alphaTexture(): NodeMaterialConnectionPoint;
  99902. /**
  99903. * Gets the alphaColor input component
  99904. */
  99905. get alphaColor(): NodeMaterialConnectionPoint;
  99906. /**
  99907. * Gets the blendColor output component
  99908. */
  99909. get blendColor(): NodeMaterialConnectionPoint;
  99910. /**
  99911. * Initialize the block and prepare the context for build
  99912. * @param state defines the state that will be used for the build
  99913. */
  99914. initialize(state: NodeMaterialBuildState): void;
  99915. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99916. }
  99917. }
  99918. declare module BABYLON {
  99919. /**
  99920. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  99921. */
  99922. export class VectorMergerBlock extends NodeMaterialBlock {
  99923. /**
  99924. * Create a new VectorMergerBlock
  99925. * @param name defines the block name
  99926. */
  99927. constructor(name: string);
  99928. /**
  99929. * Gets the current class name
  99930. * @returns the class name
  99931. */
  99932. getClassName(): string;
  99933. /**
  99934. * Gets the xyz component (input)
  99935. */
  99936. get xyzIn(): NodeMaterialConnectionPoint;
  99937. /**
  99938. * Gets the xy component (input)
  99939. */
  99940. get xyIn(): NodeMaterialConnectionPoint;
  99941. /**
  99942. * Gets the x component (input)
  99943. */
  99944. get x(): NodeMaterialConnectionPoint;
  99945. /**
  99946. * Gets the y component (input)
  99947. */
  99948. get y(): NodeMaterialConnectionPoint;
  99949. /**
  99950. * Gets the z component (input)
  99951. */
  99952. get z(): NodeMaterialConnectionPoint;
  99953. /**
  99954. * Gets the w component (input)
  99955. */
  99956. get w(): NodeMaterialConnectionPoint;
  99957. /**
  99958. * Gets the xyzw component (output)
  99959. */
  99960. get xyzw(): NodeMaterialConnectionPoint;
  99961. /**
  99962. * Gets the xyz component (output)
  99963. */
  99964. get xyzOut(): NodeMaterialConnectionPoint;
  99965. /**
  99966. * Gets the xy component (output)
  99967. */
  99968. get xyOut(): NodeMaterialConnectionPoint;
  99969. /**
  99970. * Gets the xy component (output)
  99971. * @deprecated Please use xyOut instead.
  99972. */
  99973. get xy(): NodeMaterialConnectionPoint;
  99974. /**
  99975. * Gets the xyz component (output)
  99976. * @deprecated Please use xyzOut instead.
  99977. */
  99978. get xyz(): NodeMaterialConnectionPoint;
  99979. protected _buildBlock(state: NodeMaterialBuildState): this;
  99980. }
  99981. }
  99982. declare module BABYLON {
  99983. /**
  99984. * Block used to remap a float from a range to a new one
  99985. */
  99986. export class RemapBlock extends NodeMaterialBlock {
  99987. /**
  99988. * Gets or sets the source range
  99989. */
  99990. sourceRange: Vector2;
  99991. /**
  99992. * Gets or sets the target range
  99993. */
  99994. targetRange: Vector2;
  99995. /**
  99996. * Creates a new RemapBlock
  99997. * @param name defines the block name
  99998. */
  99999. constructor(name: string);
  100000. /**
  100001. * Gets the current class name
  100002. * @returns the class name
  100003. */
  100004. getClassName(): string;
  100005. /**
  100006. * Gets the input component
  100007. */
  100008. get input(): NodeMaterialConnectionPoint;
  100009. /**
  100010. * Gets the source min input component
  100011. */
  100012. get sourceMin(): NodeMaterialConnectionPoint;
  100013. /**
  100014. * Gets the source max input component
  100015. */
  100016. get sourceMax(): NodeMaterialConnectionPoint;
  100017. /**
  100018. * Gets the target min input component
  100019. */
  100020. get targetMin(): NodeMaterialConnectionPoint;
  100021. /**
  100022. * Gets the target max input component
  100023. */
  100024. get targetMax(): NodeMaterialConnectionPoint;
  100025. /**
  100026. * Gets the output component
  100027. */
  100028. get output(): NodeMaterialConnectionPoint;
  100029. protected _buildBlock(state: NodeMaterialBuildState): this;
  100030. protected _dumpPropertiesCode(): string;
  100031. serialize(): any;
  100032. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100033. }
  100034. }
  100035. declare module BABYLON {
  100036. /**
  100037. * Block used to multiply 2 values
  100038. */
  100039. export class MultiplyBlock extends NodeMaterialBlock {
  100040. /**
  100041. * Creates a new MultiplyBlock
  100042. * @param name defines the block name
  100043. */
  100044. constructor(name: string);
  100045. /**
  100046. * Gets the current class name
  100047. * @returns the class name
  100048. */
  100049. getClassName(): string;
  100050. /**
  100051. * Gets the left operand input component
  100052. */
  100053. get left(): NodeMaterialConnectionPoint;
  100054. /**
  100055. * Gets the right operand input component
  100056. */
  100057. get right(): NodeMaterialConnectionPoint;
  100058. /**
  100059. * Gets the output component
  100060. */
  100061. get output(): NodeMaterialConnectionPoint;
  100062. protected _buildBlock(state: NodeMaterialBuildState): this;
  100063. }
  100064. }
  100065. declare module BABYLON {
  100066. /**
  100067. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  100068. */
  100069. export class ColorSplitterBlock extends NodeMaterialBlock {
  100070. /**
  100071. * Create a new ColorSplitterBlock
  100072. * @param name defines the block name
  100073. */
  100074. constructor(name: string);
  100075. /**
  100076. * Gets the current class name
  100077. * @returns the class name
  100078. */
  100079. getClassName(): string;
  100080. /**
  100081. * Gets the rgba component (input)
  100082. */
  100083. get rgba(): NodeMaterialConnectionPoint;
  100084. /**
  100085. * Gets the rgb component (input)
  100086. */
  100087. get rgbIn(): NodeMaterialConnectionPoint;
  100088. /**
  100089. * Gets the rgb component (output)
  100090. */
  100091. get rgbOut(): NodeMaterialConnectionPoint;
  100092. /**
  100093. * Gets the r component (output)
  100094. */
  100095. get r(): NodeMaterialConnectionPoint;
  100096. /**
  100097. * Gets the g component (output)
  100098. */
  100099. get g(): NodeMaterialConnectionPoint;
  100100. /**
  100101. * Gets the b component (output)
  100102. */
  100103. get b(): NodeMaterialConnectionPoint;
  100104. /**
  100105. * Gets the a component (output)
  100106. */
  100107. get a(): NodeMaterialConnectionPoint;
  100108. protected _inputRename(name: string): string;
  100109. protected _outputRename(name: string): string;
  100110. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100111. }
  100112. }
  100113. declare module BABYLON {
  100114. /**
  100115. * Interface used to configure the node material editor
  100116. */
  100117. export interface INodeMaterialEditorOptions {
  100118. /** Define the URl to load node editor script */
  100119. editorURL?: string;
  100120. }
  100121. /** @hidden */
  100122. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  100123. NORMAL: boolean;
  100124. TANGENT: boolean;
  100125. UV1: boolean;
  100126. /** BONES */
  100127. NUM_BONE_INFLUENCERS: number;
  100128. BonesPerMesh: number;
  100129. BONETEXTURE: boolean;
  100130. /** MORPH TARGETS */
  100131. MORPHTARGETS: boolean;
  100132. MORPHTARGETS_NORMAL: boolean;
  100133. MORPHTARGETS_TANGENT: boolean;
  100134. MORPHTARGETS_UV: boolean;
  100135. NUM_MORPH_INFLUENCERS: number;
  100136. /** IMAGE PROCESSING */
  100137. IMAGEPROCESSING: boolean;
  100138. VIGNETTE: boolean;
  100139. VIGNETTEBLENDMODEMULTIPLY: boolean;
  100140. VIGNETTEBLENDMODEOPAQUE: boolean;
  100141. TONEMAPPING: boolean;
  100142. TONEMAPPING_ACES: boolean;
  100143. CONTRAST: boolean;
  100144. EXPOSURE: boolean;
  100145. COLORCURVES: boolean;
  100146. COLORGRADING: boolean;
  100147. COLORGRADING3D: boolean;
  100148. SAMPLER3DGREENDEPTH: boolean;
  100149. SAMPLER3DBGRMAP: boolean;
  100150. IMAGEPROCESSINGPOSTPROCESS: boolean;
  100151. /** MISC. */
  100152. BUMPDIRECTUV: number;
  100153. constructor();
  100154. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  100155. }
  100156. /**
  100157. * Class used to configure NodeMaterial
  100158. */
  100159. export interface INodeMaterialOptions {
  100160. /**
  100161. * Defines if blocks should emit comments
  100162. */
  100163. emitComments: boolean;
  100164. }
  100165. /**
  100166. * Class used to create a node based material built by assembling shader blocks
  100167. */
  100168. export class NodeMaterial extends PushMaterial {
  100169. private static _BuildIdGenerator;
  100170. private _options;
  100171. private _vertexCompilationState;
  100172. private _fragmentCompilationState;
  100173. private _sharedData;
  100174. private _buildId;
  100175. private _buildWasSuccessful;
  100176. private _cachedWorldViewMatrix;
  100177. private _cachedWorldViewProjectionMatrix;
  100178. private _optimizers;
  100179. private _animationFrame;
  100180. /** Define the Url to load node editor script */
  100181. static EditorURL: string;
  100182. /** Define the Url to load snippets */
  100183. static SnippetUrl: string;
  100184. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  100185. static IgnoreTexturesAtLoadTime: boolean;
  100186. private BJSNODEMATERIALEDITOR;
  100187. /** Get the inspector from bundle or global */
  100188. private _getGlobalNodeMaterialEditor;
  100189. /**
  100190. * Snippet ID if the material was created from the snippet server
  100191. */
  100192. snippetId: string;
  100193. /**
  100194. * Gets or sets data used by visual editor
  100195. * @see https://nme.babylonjs.com
  100196. */
  100197. editorData: any;
  100198. /**
  100199. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  100200. */
  100201. ignoreAlpha: boolean;
  100202. /**
  100203. * Defines the maximum number of lights that can be used in the material
  100204. */
  100205. maxSimultaneousLights: number;
  100206. /**
  100207. * Observable raised when the material is built
  100208. */
  100209. onBuildObservable: Observable<NodeMaterial>;
  100210. /**
  100211. * Gets or sets the root nodes of the material vertex shader
  100212. */
  100213. _vertexOutputNodes: NodeMaterialBlock[];
  100214. /**
  100215. * Gets or sets the root nodes of the material fragment (pixel) shader
  100216. */
  100217. _fragmentOutputNodes: NodeMaterialBlock[];
  100218. /** Gets or sets options to control the node material overall behavior */
  100219. get options(): INodeMaterialOptions;
  100220. set options(options: INodeMaterialOptions);
  100221. /**
  100222. * Default configuration related to image processing available in the standard Material.
  100223. */
  100224. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100225. /**
  100226. * Gets the image processing configuration used either in this material.
  100227. */
  100228. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  100229. /**
  100230. * Sets the Default image processing configuration used either in the this material.
  100231. *
  100232. * If sets to null, the scene one is in use.
  100233. */
  100234. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  100235. /**
  100236. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  100237. */
  100238. attachedBlocks: NodeMaterialBlock[];
  100239. /**
  100240. * Specifies the mode of the node material
  100241. * @hidden
  100242. */
  100243. _mode: NodeMaterialModes;
  100244. /**
  100245. * Gets the mode property
  100246. */
  100247. get mode(): NodeMaterialModes;
  100248. /**
  100249. * Create a new node based material
  100250. * @param name defines the material name
  100251. * @param scene defines the hosting scene
  100252. * @param options defines creation option
  100253. */
  100254. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  100255. /**
  100256. * Gets the current class name of the material e.g. "NodeMaterial"
  100257. * @returns the class name
  100258. */
  100259. getClassName(): string;
  100260. /**
  100261. * Keep track of the image processing observer to allow dispose and replace.
  100262. */
  100263. private _imageProcessingObserver;
  100264. /**
  100265. * Attaches a new image processing configuration to the Standard Material.
  100266. * @param configuration
  100267. */
  100268. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100269. /**
  100270. * Get a block by its name
  100271. * @param name defines the name of the block to retrieve
  100272. * @returns the required block or null if not found
  100273. */
  100274. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  100275. /**
  100276. * Get a block by its name
  100277. * @param predicate defines the predicate used to find the good candidate
  100278. * @returns the required block or null if not found
  100279. */
  100280. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  100281. /**
  100282. * Get an input block by its name
  100283. * @param predicate defines the predicate used to find the good candidate
  100284. * @returns the required input block or null if not found
  100285. */
  100286. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  100287. /**
  100288. * Gets the list of input blocks attached to this material
  100289. * @returns an array of InputBlocks
  100290. */
  100291. getInputBlocks(): InputBlock[];
  100292. /**
  100293. * Adds a new optimizer to the list of optimizers
  100294. * @param optimizer defines the optimizers to add
  100295. * @returns the current material
  100296. */
  100297. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  100298. /**
  100299. * Remove an optimizer from the list of optimizers
  100300. * @param optimizer defines the optimizers to remove
  100301. * @returns the current material
  100302. */
  100303. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  100304. /**
  100305. * Add a new block to the list of output nodes
  100306. * @param node defines the node to add
  100307. * @returns the current material
  100308. */
  100309. addOutputNode(node: NodeMaterialBlock): this;
  100310. /**
  100311. * Remove a block from the list of root nodes
  100312. * @param node defines the node to remove
  100313. * @returns the current material
  100314. */
  100315. removeOutputNode(node: NodeMaterialBlock): this;
  100316. private _addVertexOutputNode;
  100317. private _removeVertexOutputNode;
  100318. private _addFragmentOutputNode;
  100319. private _removeFragmentOutputNode;
  100320. /**
  100321. * Specifies if the material will require alpha blending
  100322. * @returns a boolean specifying if alpha blending is needed
  100323. */
  100324. needAlphaBlending(): boolean;
  100325. /**
  100326. * Specifies if this material should be rendered in alpha test mode
  100327. * @returns a boolean specifying if an alpha test is needed.
  100328. */
  100329. needAlphaTesting(): boolean;
  100330. private _initializeBlock;
  100331. private _resetDualBlocks;
  100332. /**
  100333. * Remove a block from the current node material
  100334. * @param block defines the block to remove
  100335. */
  100336. removeBlock(block: NodeMaterialBlock): void;
  100337. /**
  100338. * Build the material and generates the inner effect
  100339. * @param verbose defines if the build should log activity
  100340. */
  100341. build(verbose?: boolean): void;
  100342. /**
  100343. * Runs an otpimization phase to try to improve the shader code
  100344. */
  100345. optimize(): void;
  100346. private _prepareDefinesForAttributes;
  100347. /**
  100348. * Create a post process from the material
  100349. * @param camera The camera to apply the render pass to.
  100350. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100351. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100352. * @param engine The engine which the post process will be applied. (default: current engine)
  100353. * @param reusable If the post process can be reused on the same frame. (default: false)
  100354. * @param textureType Type of textures used when performing the post process. (default: 0)
  100355. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  100356. * @returns the post process created
  100357. */
  100358. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  100359. /**
  100360. * Create the post process effect from the material
  100361. * @param postProcess The post process to create the effect for
  100362. */
  100363. createEffectForPostProcess(postProcess: PostProcess): void;
  100364. private _createEffectOrPostProcess;
  100365. private _createEffectForParticles;
  100366. /**
  100367. * Create the effect to be used as the custom effect for a particle system
  100368. * @param particleSystem Particle system to create the effect for
  100369. * @param onCompiled defines a function to call when the effect creation is successful
  100370. * @param onError defines a function to call when the effect creation has failed
  100371. */
  100372. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100373. private _processDefines;
  100374. /**
  100375. * Get if the submesh is ready to be used and all its information available.
  100376. * Child classes can use it to update shaders
  100377. * @param mesh defines the mesh to check
  100378. * @param subMesh defines which submesh to check
  100379. * @param useInstances specifies that instances should be used
  100380. * @returns a boolean indicating that the submesh is ready or not
  100381. */
  100382. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100383. /**
  100384. * Get a string representing the shaders built by the current node graph
  100385. */
  100386. get compiledShaders(): string;
  100387. /**
  100388. * Binds the world matrix to the material
  100389. * @param world defines the world transformation matrix
  100390. */
  100391. bindOnlyWorldMatrix(world: Matrix): void;
  100392. /**
  100393. * Binds the submesh to this material by preparing the effect and shader to draw
  100394. * @param world defines the world transformation matrix
  100395. * @param mesh defines the mesh containing the submesh
  100396. * @param subMesh defines the submesh to bind the material to
  100397. */
  100398. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100399. /**
  100400. * Gets the active textures from the material
  100401. * @returns an array of textures
  100402. */
  100403. getActiveTextures(): BaseTexture[];
  100404. /**
  100405. * Gets the list of texture blocks
  100406. * @returns an array of texture blocks
  100407. */
  100408. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  100409. /**
  100410. * Specifies if the material uses a texture
  100411. * @param texture defines the texture to check against the material
  100412. * @returns a boolean specifying if the material uses the texture
  100413. */
  100414. hasTexture(texture: BaseTexture): boolean;
  100415. /**
  100416. * Disposes the material
  100417. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100418. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100419. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  100420. */
  100421. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  100422. /** Creates the node editor window. */
  100423. private _createNodeEditor;
  100424. /**
  100425. * Launch the node material editor
  100426. * @param config Define the configuration of the editor
  100427. * @return a promise fulfilled when the node editor is visible
  100428. */
  100429. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  100430. /**
  100431. * Clear the current material
  100432. */
  100433. clear(): void;
  100434. /**
  100435. * Clear the current material and set it to a default state
  100436. */
  100437. setToDefault(): void;
  100438. /**
  100439. * Clear the current material and set it to a default state for post process
  100440. */
  100441. setToDefaultPostProcess(): void;
  100442. /**
  100443. * Clear the current material and set it to a default state for particle
  100444. */
  100445. setToDefaultParticle(): void;
  100446. /**
  100447. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  100448. * @param url defines the url to load from
  100449. * @returns a promise that will fullfil when the material is fully loaded
  100450. */
  100451. loadAsync(url: string): Promise<void>;
  100452. private _gatherBlocks;
  100453. /**
  100454. * Generate a string containing the code declaration required to create an equivalent of this material
  100455. * @returns a string
  100456. */
  100457. generateCode(): string;
  100458. /**
  100459. * Serializes this material in a JSON representation
  100460. * @returns the serialized material object
  100461. */
  100462. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  100463. private _restoreConnections;
  100464. /**
  100465. * Clear the current graph and load a new one from a serialization object
  100466. * @param source defines the JSON representation of the material
  100467. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100468. * @param merge defines whether or not the source must be merged or replace the current content
  100469. */
  100470. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  100471. /**
  100472. * Makes a duplicate of the current material.
  100473. * @param name - name to use for the new material.
  100474. */
  100475. clone(name: string): NodeMaterial;
  100476. /**
  100477. * Creates a node material from parsed material data
  100478. * @param source defines the JSON representation of the material
  100479. * @param scene defines the hosting scene
  100480. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100481. * @returns a new node material
  100482. */
  100483. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  100484. /**
  100485. * Creates a node material from a snippet saved in a remote file
  100486. * @param name defines the name of the material to create
  100487. * @param url defines the url to load from
  100488. * @param scene defines the hosting scene
  100489. * @returns a promise that will resolve to the new node material
  100490. */
  100491. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  100492. /**
  100493. * Creates a node material from a snippet saved by the node material editor
  100494. * @param snippetId defines the snippet to load
  100495. * @param scene defines the hosting scene
  100496. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100497. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  100498. * @returns a promise that will resolve to the new node material
  100499. */
  100500. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  100501. /**
  100502. * Creates a new node material set to default basic configuration
  100503. * @param name defines the name of the material
  100504. * @param scene defines the hosting scene
  100505. * @returns a new NodeMaterial
  100506. */
  100507. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  100508. }
  100509. }
  100510. declare module BABYLON {
  100511. /**
  100512. * Size options for a post process
  100513. */
  100514. export type PostProcessOptions = {
  100515. width: number;
  100516. height: number;
  100517. };
  100518. /**
  100519. * PostProcess can be used to apply a shader to a texture after it has been rendered
  100520. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  100521. */
  100522. export class PostProcess {
  100523. /** Name of the PostProcess. */
  100524. name: string;
  100525. /**
  100526. * Gets or sets the unique id of the post process
  100527. */
  100528. uniqueId: number;
  100529. /**
  100530. * Width of the texture to apply the post process on
  100531. */
  100532. width: number;
  100533. /**
  100534. * Height of the texture to apply the post process on
  100535. */
  100536. height: number;
  100537. /**
  100538. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  100539. */
  100540. nodeMaterialSource: Nullable<NodeMaterial>;
  100541. /**
  100542. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  100543. * @hidden
  100544. */
  100545. _outputTexture: Nullable<InternalTexture>;
  100546. /**
  100547. * Sampling mode used by the shader
  100548. * See https://doc.babylonjs.com/classes/3.1/texture
  100549. */
  100550. renderTargetSamplingMode: number;
  100551. /**
  100552. * Clear color to use when screen clearing
  100553. */
  100554. clearColor: Color4;
  100555. /**
  100556. * If the buffer needs to be cleared before applying the post process. (default: true)
  100557. * Should be set to false if shader will overwrite all previous pixels.
  100558. */
  100559. autoClear: boolean;
  100560. /**
  100561. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  100562. */
  100563. alphaMode: number;
  100564. /**
  100565. * Sets the setAlphaBlendConstants of the babylon engine
  100566. */
  100567. alphaConstants: Color4;
  100568. /**
  100569. * Animations to be used for the post processing
  100570. */
  100571. animations: Animation[];
  100572. /**
  100573. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  100574. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  100575. */
  100576. enablePixelPerfectMode: boolean;
  100577. /**
  100578. * Force the postprocess to be applied without taking in account viewport
  100579. */
  100580. forceFullscreenViewport: boolean;
  100581. /**
  100582. * List of inspectable custom properties (used by the Inspector)
  100583. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  100584. */
  100585. inspectableCustomProperties: IInspectable[];
  100586. /**
  100587. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  100588. *
  100589. * | Value | Type | Description |
  100590. * | ----- | ----------------------------------- | ----------- |
  100591. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  100592. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  100593. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  100594. *
  100595. */
  100596. scaleMode: number;
  100597. /**
  100598. * Force textures to be a power of two (default: false)
  100599. */
  100600. alwaysForcePOT: boolean;
  100601. private _samples;
  100602. /**
  100603. * Number of sample textures (default: 1)
  100604. */
  100605. get samples(): number;
  100606. set samples(n: number);
  100607. /**
  100608. * Modify the scale of the post process to be the same as the viewport (default: false)
  100609. */
  100610. adaptScaleToCurrentViewport: boolean;
  100611. private _camera;
  100612. protected _scene: Scene;
  100613. private _engine;
  100614. private _options;
  100615. private _reusable;
  100616. private _textureType;
  100617. private _textureFormat;
  100618. /**
  100619. * Smart array of input and output textures for the post process.
  100620. * @hidden
  100621. */
  100622. _textures: SmartArray<InternalTexture>;
  100623. /**
  100624. * The index in _textures that corresponds to the output texture.
  100625. * @hidden
  100626. */
  100627. _currentRenderTextureInd: number;
  100628. private _effect;
  100629. private _samplers;
  100630. private _fragmentUrl;
  100631. private _vertexUrl;
  100632. private _parameters;
  100633. private _scaleRatio;
  100634. protected _indexParameters: any;
  100635. private _shareOutputWithPostProcess;
  100636. private _texelSize;
  100637. private _forcedOutputTexture;
  100638. /**
  100639. * Returns the fragment url or shader name used in the post process.
  100640. * @returns the fragment url or name in the shader store.
  100641. */
  100642. getEffectName(): string;
  100643. /**
  100644. * An event triggered when the postprocess is activated.
  100645. */
  100646. onActivateObservable: Observable<Camera>;
  100647. private _onActivateObserver;
  100648. /**
  100649. * A function that is added to the onActivateObservable
  100650. */
  100651. set onActivate(callback: Nullable<(camera: Camera) => void>);
  100652. /**
  100653. * An event triggered when the postprocess changes its size.
  100654. */
  100655. onSizeChangedObservable: Observable<PostProcess>;
  100656. private _onSizeChangedObserver;
  100657. /**
  100658. * A function that is added to the onSizeChangedObservable
  100659. */
  100660. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  100661. /**
  100662. * An event triggered when the postprocess applies its effect.
  100663. */
  100664. onApplyObservable: Observable<Effect>;
  100665. private _onApplyObserver;
  100666. /**
  100667. * A function that is added to the onApplyObservable
  100668. */
  100669. set onApply(callback: (effect: Effect) => void);
  100670. /**
  100671. * An event triggered before rendering the postprocess
  100672. */
  100673. onBeforeRenderObservable: Observable<Effect>;
  100674. private _onBeforeRenderObserver;
  100675. /**
  100676. * A function that is added to the onBeforeRenderObservable
  100677. */
  100678. set onBeforeRender(callback: (effect: Effect) => void);
  100679. /**
  100680. * An event triggered after rendering the postprocess
  100681. */
  100682. onAfterRenderObservable: Observable<Effect>;
  100683. private _onAfterRenderObserver;
  100684. /**
  100685. * A function that is added to the onAfterRenderObservable
  100686. */
  100687. set onAfterRender(callback: (efect: Effect) => void);
  100688. /**
  100689. * 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
  100690. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  100691. */
  100692. get inputTexture(): InternalTexture;
  100693. set inputTexture(value: InternalTexture);
  100694. /**
  100695. * Gets the camera which post process is applied to.
  100696. * @returns The camera the post process is applied to.
  100697. */
  100698. getCamera(): Camera;
  100699. /**
  100700. * Gets the texel size of the postprocess.
  100701. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  100702. */
  100703. get texelSize(): Vector2;
  100704. /**
  100705. * Creates a new instance PostProcess
  100706. * @param name The name of the PostProcess.
  100707. * @param fragmentUrl The url of the fragment shader to be used.
  100708. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  100709. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  100710. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100711. * @param camera The camera to apply the render pass to.
  100712. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100713. * @param engine The engine which the post process will be applied. (default: current engine)
  100714. * @param reusable If the post process can be reused on the same frame. (default: false)
  100715. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  100716. * @param textureType Type of textures used when performing the post process. (default: 0)
  100717. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  100718. * @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
  100719. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  100720. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  100721. */
  100722. constructor(
  100723. /** Name of the PostProcess. */
  100724. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  100725. /**
  100726. * Gets a string idenfifying the name of the class
  100727. * @returns "PostProcess" string
  100728. */
  100729. getClassName(): string;
  100730. /**
  100731. * Gets the engine which this post process belongs to.
  100732. * @returns The engine the post process was enabled with.
  100733. */
  100734. getEngine(): Engine;
  100735. /**
  100736. * The effect that is created when initializing the post process.
  100737. * @returns The created effect corresponding the the postprocess.
  100738. */
  100739. getEffect(): Effect;
  100740. /**
  100741. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  100742. * @param postProcess The post process to share the output with.
  100743. * @returns This post process.
  100744. */
  100745. shareOutputWith(postProcess: PostProcess): PostProcess;
  100746. /**
  100747. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  100748. * This should be called if the post process that shares output with this post process is disabled/disposed.
  100749. */
  100750. useOwnOutput(): void;
  100751. /**
  100752. * Updates the effect with the current post process compile time values and recompiles the shader.
  100753. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  100754. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  100755. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  100756. * @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
  100757. * @param onCompiled Called when the shader has been compiled.
  100758. * @param onError Called if there is an error when compiling a shader.
  100759. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  100760. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  100761. */
  100762. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, vertexUrl?: string, fragmentUrl?: string): void;
  100763. /**
  100764. * The post process is reusable if it can be used multiple times within one frame.
  100765. * @returns If the post process is reusable
  100766. */
  100767. isReusable(): boolean;
  100768. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  100769. markTextureDirty(): void;
  100770. /**
  100771. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  100772. * 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.
  100773. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  100774. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  100775. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  100776. * @returns The target texture that was bound to be written to.
  100777. */
  100778. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  100779. /**
  100780. * If the post process is supported.
  100781. */
  100782. get isSupported(): boolean;
  100783. /**
  100784. * The aspect ratio of the output texture.
  100785. */
  100786. get aspectRatio(): number;
  100787. /**
  100788. * Get a value indicating if the post-process is ready to be used
  100789. * @returns true if the post-process is ready (shader is compiled)
  100790. */
  100791. isReady(): boolean;
  100792. /**
  100793. * Binds all textures and uniforms to the shader, this will be run on every pass.
  100794. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  100795. */
  100796. apply(): Nullable<Effect>;
  100797. private _disposeTextures;
  100798. /**
  100799. * Disposes the post process.
  100800. * @param camera The camera to dispose the post process on.
  100801. */
  100802. dispose(camera?: Camera): void;
  100803. }
  100804. }
  100805. declare module BABYLON {
  100806. /** @hidden */
  100807. export var kernelBlurVaryingDeclaration: {
  100808. name: string;
  100809. shader: string;
  100810. };
  100811. }
  100812. declare module BABYLON {
  100813. /** @hidden */
  100814. export var kernelBlurFragment: {
  100815. name: string;
  100816. shader: string;
  100817. };
  100818. }
  100819. declare module BABYLON {
  100820. /** @hidden */
  100821. export var kernelBlurFragment2: {
  100822. name: string;
  100823. shader: string;
  100824. };
  100825. }
  100826. declare module BABYLON {
  100827. /** @hidden */
  100828. export var kernelBlurPixelShader: {
  100829. name: string;
  100830. shader: string;
  100831. };
  100832. }
  100833. declare module BABYLON {
  100834. /** @hidden */
  100835. export var kernelBlurVertex: {
  100836. name: string;
  100837. shader: string;
  100838. };
  100839. }
  100840. declare module BABYLON {
  100841. /** @hidden */
  100842. export var kernelBlurVertexShader: {
  100843. name: string;
  100844. shader: string;
  100845. };
  100846. }
  100847. declare module BABYLON {
  100848. /**
  100849. * The Blur Post Process which blurs an image based on a kernel and direction.
  100850. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  100851. */
  100852. export class BlurPostProcess extends PostProcess {
  100853. /** The direction in which to blur the image. */
  100854. direction: Vector2;
  100855. private blockCompilation;
  100856. protected _kernel: number;
  100857. protected _idealKernel: number;
  100858. protected _packedFloat: boolean;
  100859. private _staticDefines;
  100860. /**
  100861. * Sets the length in pixels of the blur sample region
  100862. */
  100863. set kernel(v: number);
  100864. /**
  100865. * Gets the length in pixels of the blur sample region
  100866. */
  100867. get kernel(): number;
  100868. /**
  100869. * Sets wether or not the blur needs to unpack/repack floats
  100870. */
  100871. set packedFloat(v: boolean);
  100872. /**
  100873. * Gets wether or not the blur is unpacking/repacking floats
  100874. */
  100875. get packedFloat(): boolean;
  100876. /**
  100877. * Creates a new instance BlurPostProcess
  100878. * @param name The name of the effect.
  100879. * @param direction The direction in which to blur the image.
  100880. * @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.
  100881. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100882. * @param camera The camera to apply the render pass to.
  100883. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100884. * @param engine The engine which the post process will be applied. (default: current engine)
  100885. * @param reusable If the post process can be reused on the same frame. (default: false)
  100886. * @param textureType Type of textures used when performing the post process. (default: 0)
  100887. * @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)
  100888. */
  100889. constructor(name: string,
  100890. /** The direction in which to blur the image. */
  100891. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  100892. /**
  100893. * Updates the effect with the current post process compile time values and recompiles the shader.
  100894. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  100895. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  100896. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  100897. * @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
  100898. * @param onCompiled Called when the shader has been compiled.
  100899. * @param onError Called if there is an error when compiling a shader.
  100900. */
  100901. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100902. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100903. /**
  100904. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  100905. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  100906. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  100907. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  100908. * The gaps between physical kernels are compensated for in the weighting of the samples
  100909. * @param idealKernel Ideal blur kernel.
  100910. * @return Nearest best kernel.
  100911. */
  100912. protected _nearestBestKernel(idealKernel: number): number;
  100913. /**
  100914. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  100915. * @param x The point on the Gaussian distribution to sample.
  100916. * @return the value of the Gaussian function at x.
  100917. */
  100918. protected _gaussianWeight(x: number): number;
  100919. /**
  100920. * Generates a string that can be used as a floating point number in GLSL.
  100921. * @param x Value to print.
  100922. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  100923. * @return GLSL float string.
  100924. */
  100925. protected _glslFloat(x: number, decimalFigures?: number): string;
  100926. }
  100927. }
  100928. declare module BABYLON {
  100929. /**
  100930. * Mirror texture can be used to simulate the view from a mirror in a scene.
  100931. * It will dynamically be rendered every frame to adapt to the camera point of view.
  100932. * You can then easily use it as a reflectionTexture on a flat surface.
  100933. * In case the surface is not a plane, please consider relying on reflection probes.
  100934. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100935. */
  100936. export class MirrorTexture extends RenderTargetTexture {
  100937. private scene;
  100938. /**
  100939. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  100940. * 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.
  100941. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100942. */
  100943. mirrorPlane: Plane;
  100944. /**
  100945. * Define the blur ratio used to blur the reflection if needed.
  100946. */
  100947. set blurRatio(value: number);
  100948. get blurRatio(): number;
  100949. /**
  100950. * Define the adaptive blur kernel used to blur the reflection if needed.
  100951. * This will autocompute the closest best match for the `blurKernel`
  100952. */
  100953. set adaptiveBlurKernel(value: number);
  100954. /**
  100955. * Define the blur kernel used to blur the reflection if needed.
  100956. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100957. */
  100958. set blurKernel(value: number);
  100959. /**
  100960. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  100961. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100962. */
  100963. set blurKernelX(value: number);
  100964. get blurKernelX(): number;
  100965. /**
  100966. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  100967. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100968. */
  100969. set blurKernelY(value: number);
  100970. get blurKernelY(): number;
  100971. private _autoComputeBlurKernel;
  100972. protected _onRatioRescale(): void;
  100973. private _updateGammaSpace;
  100974. private _imageProcessingConfigChangeObserver;
  100975. private _transformMatrix;
  100976. private _mirrorMatrix;
  100977. private _savedViewMatrix;
  100978. private _blurX;
  100979. private _blurY;
  100980. private _adaptiveBlurKernel;
  100981. private _blurKernelX;
  100982. private _blurKernelY;
  100983. private _blurRatio;
  100984. /**
  100985. * Instantiates a Mirror Texture.
  100986. * Mirror texture can be used to simulate the view from a mirror in a scene.
  100987. * It will dynamically be rendered every frame to adapt to the camera point of view.
  100988. * You can then easily use it as a reflectionTexture on a flat surface.
  100989. * In case the surface is not a plane, please consider relying on reflection probes.
  100990. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100991. * @param name
  100992. * @param size
  100993. * @param scene
  100994. * @param generateMipMaps
  100995. * @param type
  100996. * @param samplingMode
  100997. * @param generateDepthBuffer
  100998. */
  100999. constructor(name: string, size: number | {
  101000. width: number;
  101001. height: number;
  101002. } | {
  101003. ratio: number;
  101004. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  101005. private _preparePostProcesses;
  101006. /**
  101007. * Clone the mirror texture.
  101008. * @returns the cloned texture
  101009. */
  101010. clone(): MirrorTexture;
  101011. /**
  101012. * Serialize the texture to a JSON representation you could use in Parse later on
  101013. * @returns the serialized JSON representation
  101014. */
  101015. serialize(): any;
  101016. /**
  101017. * Dispose the texture and release its associated resources.
  101018. */
  101019. dispose(): void;
  101020. }
  101021. }
  101022. declare module BABYLON {
  101023. /**
  101024. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  101025. * @see https://doc.babylonjs.com/babylon101/materials#texture
  101026. */
  101027. export class Texture extends BaseTexture {
  101028. /**
  101029. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  101030. */
  101031. static SerializeBuffers: boolean;
  101032. /** @hidden */
  101033. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  101034. /** @hidden */
  101035. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  101036. /** @hidden */
  101037. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  101038. /** nearest is mag = nearest and min = nearest and mip = linear */
  101039. static readonly NEAREST_SAMPLINGMODE: number;
  101040. /** nearest is mag = nearest and min = nearest and mip = linear */
  101041. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  101042. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101043. static readonly BILINEAR_SAMPLINGMODE: number;
  101044. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101045. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  101046. /** Trilinear is mag = linear and min = linear and mip = linear */
  101047. static readonly TRILINEAR_SAMPLINGMODE: number;
  101048. /** Trilinear is mag = linear and min = linear and mip = linear */
  101049. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  101050. /** mag = nearest and min = nearest and mip = nearest */
  101051. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  101052. /** mag = nearest and min = linear and mip = nearest */
  101053. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  101054. /** mag = nearest and min = linear and mip = linear */
  101055. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  101056. /** mag = nearest and min = linear and mip = none */
  101057. static readonly NEAREST_LINEAR: number;
  101058. /** mag = nearest and min = nearest and mip = none */
  101059. static readonly NEAREST_NEAREST: number;
  101060. /** mag = linear and min = nearest and mip = nearest */
  101061. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  101062. /** mag = linear and min = nearest and mip = linear */
  101063. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  101064. /** mag = linear and min = linear and mip = none */
  101065. static readonly LINEAR_LINEAR: number;
  101066. /** mag = linear and min = nearest and mip = none */
  101067. static readonly LINEAR_NEAREST: number;
  101068. /** Explicit coordinates mode */
  101069. static readonly EXPLICIT_MODE: number;
  101070. /** Spherical coordinates mode */
  101071. static readonly SPHERICAL_MODE: number;
  101072. /** Planar coordinates mode */
  101073. static readonly PLANAR_MODE: number;
  101074. /** Cubic coordinates mode */
  101075. static readonly CUBIC_MODE: number;
  101076. /** Projection coordinates mode */
  101077. static readonly PROJECTION_MODE: number;
  101078. /** Inverse Cubic coordinates mode */
  101079. static readonly SKYBOX_MODE: number;
  101080. /** Inverse Cubic coordinates mode */
  101081. static readonly INVCUBIC_MODE: number;
  101082. /** Equirectangular coordinates mode */
  101083. static readonly EQUIRECTANGULAR_MODE: number;
  101084. /** Equirectangular Fixed coordinates mode */
  101085. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  101086. /** Equirectangular Fixed Mirrored coordinates mode */
  101087. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  101088. /** Texture is not repeating outside of 0..1 UVs */
  101089. static readonly CLAMP_ADDRESSMODE: number;
  101090. /** Texture is repeating outside of 0..1 UVs */
  101091. static readonly WRAP_ADDRESSMODE: number;
  101092. /** Texture is repeating and mirrored */
  101093. static readonly MIRROR_ADDRESSMODE: number;
  101094. /**
  101095. * 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
  101096. */
  101097. static UseSerializedUrlIfAny: boolean;
  101098. /**
  101099. * Define the url of the texture.
  101100. */
  101101. url: Nullable<string>;
  101102. /**
  101103. * Define an offset on the texture to offset the u coordinates of the UVs
  101104. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  101105. */
  101106. uOffset: number;
  101107. /**
  101108. * Define an offset on the texture to offset the v coordinates of the UVs
  101109. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  101110. */
  101111. vOffset: number;
  101112. /**
  101113. * Define an offset on the texture to scale the u coordinates of the UVs
  101114. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  101115. */
  101116. uScale: number;
  101117. /**
  101118. * Define an offset on the texture to scale the v coordinates of the UVs
  101119. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  101120. */
  101121. vScale: number;
  101122. /**
  101123. * Define an offset on the texture to rotate around the u coordinates of the UVs
  101124. * @see https://doc.babylonjs.com/how_to/more_materials
  101125. */
  101126. uAng: number;
  101127. /**
  101128. * Define an offset on the texture to rotate around the v coordinates of the UVs
  101129. * @see https://doc.babylonjs.com/how_to/more_materials
  101130. */
  101131. vAng: number;
  101132. /**
  101133. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  101134. * @see https://doc.babylonjs.com/how_to/more_materials
  101135. */
  101136. wAng: number;
  101137. /**
  101138. * Defines the center of rotation (U)
  101139. */
  101140. uRotationCenter: number;
  101141. /**
  101142. * Defines the center of rotation (V)
  101143. */
  101144. vRotationCenter: number;
  101145. /**
  101146. * Defines the center of rotation (W)
  101147. */
  101148. wRotationCenter: number;
  101149. /**
  101150. * Are mip maps generated for this texture or not.
  101151. */
  101152. get noMipmap(): boolean;
  101153. /**
  101154. * List of inspectable custom properties (used by the Inspector)
  101155. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101156. */
  101157. inspectableCustomProperties: Nullable<IInspectable[]>;
  101158. private _noMipmap;
  101159. /** @hidden */
  101160. _invertY: boolean;
  101161. private _rowGenerationMatrix;
  101162. private _cachedTextureMatrix;
  101163. private _projectionModeMatrix;
  101164. private _t0;
  101165. private _t1;
  101166. private _t2;
  101167. private _cachedUOffset;
  101168. private _cachedVOffset;
  101169. private _cachedUScale;
  101170. private _cachedVScale;
  101171. private _cachedUAng;
  101172. private _cachedVAng;
  101173. private _cachedWAng;
  101174. private _cachedProjectionMatrixId;
  101175. private _cachedCoordinatesMode;
  101176. /** @hidden */
  101177. protected _initialSamplingMode: number;
  101178. /** @hidden */
  101179. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  101180. private _deleteBuffer;
  101181. protected _format: Nullable<number>;
  101182. private _delayedOnLoad;
  101183. private _delayedOnError;
  101184. private _mimeType?;
  101185. /**
  101186. * Observable triggered once the texture has been loaded.
  101187. */
  101188. onLoadObservable: Observable<Texture>;
  101189. protected _isBlocking: boolean;
  101190. /**
  101191. * Is the texture preventing material to render while loading.
  101192. * If false, a default texture will be used instead of the loading one during the preparation step.
  101193. */
  101194. set isBlocking(value: boolean);
  101195. get isBlocking(): boolean;
  101196. /**
  101197. * Get the current sampling mode associated with the texture.
  101198. */
  101199. get samplingMode(): number;
  101200. /**
  101201. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  101202. */
  101203. get invertY(): boolean;
  101204. /**
  101205. * Instantiates a new texture.
  101206. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  101207. * @see https://doc.babylonjs.com/babylon101/materials#texture
  101208. * @param url defines the url of the picture to load as a texture
  101209. * @param sceneOrEngine defines the scene or engine the texture will belong to
  101210. * @param noMipmap defines if the texture will require mip maps or not
  101211. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  101212. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  101213. * @param onLoad defines a callback triggered when the texture has been loaded
  101214. * @param onError defines a callback triggered when an error occurred during the loading session
  101215. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  101216. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  101217. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  101218. * @param mimeType defines an optional mime type information
  101219. */
  101220. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  101221. /**
  101222. * Update the url (and optional buffer) of this texture if url was null during construction.
  101223. * @param url the url of the texture
  101224. * @param buffer the buffer of the texture (defaults to null)
  101225. * @param onLoad callback called when the texture is loaded (defaults to null)
  101226. */
  101227. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  101228. /**
  101229. * Finish the loading sequence of a texture flagged as delayed load.
  101230. * @hidden
  101231. */
  101232. delayLoad(): void;
  101233. private _prepareRowForTextureGeneration;
  101234. /**
  101235. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  101236. * @returns the transform matrix of the texture.
  101237. */
  101238. getTextureMatrix(uBase?: number): Matrix;
  101239. /**
  101240. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  101241. * @returns The reflection texture transform
  101242. */
  101243. getReflectionTextureMatrix(): Matrix;
  101244. /**
  101245. * Clones the texture.
  101246. * @returns the cloned texture
  101247. */
  101248. clone(): Texture;
  101249. /**
  101250. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  101251. * @returns The JSON representation of the texture
  101252. */
  101253. serialize(): any;
  101254. /**
  101255. * Get the current class name of the texture useful for serialization or dynamic coding.
  101256. * @returns "Texture"
  101257. */
  101258. getClassName(): string;
  101259. /**
  101260. * Dispose the texture and release its associated resources.
  101261. */
  101262. dispose(): void;
  101263. /**
  101264. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  101265. * @param parsedTexture Define the JSON representation of the texture
  101266. * @param scene Define the scene the parsed texture should be instantiated in
  101267. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  101268. * @returns The parsed texture if successful
  101269. */
  101270. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  101271. /**
  101272. * Creates a texture from its base 64 representation.
  101273. * @param data Define the base64 payload without the data: prefix
  101274. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  101275. * @param scene Define the scene the texture should belong to
  101276. * @param noMipmap Forces the texture to not create mip map information if true
  101277. * @param invertY define if the texture needs to be inverted on the y axis during loading
  101278. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  101279. * @param onLoad define a callback triggered when the texture has been loaded
  101280. * @param onError define a callback triggered when an error occurred during the loading session
  101281. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  101282. * @returns the created texture
  101283. */
  101284. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  101285. /**
  101286. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  101287. * @param data Define the base64 payload without the data: prefix
  101288. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  101289. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  101290. * @param scene Define the scene the texture should belong to
  101291. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  101292. * @param noMipmap Forces the texture to not create mip map information if true
  101293. * @param invertY define if the texture needs to be inverted on the y axis during loading
  101294. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  101295. * @param onLoad define a callback triggered when the texture has been loaded
  101296. * @param onError define a callback triggered when an error occurred during the loading session
  101297. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  101298. * @returns the created texture
  101299. */
  101300. 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;
  101301. }
  101302. }
  101303. declare module BABYLON {
  101304. /**
  101305. * PostProcessManager is used to manage one or more post processes or post process pipelines
  101306. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  101307. */
  101308. export class PostProcessManager {
  101309. private _scene;
  101310. private _indexBuffer;
  101311. private _vertexBuffers;
  101312. /**
  101313. * Creates a new instance PostProcess
  101314. * @param scene The scene that the post process is associated with.
  101315. */
  101316. constructor(scene: Scene);
  101317. private _prepareBuffers;
  101318. private _buildIndexBuffer;
  101319. /**
  101320. * Rebuilds the vertex buffers of the manager.
  101321. * @hidden
  101322. */
  101323. _rebuild(): void;
  101324. /**
  101325. * Prepares a frame to be run through a post process.
  101326. * @param sourceTexture The input texture to the post procesess. (default: null)
  101327. * @param postProcesses An array of post processes to be run. (default: null)
  101328. * @returns True if the post processes were able to be run.
  101329. * @hidden
  101330. */
  101331. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  101332. /**
  101333. * Manually render a set of post processes to a texture.
  101334. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  101335. * @param postProcesses An array of post processes to be run.
  101336. * @param targetTexture The target texture to render to.
  101337. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  101338. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  101339. * @param lodLevel defines which lod of the texture to render to
  101340. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  101341. */
  101342. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  101343. /**
  101344. * Finalize the result of the output of the postprocesses.
  101345. * @param doNotPresent If true the result will not be displayed to the screen.
  101346. * @param targetTexture The target texture to render to.
  101347. * @param faceIndex The index of the face to bind the target texture to.
  101348. * @param postProcesses The array of post processes to render.
  101349. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  101350. * @hidden
  101351. */
  101352. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  101353. /**
  101354. * Disposes of the post process manager.
  101355. */
  101356. dispose(): void;
  101357. }
  101358. }
  101359. declare module BABYLON {
  101360. /**
  101361. * This Helps creating a texture that will be created from a camera in your scene.
  101362. * It is basically a dynamic texture that could be used to create special effects for instance.
  101363. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  101364. */
  101365. export class RenderTargetTexture extends Texture {
  101366. isCube: boolean;
  101367. /**
  101368. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  101369. */
  101370. static readonly REFRESHRATE_RENDER_ONCE: number;
  101371. /**
  101372. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  101373. */
  101374. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  101375. /**
  101376. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  101377. * the central point of your effect and can save a lot of performances.
  101378. */
  101379. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  101380. /**
  101381. * Use this predicate to dynamically define the list of mesh you want to render.
  101382. * If set, the renderList property will be overwritten.
  101383. */
  101384. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  101385. private _renderList;
  101386. /**
  101387. * Use this list to define the list of mesh you want to render.
  101388. */
  101389. get renderList(): Nullable<Array<AbstractMesh>>;
  101390. set renderList(value: Nullable<Array<AbstractMesh>>);
  101391. /**
  101392. * Use this function to overload the renderList array at rendering time.
  101393. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  101394. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  101395. * the cube (if the RTT is a cube, else layerOrFace=0).
  101396. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  101397. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  101398. * hold dummy elements!
  101399. */
  101400. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  101401. private _hookArray;
  101402. /**
  101403. * Define if particles should be rendered in your texture.
  101404. */
  101405. renderParticles: boolean;
  101406. /**
  101407. * Define if sprites should be rendered in your texture.
  101408. */
  101409. renderSprites: boolean;
  101410. /**
  101411. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  101412. */
  101413. coordinatesMode: number;
  101414. /**
  101415. * Define the camera used to render the texture.
  101416. */
  101417. activeCamera: Nullable<Camera>;
  101418. /**
  101419. * Override the mesh isReady function with your own one.
  101420. */
  101421. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  101422. /**
  101423. * Override the render function of the texture with your own one.
  101424. */
  101425. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  101426. /**
  101427. * Define if camera post processes should be use while rendering the texture.
  101428. */
  101429. useCameraPostProcesses: boolean;
  101430. /**
  101431. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  101432. */
  101433. ignoreCameraViewport: boolean;
  101434. private _postProcessManager;
  101435. private _postProcesses;
  101436. private _resizeObserver;
  101437. /**
  101438. * An event triggered when the texture is unbind.
  101439. */
  101440. onBeforeBindObservable: Observable<RenderTargetTexture>;
  101441. /**
  101442. * An event triggered when the texture is unbind.
  101443. */
  101444. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  101445. private _onAfterUnbindObserver;
  101446. /**
  101447. * Set a after unbind callback in the texture.
  101448. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  101449. */
  101450. set onAfterUnbind(callback: () => void);
  101451. /**
  101452. * An event triggered before rendering the texture
  101453. */
  101454. onBeforeRenderObservable: Observable<number>;
  101455. private _onBeforeRenderObserver;
  101456. /**
  101457. * Set a before render callback in the texture.
  101458. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  101459. */
  101460. set onBeforeRender(callback: (faceIndex: number) => void);
  101461. /**
  101462. * An event triggered after rendering the texture
  101463. */
  101464. onAfterRenderObservable: Observable<number>;
  101465. private _onAfterRenderObserver;
  101466. /**
  101467. * Set a after render callback in the texture.
  101468. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  101469. */
  101470. set onAfterRender(callback: (faceIndex: number) => void);
  101471. /**
  101472. * An event triggered after the texture clear
  101473. */
  101474. onClearObservable: Observable<Engine>;
  101475. private _onClearObserver;
  101476. /**
  101477. * Set a clear callback in the texture.
  101478. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  101479. */
  101480. set onClear(callback: (Engine: Engine) => void);
  101481. /**
  101482. * An event triggered when the texture is resized.
  101483. */
  101484. onResizeObservable: Observable<RenderTargetTexture>;
  101485. /**
  101486. * Define the clear color of the Render Target if it should be different from the scene.
  101487. */
  101488. clearColor: Color4;
  101489. protected _size: number | {
  101490. width: number;
  101491. height: number;
  101492. layers?: number;
  101493. };
  101494. protected _initialSizeParameter: number | {
  101495. width: number;
  101496. height: number;
  101497. } | {
  101498. ratio: number;
  101499. };
  101500. protected _sizeRatio: Nullable<number>;
  101501. /** @hidden */
  101502. _generateMipMaps: boolean;
  101503. protected _renderingManager: RenderingManager;
  101504. /** @hidden */
  101505. _waitingRenderList: string[];
  101506. protected _doNotChangeAspectRatio: boolean;
  101507. protected _currentRefreshId: number;
  101508. protected _refreshRate: number;
  101509. protected _textureMatrix: Matrix;
  101510. protected _samples: number;
  101511. protected _renderTargetOptions: RenderTargetCreationOptions;
  101512. /**
  101513. * Gets render target creation options that were used.
  101514. */
  101515. get renderTargetOptions(): RenderTargetCreationOptions;
  101516. protected _onRatioRescale(): void;
  101517. /**
  101518. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  101519. * It must define where the camera used to render the texture is set
  101520. */
  101521. boundingBoxPosition: Vector3;
  101522. private _boundingBoxSize;
  101523. /**
  101524. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  101525. * When defined, the cubemap will switch to local mode
  101526. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  101527. * @example https://www.babylonjs-playground.com/#RNASML
  101528. */
  101529. set boundingBoxSize(value: Vector3);
  101530. get boundingBoxSize(): Vector3;
  101531. /**
  101532. * In case the RTT has been created with a depth texture, get the associated
  101533. * depth texture.
  101534. * Otherwise, return null.
  101535. */
  101536. get depthStencilTexture(): Nullable<InternalTexture>;
  101537. /**
  101538. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  101539. * or used a shadow, depth texture...
  101540. * @param name The friendly name of the texture
  101541. * @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)
  101542. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  101543. * @param generateMipMaps True if mip maps need to be generated after render.
  101544. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  101545. * @param type The type of the buffer in the RTT (int, half float, float...)
  101546. * @param isCube True if a cube texture needs to be created
  101547. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  101548. * @param generateDepthBuffer True to generate a depth buffer
  101549. * @param generateStencilBuffer True to generate a stencil buffer
  101550. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  101551. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  101552. * @param delayAllocation if the texture allocation should be delayed (default: false)
  101553. */
  101554. constructor(name: string, size: number | {
  101555. width: number;
  101556. height: number;
  101557. layers?: number;
  101558. } | {
  101559. ratio: number;
  101560. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  101561. /**
  101562. * Creates a depth stencil texture.
  101563. * This is only available in WebGL 2 or with the depth texture extension available.
  101564. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  101565. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  101566. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  101567. */
  101568. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  101569. private _processSizeParameter;
  101570. /**
  101571. * Define the number of samples to use in case of MSAA.
  101572. * It defaults to one meaning no MSAA has been enabled.
  101573. */
  101574. get samples(): number;
  101575. set samples(value: number);
  101576. /**
  101577. * Resets the refresh counter of the texture and start bak from scratch.
  101578. * Could be useful to regenerate the texture if it is setup to render only once.
  101579. */
  101580. resetRefreshCounter(): void;
  101581. /**
  101582. * Define the refresh rate of the texture or the rendering frequency.
  101583. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  101584. */
  101585. get refreshRate(): number;
  101586. set refreshRate(value: number);
  101587. /**
  101588. * Adds a post process to the render target rendering passes.
  101589. * @param postProcess define the post process to add
  101590. */
  101591. addPostProcess(postProcess: PostProcess): void;
  101592. /**
  101593. * Clear all the post processes attached to the render target
  101594. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  101595. */
  101596. clearPostProcesses(dispose?: boolean): void;
  101597. /**
  101598. * Remove one of the post process from the list of attached post processes to the texture
  101599. * @param postProcess define the post process to remove from the list
  101600. */
  101601. removePostProcess(postProcess: PostProcess): void;
  101602. /** @hidden */
  101603. _shouldRender(): boolean;
  101604. /**
  101605. * Gets the actual render size of the texture.
  101606. * @returns the width of the render size
  101607. */
  101608. getRenderSize(): number;
  101609. /**
  101610. * Gets the actual render width of the texture.
  101611. * @returns the width of the render size
  101612. */
  101613. getRenderWidth(): number;
  101614. /**
  101615. * Gets the actual render height of the texture.
  101616. * @returns the height of the render size
  101617. */
  101618. getRenderHeight(): number;
  101619. /**
  101620. * Gets the actual number of layers of the texture.
  101621. * @returns the number of layers
  101622. */
  101623. getRenderLayers(): number;
  101624. /**
  101625. * Get if the texture can be rescaled or not.
  101626. */
  101627. get canRescale(): boolean;
  101628. /**
  101629. * Resize the texture using a ratio.
  101630. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  101631. */
  101632. scale(ratio: number): void;
  101633. /**
  101634. * Get the texture reflection matrix used to rotate/transform the reflection.
  101635. * @returns the reflection matrix
  101636. */
  101637. getReflectionTextureMatrix(): Matrix;
  101638. /**
  101639. * Resize the texture to a new desired size.
  101640. * Be carrefull as it will recreate all the data in the new texture.
  101641. * @param size Define the new size. It can be:
  101642. * - a number for squared texture,
  101643. * - an object containing { width: number, height: number }
  101644. * - or an object containing a ratio { ratio: number }
  101645. */
  101646. resize(size: number | {
  101647. width: number;
  101648. height: number;
  101649. } | {
  101650. ratio: number;
  101651. }): void;
  101652. private _defaultRenderListPrepared;
  101653. /**
  101654. * Renders all the objects from the render list into the texture.
  101655. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  101656. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  101657. */
  101658. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  101659. private _bestReflectionRenderTargetDimension;
  101660. private _prepareRenderingManager;
  101661. /**
  101662. * @hidden
  101663. * @param faceIndex face index to bind to if this is a cubetexture
  101664. * @param layer defines the index of the texture to bind in the array
  101665. */
  101666. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  101667. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  101668. private renderToTarget;
  101669. /**
  101670. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  101671. * This allowed control for front to back rendering or reversly depending of the special needs.
  101672. *
  101673. * @param renderingGroupId The rendering group id corresponding to its index
  101674. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  101675. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  101676. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  101677. */
  101678. 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;
  101679. /**
  101680. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  101681. *
  101682. * @param renderingGroupId The rendering group id corresponding to its index
  101683. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101684. */
  101685. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  101686. /**
  101687. * Clones the texture.
  101688. * @returns the cloned texture
  101689. */
  101690. clone(): RenderTargetTexture;
  101691. /**
  101692. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  101693. * @returns The JSON representation of the texture
  101694. */
  101695. serialize(): any;
  101696. /**
  101697. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  101698. */
  101699. disposeFramebufferObjects(): void;
  101700. /**
  101701. * Dispose the texture and release its associated resources.
  101702. */
  101703. dispose(): void;
  101704. /** @hidden */
  101705. _rebuild(): void;
  101706. /**
  101707. * Clear the info related to rendering groups preventing retention point in material dispose.
  101708. */
  101709. freeRenderingGroups(): void;
  101710. /**
  101711. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  101712. * @returns the view count
  101713. */
  101714. getViewCount(): number;
  101715. }
  101716. }
  101717. declare module BABYLON {
  101718. /**
  101719. * Class used to manipulate GUIDs
  101720. */
  101721. export class GUID {
  101722. /**
  101723. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  101724. * Be aware Math.random() could cause collisions, but:
  101725. * "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"
  101726. * @returns a pseudo random id
  101727. */
  101728. static RandomId(): string;
  101729. }
  101730. }
  101731. declare module BABYLON {
  101732. /**
  101733. * Options to be used when creating a shadow depth material
  101734. */
  101735. export interface IIOptionShadowDepthMaterial {
  101736. /** Variables in the vertex shader code that need to have their names remapped.
  101737. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  101738. * "var_name" should be either: worldPos or vNormalW
  101739. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  101740. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  101741. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  101742. */
  101743. remappedVariables?: string[];
  101744. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  101745. standalone?: boolean;
  101746. }
  101747. /**
  101748. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  101749. */
  101750. export class ShadowDepthWrapper {
  101751. private _scene;
  101752. private _options?;
  101753. private _baseMaterial;
  101754. private _onEffectCreatedObserver;
  101755. private _subMeshToEffect;
  101756. private _subMeshToDepthEffect;
  101757. private _meshes;
  101758. /** @hidden */
  101759. _matriceNames: any;
  101760. /** Gets the standalone status of the wrapper */
  101761. get standalone(): boolean;
  101762. /** Gets the base material the wrapper is built upon */
  101763. get baseMaterial(): Material;
  101764. /**
  101765. * Instantiate a new shadow depth wrapper.
  101766. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  101767. * generate the shadow depth map. For more information, please refer to the documentation:
  101768. * https://doc.babylonjs.com/babylon101/shadows
  101769. * @param baseMaterial Material to wrap
  101770. * @param scene Define the scene the material belongs to
  101771. * @param options Options used to create the wrapper
  101772. */
  101773. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  101774. /**
  101775. * Gets the effect to use to generate the depth map
  101776. * @param subMesh subMesh to get the effect for
  101777. * @param shadowGenerator shadow generator to get the effect for
  101778. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  101779. */
  101780. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  101781. /**
  101782. * Specifies that the submesh is ready to be used for depth rendering
  101783. * @param subMesh submesh to check
  101784. * @param defines the list of defines to take into account when checking the effect
  101785. * @param shadowGenerator combined with subMesh, it defines the effect to check
  101786. * @param useInstances specifies that instances should be used
  101787. * @returns a boolean indicating that the submesh is ready or not
  101788. */
  101789. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  101790. /**
  101791. * Disposes the resources
  101792. */
  101793. dispose(): void;
  101794. private _makeEffect;
  101795. }
  101796. }
  101797. declare module BABYLON {
  101798. /**
  101799. * Options for compiling materials.
  101800. */
  101801. export interface IMaterialCompilationOptions {
  101802. /**
  101803. * Defines whether clip planes are enabled.
  101804. */
  101805. clipPlane: boolean;
  101806. /**
  101807. * Defines whether instances are enabled.
  101808. */
  101809. useInstances: boolean;
  101810. }
  101811. /**
  101812. * Options passed when calling customShaderNameResolve
  101813. */
  101814. export interface ICustomShaderNameResolveOptions {
  101815. /**
  101816. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  101817. */
  101818. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  101819. }
  101820. /**
  101821. * Base class for the main features of a material in Babylon.js
  101822. */
  101823. export class Material implements IAnimatable {
  101824. /**
  101825. * Returns the triangle fill mode
  101826. */
  101827. static readonly TriangleFillMode: number;
  101828. /**
  101829. * Returns the wireframe mode
  101830. */
  101831. static readonly WireFrameFillMode: number;
  101832. /**
  101833. * Returns the point fill mode
  101834. */
  101835. static readonly PointFillMode: number;
  101836. /**
  101837. * Returns the point list draw mode
  101838. */
  101839. static readonly PointListDrawMode: number;
  101840. /**
  101841. * Returns the line list draw mode
  101842. */
  101843. static readonly LineListDrawMode: number;
  101844. /**
  101845. * Returns the line loop draw mode
  101846. */
  101847. static readonly LineLoopDrawMode: number;
  101848. /**
  101849. * Returns the line strip draw mode
  101850. */
  101851. static readonly LineStripDrawMode: number;
  101852. /**
  101853. * Returns the triangle strip draw mode
  101854. */
  101855. static readonly TriangleStripDrawMode: number;
  101856. /**
  101857. * Returns the triangle fan draw mode
  101858. */
  101859. static readonly TriangleFanDrawMode: number;
  101860. /**
  101861. * Stores the clock-wise side orientation
  101862. */
  101863. static readonly ClockWiseSideOrientation: number;
  101864. /**
  101865. * Stores the counter clock-wise side orientation
  101866. */
  101867. static readonly CounterClockWiseSideOrientation: number;
  101868. /**
  101869. * The dirty texture flag value
  101870. */
  101871. static readonly TextureDirtyFlag: number;
  101872. /**
  101873. * The dirty light flag value
  101874. */
  101875. static readonly LightDirtyFlag: number;
  101876. /**
  101877. * The dirty fresnel flag value
  101878. */
  101879. static readonly FresnelDirtyFlag: number;
  101880. /**
  101881. * The dirty attribute flag value
  101882. */
  101883. static readonly AttributesDirtyFlag: number;
  101884. /**
  101885. * The dirty misc flag value
  101886. */
  101887. static readonly MiscDirtyFlag: number;
  101888. /**
  101889. * The all dirty flag value
  101890. */
  101891. static readonly AllDirtyFlag: number;
  101892. /**
  101893. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  101894. */
  101895. static readonly MATERIAL_OPAQUE: number;
  101896. /**
  101897. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  101898. */
  101899. static readonly MATERIAL_ALPHATEST: number;
  101900. /**
  101901. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101902. */
  101903. static readonly MATERIAL_ALPHABLEND: number;
  101904. /**
  101905. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101906. * They are also discarded below the alpha cutoff threshold to improve performances.
  101907. */
  101908. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  101909. /**
  101910. * The Whiteout method is used to blend normals.
  101911. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  101912. */
  101913. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  101914. /**
  101915. * The Reoriented Normal Mapping method is used to blend normals.
  101916. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  101917. */
  101918. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  101919. /**
  101920. * Custom callback helping to override the default shader used in the material.
  101921. */
  101922. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  101923. /**
  101924. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  101925. */
  101926. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  101927. /**
  101928. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  101929. * This means that the material can keep using a previous shader while a new one is being compiled.
  101930. * This is mostly used when shader parallel compilation is supported (true by default)
  101931. */
  101932. allowShaderHotSwapping: boolean;
  101933. /**
  101934. * The ID of the material
  101935. */
  101936. id: string;
  101937. /**
  101938. * Gets or sets the unique id of the material
  101939. */
  101940. uniqueId: number;
  101941. /**
  101942. * The name of the material
  101943. */
  101944. name: string;
  101945. /**
  101946. * Gets or sets user defined metadata
  101947. */
  101948. metadata: any;
  101949. /**
  101950. * For internal use only. Please do not use.
  101951. */
  101952. reservedDataStore: any;
  101953. /**
  101954. * Specifies if the ready state should be checked on each call
  101955. */
  101956. checkReadyOnEveryCall: boolean;
  101957. /**
  101958. * Specifies if the ready state should be checked once
  101959. */
  101960. checkReadyOnlyOnce: boolean;
  101961. /**
  101962. * The state of the material
  101963. */
  101964. state: string;
  101965. /**
  101966. * If the material should be rendered to several textures with MRT extension
  101967. */
  101968. get shouldRenderToMRT(): boolean;
  101969. /**
  101970. * The alpha value of the material
  101971. */
  101972. protected _alpha: number;
  101973. /**
  101974. * List of inspectable custom properties (used by the Inspector)
  101975. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101976. */
  101977. inspectableCustomProperties: IInspectable[];
  101978. /**
  101979. * Sets the alpha value of the material
  101980. */
  101981. set alpha(value: number);
  101982. /**
  101983. * Gets the alpha value of the material
  101984. */
  101985. get alpha(): number;
  101986. /**
  101987. * Specifies if back face culling is enabled
  101988. */
  101989. protected _backFaceCulling: boolean;
  101990. /**
  101991. * Sets the back-face culling state
  101992. */
  101993. set backFaceCulling(value: boolean);
  101994. /**
  101995. * Gets the back-face culling state
  101996. */
  101997. get backFaceCulling(): boolean;
  101998. /**
  101999. * Stores the value for side orientation
  102000. */
  102001. sideOrientation: number;
  102002. /**
  102003. * Callback triggered when the material is compiled
  102004. */
  102005. onCompiled: Nullable<(effect: Effect) => void>;
  102006. /**
  102007. * Callback triggered when an error occurs
  102008. */
  102009. onError: Nullable<(effect: Effect, errors: string) => void>;
  102010. /**
  102011. * Callback triggered to get the render target textures
  102012. */
  102013. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  102014. /**
  102015. * Gets a boolean indicating that current material needs to register RTT
  102016. */
  102017. get hasRenderTargetTextures(): boolean;
  102018. /**
  102019. * Specifies if the material should be serialized
  102020. */
  102021. doNotSerialize: boolean;
  102022. /**
  102023. * @hidden
  102024. */
  102025. _storeEffectOnSubMeshes: boolean;
  102026. /**
  102027. * Stores the animations for the material
  102028. */
  102029. animations: Nullable<Array<Animation>>;
  102030. /**
  102031. * An event triggered when the material is disposed
  102032. */
  102033. onDisposeObservable: Observable<Material>;
  102034. /**
  102035. * An observer which watches for dispose events
  102036. */
  102037. private _onDisposeObserver;
  102038. private _onUnBindObservable;
  102039. /**
  102040. * Called during a dispose event
  102041. */
  102042. set onDispose(callback: () => void);
  102043. private _onBindObservable;
  102044. /**
  102045. * An event triggered when the material is bound
  102046. */
  102047. get onBindObservable(): Observable<AbstractMesh>;
  102048. /**
  102049. * An observer which watches for bind events
  102050. */
  102051. private _onBindObserver;
  102052. /**
  102053. * Called during a bind event
  102054. */
  102055. set onBind(callback: (Mesh: AbstractMesh) => void);
  102056. /**
  102057. * An event triggered when the material is unbound
  102058. */
  102059. get onUnBindObservable(): Observable<Material>;
  102060. protected _onEffectCreatedObservable: Nullable<Observable<{
  102061. effect: Effect;
  102062. subMesh: Nullable<SubMesh>;
  102063. }>>;
  102064. /**
  102065. * An event triggered when the effect is (re)created
  102066. */
  102067. get onEffectCreatedObservable(): Observable<{
  102068. effect: Effect;
  102069. subMesh: Nullable<SubMesh>;
  102070. }>;
  102071. /**
  102072. * Stores the value of the alpha mode
  102073. */
  102074. private _alphaMode;
  102075. /**
  102076. * Sets the value of the alpha mode.
  102077. *
  102078. * | Value | Type | Description |
  102079. * | --- | --- | --- |
  102080. * | 0 | ALPHA_DISABLE | |
  102081. * | 1 | ALPHA_ADD | |
  102082. * | 2 | ALPHA_COMBINE | |
  102083. * | 3 | ALPHA_SUBTRACT | |
  102084. * | 4 | ALPHA_MULTIPLY | |
  102085. * | 5 | ALPHA_MAXIMIZED | |
  102086. * | 6 | ALPHA_ONEONE | |
  102087. * | 7 | ALPHA_PREMULTIPLIED | |
  102088. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  102089. * | 9 | ALPHA_INTERPOLATE | |
  102090. * | 10 | ALPHA_SCREENMODE | |
  102091. *
  102092. */
  102093. set alphaMode(value: number);
  102094. /**
  102095. * Gets the value of the alpha mode
  102096. */
  102097. get alphaMode(): number;
  102098. /**
  102099. * Stores the state of the need depth pre-pass value
  102100. */
  102101. private _needDepthPrePass;
  102102. /**
  102103. * Sets the need depth pre-pass value
  102104. */
  102105. set needDepthPrePass(value: boolean);
  102106. /**
  102107. * Gets the depth pre-pass value
  102108. */
  102109. get needDepthPrePass(): boolean;
  102110. /**
  102111. * Specifies if depth writing should be disabled
  102112. */
  102113. disableDepthWrite: boolean;
  102114. /**
  102115. * Specifies if color writing should be disabled
  102116. */
  102117. disableColorWrite: boolean;
  102118. /**
  102119. * Specifies if depth writing should be forced
  102120. */
  102121. forceDepthWrite: boolean;
  102122. /**
  102123. * Specifies the depth function that should be used. 0 means the default engine function
  102124. */
  102125. depthFunction: number;
  102126. /**
  102127. * Specifies if there should be a separate pass for culling
  102128. */
  102129. separateCullingPass: boolean;
  102130. /**
  102131. * Stores the state specifing if fog should be enabled
  102132. */
  102133. private _fogEnabled;
  102134. /**
  102135. * Sets the state for enabling fog
  102136. */
  102137. set fogEnabled(value: boolean);
  102138. /**
  102139. * Gets the value of the fog enabled state
  102140. */
  102141. get fogEnabled(): boolean;
  102142. /**
  102143. * Stores the size of points
  102144. */
  102145. pointSize: number;
  102146. /**
  102147. * Stores the z offset value
  102148. */
  102149. zOffset: number;
  102150. get wireframe(): boolean;
  102151. /**
  102152. * Sets the state of wireframe mode
  102153. */
  102154. set wireframe(value: boolean);
  102155. /**
  102156. * Gets the value specifying if point clouds are enabled
  102157. */
  102158. get pointsCloud(): boolean;
  102159. /**
  102160. * Sets the state of point cloud mode
  102161. */
  102162. set pointsCloud(value: boolean);
  102163. /**
  102164. * Gets the material fill mode
  102165. */
  102166. get fillMode(): number;
  102167. /**
  102168. * Sets the material fill mode
  102169. */
  102170. set fillMode(value: number);
  102171. /**
  102172. * @hidden
  102173. * Stores the effects for the material
  102174. */
  102175. _effect: Nullable<Effect>;
  102176. /**
  102177. * Specifies if uniform buffers should be used
  102178. */
  102179. private _useUBO;
  102180. /**
  102181. * Stores a reference to the scene
  102182. */
  102183. private _scene;
  102184. /**
  102185. * Stores the fill mode state
  102186. */
  102187. private _fillMode;
  102188. /**
  102189. * Specifies if the depth write state should be cached
  102190. */
  102191. private _cachedDepthWriteState;
  102192. /**
  102193. * Specifies if the color write state should be cached
  102194. */
  102195. private _cachedColorWriteState;
  102196. /**
  102197. * Specifies if the depth function state should be cached
  102198. */
  102199. private _cachedDepthFunctionState;
  102200. /**
  102201. * Stores the uniform buffer
  102202. */
  102203. protected _uniformBuffer: UniformBuffer;
  102204. /** @hidden */
  102205. _indexInSceneMaterialArray: number;
  102206. /** @hidden */
  102207. meshMap: Nullable<{
  102208. [id: string]: AbstractMesh | undefined;
  102209. }>;
  102210. /**
  102211. * Creates a material instance
  102212. * @param name defines the name of the material
  102213. * @param scene defines the scene to reference
  102214. * @param doNotAdd specifies if the material should be added to the scene
  102215. */
  102216. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  102217. /**
  102218. * Returns a string representation of the current material
  102219. * @param fullDetails defines a boolean indicating which levels of logging is desired
  102220. * @returns a string with material information
  102221. */
  102222. toString(fullDetails?: boolean): string;
  102223. /**
  102224. * Gets the class name of the material
  102225. * @returns a string with the class name of the material
  102226. */
  102227. getClassName(): string;
  102228. /**
  102229. * Specifies if updates for the material been locked
  102230. */
  102231. get isFrozen(): boolean;
  102232. /**
  102233. * Locks updates for the material
  102234. */
  102235. freeze(): void;
  102236. /**
  102237. * Unlocks updates for the material
  102238. */
  102239. unfreeze(): void;
  102240. /**
  102241. * Specifies if the material is ready to be used
  102242. * @param mesh defines the mesh to check
  102243. * @param useInstances specifies if instances should be used
  102244. * @returns a boolean indicating if the material is ready to be used
  102245. */
  102246. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102247. /**
  102248. * Specifies that the submesh is ready to be used
  102249. * @param mesh defines the mesh to check
  102250. * @param subMesh defines which submesh to check
  102251. * @param useInstances specifies that instances should be used
  102252. * @returns a boolean indicating that the submesh is ready or not
  102253. */
  102254. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102255. /**
  102256. * Returns the material effect
  102257. * @returns the effect associated with the material
  102258. */
  102259. getEffect(): Nullable<Effect>;
  102260. /**
  102261. * Returns the current scene
  102262. * @returns a Scene
  102263. */
  102264. getScene(): Scene;
  102265. /**
  102266. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  102267. */
  102268. protected _forceAlphaTest: boolean;
  102269. /**
  102270. * The transparency mode of the material.
  102271. */
  102272. protected _transparencyMode: Nullable<number>;
  102273. /**
  102274. * Gets the current transparency mode.
  102275. */
  102276. get transparencyMode(): Nullable<number>;
  102277. /**
  102278. * Sets the transparency mode of the material.
  102279. *
  102280. * | Value | Type | Description |
  102281. * | ----- | ----------------------------------- | ----------- |
  102282. * | 0 | OPAQUE | |
  102283. * | 1 | ALPHATEST | |
  102284. * | 2 | ALPHABLEND | |
  102285. * | 3 | ALPHATESTANDBLEND | |
  102286. *
  102287. */
  102288. set transparencyMode(value: Nullable<number>);
  102289. /**
  102290. * Returns true if alpha blending should be disabled.
  102291. */
  102292. protected get _disableAlphaBlending(): boolean;
  102293. /**
  102294. * Specifies whether or not this material should be rendered in alpha blend mode.
  102295. * @returns a boolean specifying if alpha blending is needed
  102296. */
  102297. needAlphaBlending(): boolean;
  102298. /**
  102299. * Specifies if the mesh will require alpha blending
  102300. * @param mesh defines the mesh to check
  102301. * @returns a boolean specifying if alpha blending is needed for the mesh
  102302. */
  102303. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  102304. /**
  102305. * Specifies whether or not this material should be rendered in alpha test mode.
  102306. * @returns a boolean specifying if an alpha test is needed.
  102307. */
  102308. needAlphaTesting(): boolean;
  102309. /**
  102310. * Specifies if material alpha testing should be turned on for the mesh
  102311. * @param mesh defines the mesh to check
  102312. */
  102313. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  102314. /**
  102315. * Gets the texture used for the alpha test
  102316. * @returns the texture to use for alpha testing
  102317. */
  102318. getAlphaTestTexture(): Nullable<BaseTexture>;
  102319. /**
  102320. * Marks the material to indicate that it needs to be re-calculated
  102321. */
  102322. markDirty(): void;
  102323. /** @hidden */
  102324. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  102325. /**
  102326. * Binds the material to the mesh
  102327. * @param world defines the world transformation matrix
  102328. * @param mesh defines the mesh to bind the material to
  102329. */
  102330. bind(world: Matrix, mesh?: Mesh): void;
  102331. /**
  102332. * Binds the submesh to the material
  102333. * @param world defines the world transformation matrix
  102334. * @param mesh defines the mesh containing the submesh
  102335. * @param subMesh defines the submesh to bind the material to
  102336. */
  102337. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102338. /**
  102339. * Binds the world matrix to the material
  102340. * @param world defines the world transformation matrix
  102341. */
  102342. bindOnlyWorldMatrix(world: Matrix): void;
  102343. /**
  102344. * Binds the scene's uniform buffer to the effect.
  102345. * @param effect defines the effect to bind to the scene uniform buffer
  102346. * @param sceneUbo defines the uniform buffer storing scene data
  102347. */
  102348. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  102349. /**
  102350. * Binds the view matrix to the effect
  102351. * @param effect defines the effect to bind the view matrix to
  102352. */
  102353. bindView(effect: Effect): void;
  102354. /**
  102355. * Binds the view projection matrix to the effect
  102356. * @param effect defines the effect to bind the view projection matrix to
  102357. */
  102358. bindViewProjection(effect: Effect): void;
  102359. /**
  102360. * Processes to execute after binding the material to a mesh
  102361. * @param mesh defines the rendered mesh
  102362. */
  102363. protected _afterBind(mesh?: Mesh): void;
  102364. /**
  102365. * Unbinds the material from the mesh
  102366. */
  102367. unbind(): void;
  102368. /**
  102369. * Gets the active textures from the material
  102370. * @returns an array of textures
  102371. */
  102372. getActiveTextures(): BaseTexture[];
  102373. /**
  102374. * Specifies if the material uses a texture
  102375. * @param texture defines the texture to check against the material
  102376. * @returns a boolean specifying if the material uses the texture
  102377. */
  102378. hasTexture(texture: BaseTexture): boolean;
  102379. /**
  102380. * Makes a duplicate of the material, and gives it a new name
  102381. * @param name defines the new name for the duplicated material
  102382. * @returns the cloned material
  102383. */
  102384. clone(name: string): Nullable<Material>;
  102385. /**
  102386. * Gets the meshes bound to the material
  102387. * @returns an array of meshes bound to the material
  102388. */
  102389. getBindedMeshes(): AbstractMesh[];
  102390. /**
  102391. * Force shader compilation
  102392. * @param mesh defines the mesh associated with this material
  102393. * @param onCompiled defines a function to execute once the material is compiled
  102394. * @param options defines the options to configure the compilation
  102395. * @param onError defines a function to execute if the material fails compiling
  102396. */
  102397. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  102398. /**
  102399. * Force shader compilation
  102400. * @param mesh defines the mesh that will use this material
  102401. * @param options defines additional options for compiling the shaders
  102402. * @returns a promise that resolves when the compilation completes
  102403. */
  102404. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  102405. private static readonly _AllDirtyCallBack;
  102406. private static readonly _ImageProcessingDirtyCallBack;
  102407. private static readonly _TextureDirtyCallBack;
  102408. private static readonly _FresnelDirtyCallBack;
  102409. private static readonly _MiscDirtyCallBack;
  102410. private static readonly _LightsDirtyCallBack;
  102411. private static readonly _AttributeDirtyCallBack;
  102412. private static _FresnelAndMiscDirtyCallBack;
  102413. private static _TextureAndMiscDirtyCallBack;
  102414. private static readonly _DirtyCallbackArray;
  102415. private static readonly _RunDirtyCallBacks;
  102416. /**
  102417. * Marks a define in the material to indicate that it needs to be re-computed
  102418. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  102419. */
  102420. markAsDirty(flag: number): void;
  102421. /**
  102422. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  102423. * @param func defines a function which checks material defines against the submeshes
  102424. */
  102425. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  102426. /**
  102427. * Indicates that the scene should check if the rendering now needs a prepass
  102428. */
  102429. protected _markScenePrePassDirty(): void;
  102430. /**
  102431. * Indicates that we need to re-calculated for all submeshes
  102432. */
  102433. protected _markAllSubMeshesAsAllDirty(): void;
  102434. /**
  102435. * Indicates that image processing needs to be re-calculated for all submeshes
  102436. */
  102437. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  102438. /**
  102439. * Indicates that textures need to be re-calculated for all submeshes
  102440. */
  102441. protected _markAllSubMeshesAsTexturesDirty(): void;
  102442. /**
  102443. * Indicates that fresnel needs to be re-calculated for all submeshes
  102444. */
  102445. protected _markAllSubMeshesAsFresnelDirty(): void;
  102446. /**
  102447. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  102448. */
  102449. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  102450. /**
  102451. * Indicates that lights need to be re-calculated for all submeshes
  102452. */
  102453. protected _markAllSubMeshesAsLightsDirty(): void;
  102454. /**
  102455. * Indicates that attributes need to be re-calculated for all submeshes
  102456. */
  102457. protected _markAllSubMeshesAsAttributesDirty(): void;
  102458. /**
  102459. * Indicates that misc needs to be re-calculated for all submeshes
  102460. */
  102461. protected _markAllSubMeshesAsMiscDirty(): void;
  102462. /**
  102463. * Indicates that textures and misc need to be re-calculated for all submeshes
  102464. */
  102465. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  102466. /**
  102467. * Disposes the material
  102468. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102469. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102470. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  102471. */
  102472. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  102473. /** @hidden */
  102474. private releaseVertexArrayObject;
  102475. /**
  102476. * Serializes this material
  102477. * @returns the serialized material object
  102478. */
  102479. serialize(): any;
  102480. /**
  102481. * Creates a material from parsed material data
  102482. * @param parsedMaterial defines parsed material data
  102483. * @param scene defines the hosting scene
  102484. * @param rootUrl defines the root URL to use to load textures
  102485. * @returns a new material
  102486. */
  102487. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  102488. }
  102489. }
  102490. declare module BABYLON {
  102491. /**
  102492. * A multi-material is used to apply different materials to different parts of the same object without the need of
  102493. * separate meshes. This can be use to improve performances.
  102494. * @see https://doc.babylonjs.com/how_to/multi_materials
  102495. */
  102496. export class MultiMaterial extends Material {
  102497. private _subMaterials;
  102498. /**
  102499. * Gets or Sets the list of Materials used within the multi material.
  102500. * They need to be ordered according to the submeshes order in the associated mesh
  102501. */
  102502. get subMaterials(): Nullable<Material>[];
  102503. set subMaterials(value: Nullable<Material>[]);
  102504. /**
  102505. * Function used to align with Node.getChildren()
  102506. * @returns the list of Materials used within the multi material
  102507. */
  102508. getChildren(): Nullable<Material>[];
  102509. /**
  102510. * Instantiates a new Multi Material
  102511. * A multi-material is used to apply different materials to different parts of the same object without the need of
  102512. * separate meshes. This can be use to improve performances.
  102513. * @see https://doc.babylonjs.com/how_to/multi_materials
  102514. * @param name Define the name in the scene
  102515. * @param scene Define the scene the material belongs to
  102516. */
  102517. constructor(name: string, scene: Scene);
  102518. private _hookArray;
  102519. /**
  102520. * Get one of the submaterial by its index in the submaterials array
  102521. * @param index The index to look the sub material at
  102522. * @returns The Material if the index has been defined
  102523. */
  102524. getSubMaterial(index: number): Nullable<Material>;
  102525. /**
  102526. * Get the list of active textures for the whole sub materials list.
  102527. * @returns All the textures that will be used during the rendering
  102528. */
  102529. getActiveTextures(): BaseTexture[];
  102530. /**
  102531. * Gets the current class name of the material e.g. "MultiMaterial"
  102532. * Mainly use in serialization.
  102533. * @returns the class name
  102534. */
  102535. getClassName(): string;
  102536. /**
  102537. * Checks if the material is ready to render the requested sub mesh
  102538. * @param mesh Define the mesh the submesh belongs to
  102539. * @param subMesh Define the sub mesh to look readyness for
  102540. * @param useInstances Define whether or not the material is used with instances
  102541. * @returns true if ready, otherwise false
  102542. */
  102543. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102544. /**
  102545. * Clones the current material and its related sub materials
  102546. * @param name Define the name of the newly cloned material
  102547. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  102548. * @returns the cloned material
  102549. */
  102550. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  102551. /**
  102552. * Serializes the materials into a JSON representation.
  102553. * @returns the JSON representation
  102554. */
  102555. serialize(): any;
  102556. /**
  102557. * Dispose the material and release its associated resources
  102558. * @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)
  102559. * @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)
  102560. * @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)
  102561. */
  102562. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  102563. /**
  102564. * Creates a MultiMaterial from parsed MultiMaterial data.
  102565. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  102566. * @param scene defines the hosting scene
  102567. * @returns a new MultiMaterial
  102568. */
  102569. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  102570. }
  102571. }
  102572. declare module BABYLON {
  102573. /**
  102574. * Defines a subdivision inside a mesh
  102575. */
  102576. export class SubMesh implements ICullable {
  102577. /** the material index to use */
  102578. materialIndex: number;
  102579. /** vertex index start */
  102580. verticesStart: number;
  102581. /** vertices count */
  102582. verticesCount: number;
  102583. /** index start */
  102584. indexStart: number;
  102585. /** indices count */
  102586. indexCount: number;
  102587. /** @hidden */
  102588. _materialDefines: Nullable<MaterialDefines>;
  102589. /** @hidden */
  102590. _materialEffect: Nullable<Effect>;
  102591. /** @hidden */
  102592. _effectOverride: Nullable<Effect>;
  102593. /**
  102594. * Gets material defines used by the effect associated to the sub mesh
  102595. */
  102596. get materialDefines(): Nullable<MaterialDefines>;
  102597. /**
  102598. * Sets material defines used by the effect associated to the sub mesh
  102599. */
  102600. set materialDefines(defines: Nullable<MaterialDefines>);
  102601. /**
  102602. * Gets associated effect
  102603. */
  102604. get effect(): Nullable<Effect>;
  102605. /**
  102606. * Sets associated effect (effect used to render this submesh)
  102607. * @param effect defines the effect to associate with
  102608. * @param defines defines the set of defines used to compile this effect
  102609. */
  102610. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  102611. /** @hidden */
  102612. _linesIndexCount: number;
  102613. private _mesh;
  102614. private _renderingMesh;
  102615. private _boundingInfo;
  102616. private _linesIndexBuffer;
  102617. /** @hidden */
  102618. _lastColliderWorldVertices: Nullable<Vector3[]>;
  102619. /** @hidden */
  102620. _trianglePlanes: Plane[];
  102621. /** @hidden */
  102622. _lastColliderTransformMatrix: Nullable<Matrix>;
  102623. /** @hidden */
  102624. _renderId: number;
  102625. /** @hidden */
  102626. _alphaIndex: number;
  102627. /** @hidden */
  102628. _distanceToCamera: number;
  102629. /** @hidden */
  102630. _id: number;
  102631. private _currentMaterial;
  102632. /**
  102633. * Add a new submesh to a mesh
  102634. * @param materialIndex defines the material index to use
  102635. * @param verticesStart defines vertex index start
  102636. * @param verticesCount defines vertices count
  102637. * @param indexStart defines index start
  102638. * @param indexCount defines indices count
  102639. * @param mesh defines the parent mesh
  102640. * @param renderingMesh defines an optional rendering mesh
  102641. * @param createBoundingBox defines if bounding box should be created for this submesh
  102642. * @returns the new submesh
  102643. */
  102644. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  102645. /**
  102646. * Creates a new submesh
  102647. * @param materialIndex defines the material index to use
  102648. * @param verticesStart defines vertex index start
  102649. * @param verticesCount defines vertices count
  102650. * @param indexStart defines index start
  102651. * @param indexCount defines indices count
  102652. * @param mesh defines the parent mesh
  102653. * @param renderingMesh defines an optional rendering mesh
  102654. * @param createBoundingBox defines if bounding box should be created for this submesh
  102655. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  102656. */
  102657. constructor(
  102658. /** the material index to use */
  102659. materialIndex: number,
  102660. /** vertex index start */
  102661. verticesStart: number,
  102662. /** vertices count */
  102663. verticesCount: number,
  102664. /** index start */
  102665. indexStart: number,
  102666. /** indices count */
  102667. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  102668. /**
  102669. * Returns true if this submesh covers the entire parent mesh
  102670. * @ignorenaming
  102671. */
  102672. get IsGlobal(): boolean;
  102673. /**
  102674. * Returns the submesh BoudingInfo object
  102675. * @returns current bounding info (or mesh's one if the submesh is global)
  102676. */
  102677. getBoundingInfo(): BoundingInfo;
  102678. /**
  102679. * Sets the submesh BoundingInfo
  102680. * @param boundingInfo defines the new bounding info to use
  102681. * @returns the SubMesh
  102682. */
  102683. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  102684. /**
  102685. * Returns the mesh of the current submesh
  102686. * @return the parent mesh
  102687. */
  102688. getMesh(): AbstractMesh;
  102689. /**
  102690. * Returns the rendering mesh of the submesh
  102691. * @returns the rendering mesh (could be different from parent mesh)
  102692. */
  102693. getRenderingMesh(): Mesh;
  102694. /**
  102695. * Returns the replacement mesh of the submesh
  102696. * @returns the replacement mesh (could be different from parent mesh)
  102697. */
  102698. getReplacementMesh(): Nullable<AbstractMesh>;
  102699. /**
  102700. * Returns the effective mesh of the submesh
  102701. * @returns the effective mesh (could be different from parent mesh)
  102702. */
  102703. getEffectiveMesh(): AbstractMesh;
  102704. /**
  102705. * Returns the submesh material
  102706. * @returns null or the current material
  102707. */
  102708. getMaterial(): Nullable<Material>;
  102709. private _IsMultiMaterial;
  102710. /**
  102711. * Sets a new updated BoundingInfo object to the submesh
  102712. * @param data defines an optional position array to use to determine the bounding info
  102713. * @returns the SubMesh
  102714. */
  102715. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  102716. /** @hidden */
  102717. _checkCollision(collider: Collider): boolean;
  102718. /**
  102719. * Updates the submesh BoundingInfo
  102720. * @param world defines the world matrix to use to update the bounding info
  102721. * @returns the submesh
  102722. */
  102723. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  102724. /**
  102725. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  102726. * @param frustumPlanes defines the frustum planes
  102727. * @returns true if the submesh is intersecting with the frustum
  102728. */
  102729. isInFrustum(frustumPlanes: Plane[]): boolean;
  102730. /**
  102731. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  102732. * @param frustumPlanes defines the frustum planes
  102733. * @returns true if the submesh is inside the frustum
  102734. */
  102735. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  102736. /**
  102737. * Renders the submesh
  102738. * @param enableAlphaMode defines if alpha needs to be used
  102739. * @returns the submesh
  102740. */
  102741. render(enableAlphaMode: boolean): SubMesh;
  102742. /**
  102743. * @hidden
  102744. */
  102745. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  102746. /**
  102747. * Checks if the submesh intersects with a ray
  102748. * @param ray defines the ray to test
  102749. * @returns true is the passed ray intersects the submesh bounding box
  102750. */
  102751. canIntersects(ray: Ray): boolean;
  102752. /**
  102753. * Intersects current submesh with a ray
  102754. * @param ray defines the ray to test
  102755. * @param positions defines mesh's positions array
  102756. * @param indices defines mesh's indices array
  102757. * @param fastCheck defines if the first intersection will be used (and not the closest)
  102758. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102759. * @returns intersection info or null if no intersection
  102760. */
  102761. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  102762. /** @hidden */
  102763. private _intersectLines;
  102764. /** @hidden */
  102765. private _intersectUnIndexedLines;
  102766. /** @hidden */
  102767. private _intersectTriangles;
  102768. /** @hidden */
  102769. private _intersectUnIndexedTriangles;
  102770. /** @hidden */
  102771. _rebuild(): void;
  102772. /**
  102773. * Creates a new submesh from the passed mesh
  102774. * @param newMesh defines the new hosting mesh
  102775. * @param newRenderingMesh defines an optional rendering mesh
  102776. * @returns the new submesh
  102777. */
  102778. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  102779. /**
  102780. * Release associated resources
  102781. */
  102782. dispose(): void;
  102783. /**
  102784. * Gets the class name
  102785. * @returns the string "SubMesh".
  102786. */
  102787. getClassName(): string;
  102788. /**
  102789. * Creates a new submesh from indices data
  102790. * @param materialIndex the index of the main mesh material
  102791. * @param startIndex the index where to start the copy in the mesh indices array
  102792. * @param indexCount the number of indices to copy then from the startIndex
  102793. * @param mesh the main mesh to create the submesh from
  102794. * @param renderingMesh the optional rendering mesh
  102795. * @returns a new submesh
  102796. */
  102797. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  102798. }
  102799. }
  102800. declare module BABYLON {
  102801. /**
  102802. * Class used to represent data loading progression
  102803. */
  102804. export class SceneLoaderFlags {
  102805. private static _ForceFullSceneLoadingForIncremental;
  102806. private static _ShowLoadingScreen;
  102807. private static _CleanBoneMatrixWeights;
  102808. private static _loggingLevel;
  102809. /**
  102810. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  102811. */
  102812. static get ForceFullSceneLoadingForIncremental(): boolean;
  102813. static set ForceFullSceneLoadingForIncremental(value: boolean);
  102814. /**
  102815. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  102816. */
  102817. static get ShowLoadingScreen(): boolean;
  102818. static set ShowLoadingScreen(value: boolean);
  102819. /**
  102820. * Defines the current logging level (while loading the scene)
  102821. * @ignorenaming
  102822. */
  102823. static get loggingLevel(): number;
  102824. static set loggingLevel(value: number);
  102825. /**
  102826. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  102827. */
  102828. static get CleanBoneMatrixWeights(): boolean;
  102829. static set CleanBoneMatrixWeights(value: boolean);
  102830. }
  102831. }
  102832. declare module BABYLON {
  102833. /**
  102834. * Class used to store geometry data (vertex buffers + index buffer)
  102835. */
  102836. export class Geometry implements IGetSetVerticesData {
  102837. /**
  102838. * Gets or sets the ID of the geometry
  102839. */
  102840. id: string;
  102841. /**
  102842. * Gets or sets the unique ID of the geometry
  102843. */
  102844. uniqueId: number;
  102845. /**
  102846. * Gets the delay loading state of the geometry (none by default which means not delayed)
  102847. */
  102848. delayLoadState: number;
  102849. /**
  102850. * Gets the file containing the data to load when running in delay load state
  102851. */
  102852. delayLoadingFile: Nullable<string>;
  102853. /**
  102854. * Callback called when the geometry is updated
  102855. */
  102856. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  102857. private _scene;
  102858. private _engine;
  102859. private _meshes;
  102860. private _totalVertices;
  102861. /** @hidden */
  102862. _indices: IndicesArray;
  102863. /** @hidden */
  102864. _vertexBuffers: {
  102865. [key: string]: VertexBuffer;
  102866. };
  102867. private _isDisposed;
  102868. private _extend;
  102869. private _boundingBias;
  102870. /** @hidden */
  102871. _delayInfo: Array<string>;
  102872. private _indexBuffer;
  102873. private _indexBufferIsUpdatable;
  102874. /** @hidden */
  102875. _boundingInfo: Nullable<BoundingInfo>;
  102876. /** @hidden */
  102877. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  102878. /** @hidden */
  102879. _softwareSkinningFrameId: number;
  102880. private _vertexArrayObjects;
  102881. private _updatable;
  102882. /** @hidden */
  102883. _positions: Nullable<Vector3[]>;
  102884. /**
  102885. * 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
  102886. */
  102887. get boundingBias(): Vector2;
  102888. /**
  102889. * 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
  102890. */
  102891. set boundingBias(value: Vector2);
  102892. /**
  102893. * Static function used to attach a new empty geometry to a mesh
  102894. * @param mesh defines the mesh to attach the geometry to
  102895. * @returns the new Geometry
  102896. */
  102897. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  102898. /** Get the list of meshes using this geometry */
  102899. get meshes(): Mesh[];
  102900. /**
  102901. * Creates a new geometry
  102902. * @param id defines the unique ID
  102903. * @param scene defines the hosting scene
  102904. * @param vertexData defines the VertexData used to get geometry data
  102905. * @param updatable defines if geometry must be updatable (false by default)
  102906. * @param mesh defines the mesh that will be associated with the geometry
  102907. */
  102908. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  102909. /**
  102910. * Gets the current extend of the geometry
  102911. */
  102912. get extend(): {
  102913. minimum: Vector3;
  102914. maximum: Vector3;
  102915. };
  102916. /**
  102917. * Gets the hosting scene
  102918. * @returns the hosting Scene
  102919. */
  102920. getScene(): Scene;
  102921. /**
  102922. * Gets the hosting engine
  102923. * @returns the hosting Engine
  102924. */
  102925. getEngine(): Engine;
  102926. /**
  102927. * Defines if the geometry is ready to use
  102928. * @returns true if the geometry is ready to be used
  102929. */
  102930. isReady(): boolean;
  102931. /**
  102932. * Gets a value indicating that the geometry should not be serialized
  102933. */
  102934. get doNotSerialize(): boolean;
  102935. /** @hidden */
  102936. _rebuild(): void;
  102937. /**
  102938. * Affects all geometry data in one call
  102939. * @param vertexData defines the geometry data
  102940. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  102941. */
  102942. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  102943. /**
  102944. * Set specific vertex data
  102945. * @param kind defines the data kind (Position, normal, etc...)
  102946. * @param data defines the vertex data to use
  102947. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  102948. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  102949. */
  102950. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  102951. /**
  102952. * Removes a specific vertex data
  102953. * @param kind defines the data kind (Position, normal, etc...)
  102954. */
  102955. removeVerticesData(kind: string): void;
  102956. /**
  102957. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  102958. * @param buffer defines the vertex buffer to use
  102959. * @param totalVertices defines the total number of vertices for position kind (could be null)
  102960. */
  102961. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  102962. /**
  102963. * Update a specific vertex buffer
  102964. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  102965. * It will do nothing if the buffer is not updatable
  102966. * @param kind defines the data kind (Position, normal, etc...)
  102967. * @param data defines the data to use
  102968. * @param offset defines the offset in the target buffer where to store the data
  102969. * @param useBytes set to true if the offset is in bytes
  102970. */
  102971. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  102972. /**
  102973. * Update a specific vertex buffer
  102974. * This function will create a new buffer if the current one is not updatable
  102975. * @param kind defines the data kind (Position, normal, etc...)
  102976. * @param data defines the data to use
  102977. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  102978. */
  102979. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  102980. private _updateBoundingInfo;
  102981. /** @hidden */
  102982. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  102983. /**
  102984. * Gets total number of vertices
  102985. * @returns the total number of vertices
  102986. */
  102987. getTotalVertices(): number;
  102988. /**
  102989. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  102990. * @param kind defines the data kind (Position, normal, etc...)
  102991. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  102992. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102993. * @returns a float array containing vertex data
  102994. */
  102995. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  102996. /**
  102997. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  102998. * @param kind defines the data kind (Position, normal, etc...)
  102999. * @returns true if the vertex buffer with the specified kind is updatable
  103000. */
  103001. isVertexBufferUpdatable(kind: string): boolean;
  103002. /**
  103003. * Gets a specific vertex buffer
  103004. * @param kind defines the data kind (Position, normal, etc...)
  103005. * @returns a VertexBuffer
  103006. */
  103007. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  103008. /**
  103009. * Returns all vertex buffers
  103010. * @return an object holding all vertex buffers indexed by kind
  103011. */
  103012. getVertexBuffers(): Nullable<{
  103013. [key: string]: VertexBuffer;
  103014. }>;
  103015. /**
  103016. * Gets a boolean indicating if specific vertex buffer is present
  103017. * @param kind defines the data kind (Position, normal, etc...)
  103018. * @returns true if data is present
  103019. */
  103020. isVerticesDataPresent(kind: string): boolean;
  103021. /**
  103022. * Gets a list of all attached data kinds (Position, normal, etc...)
  103023. * @returns a list of string containing all kinds
  103024. */
  103025. getVerticesDataKinds(): string[];
  103026. /**
  103027. * Update index buffer
  103028. * @param indices defines the indices to store in the index buffer
  103029. * @param offset defines the offset in the target buffer where to store the data
  103030. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  103031. */
  103032. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  103033. /**
  103034. * Creates a new index buffer
  103035. * @param indices defines the indices to store in the index buffer
  103036. * @param totalVertices defines the total number of vertices (could be null)
  103037. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  103038. */
  103039. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  103040. /**
  103041. * Return the total number of indices
  103042. * @returns the total number of indices
  103043. */
  103044. getTotalIndices(): number;
  103045. /**
  103046. * Gets the index buffer array
  103047. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  103048. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  103049. * @returns the index buffer array
  103050. */
  103051. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  103052. /**
  103053. * Gets the index buffer
  103054. * @return the index buffer
  103055. */
  103056. getIndexBuffer(): Nullable<DataBuffer>;
  103057. /** @hidden */
  103058. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  103059. /**
  103060. * Release the associated resources for a specific mesh
  103061. * @param mesh defines the source mesh
  103062. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  103063. */
  103064. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  103065. /**
  103066. * Apply current geometry to a given mesh
  103067. * @param mesh defines the mesh to apply geometry to
  103068. */
  103069. applyToMesh(mesh: Mesh): void;
  103070. private _updateExtend;
  103071. private _applyToMesh;
  103072. private notifyUpdate;
  103073. /**
  103074. * Load the geometry if it was flagged as delay loaded
  103075. * @param scene defines the hosting scene
  103076. * @param onLoaded defines a callback called when the geometry is loaded
  103077. */
  103078. load(scene: Scene, onLoaded?: () => void): void;
  103079. private _queueLoad;
  103080. /**
  103081. * Invert the geometry to move from a right handed system to a left handed one.
  103082. */
  103083. toLeftHanded(): void;
  103084. /** @hidden */
  103085. _resetPointsArrayCache(): void;
  103086. /** @hidden */
  103087. _generatePointsArray(): boolean;
  103088. /**
  103089. * Gets a value indicating if the geometry is disposed
  103090. * @returns true if the geometry was disposed
  103091. */
  103092. isDisposed(): boolean;
  103093. private _disposeVertexArrayObjects;
  103094. /**
  103095. * Free all associated resources
  103096. */
  103097. dispose(): void;
  103098. /**
  103099. * Clone the current geometry into a new geometry
  103100. * @param id defines the unique ID of the new geometry
  103101. * @returns a new geometry object
  103102. */
  103103. copy(id: string): Geometry;
  103104. /**
  103105. * Serialize the current geometry info (and not the vertices data) into a JSON object
  103106. * @return a JSON representation of the current geometry data (without the vertices data)
  103107. */
  103108. serialize(): any;
  103109. private toNumberArray;
  103110. /**
  103111. * Serialize all vertices data into a JSON oject
  103112. * @returns a JSON representation of the current geometry data
  103113. */
  103114. serializeVerticeData(): any;
  103115. /**
  103116. * Extracts a clone of a mesh geometry
  103117. * @param mesh defines the source mesh
  103118. * @param id defines the unique ID of the new geometry object
  103119. * @returns the new geometry object
  103120. */
  103121. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  103122. /**
  103123. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  103124. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  103125. * Be aware Math.random() could cause collisions, but:
  103126. * "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"
  103127. * @returns a string containing a new GUID
  103128. */
  103129. static RandomId(): string;
  103130. /** @hidden */
  103131. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  103132. private static _CleanMatricesWeights;
  103133. /**
  103134. * Create a new geometry from persisted data (Using .babylon file format)
  103135. * @param parsedVertexData defines the persisted data
  103136. * @param scene defines the hosting scene
  103137. * @param rootUrl defines the root url to use to load assets (like delayed data)
  103138. * @returns the new geometry object
  103139. */
  103140. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  103141. }
  103142. }
  103143. declare module BABYLON {
  103144. /**
  103145. * Define an interface for all classes that will get and set the data on vertices
  103146. */
  103147. export interface IGetSetVerticesData {
  103148. /**
  103149. * Gets a boolean indicating if specific vertex data is present
  103150. * @param kind defines the vertex data kind to use
  103151. * @returns true is data kind is present
  103152. */
  103153. isVerticesDataPresent(kind: string): boolean;
  103154. /**
  103155. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  103156. * @param kind defines the data kind (Position, normal, etc...)
  103157. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  103158. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  103159. * @returns a float array containing vertex data
  103160. */
  103161. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  103162. /**
  103163. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  103164. * @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.
  103165. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  103166. * @returns the indices array or an empty array if the mesh has no geometry
  103167. */
  103168. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  103169. /**
  103170. * Set specific vertex data
  103171. * @param kind defines the data kind (Position, normal, etc...)
  103172. * @param data defines the vertex data to use
  103173. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  103174. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  103175. */
  103176. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  103177. /**
  103178. * Update a specific associated vertex buffer
  103179. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  103180. * - VertexBuffer.PositionKind
  103181. * - VertexBuffer.UVKind
  103182. * - VertexBuffer.UV2Kind
  103183. * - VertexBuffer.UV3Kind
  103184. * - VertexBuffer.UV4Kind
  103185. * - VertexBuffer.UV5Kind
  103186. * - VertexBuffer.UV6Kind
  103187. * - VertexBuffer.ColorKind
  103188. * - VertexBuffer.MatricesIndicesKind
  103189. * - VertexBuffer.MatricesIndicesExtraKind
  103190. * - VertexBuffer.MatricesWeightsKind
  103191. * - VertexBuffer.MatricesWeightsExtraKind
  103192. * @param data defines the data source
  103193. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  103194. * @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)
  103195. */
  103196. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  103197. /**
  103198. * Creates a new index buffer
  103199. * @param indices defines the indices to store in the index buffer
  103200. * @param totalVertices defines the total number of vertices (could be null)
  103201. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  103202. */
  103203. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  103204. }
  103205. /**
  103206. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  103207. */
  103208. export class VertexData {
  103209. /**
  103210. * Mesh side orientation : usually the external or front surface
  103211. */
  103212. static readonly FRONTSIDE: number;
  103213. /**
  103214. * Mesh side orientation : usually the internal or back surface
  103215. */
  103216. static readonly BACKSIDE: number;
  103217. /**
  103218. * Mesh side orientation : both internal and external or front and back surfaces
  103219. */
  103220. static readonly DOUBLESIDE: number;
  103221. /**
  103222. * Mesh side orientation : by default, `FRONTSIDE`
  103223. */
  103224. static readonly DEFAULTSIDE: number;
  103225. /**
  103226. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  103227. */
  103228. positions: Nullable<FloatArray>;
  103229. /**
  103230. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  103231. */
  103232. normals: Nullable<FloatArray>;
  103233. /**
  103234. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  103235. */
  103236. tangents: Nullable<FloatArray>;
  103237. /**
  103238. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103239. */
  103240. uvs: Nullable<FloatArray>;
  103241. /**
  103242. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103243. */
  103244. uvs2: Nullable<FloatArray>;
  103245. /**
  103246. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103247. */
  103248. uvs3: Nullable<FloatArray>;
  103249. /**
  103250. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103251. */
  103252. uvs4: Nullable<FloatArray>;
  103253. /**
  103254. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103255. */
  103256. uvs5: Nullable<FloatArray>;
  103257. /**
  103258. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103259. */
  103260. uvs6: Nullable<FloatArray>;
  103261. /**
  103262. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  103263. */
  103264. colors: Nullable<FloatArray>;
  103265. /**
  103266. * 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).
  103267. */
  103268. matricesIndices: Nullable<FloatArray>;
  103269. /**
  103270. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  103271. */
  103272. matricesWeights: Nullable<FloatArray>;
  103273. /**
  103274. * An array extending the number of possible indices
  103275. */
  103276. matricesIndicesExtra: Nullable<FloatArray>;
  103277. /**
  103278. * An array extending the number of possible weights when the number of indices is extended
  103279. */
  103280. matricesWeightsExtra: Nullable<FloatArray>;
  103281. /**
  103282. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  103283. */
  103284. indices: Nullable<IndicesArray>;
  103285. /**
  103286. * Uses the passed data array to set the set the values for the specified kind of data
  103287. * @param data a linear array of floating numbers
  103288. * @param kind the type of data that is being set, eg positions, colors etc
  103289. */
  103290. set(data: FloatArray, kind: string): void;
  103291. /**
  103292. * Associates the vertexData to the passed Mesh.
  103293. * Sets it as updatable or not (default `false`)
  103294. * @param mesh the mesh the vertexData is applied to
  103295. * @param updatable when used and having the value true allows new data to update the vertexData
  103296. * @returns the VertexData
  103297. */
  103298. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  103299. /**
  103300. * Associates the vertexData to the passed Geometry.
  103301. * Sets it as updatable or not (default `false`)
  103302. * @param geometry the geometry the vertexData is applied to
  103303. * @param updatable when used and having the value true allows new data to update the vertexData
  103304. * @returns VertexData
  103305. */
  103306. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  103307. /**
  103308. * Updates the associated mesh
  103309. * @param mesh the mesh to be updated
  103310. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  103311. * @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
  103312. * @returns VertexData
  103313. */
  103314. updateMesh(mesh: Mesh): VertexData;
  103315. /**
  103316. * Updates the associated geometry
  103317. * @param geometry the geometry to be updated
  103318. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  103319. * @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
  103320. * @returns VertexData.
  103321. */
  103322. updateGeometry(geometry: Geometry): VertexData;
  103323. private _applyTo;
  103324. private _update;
  103325. /**
  103326. * Transforms each position and each normal of the vertexData according to the passed Matrix
  103327. * @param matrix the transforming matrix
  103328. * @returns the VertexData
  103329. */
  103330. transform(matrix: Matrix): VertexData;
  103331. /**
  103332. * Merges the passed VertexData into the current one
  103333. * @param other the VertexData to be merged into the current one
  103334. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  103335. * @returns the modified VertexData
  103336. */
  103337. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  103338. private _mergeElement;
  103339. private _validate;
  103340. /**
  103341. * Serializes the VertexData
  103342. * @returns a serialized object
  103343. */
  103344. serialize(): any;
  103345. /**
  103346. * Extracts the vertexData from a mesh
  103347. * @param mesh the mesh from which to extract the VertexData
  103348. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  103349. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  103350. * @returns the object VertexData associated to the passed mesh
  103351. */
  103352. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  103353. /**
  103354. * Extracts the vertexData from the geometry
  103355. * @param geometry the geometry from which to extract the VertexData
  103356. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  103357. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  103358. * @returns the object VertexData associated to the passed mesh
  103359. */
  103360. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  103361. private static _ExtractFrom;
  103362. /**
  103363. * Creates the VertexData for a Ribbon
  103364. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  103365. * * pathArray array of paths, each of which an array of successive Vector3
  103366. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  103367. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  103368. * * 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
  103369. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103370. * * 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)
  103371. * * 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)
  103372. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  103373. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  103374. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  103375. * @returns the VertexData of the ribbon
  103376. */
  103377. static CreateRibbon(options: {
  103378. pathArray: Vector3[][];
  103379. closeArray?: boolean;
  103380. closePath?: boolean;
  103381. offset?: number;
  103382. sideOrientation?: number;
  103383. frontUVs?: Vector4;
  103384. backUVs?: Vector4;
  103385. invertUV?: boolean;
  103386. uvs?: Vector2[];
  103387. colors?: Color4[];
  103388. }): VertexData;
  103389. /**
  103390. * Creates the VertexData for a box
  103391. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103392. * * size sets the width, height and depth of the box to the value of size, optional default 1
  103393. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  103394. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  103395. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  103396. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  103397. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  103398. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103399. * * 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)
  103400. * * 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)
  103401. * @returns the VertexData of the box
  103402. */
  103403. static CreateBox(options: {
  103404. size?: number;
  103405. width?: number;
  103406. height?: number;
  103407. depth?: number;
  103408. faceUV?: Vector4[];
  103409. faceColors?: Color4[];
  103410. sideOrientation?: number;
  103411. frontUVs?: Vector4;
  103412. backUVs?: Vector4;
  103413. }): VertexData;
  103414. /**
  103415. * Creates the VertexData for a tiled box
  103416. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103417. * * faceTiles sets the pattern, tile size and number of tiles for a face
  103418. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  103419. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  103420. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103421. * @returns the VertexData of the box
  103422. */
  103423. static CreateTiledBox(options: {
  103424. pattern?: number;
  103425. width?: number;
  103426. height?: number;
  103427. depth?: number;
  103428. tileSize?: number;
  103429. tileWidth?: number;
  103430. tileHeight?: number;
  103431. alignHorizontal?: number;
  103432. alignVertical?: number;
  103433. faceUV?: Vector4[];
  103434. faceColors?: Color4[];
  103435. sideOrientation?: number;
  103436. }): VertexData;
  103437. /**
  103438. * Creates the VertexData for a tiled plane
  103439. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103440. * * pattern a limited pattern arrangement depending on the number
  103441. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  103442. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  103443. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  103444. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103445. * * 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)
  103446. * * 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)
  103447. * @returns the VertexData of the tiled plane
  103448. */
  103449. static CreateTiledPlane(options: {
  103450. pattern?: number;
  103451. tileSize?: number;
  103452. tileWidth?: number;
  103453. tileHeight?: number;
  103454. size?: number;
  103455. width?: number;
  103456. height?: number;
  103457. alignHorizontal?: number;
  103458. alignVertical?: number;
  103459. sideOrientation?: number;
  103460. frontUVs?: Vector4;
  103461. backUVs?: Vector4;
  103462. }): VertexData;
  103463. /**
  103464. * Creates the VertexData for an ellipsoid, defaults to a sphere
  103465. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103466. * * segments sets the number of horizontal strips optional, default 32
  103467. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  103468. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  103469. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  103470. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  103471. * * 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
  103472. * * 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
  103473. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103474. * * 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)
  103475. * * 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)
  103476. * @returns the VertexData of the ellipsoid
  103477. */
  103478. static CreateSphere(options: {
  103479. segments?: number;
  103480. diameter?: number;
  103481. diameterX?: number;
  103482. diameterY?: number;
  103483. diameterZ?: number;
  103484. arc?: number;
  103485. slice?: number;
  103486. sideOrientation?: number;
  103487. frontUVs?: Vector4;
  103488. backUVs?: Vector4;
  103489. }): VertexData;
  103490. /**
  103491. * Creates the VertexData for a cylinder, cone or prism
  103492. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103493. * * height sets the height (y direction) of the cylinder, optional, default 2
  103494. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  103495. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  103496. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  103497. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  103498. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  103499. * * 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
  103500. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103501. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103502. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  103503. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  103504. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103505. * * 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)
  103506. * * 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)
  103507. * @returns the VertexData of the cylinder, cone or prism
  103508. */
  103509. static CreateCylinder(options: {
  103510. height?: number;
  103511. diameterTop?: number;
  103512. diameterBottom?: number;
  103513. diameter?: number;
  103514. tessellation?: number;
  103515. subdivisions?: number;
  103516. arc?: number;
  103517. faceColors?: Color4[];
  103518. faceUV?: Vector4[];
  103519. hasRings?: boolean;
  103520. enclose?: boolean;
  103521. sideOrientation?: number;
  103522. frontUVs?: Vector4;
  103523. backUVs?: Vector4;
  103524. }): VertexData;
  103525. /**
  103526. * Creates the VertexData for a torus
  103527. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103528. * * diameter the diameter of the torus, optional default 1
  103529. * * thickness the diameter of the tube forming the torus, optional default 0.5
  103530. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  103531. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103532. * * 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)
  103533. * * 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)
  103534. * @returns the VertexData of the torus
  103535. */
  103536. static CreateTorus(options: {
  103537. diameter?: number;
  103538. thickness?: number;
  103539. tessellation?: number;
  103540. sideOrientation?: number;
  103541. frontUVs?: Vector4;
  103542. backUVs?: Vector4;
  103543. }): VertexData;
  103544. /**
  103545. * Creates the VertexData of the LineSystem
  103546. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  103547. * - lines an array of lines, each line being an array of successive Vector3
  103548. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  103549. * @returns the VertexData of the LineSystem
  103550. */
  103551. static CreateLineSystem(options: {
  103552. lines: Vector3[][];
  103553. colors?: Nullable<Color4[][]>;
  103554. }): VertexData;
  103555. /**
  103556. * Create the VertexData for a DashedLines
  103557. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  103558. * - points an array successive Vector3
  103559. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  103560. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  103561. * - dashNb the intended total number of dashes, optional, default 200
  103562. * @returns the VertexData for the DashedLines
  103563. */
  103564. static CreateDashedLines(options: {
  103565. points: Vector3[];
  103566. dashSize?: number;
  103567. gapSize?: number;
  103568. dashNb?: number;
  103569. }): VertexData;
  103570. /**
  103571. * Creates the VertexData for a Ground
  103572. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  103573. * - width the width (x direction) of the ground, optional, default 1
  103574. * - height the height (z direction) of the ground, optional, default 1
  103575. * - subdivisions the number of subdivisions per side, optional, default 1
  103576. * @returns the VertexData of the Ground
  103577. */
  103578. static CreateGround(options: {
  103579. width?: number;
  103580. height?: number;
  103581. subdivisions?: number;
  103582. subdivisionsX?: number;
  103583. subdivisionsY?: number;
  103584. }): VertexData;
  103585. /**
  103586. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  103587. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  103588. * * xmin the ground minimum X coordinate, optional, default -1
  103589. * * zmin the ground minimum Z coordinate, optional, default -1
  103590. * * xmax the ground maximum X coordinate, optional, default 1
  103591. * * zmax the ground maximum Z coordinate, optional, default 1
  103592. * * 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}
  103593. * * 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}
  103594. * @returns the VertexData of the TiledGround
  103595. */
  103596. static CreateTiledGround(options: {
  103597. xmin: number;
  103598. zmin: number;
  103599. xmax: number;
  103600. zmax: number;
  103601. subdivisions?: {
  103602. w: number;
  103603. h: number;
  103604. };
  103605. precision?: {
  103606. w: number;
  103607. h: number;
  103608. };
  103609. }): VertexData;
  103610. /**
  103611. * Creates the VertexData of the Ground designed from a heightmap
  103612. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  103613. * * width the width (x direction) of the ground
  103614. * * height the height (z direction) of the ground
  103615. * * subdivisions the number of subdivisions per side
  103616. * * minHeight the minimum altitude on the ground, optional, default 0
  103617. * * maxHeight the maximum altitude on the ground, optional default 1
  103618. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  103619. * * buffer the array holding the image color data
  103620. * * bufferWidth the width of image
  103621. * * bufferHeight the height of image
  103622. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  103623. * @returns the VertexData of the Ground designed from a heightmap
  103624. */
  103625. static CreateGroundFromHeightMap(options: {
  103626. width: number;
  103627. height: number;
  103628. subdivisions: number;
  103629. minHeight: number;
  103630. maxHeight: number;
  103631. colorFilter: Color3;
  103632. buffer: Uint8Array;
  103633. bufferWidth: number;
  103634. bufferHeight: number;
  103635. alphaFilter: number;
  103636. }): VertexData;
  103637. /**
  103638. * Creates the VertexData for a Plane
  103639. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  103640. * * size sets the width and height of the plane to the value of size, optional default 1
  103641. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  103642. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  103643. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103644. * * 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)
  103645. * * 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)
  103646. * @returns the VertexData of the box
  103647. */
  103648. static CreatePlane(options: {
  103649. size?: number;
  103650. width?: number;
  103651. height?: number;
  103652. sideOrientation?: number;
  103653. frontUVs?: Vector4;
  103654. backUVs?: Vector4;
  103655. }): VertexData;
  103656. /**
  103657. * Creates the VertexData of the Disc or regular Polygon
  103658. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  103659. * * radius the radius of the disc, optional default 0.5
  103660. * * tessellation the number of polygon sides, optional, default 64
  103661. * * 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
  103662. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103663. * * 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)
  103664. * * 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)
  103665. * @returns the VertexData of the box
  103666. */
  103667. static CreateDisc(options: {
  103668. radius?: number;
  103669. tessellation?: number;
  103670. arc?: number;
  103671. sideOrientation?: number;
  103672. frontUVs?: Vector4;
  103673. backUVs?: Vector4;
  103674. }): VertexData;
  103675. /**
  103676. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  103677. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  103678. * @param polygon a mesh built from polygonTriangulation.build()
  103679. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103680. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103681. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103682. * @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)
  103683. * @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)
  103684. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  103685. * @returns the VertexData of the Polygon
  103686. */
  103687. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  103688. /**
  103689. * Creates the VertexData of the IcoSphere
  103690. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  103691. * * radius the radius of the IcoSphere, optional default 1
  103692. * * radiusX allows stretching in the x direction, optional, default radius
  103693. * * radiusY allows stretching in the y direction, optional, default radius
  103694. * * radiusZ allows stretching in the z direction, optional, default radius
  103695. * * flat when true creates a flat shaded mesh, optional, default true
  103696. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  103697. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103698. * * 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)
  103699. * * 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)
  103700. * @returns the VertexData of the IcoSphere
  103701. */
  103702. static CreateIcoSphere(options: {
  103703. radius?: number;
  103704. radiusX?: number;
  103705. radiusY?: number;
  103706. radiusZ?: number;
  103707. flat?: boolean;
  103708. subdivisions?: number;
  103709. sideOrientation?: number;
  103710. frontUVs?: Vector4;
  103711. backUVs?: Vector4;
  103712. }): VertexData;
  103713. /**
  103714. * Creates the VertexData for a Polyhedron
  103715. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  103716. * * type provided types are:
  103717. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  103718. * * 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)
  103719. * * size the size of the IcoSphere, optional default 1
  103720. * * sizeX allows stretching in the x direction, optional, default size
  103721. * * sizeY allows stretching in the y direction, optional, default size
  103722. * * sizeZ allows stretching in the z direction, optional, default size
  103723. * * 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
  103724. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103725. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103726. * * flat when true creates a flat shaded mesh, optional, default true
  103727. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  103728. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103729. * * 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)
  103730. * * 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)
  103731. * @returns the VertexData of the Polyhedron
  103732. */
  103733. static CreatePolyhedron(options: {
  103734. type?: number;
  103735. size?: number;
  103736. sizeX?: number;
  103737. sizeY?: number;
  103738. sizeZ?: number;
  103739. custom?: any;
  103740. faceUV?: Vector4[];
  103741. faceColors?: Color4[];
  103742. flat?: boolean;
  103743. sideOrientation?: number;
  103744. frontUVs?: Vector4;
  103745. backUVs?: Vector4;
  103746. }): VertexData;
  103747. /**
  103748. * Creates the VertexData for a TorusKnot
  103749. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  103750. * * radius the radius of the torus knot, optional, default 2
  103751. * * tube the thickness of the tube, optional, default 0.5
  103752. * * radialSegments the number of sides on each tube segments, optional, default 32
  103753. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  103754. * * p the number of windings around the z axis, optional, default 2
  103755. * * q the number of windings around the x axis, optional, default 3
  103756. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103757. * * 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)
  103758. * * 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)
  103759. * @returns the VertexData of the Torus Knot
  103760. */
  103761. static CreateTorusKnot(options: {
  103762. radius?: number;
  103763. tube?: number;
  103764. radialSegments?: number;
  103765. tubularSegments?: number;
  103766. p?: number;
  103767. q?: number;
  103768. sideOrientation?: number;
  103769. frontUVs?: Vector4;
  103770. backUVs?: Vector4;
  103771. }): VertexData;
  103772. /**
  103773. * Compute normals for given positions and indices
  103774. * @param positions an array of vertex positions, [...., x, y, z, ......]
  103775. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  103776. * @param normals an array of vertex normals, [...., x, y, z, ......]
  103777. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  103778. * * facetNormals : optional array of facet normals (vector3)
  103779. * * facetPositions : optional array of facet positions (vector3)
  103780. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  103781. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  103782. * * bInfo : optional bounding info, required for facetPartitioning computation
  103783. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  103784. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  103785. * * useRightHandedSystem: optional boolean to for right handed system computation
  103786. * * depthSort : optional boolean to enable the facet depth sort computation
  103787. * * distanceTo : optional Vector3 to compute the facet depth from this location
  103788. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  103789. */
  103790. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  103791. facetNormals?: any;
  103792. facetPositions?: any;
  103793. facetPartitioning?: any;
  103794. ratio?: number;
  103795. bInfo?: any;
  103796. bbSize?: Vector3;
  103797. subDiv?: any;
  103798. useRightHandedSystem?: boolean;
  103799. depthSort?: boolean;
  103800. distanceTo?: Vector3;
  103801. depthSortedFacets?: any;
  103802. }): void;
  103803. /** @hidden */
  103804. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  103805. /**
  103806. * Applies VertexData created from the imported parameters to the geometry
  103807. * @param parsedVertexData the parsed data from an imported file
  103808. * @param geometry the geometry to apply the VertexData to
  103809. */
  103810. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  103811. }
  103812. }
  103813. declare module BABYLON {
  103814. /**
  103815. * Defines a target to use with MorphTargetManager
  103816. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  103817. */
  103818. export class MorphTarget implements IAnimatable {
  103819. /** defines the name of the target */
  103820. name: string;
  103821. /**
  103822. * Gets or sets the list of animations
  103823. */
  103824. animations: Animation[];
  103825. private _scene;
  103826. private _positions;
  103827. private _normals;
  103828. private _tangents;
  103829. private _uvs;
  103830. private _influence;
  103831. private _uniqueId;
  103832. /**
  103833. * Observable raised when the influence changes
  103834. */
  103835. onInfluenceChanged: Observable<boolean>;
  103836. /** @hidden */
  103837. _onDataLayoutChanged: Observable<void>;
  103838. /**
  103839. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  103840. */
  103841. get influence(): number;
  103842. set influence(influence: number);
  103843. /**
  103844. * Gets or sets the id of the morph Target
  103845. */
  103846. id: string;
  103847. private _animationPropertiesOverride;
  103848. /**
  103849. * Gets or sets the animation properties override
  103850. */
  103851. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  103852. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  103853. /**
  103854. * Creates a new MorphTarget
  103855. * @param name defines the name of the target
  103856. * @param influence defines the influence to use
  103857. * @param scene defines the scene the morphtarget belongs to
  103858. */
  103859. constructor(
  103860. /** defines the name of the target */
  103861. name: string, influence?: number, scene?: Nullable<Scene>);
  103862. /**
  103863. * Gets the unique ID of this manager
  103864. */
  103865. get uniqueId(): number;
  103866. /**
  103867. * Gets a boolean defining if the target contains position data
  103868. */
  103869. get hasPositions(): boolean;
  103870. /**
  103871. * Gets a boolean defining if the target contains normal data
  103872. */
  103873. get hasNormals(): boolean;
  103874. /**
  103875. * Gets a boolean defining if the target contains tangent data
  103876. */
  103877. get hasTangents(): boolean;
  103878. /**
  103879. * Gets a boolean defining if the target contains texture coordinates data
  103880. */
  103881. get hasUVs(): boolean;
  103882. /**
  103883. * Affects position data to this target
  103884. * @param data defines the position data to use
  103885. */
  103886. setPositions(data: Nullable<FloatArray>): void;
  103887. /**
  103888. * Gets the position data stored in this target
  103889. * @returns a FloatArray containing the position data (or null if not present)
  103890. */
  103891. getPositions(): Nullable<FloatArray>;
  103892. /**
  103893. * Affects normal data to this target
  103894. * @param data defines the normal data to use
  103895. */
  103896. setNormals(data: Nullable<FloatArray>): void;
  103897. /**
  103898. * Gets the normal data stored in this target
  103899. * @returns a FloatArray containing the normal data (or null if not present)
  103900. */
  103901. getNormals(): Nullable<FloatArray>;
  103902. /**
  103903. * Affects tangent data to this target
  103904. * @param data defines the tangent data to use
  103905. */
  103906. setTangents(data: Nullable<FloatArray>): void;
  103907. /**
  103908. * Gets the tangent data stored in this target
  103909. * @returns a FloatArray containing the tangent data (or null if not present)
  103910. */
  103911. getTangents(): Nullable<FloatArray>;
  103912. /**
  103913. * Affects texture coordinates data to this target
  103914. * @param data defines the texture coordinates data to use
  103915. */
  103916. setUVs(data: Nullable<FloatArray>): void;
  103917. /**
  103918. * Gets the texture coordinates data stored in this target
  103919. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  103920. */
  103921. getUVs(): Nullable<FloatArray>;
  103922. /**
  103923. * Clone the current target
  103924. * @returns a new MorphTarget
  103925. */
  103926. clone(): MorphTarget;
  103927. /**
  103928. * Serializes the current target into a Serialization object
  103929. * @returns the serialized object
  103930. */
  103931. serialize(): any;
  103932. /**
  103933. * Returns the string "MorphTarget"
  103934. * @returns "MorphTarget"
  103935. */
  103936. getClassName(): string;
  103937. /**
  103938. * Creates a new target from serialized data
  103939. * @param serializationObject defines the serialized data to use
  103940. * @returns a new MorphTarget
  103941. */
  103942. static Parse(serializationObject: any): MorphTarget;
  103943. /**
  103944. * Creates a MorphTarget from mesh data
  103945. * @param mesh defines the source mesh
  103946. * @param name defines the name to use for the new target
  103947. * @param influence defines the influence to attach to the target
  103948. * @returns a new MorphTarget
  103949. */
  103950. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  103951. }
  103952. }
  103953. declare module BABYLON {
  103954. /**
  103955. * This class is used to deform meshes using morphing between different targets
  103956. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  103957. */
  103958. export class MorphTargetManager {
  103959. private _targets;
  103960. private _targetInfluenceChangedObservers;
  103961. private _targetDataLayoutChangedObservers;
  103962. private _activeTargets;
  103963. private _scene;
  103964. private _influences;
  103965. private _supportsNormals;
  103966. private _supportsTangents;
  103967. private _supportsUVs;
  103968. private _vertexCount;
  103969. private _uniqueId;
  103970. private _tempInfluences;
  103971. /**
  103972. * Gets or sets a boolean indicating if normals must be morphed
  103973. */
  103974. enableNormalMorphing: boolean;
  103975. /**
  103976. * Gets or sets a boolean indicating if tangents must be morphed
  103977. */
  103978. enableTangentMorphing: boolean;
  103979. /**
  103980. * Gets or sets a boolean indicating if UV must be morphed
  103981. */
  103982. enableUVMorphing: boolean;
  103983. /**
  103984. * Creates a new MorphTargetManager
  103985. * @param scene defines the current scene
  103986. */
  103987. constructor(scene?: Nullable<Scene>);
  103988. /**
  103989. * Gets the unique ID of this manager
  103990. */
  103991. get uniqueId(): number;
  103992. /**
  103993. * Gets the number of vertices handled by this manager
  103994. */
  103995. get vertexCount(): number;
  103996. /**
  103997. * Gets a boolean indicating if this manager supports morphing of normals
  103998. */
  103999. get supportsNormals(): boolean;
  104000. /**
  104001. * Gets a boolean indicating if this manager supports morphing of tangents
  104002. */
  104003. get supportsTangents(): boolean;
  104004. /**
  104005. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  104006. */
  104007. get supportsUVs(): boolean;
  104008. /**
  104009. * Gets the number of targets stored in this manager
  104010. */
  104011. get numTargets(): number;
  104012. /**
  104013. * Gets the number of influencers (ie. the number of targets with influences > 0)
  104014. */
  104015. get numInfluencers(): number;
  104016. /**
  104017. * Gets the list of influences (one per target)
  104018. */
  104019. get influences(): Float32Array;
  104020. /**
  104021. * Gets the active target at specified index. An active target is a target with an influence > 0
  104022. * @param index defines the index to check
  104023. * @returns the requested target
  104024. */
  104025. getActiveTarget(index: number): MorphTarget;
  104026. /**
  104027. * Gets the target at specified index
  104028. * @param index defines the index to check
  104029. * @returns the requested target
  104030. */
  104031. getTarget(index: number): MorphTarget;
  104032. /**
  104033. * Add a new target to this manager
  104034. * @param target defines the target to add
  104035. */
  104036. addTarget(target: MorphTarget): void;
  104037. /**
  104038. * Removes a target from the manager
  104039. * @param target defines the target to remove
  104040. */
  104041. removeTarget(target: MorphTarget): void;
  104042. /**
  104043. * Clone the current manager
  104044. * @returns a new MorphTargetManager
  104045. */
  104046. clone(): MorphTargetManager;
  104047. /**
  104048. * Serializes the current manager into a Serialization object
  104049. * @returns the serialized object
  104050. */
  104051. serialize(): any;
  104052. private _syncActiveTargets;
  104053. /**
  104054. * Syncrhonize the targets with all the meshes using this morph target manager
  104055. */
  104056. synchronize(): void;
  104057. /**
  104058. * Creates a new MorphTargetManager from serialized data
  104059. * @param serializationObject defines the serialized data
  104060. * @param scene defines the hosting scene
  104061. * @returns the new MorphTargetManager
  104062. */
  104063. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  104064. }
  104065. }
  104066. declare module BABYLON {
  104067. /**
  104068. * Class used to represent a specific level of detail of a mesh
  104069. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104070. */
  104071. export class MeshLODLevel {
  104072. /** Defines the distance where this level should start being displayed */
  104073. distance: number;
  104074. /** Defines the mesh to use to render this level */
  104075. mesh: Nullable<Mesh>;
  104076. /**
  104077. * Creates a new LOD level
  104078. * @param distance defines the distance where this level should star being displayed
  104079. * @param mesh defines the mesh to use to render this level
  104080. */
  104081. constructor(
  104082. /** Defines the distance where this level should start being displayed */
  104083. distance: number,
  104084. /** Defines the mesh to use to render this level */
  104085. mesh: Nullable<Mesh>);
  104086. }
  104087. }
  104088. declare module BABYLON {
  104089. /**
  104090. * Helper class used to generate a canvas to manipulate images
  104091. */
  104092. export class CanvasGenerator {
  104093. /**
  104094. * Create a new canvas (or offscreen canvas depending on the context)
  104095. * @param width defines the expected width
  104096. * @param height defines the expected height
  104097. * @return a new canvas or offscreen canvas
  104098. */
  104099. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  104100. }
  104101. }
  104102. declare module BABYLON {
  104103. /**
  104104. * Mesh representing the gorund
  104105. */
  104106. export class GroundMesh extends Mesh {
  104107. /** If octree should be generated */
  104108. generateOctree: boolean;
  104109. private _heightQuads;
  104110. /** @hidden */
  104111. _subdivisionsX: number;
  104112. /** @hidden */
  104113. _subdivisionsY: number;
  104114. /** @hidden */
  104115. _width: number;
  104116. /** @hidden */
  104117. _height: number;
  104118. /** @hidden */
  104119. _minX: number;
  104120. /** @hidden */
  104121. _maxX: number;
  104122. /** @hidden */
  104123. _minZ: number;
  104124. /** @hidden */
  104125. _maxZ: number;
  104126. constructor(name: string, scene: Scene);
  104127. /**
  104128. * "GroundMesh"
  104129. * @returns "GroundMesh"
  104130. */
  104131. getClassName(): string;
  104132. /**
  104133. * The minimum of x and y subdivisions
  104134. */
  104135. get subdivisions(): number;
  104136. /**
  104137. * X subdivisions
  104138. */
  104139. get subdivisionsX(): number;
  104140. /**
  104141. * Y subdivisions
  104142. */
  104143. get subdivisionsY(): number;
  104144. /**
  104145. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  104146. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  104147. * @param chunksCount the number of subdivisions for x and y
  104148. * @param octreeBlocksSize (Default: 32)
  104149. */
  104150. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  104151. /**
  104152. * Returns a height (y) value in the Worl system :
  104153. * the ground altitude at the coordinates (x, z) expressed in the World system.
  104154. * @param x x coordinate
  104155. * @param z z coordinate
  104156. * @returns the ground y position if (x, z) are outside the ground surface.
  104157. */
  104158. getHeightAtCoordinates(x: number, z: number): number;
  104159. /**
  104160. * Returns a normalized vector (Vector3) orthogonal to the ground
  104161. * at the ground coordinates (x, z) expressed in the World system.
  104162. * @param x x coordinate
  104163. * @param z z coordinate
  104164. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  104165. */
  104166. getNormalAtCoordinates(x: number, z: number): Vector3;
  104167. /**
  104168. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  104169. * at the ground coordinates (x, z) expressed in the World system.
  104170. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  104171. * @param x x coordinate
  104172. * @param z z coordinate
  104173. * @param ref vector to store the result
  104174. * @returns the GroundMesh.
  104175. */
  104176. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  104177. /**
  104178. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  104179. * if the ground has been updated.
  104180. * This can be used in the render loop.
  104181. * @returns the GroundMesh.
  104182. */
  104183. updateCoordinateHeights(): GroundMesh;
  104184. private _getFacetAt;
  104185. private _initHeightQuads;
  104186. private _computeHeightQuads;
  104187. /**
  104188. * Serializes this ground mesh
  104189. * @param serializationObject object to write serialization to
  104190. */
  104191. serialize(serializationObject: any): void;
  104192. /**
  104193. * Parses a serialized ground mesh
  104194. * @param parsedMesh the serialized mesh
  104195. * @param scene the scene to create the ground mesh in
  104196. * @returns the created ground mesh
  104197. */
  104198. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  104199. }
  104200. }
  104201. declare module BABYLON {
  104202. /**
  104203. * Interface for Physics-Joint data
  104204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104205. */
  104206. export interface PhysicsJointData {
  104207. /**
  104208. * The main pivot of the joint
  104209. */
  104210. mainPivot?: Vector3;
  104211. /**
  104212. * The connected pivot of the joint
  104213. */
  104214. connectedPivot?: Vector3;
  104215. /**
  104216. * The main axis of the joint
  104217. */
  104218. mainAxis?: Vector3;
  104219. /**
  104220. * The connected axis of the joint
  104221. */
  104222. connectedAxis?: Vector3;
  104223. /**
  104224. * The collision of the joint
  104225. */
  104226. collision?: boolean;
  104227. /**
  104228. * Native Oimo/Cannon/Energy data
  104229. */
  104230. nativeParams?: any;
  104231. }
  104232. /**
  104233. * This is a holder class for the physics joint created by the physics plugin
  104234. * It holds a set of functions to control the underlying joint
  104235. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104236. */
  104237. export class PhysicsJoint {
  104238. /**
  104239. * The type of the physics joint
  104240. */
  104241. type: number;
  104242. /**
  104243. * The data for the physics joint
  104244. */
  104245. jointData: PhysicsJointData;
  104246. private _physicsJoint;
  104247. protected _physicsPlugin: IPhysicsEnginePlugin;
  104248. /**
  104249. * Initializes the physics joint
  104250. * @param type The type of the physics joint
  104251. * @param jointData The data for the physics joint
  104252. */
  104253. constructor(
  104254. /**
  104255. * The type of the physics joint
  104256. */
  104257. type: number,
  104258. /**
  104259. * The data for the physics joint
  104260. */
  104261. jointData: PhysicsJointData);
  104262. /**
  104263. * Gets the physics joint
  104264. */
  104265. get physicsJoint(): any;
  104266. /**
  104267. * Sets the physics joint
  104268. */
  104269. set physicsJoint(newJoint: any);
  104270. /**
  104271. * Sets the physics plugin
  104272. */
  104273. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  104274. /**
  104275. * Execute a function that is physics-plugin specific.
  104276. * @param {Function} func the function that will be executed.
  104277. * It accepts two parameters: the physics world and the physics joint
  104278. */
  104279. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  104280. /**
  104281. * Distance-Joint type
  104282. */
  104283. static DistanceJoint: number;
  104284. /**
  104285. * Hinge-Joint type
  104286. */
  104287. static HingeJoint: number;
  104288. /**
  104289. * Ball-and-Socket joint type
  104290. */
  104291. static BallAndSocketJoint: number;
  104292. /**
  104293. * Wheel-Joint type
  104294. */
  104295. static WheelJoint: number;
  104296. /**
  104297. * Slider-Joint type
  104298. */
  104299. static SliderJoint: number;
  104300. /**
  104301. * Prismatic-Joint type
  104302. */
  104303. static PrismaticJoint: number;
  104304. /**
  104305. * Universal-Joint type
  104306. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  104307. */
  104308. static UniversalJoint: number;
  104309. /**
  104310. * Hinge-Joint 2 type
  104311. */
  104312. static Hinge2Joint: number;
  104313. /**
  104314. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  104315. */
  104316. static PointToPointJoint: number;
  104317. /**
  104318. * Spring-Joint type
  104319. */
  104320. static SpringJoint: number;
  104321. /**
  104322. * Lock-Joint type
  104323. */
  104324. static LockJoint: number;
  104325. }
  104326. /**
  104327. * A class representing a physics distance joint
  104328. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104329. */
  104330. export class DistanceJoint extends PhysicsJoint {
  104331. /**
  104332. *
  104333. * @param jointData The data for the Distance-Joint
  104334. */
  104335. constructor(jointData: DistanceJointData);
  104336. /**
  104337. * Update the predefined distance.
  104338. * @param maxDistance The maximum preferred distance
  104339. * @param minDistance The minimum preferred distance
  104340. */
  104341. updateDistance(maxDistance: number, minDistance?: number): void;
  104342. }
  104343. /**
  104344. * Represents a Motor-Enabled Joint
  104345. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104346. */
  104347. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  104348. /**
  104349. * Initializes the Motor-Enabled Joint
  104350. * @param type The type of the joint
  104351. * @param jointData The physica joint data for the joint
  104352. */
  104353. constructor(type: number, jointData: PhysicsJointData);
  104354. /**
  104355. * Set the motor values.
  104356. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104357. * @param force the force to apply
  104358. * @param maxForce max force for this motor.
  104359. */
  104360. setMotor(force?: number, maxForce?: number): void;
  104361. /**
  104362. * Set the motor's limits.
  104363. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104364. * @param upperLimit The upper limit of the motor
  104365. * @param lowerLimit The lower limit of the motor
  104366. */
  104367. setLimit(upperLimit: number, lowerLimit?: number): void;
  104368. }
  104369. /**
  104370. * This class represents a single physics Hinge-Joint
  104371. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104372. */
  104373. export class HingeJoint extends MotorEnabledJoint {
  104374. /**
  104375. * Initializes the Hinge-Joint
  104376. * @param jointData The joint data for the Hinge-Joint
  104377. */
  104378. constructor(jointData: PhysicsJointData);
  104379. /**
  104380. * Set the motor values.
  104381. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104382. * @param {number} force the force to apply
  104383. * @param {number} maxForce max force for this motor.
  104384. */
  104385. setMotor(force?: number, maxForce?: number): void;
  104386. /**
  104387. * Set the motor's limits.
  104388. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104389. * @param upperLimit The upper limit of the motor
  104390. * @param lowerLimit The lower limit of the motor
  104391. */
  104392. setLimit(upperLimit: number, lowerLimit?: number): void;
  104393. }
  104394. /**
  104395. * This class represents a dual hinge physics joint (same as wheel joint)
  104396. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104397. */
  104398. export class Hinge2Joint extends MotorEnabledJoint {
  104399. /**
  104400. * Initializes the Hinge2-Joint
  104401. * @param jointData The joint data for the Hinge2-Joint
  104402. */
  104403. constructor(jointData: PhysicsJointData);
  104404. /**
  104405. * Set the motor values.
  104406. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104407. * @param {number} targetSpeed the speed the motor is to reach
  104408. * @param {number} maxForce max force for this motor.
  104409. * @param {motorIndex} the motor's index, 0 or 1.
  104410. */
  104411. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  104412. /**
  104413. * Set the motor limits.
  104414. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104415. * @param {number} upperLimit the upper limit
  104416. * @param {number} lowerLimit lower limit
  104417. * @param {motorIndex} the motor's index, 0 or 1.
  104418. */
  104419. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104420. }
  104421. /**
  104422. * Interface for a motor enabled joint
  104423. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104424. */
  104425. export interface IMotorEnabledJoint {
  104426. /**
  104427. * Physics joint
  104428. */
  104429. physicsJoint: any;
  104430. /**
  104431. * Sets the motor of the motor-enabled joint
  104432. * @param force The force of the motor
  104433. * @param maxForce The maximum force of the motor
  104434. * @param motorIndex The index of the motor
  104435. */
  104436. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  104437. /**
  104438. * Sets the limit of the motor
  104439. * @param upperLimit The upper limit of the motor
  104440. * @param lowerLimit The lower limit of the motor
  104441. * @param motorIndex The index of the motor
  104442. */
  104443. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104444. }
  104445. /**
  104446. * Joint data for a Distance-Joint
  104447. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104448. */
  104449. export interface DistanceJointData extends PhysicsJointData {
  104450. /**
  104451. * Max distance the 2 joint objects can be apart
  104452. */
  104453. maxDistance: number;
  104454. }
  104455. /**
  104456. * Joint data from a spring joint
  104457. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104458. */
  104459. export interface SpringJointData extends PhysicsJointData {
  104460. /**
  104461. * Length of the spring
  104462. */
  104463. length: number;
  104464. /**
  104465. * Stiffness of the spring
  104466. */
  104467. stiffness: number;
  104468. /**
  104469. * Damping of the spring
  104470. */
  104471. damping: number;
  104472. /** this callback will be called when applying the force to the impostors. */
  104473. forceApplicationCallback: () => void;
  104474. }
  104475. }
  104476. declare module BABYLON {
  104477. /**
  104478. * Holds the data for the raycast result
  104479. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104480. */
  104481. export class PhysicsRaycastResult {
  104482. private _hasHit;
  104483. private _hitDistance;
  104484. private _hitNormalWorld;
  104485. private _hitPointWorld;
  104486. private _rayFromWorld;
  104487. private _rayToWorld;
  104488. /**
  104489. * Gets if there was a hit
  104490. */
  104491. get hasHit(): boolean;
  104492. /**
  104493. * Gets the distance from the hit
  104494. */
  104495. get hitDistance(): number;
  104496. /**
  104497. * Gets the hit normal/direction in the world
  104498. */
  104499. get hitNormalWorld(): Vector3;
  104500. /**
  104501. * Gets the hit point in the world
  104502. */
  104503. get hitPointWorld(): Vector3;
  104504. /**
  104505. * Gets the ray "start point" of the ray in the world
  104506. */
  104507. get rayFromWorld(): Vector3;
  104508. /**
  104509. * Gets the ray "end point" of the ray in the world
  104510. */
  104511. get rayToWorld(): Vector3;
  104512. /**
  104513. * Sets the hit data (normal & point in world space)
  104514. * @param hitNormalWorld defines the normal in world space
  104515. * @param hitPointWorld defines the point in world space
  104516. */
  104517. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  104518. /**
  104519. * Sets the distance from the start point to the hit point
  104520. * @param distance
  104521. */
  104522. setHitDistance(distance: number): void;
  104523. /**
  104524. * Calculates the distance manually
  104525. */
  104526. calculateHitDistance(): void;
  104527. /**
  104528. * Resets all the values to default
  104529. * @param from The from point on world space
  104530. * @param to The to point on world space
  104531. */
  104532. reset(from?: Vector3, to?: Vector3): void;
  104533. }
  104534. /**
  104535. * Interface for the size containing width and height
  104536. */
  104537. interface IXYZ {
  104538. /**
  104539. * X
  104540. */
  104541. x: number;
  104542. /**
  104543. * Y
  104544. */
  104545. y: number;
  104546. /**
  104547. * Z
  104548. */
  104549. z: number;
  104550. }
  104551. }
  104552. declare module BABYLON {
  104553. /**
  104554. * Interface used to describe a physics joint
  104555. */
  104556. export interface PhysicsImpostorJoint {
  104557. /** Defines the main impostor to which the joint is linked */
  104558. mainImpostor: PhysicsImpostor;
  104559. /** Defines the impostor that is connected to the main impostor using this joint */
  104560. connectedImpostor: PhysicsImpostor;
  104561. /** Defines the joint itself */
  104562. joint: PhysicsJoint;
  104563. }
  104564. /** @hidden */
  104565. export interface IPhysicsEnginePlugin {
  104566. world: any;
  104567. name: string;
  104568. setGravity(gravity: Vector3): void;
  104569. setTimeStep(timeStep: number): void;
  104570. getTimeStep(): number;
  104571. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  104572. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104573. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104574. generatePhysicsBody(impostor: PhysicsImpostor): void;
  104575. removePhysicsBody(impostor: PhysicsImpostor): void;
  104576. generateJoint(joint: PhysicsImpostorJoint): void;
  104577. removeJoint(joint: PhysicsImpostorJoint): void;
  104578. isSupported(): boolean;
  104579. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  104580. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  104581. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  104582. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  104583. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104584. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104585. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  104586. getBodyMass(impostor: PhysicsImpostor): number;
  104587. getBodyFriction(impostor: PhysicsImpostor): number;
  104588. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  104589. getBodyRestitution(impostor: PhysicsImpostor): number;
  104590. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  104591. getBodyPressure?(impostor: PhysicsImpostor): number;
  104592. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  104593. getBodyStiffness?(impostor: PhysicsImpostor): number;
  104594. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  104595. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  104596. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  104597. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  104598. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  104599. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  104600. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  104601. sleepBody(impostor: PhysicsImpostor): void;
  104602. wakeUpBody(impostor: PhysicsImpostor): void;
  104603. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  104604. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  104605. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  104606. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104607. getRadius(impostor: PhysicsImpostor): number;
  104608. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104609. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104610. dispose(): void;
  104611. }
  104612. /**
  104613. * Interface used to define a physics engine
  104614. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104615. */
  104616. export interface IPhysicsEngine {
  104617. /**
  104618. * Gets the gravity vector used by the simulation
  104619. */
  104620. gravity: Vector3;
  104621. /**
  104622. * Sets the gravity vector used by the simulation
  104623. * @param gravity defines the gravity vector to use
  104624. */
  104625. setGravity(gravity: Vector3): void;
  104626. /**
  104627. * Set the time step of the physics engine.
  104628. * Default is 1/60.
  104629. * To slow it down, enter 1/600 for example.
  104630. * To speed it up, 1/30
  104631. * @param newTimeStep the new timestep to apply to this world.
  104632. */
  104633. setTimeStep(newTimeStep: number): void;
  104634. /**
  104635. * Get the time step of the physics engine.
  104636. * @returns the current time step
  104637. */
  104638. getTimeStep(): number;
  104639. /**
  104640. * Set the sub time step of the physics engine.
  104641. * Default is 0 meaning there is no sub steps
  104642. * To increase physics resolution precision, set a small value (like 1 ms)
  104643. * @param subTimeStep defines the new sub timestep used for physics resolution.
  104644. */
  104645. setSubTimeStep(subTimeStep: number): void;
  104646. /**
  104647. * Get the sub time step of the physics engine.
  104648. * @returns the current sub time step
  104649. */
  104650. getSubTimeStep(): number;
  104651. /**
  104652. * Release all resources
  104653. */
  104654. dispose(): void;
  104655. /**
  104656. * Gets the name of the current physics plugin
  104657. * @returns the name of the plugin
  104658. */
  104659. getPhysicsPluginName(): string;
  104660. /**
  104661. * Adding a new impostor for the impostor tracking.
  104662. * This will be done by the impostor itself.
  104663. * @param impostor the impostor to add
  104664. */
  104665. addImpostor(impostor: PhysicsImpostor): void;
  104666. /**
  104667. * Remove an impostor from the engine.
  104668. * This impostor and its mesh will not longer be updated by the physics engine.
  104669. * @param impostor the impostor to remove
  104670. */
  104671. removeImpostor(impostor: PhysicsImpostor): void;
  104672. /**
  104673. * Add a joint to the physics engine
  104674. * @param mainImpostor defines the main impostor to which the joint is added.
  104675. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  104676. * @param joint defines the joint that will connect both impostors.
  104677. */
  104678. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104679. /**
  104680. * Removes a joint from the simulation
  104681. * @param mainImpostor defines the impostor used with the joint
  104682. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  104683. * @param joint defines the joint to remove
  104684. */
  104685. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104686. /**
  104687. * Gets the current plugin used to run the simulation
  104688. * @returns current plugin
  104689. */
  104690. getPhysicsPlugin(): IPhysicsEnginePlugin;
  104691. /**
  104692. * Gets the list of physic impostors
  104693. * @returns an array of PhysicsImpostor
  104694. */
  104695. getImpostors(): Array<PhysicsImpostor>;
  104696. /**
  104697. * Gets the impostor for a physics enabled object
  104698. * @param object defines the object impersonated by the impostor
  104699. * @returns the PhysicsImpostor or null if not found
  104700. */
  104701. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  104702. /**
  104703. * Gets the impostor for a physics body object
  104704. * @param body defines physics body used by the impostor
  104705. * @returns the PhysicsImpostor or null if not found
  104706. */
  104707. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  104708. /**
  104709. * Does a raycast in the physics world
  104710. * @param from when should the ray start?
  104711. * @param to when should the ray end?
  104712. * @returns PhysicsRaycastResult
  104713. */
  104714. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  104715. /**
  104716. * Called by the scene. No need to call it.
  104717. * @param delta defines the timespam between frames
  104718. */
  104719. _step(delta: number): void;
  104720. }
  104721. }
  104722. declare module BABYLON {
  104723. /**
  104724. * The interface for the physics imposter parameters
  104725. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104726. */
  104727. export interface PhysicsImpostorParameters {
  104728. /**
  104729. * The mass of the physics imposter
  104730. */
  104731. mass: number;
  104732. /**
  104733. * The friction of the physics imposter
  104734. */
  104735. friction?: number;
  104736. /**
  104737. * The coefficient of restitution of the physics imposter
  104738. */
  104739. restitution?: number;
  104740. /**
  104741. * The native options of the physics imposter
  104742. */
  104743. nativeOptions?: any;
  104744. /**
  104745. * Specifies if the parent should be ignored
  104746. */
  104747. ignoreParent?: boolean;
  104748. /**
  104749. * Specifies if bi-directional transformations should be disabled
  104750. */
  104751. disableBidirectionalTransformation?: boolean;
  104752. /**
  104753. * The pressure inside the physics imposter, soft object only
  104754. */
  104755. pressure?: number;
  104756. /**
  104757. * The stiffness the physics imposter, soft object only
  104758. */
  104759. stiffness?: number;
  104760. /**
  104761. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  104762. */
  104763. velocityIterations?: number;
  104764. /**
  104765. * The number of iterations used in maintaining consistent vertex positions, soft object only
  104766. */
  104767. positionIterations?: number;
  104768. /**
  104769. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  104770. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  104771. * Add to fix multiple points
  104772. */
  104773. fixedPoints?: number;
  104774. /**
  104775. * The collision margin around a soft object
  104776. */
  104777. margin?: number;
  104778. /**
  104779. * The collision margin around a soft object
  104780. */
  104781. damping?: number;
  104782. /**
  104783. * The path for a rope based on an extrusion
  104784. */
  104785. path?: any;
  104786. /**
  104787. * The shape of an extrusion used for a rope based on an extrusion
  104788. */
  104789. shape?: any;
  104790. }
  104791. /**
  104792. * Interface for a physics-enabled object
  104793. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104794. */
  104795. export interface IPhysicsEnabledObject {
  104796. /**
  104797. * The position of the physics-enabled object
  104798. */
  104799. position: Vector3;
  104800. /**
  104801. * The rotation of the physics-enabled object
  104802. */
  104803. rotationQuaternion: Nullable<Quaternion>;
  104804. /**
  104805. * The scale of the physics-enabled object
  104806. */
  104807. scaling: Vector3;
  104808. /**
  104809. * The rotation of the physics-enabled object
  104810. */
  104811. rotation?: Vector3;
  104812. /**
  104813. * The parent of the physics-enabled object
  104814. */
  104815. parent?: any;
  104816. /**
  104817. * The bounding info of the physics-enabled object
  104818. * @returns The bounding info of the physics-enabled object
  104819. */
  104820. getBoundingInfo(): BoundingInfo;
  104821. /**
  104822. * Computes the world matrix
  104823. * @param force Specifies if the world matrix should be computed by force
  104824. * @returns A world matrix
  104825. */
  104826. computeWorldMatrix(force: boolean): Matrix;
  104827. /**
  104828. * Gets the world matrix
  104829. * @returns A world matrix
  104830. */
  104831. getWorldMatrix?(): Matrix;
  104832. /**
  104833. * Gets the child meshes
  104834. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  104835. * @returns An array of abstract meshes
  104836. */
  104837. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  104838. /**
  104839. * Gets the vertex data
  104840. * @param kind The type of vertex data
  104841. * @returns A nullable array of numbers, or a float32 array
  104842. */
  104843. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  104844. /**
  104845. * Gets the indices from the mesh
  104846. * @returns A nullable array of index arrays
  104847. */
  104848. getIndices?(): Nullable<IndicesArray>;
  104849. /**
  104850. * Gets the scene from the mesh
  104851. * @returns the indices array or null
  104852. */
  104853. getScene?(): Scene;
  104854. /**
  104855. * Gets the absolute position from the mesh
  104856. * @returns the absolute position
  104857. */
  104858. getAbsolutePosition(): Vector3;
  104859. /**
  104860. * Gets the absolute pivot point from the mesh
  104861. * @returns the absolute pivot point
  104862. */
  104863. getAbsolutePivotPoint(): Vector3;
  104864. /**
  104865. * Rotates the mesh
  104866. * @param axis The axis of rotation
  104867. * @param amount The amount of rotation
  104868. * @param space The space of the rotation
  104869. * @returns The rotation transform node
  104870. */
  104871. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  104872. /**
  104873. * Translates the mesh
  104874. * @param axis The axis of translation
  104875. * @param distance The distance of translation
  104876. * @param space The space of the translation
  104877. * @returns The transform node
  104878. */
  104879. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  104880. /**
  104881. * Sets the absolute position of the mesh
  104882. * @param absolutePosition The absolute position of the mesh
  104883. * @returns The transform node
  104884. */
  104885. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  104886. /**
  104887. * Gets the class name of the mesh
  104888. * @returns The class name
  104889. */
  104890. getClassName(): string;
  104891. }
  104892. /**
  104893. * Represents a physics imposter
  104894. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104895. */
  104896. export class PhysicsImpostor {
  104897. /**
  104898. * The physics-enabled object used as the physics imposter
  104899. */
  104900. object: IPhysicsEnabledObject;
  104901. /**
  104902. * The type of the physics imposter
  104903. */
  104904. type: number;
  104905. private _options;
  104906. private _scene?;
  104907. /**
  104908. * The default object size of the imposter
  104909. */
  104910. static DEFAULT_OBJECT_SIZE: Vector3;
  104911. /**
  104912. * The identity quaternion of the imposter
  104913. */
  104914. static IDENTITY_QUATERNION: Quaternion;
  104915. /** @hidden */
  104916. _pluginData: any;
  104917. private _physicsEngine;
  104918. private _physicsBody;
  104919. private _bodyUpdateRequired;
  104920. private _onBeforePhysicsStepCallbacks;
  104921. private _onAfterPhysicsStepCallbacks;
  104922. /** @hidden */
  104923. _onPhysicsCollideCallbacks: Array<{
  104924. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  104925. otherImpostors: Array<PhysicsImpostor>;
  104926. }>;
  104927. private _deltaPosition;
  104928. private _deltaRotation;
  104929. private _deltaRotationConjugated;
  104930. /** @hidden */
  104931. _isFromLine: boolean;
  104932. private _parent;
  104933. private _isDisposed;
  104934. private static _tmpVecs;
  104935. private static _tmpQuat;
  104936. /**
  104937. * Specifies if the physics imposter is disposed
  104938. */
  104939. get isDisposed(): boolean;
  104940. /**
  104941. * Gets the mass of the physics imposter
  104942. */
  104943. get mass(): number;
  104944. set mass(value: number);
  104945. /**
  104946. * Gets the coefficient of friction
  104947. */
  104948. get friction(): number;
  104949. /**
  104950. * Sets the coefficient of friction
  104951. */
  104952. set friction(value: number);
  104953. /**
  104954. * Gets the coefficient of restitution
  104955. */
  104956. get restitution(): number;
  104957. /**
  104958. * Sets the coefficient of restitution
  104959. */
  104960. set restitution(value: number);
  104961. /**
  104962. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  104963. */
  104964. get pressure(): number;
  104965. /**
  104966. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  104967. */
  104968. set pressure(value: number);
  104969. /**
  104970. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  104971. */
  104972. get stiffness(): number;
  104973. /**
  104974. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  104975. */
  104976. set stiffness(value: number);
  104977. /**
  104978. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  104979. */
  104980. get velocityIterations(): number;
  104981. /**
  104982. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  104983. */
  104984. set velocityIterations(value: number);
  104985. /**
  104986. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  104987. */
  104988. get positionIterations(): number;
  104989. /**
  104990. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  104991. */
  104992. set positionIterations(value: number);
  104993. /**
  104994. * The unique id of the physics imposter
  104995. * set by the physics engine when adding this impostor to the array
  104996. */
  104997. uniqueId: number;
  104998. /**
  104999. * @hidden
  105000. */
  105001. soft: boolean;
  105002. /**
  105003. * @hidden
  105004. */
  105005. segments: number;
  105006. private _joints;
  105007. /**
  105008. * Initializes the physics imposter
  105009. * @param object The physics-enabled object used as the physics imposter
  105010. * @param type The type of the physics imposter
  105011. * @param _options The options for the physics imposter
  105012. * @param _scene The Babylon scene
  105013. */
  105014. constructor(
  105015. /**
  105016. * The physics-enabled object used as the physics imposter
  105017. */
  105018. object: IPhysicsEnabledObject,
  105019. /**
  105020. * The type of the physics imposter
  105021. */
  105022. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  105023. /**
  105024. * This function will completly initialize this impostor.
  105025. * It will create a new body - but only if this mesh has no parent.
  105026. * If it has, this impostor will not be used other than to define the impostor
  105027. * of the child mesh.
  105028. * @hidden
  105029. */
  105030. _init(): void;
  105031. private _getPhysicsParent;
  105032. /**
  105033. * Should a new body be generated.
  105034. * @returns boolean specifying if body initialization is required
  105035. */
  105036. isBodyInitRequired(): boolean;
  105037. /**
  105038. * Sets the updated scaling
  105039. * @param updated Specifies if the scaling is updated
  105040. */
  105041. setScalingUpdated(): void;
  105042. /**
  105043. * Force a regeneration of this or the parent's impostor's body.
  105044. * Use under cautious - This will remove all joints already implemented.
  105045. */
  105046. forceUpdate(): void;
  105047. /**
  105048. * Gets the body that holds this impostor. Either its own, or its parent.
  105049. */
  105050. get physicsBody(): any;
  105051. /**
  105052. * Get the parent of the physics imposter
  105053. * @returns Physics imposter or null
  105054. */
  105055. get parent(): Nullable<PhysicsImpostor>;
  105056. /**
  105057. * Sets the parent of the physics imposter
  105058. */
  105059. set parent(value: Nullable<PhysicsImpostor>);
  105060. /**
  105061. * Set the physics body. Used mainly by the physics engine/plugin
  105062. */
  105063. set physicsBody(physicsBody: any);
  105064. /**
  105065. * Resets the update flags
  105066. */
  105067. resetUpdateFlags(): void;
  105068. /**
  105069. * Gets the object extend size
  105070. * @returns the object extend size
  105071. */
  105072. getObjectExtendSize(): Vector3;
  105073. /**
  105074. * Gets the object center
  105075. * @returns The object center
  105076. */
  105077. getObjectCenter(): Vector3;
  105078. /**
  105079. * Get a specific parameter from the options parameters
  105080. * @param paramName The object parameter name
  105081. * @returns The object parameter
  105082. */
  105083. getParam(paramName: string): any;
  105084. /**
  105085. * Sets a specific parameter in the options given to the physics plugin
  105086. * @param paramName The parameter name
  105087. * @param value The value of the parameter
  105088. */
  105089. setParam(paramName: string, value: number): void;
  105090. /**
  105091. * Specifically change the body's mass option. Won't recreate the physics body object
  105092. * @param mass The mass of the physics imposter
  105093. */
  105094. setMass(mass: number): void;
  105095. /**
  105096. * Gets the linear velocity
  105097. * @returns linear velocity or null
  105098. */
  105099. getLinearVelocity(): Nullable<Vector3>;
  105100. /**
  105101. * Sets the linear velocity
  105102. * @param velocity linear velocity or null
  105103. */
  105104. setLinearVelocity(velocity: Nullable<Vector3>): void;
  105105. /**
  105106. * Gets the angular velocity
  105107. * @returns angular velocity or null
  105108. */
  105109. getAngularVelocity(): Nullable<Vector3>;
  105110. /**
  105111. * Sets the angular velocity
  105112. * @param velocity The velocity or null
  105113. */
  105114. setAngularVelocity(velocity: Nullable<Vector3>): void;
  105115. /**
  105116. * Execute a function with the physics plugin native code
  105117. * Provide a function the will have two variables - the world object and the physics body object
  105118. * @param func The function to execute with the physics plugin native code
  105119. */
  105120. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  105121. /**
  105122. * Register a function that will be executed before the physics world is stepping forward
  105123. * @param func The function to execute before the physics world is stepped forward
  105124. */
  105125. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  105126. /**
  105127. * Unregister a function that will be executed before the physics world is stepping forward
  105128. * @param func The function to execute before the physics world is stepped forward
  105129. */
  105130. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  105131. /**
  105132. * Register a function that will be executed after the physics step
  105133. * @param func The function to execute after physics step
  105134. */
  105135. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  105136. /**
  105137. * Unregisters a function that will be executed after the physics step
  105138. * @param func The function to execute after physics step
  105139. */
  105140. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  105141. /**
  105142. * register a function that will be executed when this impostor collides against a different body
  105143. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  105144. * @param func Callback that is executed on collision
  105145. */
  105146. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  105147. /**
  105148. * Unregisters the physics imposter on contact
  105149. * @param collideAgainst The physics object to collide against
  105150. * @param func Callback to execute on collision
  105151. */
  105152. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  105153. private _tmpQuat;
  105154. private _tmpQuat2;
  105155. /**
  105156. * Get the parent rotation
  105157. * @returns The parent rotation
  105158. */
  105159. getParentsRotation(): Quaternion;
  105160. /**
  105161. * this function is executed by the physics engine.
  105162. */
  105163. beforeStep: () => void;
  105164. /**
  105165. * this function is executed by the physics engine
  105166. */
  105167. afterStep: () => void;
  105168. /**
  105169. * Legacy collision detection event support
  105170. */
  105171. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  105172. /**
  105173. * event and body object due to cannon's event-based architecture.
  105174. */
  105175. onCollide: (e: {
  105176. body: any;
  105177. }) => void;
  105178. /**
  105179. * Apply a force
  105180. * @param force The force to apply
  105181. * @param contactPoint The contact point for the force
  105182. * @returns The physics imposter
  105183. */
  105184. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  105185. /**
  105186. * Apply an impulse
  105187. * @param force The impulse force
  105188. * @param contactPoint The contact point for the impulse force
  105189. * @returns The physics imposter
  105190. */
  105191. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  105192. /**
  105193. * A help function to create a joint
  105194. * @param otherImpostor A physics imposter used to create a joint
  105195. * @param jointType The type of joint
  105196. * @param jointData The data for the joint
  105197. * @returns The physics imposter
  105198. */
  105199. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  105200. /**
  105201. * Add a joint to this impostor with a different impostor
  105202. * @param otherImpostor A physics imposter used to add a joint
  105203. * @param joint The joint to add
  105204. * @returns The physics imposter
  105205. */
  105206. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  105207. /**
  105208. * Add an anchor to a cloth impostor
  105209. * @param otherImpostor rigid impostor to anchor to
  105210. * @param width ratio across width from 0 to 1
  105211. * @param height ratio up height from 0 to 1
  105212. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  105213. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  105214. * @returns impostor the soft imposter
  105215. */
  105216. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  105217. /**
  105218. * Add a hook to a rope impostor
  105219. * @param otherImpostor rigid impostor to anchor to
  105220. * @param length ratio across rope from 0 to 1
  105221. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  105222. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  105223. * @returns impostor the rope imposter
  105224. */
  105225. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  105226. /**
  105227. * Will keep this body still, in a sleep mode.
  105228. * @returns the physics imposter
  105229. */
  105230. sleep(): PhysicsImpostor;
  105231. /**
  105232. * Wake the body up.
  105233. * @returns The physics imposter
  105234. */
  105235. wakeUp(): PhysicsImpostor;
  105236. /**
  105237. * Clones the physics imposter
  105238. * @param newObject The physics imposter clones to this physics-enabled object
  105239. * @returns A nullable physics imposter
  105240. */
  105241. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  105242. /**
  105243. * Disposes the physics imposter
  105244. */
  105245. dispose(): void;
  105246. /**
  105247. * Sets the delta position
  105248. * @param position The delta position amount
  105249. */
  105250. setDeltaPosition(position: Vector3): void;
  105251. /**
  105252. * Sets the delta rotation
  105253. * @param rotation The delta rotation amount
  105254. */
  105255. setDeltaRotation(rotation: Quaternion): void;
  105256. /**
  105257. * Gets the box size of the physics imposter and stores the result in the input parameter
  105258. * @param result Stores the box size
  105259. * @returns The physics imposter
  105260. */
  105261. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  105262. /**
  105263. * Gets the radius of the physics imposter
  105264. * @returns Radius of the physics imposter
  105265. */
  105266. getRadius(): number;
  105267. /**
  105268. * Sync a bone with this impostor
  105269. * @param bone The bone to sync to the impostor.
  105270. * @param boneMesh The mesh that the bone is influencing.
  105271. * @param jointPivot The pivot of the joint / bone in local space.
  105272. * @param distToJoint Optional distance from the impostor to the joint.
  105273. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  105274. */
  105275. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  105276. /**
  105277. * Sync impostor to a bone
  105278. * @param bone The bone that the impostor will be synced to.
  105279. * @param boneMesh The mesh that the bone is influencing.
  105280. * @param jointPivot The pivot of the joint / bone in local space.
  105281. * @param distToJoint Optional distance from the impostor to the joint.
  105282. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  105283. * @param boneAxis Optional vector3 axis the bone is aligned with
  105284. */
  105285. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  105286. /**
  105287. * No-Imposter type
  105288. */
  105289. static NoImpostor: number;
  105290. /**
  105291. * Sphere-Imposter type
  105292. */
  105293. static SphereImpostor: number;
  105294. /**
  105295. * Box-Imposter type
  105296. */
  105297. static BoxImpostor: number;
  105298. /**
  105299. * Plane-Imposter type
  105300. */
  105301. static PlaneImpostor: number;
  105302. /**
  105303. * Mesh-imposter type
  105304. */
  105305. static MeshImpostor: number;
  105306. /**
  105307. * Capsule-Impostor type (Ammo.js plugin only)
  105308. */
  105309. static CapsuleImpostor: number;
  105310. /**
  105311. * Cylinder-Imposter type
  105312. */
  105313. static CylinderImpostor: number;
  105314. /**
  105315. * Particle-Imposter type
  105316. */
  105317. static ParticleImpostor: number;
  105318. /**
  105319. * Heightmap-Imposter type
  105320. */
  105321. static HeightmapImpostor: number;
  105322. /**
  105323. * ConvexHull-Impostor type (Ammo.js plugin only)
  105324. */
  105325. static ConvexHullImpostor: number;
  105326. /**
  105327. * Custom-Imposter type (Ammo.js plugin only)
  105328. */
  105329. static CustomImpostor: number;
  105330. /**
  105331. * Rope-Imposter type
  105332. */
  105333. static RopeImpostor: number;
  105334. /**
  105335. * Cloth-Imposter type
  105336. */
  105337. static ClothImpostor: number;
  105338. /**
  105339. * Softbody-Imposter type
  105340. */
  105341. static SoftbodyImpostor: number;
  105342. }
  105343. }
  105344. declare module BABYLON {
  105345. /**
  105346. * @hidden
  105347. **/
  105348. export class _CreationDataStorage {
  105349. closePath?: boolean;
  105350. closeArray?: boolean;
  105351. idx: number[];
  105352. dashSize: number;
  105353. gapSize: number;
  105354. path3D: Path3D;
  105355. pathArray: Vector3[][];
  105356. arc: number;
  105357. radius: number;
  105358. cap: number;
  105359. tessellation: number;
  105360. }
  105361. /**
  105362. * @hidden
  105363. **/
  105364. class _InstanceDataStorage {
  105365. visibleInstances: any;
  105366. batchCache: _InstancesBatch;
  105367. instancesBufferSize: number;
  105368. instancesBuffer: Nullable<Buffer>;
  105369. instancesData: Float32Array;
  105370. overridenInstanceCount: number;
  105371. isFrozen: boolean;
  105372. previousBatch: Nullable<_InstancesBatch>;
  105373. hardwareInstancedRendering: boolean;
  105374. sideOrientation: number;
  105375. manualUpdate: boolean;
  105376. }
  105377. /**
  105378. * @hidden
  105379. **/
  105380. export class _InstancesBatch {
  105381. mustReturn: boolean;
  105382. visibleInstances: Nullable<InstancedMesh[]>[];
  105383. renderSelf: boolean[];
  105384. hardwareInstancedRendering: boolean[];
  105385. }
  105386. /**
  105387. * @hidden
  105388. **/
  105389. class _ThinInstanceDataStorage {
  105390. instancesCount: number;
  105391. matrixBuffer: Nullable<Buffer>;
  105392. matrixBufferSize: number;
  105393. matrixData: Nullable<Float32Array>;
  105394. boundingVectors: Array<Vector3>;
  105395. }
  105396. /**
  105397. * Class used to represent renderable models
  105398. */
  105399. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  105400. /**
  105401. * Mesh side orientation : usually the external or front surface
  105402. */
  105403. static readonly FRONTSIDE: number;
  105404. /**
  105405. * Mesh side orientation : usually the internal or back surface
  105406. */
  105407. static readonly BACKSIDE: number;
  105408. /**
  105409. * Mesh side orientation : both internal and external or front and back surfaces
  105410. */
  105411. static readonly DOUBLESIDE: number;
  105412. /**
  105413. * Mesh side orientation : by default, `FRONTSIDE`
  105414. */
  105415. static readonly DEFAULTSIDE: number;
  105416. /**
  105417. * Mesh cap setting : no cap
  105418. */
  105419. static readonly NO_CAP: number;
  105420. /**
  105421. * Mesh cap setting : one cap at the beginning of the mesh
  105422. */
  105423. static readonly CAP_START: number;
  105424. /**
  105425. * Mesh cap setting : one cap at the end of the mesh
  105426. */
  105427. static readonly CAP_END: number;
  105428. /**
  105429. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  105430. */
  105431. static readonly CAP_ALL: number;
  105432. /**
  105433. * Mesh pattern setting : no flip or rotate
  105434. */
  105435. static readonly NO_FLIP: number;
  105436. /**
  105437. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  105438. */
  105439. static readonly FLIP_TILE: number;
  105440. /**
  105441. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  105442. */
  105443. static readonly ROTATE_TILE: number;
  105444. /**
  105445. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  105446. */
  105447. static readonly FLIP_ROW: number;
  105448. /**
  105449. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  105450. */
  105451. static readonly ROTATE_ROW: number;
  105452. /**
  105453. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  105454. */
  105455. static readonly FLIP_N_ROTATE_TILE: number;
  105456. /**
  105457. * Mesh pattern setting : rotate pattern and rotate
  105458. */
  105459. static readonly FLIP_N_ROTATE_ROW: number;
  105460. /**
  105461. * Mesh tile positioning : part tiles same on left/right or top/bottom
  105462. */
  105463. static readonly CENTER: number;
  105464. /**
  105465. * Mesh tile positioning : part tiles on left
  105466. */
  105467. static readonly LEFT: number;
  105468. /**
  105469. * Mesh tile positioning : part tiles on right
  105470. */
  105471. static readonly RIGHT: number;
  105472. /**
  105473. * Mesh tile positioning : part tiles on top
  105474. */
  105475. static readonly TOP: number;
  105476. /**
  105477. * Mesh tile positioning : part tiles on bottom
  105478. */
  105479. static readonly BOTTOM: number;
  105480. /**
  105481. * Gets the default side orientation.
  105482. * @param orientation the orientation to value to attempt to get
  105483. * @returns the default orientation
  105484. * @hidden
  105485. */
  105486. static _GetDefaultSideOrientation(orientation?: number): number;
  105487. private _internalMeshDataInfo;
  105488. /**
  105489. * An event triggered before rendering the mesh
  105490. */
  105491. get onBeforeRenderObservable(): Observable<Mesh>;
  105492. /**
  105493. * An event triggered before binding the mesh
  105494. */
  105495. get onBeforeBindObservable(): Observable<Mesh>;
  105496. /**
  105497. * An event triggered after rendering the mesh
  105498. */
  105499. get onAfterRenderObservable(): Observable<Mesh>;
  105500. /**
  105501. * An event triggered before drawing the mesh
  105502. */
  105503. get onBeforeDrawObservable(): Observable<Mesh>;
  105504. private _onBeforeDrawObserver;
  105505. /**
  105506. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  105507. */
  105508. set onBeforeDraw(callback: () => void);
  105509. get hasInstances(): boolean;
  105510. get hasThinInstances(): boolean;
  105511. /**
  105512. * Gets the delay loading state of the mesh (when delay loading is turned on)
  105513. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  105514. */
  105515. delayLoadState: number;
  105516. /**
  105517. * Gets the list of instances created from this mesh
  105518. * it is not supposed to be modified manually.
  105519. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  105520. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  105521. */
  105522. instances: InstancedMesh[];
  105523. /**
  105524. * Gets the file containing delay loading data for this mesh
  105525. */
  105526. delayLoadingFile: string;
  105527. /** @hidden */
  105528. _binaryInfo: any;
  105529. /**
  105530. * User defined function used to change how LOD level selection is done
  105531. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105532. */
  105533. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  105534. /**
  105535. * Gets or sets the morph target manager
  105536. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105537. */
  105538. get morphTargetManager(): Nullable<MorphTargetManager>;
  105539. set morphTargetManager(value: Nullable<MorphTargetManager>);
  105540. /** @hidden */
  105541. _creationDataStorage: Nullable<_CreationDataStorage>;
  105542. /** @hidden */
  105543. _geometry: Nullable<Geometry>;
  105544. /** @hidden */
  105545. _delayInfo: Array<string>;
  105546. /** @hidden */
  105547. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  105548. /** @hidden */
  105549. _instanceDataStorage: _InstanceDataStorage;
  105550. /** @hidden */
  105551. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  105552. private _effectiveMaterial;
  105553. /** @hidden */
  105554. _shouldGenerateFlatShading: boolean;
  105555. /** @hidden */
  105556. _originalBuilderSideOrientation: number;
  105557. /**
  105558. * Use this property to change the original side orientation defined at construction time
  105559. */
  105560. overrideMaterialSideOrientation: Nullable<number>;
  105561. /**
  105562. * Gets the source mesh (the one used to clone this one from)
  105563. */
  105564. get source(): Nullable<Mesh>;
  105565. /**
  105566. * Gets or sets a boolean indicating that this mesh does not use index buffer
  105567. */
  105568. get isUnIndexed(): boolean;
  105569. set isUnIndexed(value: boolean);
  105570. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  105571. get worldMatrixInstancedBuffer(): Float32Array;
  105572. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  105573. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  105574. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  105575. /**
  105576. * @constructor
  105577. * @param name The value used by scene.getMeshByName() to do a lookup.
  105578. * @param scene The scene to add this mesh to.
  105579. * @param parent The parent of this mesh, if it has one
  105580. * @param source An optional Mesh from which geometry is shared, cloned.
  105581. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  105582. * When false, achieved by calling a clone(), also passing False.
  105583. * This will make creation of children, recursive.
  105584. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  105585. */
  105586. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  105587. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  105588. doNotInstantiate: boolean;
  105589. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  105590. /**
  105591. * Gets the class name
  105592. * @returns the string "Mesh".
  105593. */
  105594. getClassName(): string;
  105595. /** @hidden */
  105596. get _isMesh(): boolean;
  105597. /**
  105598. * Returns a description of this mesh
  105599. * @param fullDetails define if full details about this mesh must be used
  105600. * @returns a descriptive string representing this mesh
  105601. */
  105602. toString(fullDetails?: boolean): string;
  105603. /** @hidden */
  105604. _unBindEffect(): void;
  105605. /**
  105606. * Gets a boolean indicating if this mesh has LOD
  105607. */
  105608. get hasLODLevels(): boolean;
  105609. /**
  105610. * Gets the list of MeshLODLevel associated with the current mesh
  105611. * @returns an array of MeshLODLevel
  105612. */
  105613. getLODLevels(): MeshLODLevel[];
  105614. private _sortLODLevels;
  105615. /**
  105616. * Add a mesh as LOD level triggered at the given distance.
  105617. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105618. * @param distance The distance from the center of the object to show this level
  105619. * @param mesh The mesh to be added as LOD level (can be null)
  105620. * @return This mesh (for chaining)
  105621. */
  105622. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  105623. /**
  105624. * Returns the LOD level mesh at the passed distance or null if not found.
  105625. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105626. * @param distance The distance from the center of the object to show this level
  105627. * @returns a Mesh or `null`
  105628. */
  105629. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  105630. /**
  105631. * Remove a mesh from the LOD array
  105632. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105633. * @param mesh defines the mesh to be removed
  105634. * @return This mesh (for chaining)
  105635. */
  105636. removeLODLevel(mesh: Mesh): Mesh;
  105637. /**
  105638. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  105639. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105640. * @param camera defines the camera to use to compute distance
  105641. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  105642. * @return This mesh (for chaining)
  105643. */
  105644. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  105645. /**
  105646. * Gets the mesh internal Geometry object
  105647. */
  105648. get geometry(): Nullable<Geometry>;
  105649. /**
  105650. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  105651. * @returns the total number of vertices
  105652. */
  105653. getTotalVertices(): number;
  105654. /**
  105655. * Returns the content of an associated vertex buffer
  105656. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105657. * - VertexBuffer.PositionKind
  105658. * - VertexBuffer.UVKind
  105659. * - VertexBuffer.UV2Kind
  105660. * - VertexBuffer.UV3Kind
  105661. * - VertexBuffer.UV4Kind
  105662. * - VertexBuffer.UV5Kind
  105663. * - VertexBuffer.UV6Kind
  105664. * - VertexBuffer.ColorKind
  105665. * - VertexBuffer.MatricesIndicesKind
  105666. * - VertexBuffer.MatricesIndicesExtraKind
  105667. * - VertexBuffer.MatricesWeightsKind
  105668. * - VertexBuffer.MatricesWeightsExtraKind
  105669. * @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
  105670. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  105671. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  105672. */
  105673. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  105674. /**
  105675. * Returns the mesh VertexBuffer object from the requested `kind`
  105676. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105677. * - VertexBuffer.PositionKind
  105678. * - VertexBuffer.NormalKind
  105679. * - VertexBuffer.UVKind
  105680. * - VertexBuffer.UV2Kind
  105681. * - VertexBuffer.UV3Kind
  105682. * - VertexBuffer.UV4Kind
  105683. * - VertexBuffer.UV5Kind
  105684. * - VertexBuffer.UV6Kind
  105685. * - VertexBuffer.ColorKind
  105686. * - VertexBuffer.MatricesIndicesKind
  105687. * - VertexBuffer.MatricesIndicesExtraKind
  105688. * - VertexBuffer.MatricesWeightsKind
  105689. * - VertexBuffer.MatricesWeightsExtraKind
  105690. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  105691. */
  105692. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  105693. /**
  105694. * Tests if a specific vertex buffer is associated with this mesh
  105695. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  105696. * - VertexBuffer.PositionKind
  105697. * - VertexBuffer.NormalKind
  105698. * - VertexBuffer.UVKind
  105699. * - VertexBuffer.UV2Kind
  105700. * - VertexBuffer.UV3Kind
  105701. * - VertexBuffer.UV4Kind
  105702. * - VertexBuffer.UV5Kind
  105703. * - VertexBuffer.UV6Kind
  105704. * - VertexBuffer.ColorKind
  105705. * - VertexBuffer.MatricesIndicesKind
  105706. * - VertexBuffer.MatricesIndicesExtraKind
  105707. * - VertexBuffer.MatricesWeightsKind
  105708. * - VertexBuffer.MatricesWeightsExtraKind
  105709. * @returns a boolean
  105710. */
  105711. isVerticesDataPresent(kind: string): boolean;
  105712. /**
  105713. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  105714. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  105715. * - VertexBuffer.PositionKind
  105716. * - VertexBuffer.UVKind
  105717. * - VertexBuffer.UV2Kind
  105718. * - VertexBuffer.UV3Kind
  105719. * - VertexBuffer.UV4Kind
  105720. * - VertexBuffer.UV5Kind
  105721. * - VertexBuffer.UV6Kind
  105722. * - VertexBuffer.ColorKind
  105723. * - VertexBuffer.MatricesIndicesKind
  105724. * - VertexBuffer.MatricesIndicesExtraKind
  105725. * - VertexBuffer.MatricesWeightsKind
  105726. * - VertexBuffer.MatricesWeightsExtraKind
  105727. * @returns a boolean
  105728. */
  105729. isVertexBufferUpdatable(kind: string): boolean;
  105730. /**
  105731. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  105732. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105733. * - VertexBuffer.PositionKind
  105734. * - VertexBuffer.NormalKind
  105735. * - VertexBuffer.UVKind
  105736. * - VertexBuffer.UV2Kind
  105737. * - VertexBuffer.UV3Kind
  105738. * - VertexBuffer.UV4Kind
  105739. * - VertexBuffer.UV5Kind
  105740. * - VertexBuffer.UV6Kind
  105741. * - VertexBuffer.ColorKind
  105742. * - VertexBuffer.MatricesIndicesKind
  105743. * - VertexBuffer.MatricesIndicesExtraKind
  105744. * - VertexBuffer.MatricesWeightsKind
  105745. * - VertexBuffer.MatricesWeightsExtraKind
  105746. * @returns an array of strings
  105747. */
  105748. getVerticesDataKinds(): string[];
  105749. /**
  105750. * Returns a positive integer : the total number of indices in this mesh geometry.
  105751. * @returns the numner of indices or zero if the mesh has no geometry.
  105752. */
  105753. getTotalIndices(): number;
  105754. /**
  105755. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  105756. * @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.
  105757. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105758. * @returns the indices array or an empty array if the mesh has no geometry
  105759. */
  105760. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  105761. get isBlocked(): boolean;
  105762. /**
  105763. * Determine if the current mesh is ready to be rendered
  105764. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  105765. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  105766. * @returns true if all associated assets are ready (material, textures, shaders)
  105767. */
  105768. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  105769. /**
  105770. * 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.
  105771. */
  105772. get areNormalsFrozen(): boolean;
  105773. /**
  105774. * 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.
  105775. * @returns the current mesh
  105776. */
  105777. freezeNormals(): Mesh;
  105778. /**
  105779. * 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
  105780. * @returns the current mesh
  105781. */
  105782. unfreezeNormals(): Mesh;
  105783. /**
  105784. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  105785. */
  105786. set overridenInstanceCount(count: number);
  105787. /** @hidden */
  105788. _preActivate(): Mesh;
  105789. /** @hidden */
  105790. _preActivateForIntermediateRendering(renderId: number): Mesh;
  105791. /** @hidden */
  105792. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  105793. protected _afterComputeWorldMatrix(): void;
  105794. /** @hidden */
  105795. _postActivate(): void;
  105796. /**
  105797. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  105798. * This means the mesh underlying bounding box and sphere are recomputed.
  105799. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  105800. * @returns the current mesh
  105801. */
  105802. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  105803. /** @hidden */
  105804. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  105805. /**
  105806. * This function will subdivide the mesh into multiple submeshes
  105807. * @param count defines the expected number of submeshes
  105808. */
  105809. subdivide(count: number): void;
  105810. /**
  105811. * Copy a FloatArray into a specific associated vertex buffer
  105812. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  105813. * - VertexBuffer.PositionKind
  105814. * - VertexBuffer.UVKind
  105815. * - VertexBuffer.UV2Kind
  105816. * - VertexBuffer.UV3Kind
  105817. * - VertexBuffer.UV4Kind
  105818. * - VertexBuffer.UV5Kind
  105819. * - VertexBuffer.UV6Kind
  105820. * - VertexBuffer.ColorKind
  105821. * - VertexBuffer.MatricesIndicesKind
  105822. * - VertexBuffer.MatricesIndicesExtraKind
  105823. * - VertexBuffer.MatricesWeightsKind
  105824. * - VertexBuffer.MatricesWeightsExtraKind
  105825. * @param data defines the data source
  105826. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  105827. * @param stride defines the data stride size (can be null)
  105828. * @returns the current mesh
  105829. */
  105830. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  105831. /**
  105832. * Delete a vertex buffer associated with this mesh
  105833. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  105834. * - VertexBuffer.PositionKind
  105835. * - VertexBuffer.UVKind
  105836. * - VertexBuffer.UV2Kind
  105837. * - VertexBuffer.UV3Kind
  105838. * - VertexBuffer.UV4Kind
  105839. * - VertexBuffer.UV5Kind
  105840. * - VertexBuffer.UV6Kind
  105841. * - VertexBuffer.ColorKind
  105842. * - VertexBuffer.MatricesIndicesKind
  105843. * - VertexBuffer.MatricesIndicesExtraKind
  105844. * - VertexBuffer.MatricesWeightsKind
  105845. * - VertexBuffer.MatricesWeightsExtraKind
  105846. */
  105847. removeVerticesData(kind: string): void;
  105848. /**
  105849. * Flags an associated vertex buffer as updatable
  105850. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  105851. * - VertexBuffer.PositionKind
  105852. * - VertexBuffer.UVKind
  105853. * - VertexBuffer.UV2Kind
  105854. * - VertexBuffer.UV3Kind
  105855. * - VertexBuffer.UV4Kind
  105856. * - VertexBuffer.UV5Kind
  105857. * - VertexBuffer.UV6Kind
  105858. * - VertexBuffer.ColorKind
  105859. * - VertexBuffer.MatricesIndicesKind
  105860. * - VertexBuffer.MatricesIndicesExtraKind
  105861. * - VertexBuffer.MatricesWeightsKind
  105862. * - VertexBuffer.MatricesWeightsExtraKind
  105863. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  105864. */
  105865. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  105866. /**
  105867. * Sets the mesh global Vertex Buffer
  105868. * @param buffer defines the buffer to use
  105869. * @returns the current mesh
  105870. */
  105871. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  105872. /**
  105873. * Update a specific associated vertex buffer
  105874. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  105875. * - VertexBuffer.PositionKind
  105876. * - VertexBuffer.UVKind
  105877. * - VertexBuffer.UV2Kind
  105878. * - VertexBuffer.UV3Kind
  105879. * - VertexBuffer.UV4Kind
  105880. * - VertexBuffer.UV5Kind
  105881. * - VertexBuffer.UV6Kind
  105882. * - VertexBuffer.ColorKind
  105883. * - VertexBuffer.MatricesIndicesKind
  105884. * - VertexBuffer.MatricesIndicesExtraKind
  105885. * - VertexBuffer.MatricesWeightsKind
  105886. * - VertexBuffer.MatricesWeightsExtraKind
  105887. * @param data defines the data source
  105888. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  105889. * @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)
  105890. * @returns the current mesh
  105891. */
  105892. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  105893. /**
  105894. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  105895. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  105896. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  105897. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  105898. * @returns the current mesh
  105899. */
  105900. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  105901. /**
  105902. * Creates a un-shared specific occurence of the geometry for the mesh.
  105903. * @returns the current mesh
  105904. */
  105905. makeGeometryUnique(): Mesh;
  105906. /**
  105907. * Set the index buffer of this mesh
  105908. * @param indices defines the source data
  105909. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  105910. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  105911. * @returns the current mesh
  105912. */
  105913. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  105914. /**
  105915. * Update the current index buffer
  105916. * @param indices defines the source data
  105917. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  105918. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  105919. * @returns the current mesh
  105920. */
  105921. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  105922. /**
  105923. * Invert the geometry to move from a right handed system to a left handed one.
  105924. * @returns the current mesh
  105925. */
  105926. toLeftHanded(): Mesh;
  105927. /** @hidden */
  105928. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  105929. /** @hidden */
  105930. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  105931. /**
  105932. * Registers for this mesh a javascript function called just before the rendering process
  105933. * @param func defines the function to call before rendering this mesh
  105934. * @returns the current mesh
  105935. */
  105936. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  105937. /**
  105938. * Disposes a previously registered javascript function called before the rendering
  105939. * @param func defines the function to remove
  105940. * @returns the current mesh
  105941. */
  105942. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  105943. /**
  105944. * Registers for this mesh a javascript function called just after the rendering is complete
  105945. * @param func defines the function to call after rendering this mesh
  105946. * @returns the current mesh
  105947. */
  105948. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  105949. /**
  105950. * Disposes a previously registered javascript function called after the rendering.
  105951. * @param func defines the function to remove
  105952. * @returns the current mesh
  105953. */
  105954. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  105955. /** @hidden */
  105956. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  105957. /** @hidden */
  105958. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  105959. /** @hidden */
  105960. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  105961. /** @hidden */
  105962. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  105963. /** @hidden */
  105964. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  105965. /** @hidden */
  105966. _rebuild(): void;
  105967. /** @hidden */
  105968. _freeze(): void;
  105969. /** @hidden */
  105970. _unFreeze(): void;
  105971. /**
  105972. * 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
  105973. * @param subMesh defines the subMesh to render
  105974. * @param enableAlphaMode defines if alpha mode can be changed
  105975. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  105976. * @returns the current mesh
  105977. */
  105978. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  105979. private _onBeforeDraw;
  105980. /**
  105981. * Renormalize the mesh and patch it up if there are no weights
  105982. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  105983. * However in the case of zero weights then we set just a single influence to 1.
  105984. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  105985. */
  105986. cleanMatrixWeights(): void;
  105987. private normalizeSkinFourWeights;
  105988. private normalizeSkinWeightsAndExtra;
  105989. /**
  105990. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  105991. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  105992. * the user know there was an issue with importing the mesh
  105993. * @returns a validation object with skinned, valid and report string
  105994. */
  105995. validateSkinning(): {
  105996. skinned: boolean;
  105997. valid: boolean;
  105998. report: string;
  105999. };
  106000. /** @hidden */
  106001. _checkDelayState(): Mesh;
  106002. private _queueLoad;
  106003. /**
  106004. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  106005. * A mesh is in the frustum if its bounding box intersects the frustum
  106006. * @param frustumPlanes defines the frustum to test
  106007. * @returns true if the mesh is in the frustum planes
  106008. */
  106009. isInFrustum(frustumPlanes: Plane[]): boolean;
  106010. /**
  106011. * Sets the mesh material by the material or multiMaterial `id` property
  106012. * @param id is a string identifying the material or the multiMaterial
  106013. * @returns the current mesh
  106014. */
  106015. setMaterialByID(id: string): Mesh;
  106016. /**
  106017. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  106018. * @returns an array of IAnimatable
  106019. */
  106020. getAnimatables(): IAnimatable[];
  106021. /**
  106022. * Modifies the mesh geometry according to the passed transformation matrix.
  106023. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  106024. * The mesh normals are modified using the same transformation.
  106025. * Note that, under the hood, this method sets a new VertexBuffer each call.
  106026. * @param transform defines the transform matrix to use
  106027. * @see https://doc.babylonjs.com/resources/baking_transformations
  106028. * @returns the current mesh
  106029. */
  106030. bakeTransformIntoVertices(transform: Matrix): Mesh;
  106031. /**
  106032. * Modifies the mesh geometry according to its own current World Matrix.
  106033. * The mesh World Matrix is then reset.
  106034. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  106035. * Note that, under the hood, this method sets a new VertexBuffer each call.
  106036. * @see https://doc.babylonjs.com/resources/baking_transformations
  106037. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  106038. * @returns the current mesh
  106039. */
  106040. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  106041. /** @hidden */
  106042. get _positions(): Nullable<Vector3[]>;
  106043. /** @hidden */
  106044. _resetPointsArrayCache(): Mesh;
  106045. /** @hidden */
  106046. _generatePointsArray(): boolean;
  106047. /**
  106048. * Returns a new Mesh object generated from the current mesh properties.
  106049. * This method must not get confused with createInstance()
  106050. * @param name is a string, the name given to the new mesh
  106051. * @param newParent can be any Node object (default `null`)
  106052. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  106053. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  106054. * @returns a new mesh
  106055. */
  106056. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  106057. /**
  106058. * Releases resources associated with this mesh.
  106059. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106060. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106061. */
  106062. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106063. /** @hidden */
  106064. _disposeInstanceSpecificData(): void;
  106065. /** @hidden */
  106066. _disposeThinInstanceSpecificData(): void;
  106067. /**
  106068. * Modifies the mesh geometry according to a displacement map.
  106069. * 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.
  106070. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  106071. * @param url is a string, the URL from the image file is to be downloaded.
  106072. * @param minHeight is the lower limit of the displacement.
  106073. * @param maxHeight is the upper limit of the displacement.
  106074. * @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.
  106075. * @param uvOffset is an optional vector2 used to offset UV.
  106076. * @param uvScale is an optional vector2 used to scale UV.
  106077. * @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.
  106078. * @returns the Mesh.
  106079. */
  106080. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  106081. /**
  106082. * Modifies the mesh geometry according to a displacementMap buffer.
  106083. * 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.
  106084. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  106085. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  106086. * @param heightMapWidth is the width of the buffer image.
  106087. * @param heightMapHeight is the height of the buffer image.
  106088. * @param minHeight is the lower limit of the displacement.
  106089. * @param maxHeight is the upper limit of the displacement.
  106090. * @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.
  106091. * @param uvOffset is an optional vector2 used to offset UV.
  106092. * @param uvScale is an optional vector2 used to scale UV.
  106093. * @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.
  106094. * @returns the Mesh.
  106095. */
  106096. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  106097. /**
  106098. * Modify the mesh to get a flat shading rendering.
  106099. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  106100. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  106101. * @returns current mesh
  106102. */
  106103. convertToFlatShadedMesh(): Mesh;
  106104. /**
  106105. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  106106. * In other words, more vertices, no more indices and a single bigger VBO.
  106107. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  106108. * @returns current mesh
  106109. */
  106110. convertToUnIndexedMesh(): Mesh;
  106111. /**
  106112. * Inverses facet orientations.
  106113. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  106114. * @param flipNormals will also inverts the normals
  106115. * @returns current mesh
  106116. */
  106117. flipFaces(flipNormals?: boolean): Mesh;
  106118. /**
  106119. * Increase the number of facets and hence vertices in a mesh
  106120. * Vertex normals are interpolated from existing vertex normals
  106121. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  106122. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  106123. */
  106124. increaseVertices(numberPerEdge: number): void;
  106125. /**
  106126. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  106127. * This will undo any application of covertToFlatShadedMesh
  106128. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  106129. */
  106130. forceSharedVertices(): void;
  106131. /** @hidden */
  106132. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  106133. /** @hidden */
  106134. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  106135. /**
  106136. * Creates a new InstancedMesh object from the mesh model.
  106137. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  106138. * @param name defines the name of the new instance
  106139. * @returns a new InstancedMesh
  106140. */
  106141. createInstance(name: string): InstancedMesh;
  106142. /**
  106143. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  106144. * After this call, all the mesh instances have the same submeshes than the current mesh.
  106145. * @returns the current mesh
  106146. */
  106147. synchronizeInstances(): Mesh;
  106148. /**
  106149. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  106150. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  106151. * This should be used together with the simplification to avoid disappearing triangles.
  106152. * @param successCallback an optional success callback to be called after the optimization finished.
  106153. * @returns the current mesh
  106154. */
  106155. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  106156. /**
  106157. * Serialize current mesh
  106158. * @param serializationObject defines the object which will receive the serialization data
  106159. */
  106160. serialize(serializationObject: any): void;
  106161. /** @hidden */
  106162. _syncGeometryWithMorphTargetManager(): void;
  106163. /** @hidden */
  106164. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  106165. /**
  106166. * Returns a new Mesh object parsed from the source provided.
  106167. * @param parsedMesh is the source
  106168. * @param scene defines the hosting scene
  106169. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  106170. * @returns a new Mesh
  106171. */
  106172. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  106173. /**
  106174. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  106175. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106176. * @param name defines the name of the mesh to create
  106177. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  106178. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  106179. * @param closePath creates a seam between the first and the last points of each path of the path array
  106180. * @param offset is taken in account only if the `pathArray` is containing a single path
  106181. * @param scene defines the hosting scene
  106182. * @param updatable defines if the mesh must be flagged as updatable
  106183. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106184. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  106185. * @returns a new Mesh
  106186. */
  106187. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  106188. /**
  106189. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  106190. * @param name defines the name of the mesh to create
  106191. * @param radius sets the radius size (float) of the polygon (default 0.5)
  106192. * @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
  106193. * @param scene defines the hosting scene
  106194. * @param updatable defines if the mesh must be flagged as updatable
  106195. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106196. * @returns a new Mesh
  106197. */
  106198. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  106199. /**
  106200. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  106201. * @param name defines the name of the mesh to create
  106202. * @param size sets the size (float) of each box side (default 1)
  106203. * @param scene defines the hosting scene
  106204. * @param updatable defines if the mesh must be flagged as updatable
  106205. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106206. * @returns a new Mesh
  106207. */
  106208. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  106209. /**
  106210. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  106211. * @param name defines the name of the mesh to create
  106212. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  106213. * @param diameter sets the diameter size (float) of the sphere (default 1)
  106214. * @param scene defines the hosting scene
  106215. * @param updatable defines if the mesh must be flagged as updatable
  106216. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106217. * @returns a new Mesh
  106218. */
  106219. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106220. /**
  106221. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  106222. * @param name defines the name of the mesh to create
  106223. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  106224. * @param diameter sets the diameter size (float) of the sphere (default 1)
  106225. * @param scene defines the hosting scene
  106226. * @returns a new Mesh
  106227. */
  106228. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  106229. /**
  106230. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  106231. * @param name defines the name of the mesh to create
  106232. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  106233. * @param diameterTop set the top cap diameter (floats, default 1)
  106234. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  106235. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  106236. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  106237. * @param scene defines the hosting scene
  106238. * @param updatable defines if the mesh must be flagged as updatable
  106239. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106240. * @returns a new Mesh
  106241. */
  106242. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  106243. /**
  106244. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  106245. * @param name defines the name of the mesh to create
  106246. * @param diameter sets the diameter size (float) of the torus (default 1)
  106247. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  106248. * @param tessellation sets the number of torus sides (postive integer, default 16)
  106249. * @param scene defines the hosting scene
  106250. * @param updatable defines if the mesh must be flagged as updatable
  106251. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106252. * @returns a new Mesh
  106253. */
  106254. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106255. /**
  106256. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  106257. * @param name defines the name of the mesh to create
  106258. * @param radius sets the global radius size (float) of the torus knot (default 2)
  106259. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  106260. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  106261. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  106262. * @param p the number of windings on X axis (positive integers, default 2)
  106263. * @param q the number of windings on Y axis (positive integers, default 3)
  106264. * @param scene defines the hosting scene
  106265. * @param updatable defines if the mesh must be flagged as updatable
  106266. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106267. * @returns a new Mesh
  106268. */
  106269. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106270. /**
  106271. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  106272. * @param name defines the name of the mesh to create
  106273. * @param points is an array successive Vector3
  106274. * @param scene defines the hosting scene
  106275. * @param updatable defines if the mesh must be flagged as updatable
  106276. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  106277. * @returns a new Mesh
  106278. */
  106279. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  106280. /**
  106281. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  106282. * @param name defines the name of the mesh to create
  106283. * @param points is an array successive Vector3
  106284. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  106285. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  106286. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  106287. * @param scene defines the hosting scene
  106288. * @param updatable defines if the mesh must be flagged as updatable
  106289. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  106290. * @returns a new Mesh
  106291. */
  106292. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  106293. /**
  106294. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  106295. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  106296. * 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.
  106297. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106298. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106299. * Remember you can only change the shape positions, not their number when updating a polygon.
  106300. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  106301. * @param name defines the name of the mesh to create
  106302. * @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
  106303. * @param scene defines the hosting scene
  106304. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  106305. * @param updatable defines if the mesh must be flagged as updatable
  106306. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106307. * @param earcutInjection can be used to inject your own earcut reference
  106308. * @returns a new Mesh
  106309. */
  106310. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  106311. /**
  106312. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  106313. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  106314. * @param name defines the name of the mesh to create
  106315. * @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
  106316. * @param depth defines the height of extrusion
  106317. * @param scene defines the hosting scene
  106318. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  106319. * @param updatable defines if the mesh must be flagged as updatable
  106320. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106321. * @param earcutInjection can be used to inject your own earcut reference
  106322. * @returns a new Mesh
  106323. */
  106324. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  106325. /**
  106326. * Creates an extruded shape mesh.
  106327. * 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
  106328. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106329. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106330. * @param name defines the name of the mesh to create
  106331. * @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
  106332. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  106333. * @param scale is the value to scale the shape
  106334. * @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
  106335. * @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
  106336. * @param scene defines the hosting scene
  106337. * @param updatable defines if the mesh must be flagged as updatable
  106338. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106339. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  106340. * @returns a new Mesh
  106341. */
  106342. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  106343. /**
  106344. * Creates an custom extruded shape mesh.
  106345. * The custom extrusion is a parametric shape.
  106346. * It has no predefined shape. Its final shape will depend on the input parameters.
  106347. * Please consider using the same method from the MeshBuilder class instead
  106348. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106349. * @param name defines the name of the mesh to create
  106350. * @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
  106351. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  106352. * @param scaleFunction is a custom Javascript function called on each path point
  106353. * @param rotationFunction is a custom Javascript function called on each path point
  106354. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  106355. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  106356. * @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
  106357. * @param scene defines the hosting scene
  106358. * @param updatable defines if the mesh must be flagged as updatable
  106359. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106360. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  106361. * @returns a new Mesh
  106362. */
  106363. 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;
  106364. /**
  106365. * Creates lathe mesh.
  106366. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  106367. * Please consider using the same method from the MeshBuilder class instead
  106368. * @param name defines the name of the mesh to create
  106369. * @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
  106370. * @param radius is the radius value of the lathe
  106371. * @param tessellation is the side number of the lathe.
  106372. * @param scene defines the hosting scene
  106373. * @param updatable defines if the mesh must be flagged as updatable
  106374. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106375. * @returns a new Mesh
  106376. */
  106377. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106378. /**
  106379. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  106380. * @param name defines the name of the mesh to create
  106381. * @param size sets the size (float) of both sides of the plane at once (default 1)
  106382. * @param scene defines the hosting scene
  106383. * @param updatable defines if the mesh must be flagged as updatable
  106384. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106385. * @returns a new Mesh
  106386. */
  106387. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106388. /**
  106389. * Creates a ground mesh.
  106390. * Please consider using the same method from the MeshBuilder class instead
  106391. * @param name defines the name of the mesh to create
  106392. * @param width set the width of the ground
  106393. * @param height set the height of the ground
  106394. * @param subdivisions sets the number of subdivisions per side
  106395. * @param scene defines the hosting scene
  106396. * @param updatable defines if the mesh must be flagged as updatable
  106397. * @returns a new Mesh
  106398. */
  106399. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  106400. /**
  106401. * Creates a tiled ground mesh.
  106402. * Please consider using the same method from the MeshBuilder class instead
  106403. * @param name defines the name of the mesh to create
  106404. * @param xmin set the ground minimum X coordinate
  106405. * @param zmin set the ground minimum Y coordinate
  106406. * @param xmax set the ground maximum X coordinate
  106407. * @param zmax set the ground maximum Z coordinate
  106408. * @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
  106409. * @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
  106410. * @param scene defines the hosting scene
  106411. * @param updatable defines if the mesh must be flagged as updatable
  106412. * @returns a new Mesh
  106413. */
  106414. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  106415. w: number;
  106416. h: number;
  106417. }, precision: {
  106418. w: number;
  106419. h: number;
  106420. }, scene: Scene, updatable?: boolean): Mesh;
  106421. /**
  106422. * Creates a ground mesh from a height map.
  106423. * Please consider using the same method from the MeshBuilder class instead
  106424. * @see https://doc.babylonjs.com/babylon101/height_map
  106425. * @param name defines the name of the mesh to create
  106426. * @param url sets the URL of the height map image resource
  106427. * @param width set the ground width size
  106428. * @param height set the ground height size
  106429. * @param subdivisions sets the number of subdivision per side
  106430. * @param minHeight is the minimum altitude on the ground
  106431. * @param maxHeight is the maximum altitude on the ground
  106432. * @param scene defines the hosting scene
  106433. * @param updatable defines if the mesh must be flagged as updatable
  106434. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  106435. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106436. * @returns a new Mesh
  106437. */
  106438. 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;
  106439. /**
  106440. * Creates a tube mesh.
  106441. * The tube is a parametric shape.
  106442. * It has no predefined shape. Its final shape will depend on the input parameters.
  106443. * Please consider using the same method from the MeshBuilder class instead
  106444. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106445. * @param name defines the name of the mesh to create
  106446. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  106447. * @param radius sets the tube radius size
  106448. * @param tessellation is the number of sides on the tubular surface
  106449. * @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
  106450. * @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
  106451. * @param scene defines the hosting scene
  106452. * @param updatable defines if the mesh must be flagged as updatable
  106453. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106454. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  106455. * @returns a new Mesh
  106456. */
  106457. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  106458. (i: number, distance: number): number;
  106459. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  106460. /**
  106461. * Creates a polyhedron mesh.
  106462. * Please consider using the same method from the MeshBuilder class instead.
  106463. * * 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
  106464. * * The parameter `size` (positive float, default 1) sets the polygon size
  106465. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  106466. * * 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`
  106467. * * 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
  106468. * * 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)`)
  106469. * * 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
  106470. * * 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
  106471. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106472. * * 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
  106473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106474. * @param name defines the name of the mesh to create
  106475. * @param options defines the options used to create the mesh
  106476. * @param scene defines the hosting scene
  106477. * @returns a new Mesh
  106478. */
  106479. static CreatePolyhedron(name: string, options: {
  106480. type?: number;
  106481. size?: number;
  106482. sizeX?: number;
  106483. sizeY?: number;
  106484. sizeZ?: number;
  106485. custom?: any;
  106486. faceUV?: Vector4[];
  106487. faceColors?: Color4[];
  106488. updatable?: boolean;
  106489. sideOrientation?: number;
  106490. }, scene: Scene): Mesh;
  106491. /**
  106492. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  106493. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  106494. * * 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`)
  106495. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  106496. * * 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
  106497. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106498. * * 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
  106499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106500. * @param name defines the name of the mesh
  106501. * @param options defines the options used to create the mesh
  106502. * @param scene defines the hosting scene
  106503. * @returns a new Mesh
  106504. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  106505. */
  106506. static CreateIcoSphere(name: string, options: {
  106507. radius?: number;
  106508. flat?: boolean;
  106509. subdivisions?: number;
  106510. sideOrientation?: number;
  106511. updatable?: boolean;
  106512. }, scene: Scene): Mesh;
  106513. /**
  106514. * Creates a decal mesh.
  106515. * Please consider using the same method from the MeshBuilder class instead.
  106516. * A decal is a mesh usually applied as a model onto the surface of another mesh
  106517. * @param name defines the name of the mesh
  106518. * @param sourceMesh defines the mesh receiving the decal
  106519. * @param position sets the position of the decal in world coordinates
  106520. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  106521. * @param size sets the decal scaling
  106522. * @param angle sets the angle to rotate the decal
  106523. * @returns a new Mesh
  106524. */
  106525. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  106526. /**
  106527. * Prepare internal position array for software CPU skinning
  106528. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  106529. */
  106530. setPositionsForCPUSkinning(): Float32Array;
  106531. /**
  106532. * Prepare internal normal array for software CPU skinning
  106533. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  106534. */
  106535. setNormalsForCPUSkinning(): Float32Array;
  106536. /**
  106537. * Updates the vertex buffer by applying transformation from the bones
  106538. * @param skeleton defines the skeleton to apply to current mesh
  106539. * @returns the current mesh
  106540. */
  106541. applySkeleton(skeleton: Skeleton): Mesh;
  106542. /**
  106543. * 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
  106544. * @param meshes defines the list of meshes to scan
  106545. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  106546. */
  106547. static MinMax(meshes: AbstractMesh[]): {
  106548. min: Vector3;
  106549. max: Vector3;
  106550. };
  106551. /**
  106552. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  106553. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  106554. * @returns a vector3
  106555. */
  106556. static Center(meshesOrMinMaxVector: {
  106557. min: Vector3;
  106558. max: Vector3;
  106559. } | AbstractMesh[]): Vector3;
  106560. /**
  106561. * Merge the array of meshes into a single mesh for performance reasons.
  106562. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  106563. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  106564. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  106565. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  106566. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  106567. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  106568. * @returns a new mesh
  106569. */
  106570. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  106571. /** @hidden */
  106572. addInstance(instance: InstancedMesh): void;
  106573. /** @hidden */
  106574. removeInstance(instance: InstancedMesh): void;
  106575. }
  106576. }
  106577. declare module BABYLON {
  106578. /**
  106579. * This is the base class of all the camera used in the application.
  106580. * @see https://doc.babylonjs.com/features/cameras
  106581. */
  106582. export class Camera extends Node {
  106583. /** @hidden */
  106584. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  106585. /**
  106586. * This is the default projection mode used by the cameras.
  106587. * It helps recreating a feeling of perspective and better appreciate depth.
  106588. * This is the best way to simulate real life cameras.
  106589. */
  106590. static readonly PERSPECTIVE_CAMERA: number;
  106591. /**
  106592. * This helps creating camera with an orthographic mode.
  106593. * 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.
  106594. */
  106595. static readonly ORTHOGRAPHIC_CAMERA: number;
  106596. /**
  106597. * This is the default FOV mode for perspective cameras.
  106598. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  106599. */
  106600. static readonly FOVMODE_VERTICAL_FIXED: number;
  106601. /**
  106602. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  106603. */
  106604. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  106605. /**
  106606. * This specifies ther is no need for a camera rig.
  106607. * Basically only one eye is rendered corresponding to the camera.
  106608. */
  106609. static readonly RIG_MODE_NONE: number;
  106610. /**
  106611. * Simulates a camera Rig with one blue eye and one red eye.
  106612. * This can be use with 3d blue and red glasses.
  106613. */
  106614. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  106615. /**
  106616. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  106617. */
  106618. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  106619. /**
  106620. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  106621. */
  106622. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  106623. /**
  106624. * Defines that both eyes of the camera will be rendered over under each other.
  106625. */
  106626. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  106627. /**
  106628. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  106629. */
  106630. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  106631. /**
  106632. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  106633. */
  106634. static readonly RIG_MODE_VR: number;
  106635. /**
  106636. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  106637. */
  106638. static readonly RIG_MODE_WEBVR: number;
  106639. /**
  106640. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  106641. */
  106642. static readonly RIG_MODE_CUSTOM: number;
  106643. /**
  106644. * Defines if by default attaching controls should prevent the default javascript event to continue.
  106645. */
  106646. static ForceAttachControlToAlwaysPreventDefault: boolean;
  106647. /**
  106648. * Define the input manager associated with the camera.
  106649. */
  106650. inputs: CameraInputsManager<Camera>;
  106651. /** @hidden */
  106652. _position: Vector3;
  106653. /**
  106654. * Define the current local position of the camera in the scene
  106655. */
  106656. get position(): Vector3;
  106657. set position(newPosition: Vector3);
  106658. /**
  106659. * The vector the camera should consider as up.
  106660. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  106661. */
  106662. upVector: Vector3;
  106663. /**
  106664. * Define the current limit on the left side for an orthographic camera
  106665. * In scene unit
  106666. */
  106667. orthoLeft: Nullable<number>;
  106668. /**
  106669. * Define the current limit on the right side for an orthographic camera
  106670. * In scene unit
  106671. */
  106672. orthoRight: Nullable<number>;
  106673. /**
  106674. * Define the current limit on the bottom side for an orthographic camera
  106675. * In scene unit
  106676. */
  106677. orthoBottom: Nullable<number>;
  106678. /**
  106679. * Define the current limit on the top side for an orthographic camera
  106680. * In scene unit
  106681. */
  106682. orthoTop: Nullable<number>;
  106683. /**
  106684. * Field Of View is set in Radians. (default is 0.8)
  106685. */
  106686. fov: number;
  106687. /**
  106688. * Define the minimum distance the camera can see from.
  106689. * This is important to note that the depth buffer are not infinite and the closer it starts
  106690. * the more your scene might encounter depth fighting issue.
  106691. */
  106692. minZ: number;
  106693. /**
  106694. * Define the maximum distance the camera can see to.
  106695. * This is important to note that the depth buffer are not infinite and the further it end
  106696. * the more your scene might encounter depth fighting issue.
  106697. */
  106698. maxZ: number;
  106699. /**
  106700. * Define the default inertia of the camera.
  106701. * This helps giving a smooth feeling to the camera movement.
  106702. */
  106703. inertia: number;
  106704. /**
  106705. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  106706. */
  106707. mode: number;
  106708. /**
  106709. * Define whether the camera is intermediate.
  106710. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  106711. */
  106712. isIntermediate: boolean;
  106713. /**
  106714. * Define the viewport of the camera.
  106715. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  106716. */
  106717. viewport: Viewport;
  106718. /**
  106719. * Restricts the camera to viewing objects with the same layerMask.
  106720. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  106721. */
  106722. layerMask: number;
  106723. /**
  106724. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  106725. */
  106726. fovMode: number;
  106727. /**
  106728. * Rig mode of the camera.
  106729. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  106730. * This is normally controlled byt the camera themselves as internal use.
  106731. */
  106732. cameraRigMode: number;
  106733. /**
  106734. * Defines the distance between both "eyes" in case of a RIG
  106735. */
  106736. interaxialDistance: number;
  106737. /**
  106738. * Defines if stereoscopic rendering is done side by side or over under.
  106739. */
  106740. isStereoscopicSideBySide: boolean;
  106741. /**
  106742. * 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
  106743. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  106744. * else in the scene. (Eg. security camera)
  106745. *
  106746. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  106747. */
  106748. customRenderTargets: RenderTargetTexture[];
  106749. /**
  106750. * When set, the camera will render to this render target instead of the default canvas
  106751. *
  106752. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  106753. */
  106754. outputRenderTarget: Nullable<RenderTargetTexture>;
  106755. /**
  106756. * Observable triggered when the camera view matrix has changed.
  106757. */
  106758. onViewMatrixChangedObservable: Observable<Camera>;
  106759. /**
  106760. * Observable triggered when the camera Projection matrix has changed.
  106761. */
  106762. onProjectionMatrixChangedObservable: Observable<Camera>;
  106763. /**
  106764. * Observable triggered when the inputs have been processed.
  106765. */
  106766. onAfterCheckInputsObservable: Observable<Camera>;
  106767. /**
  106768. * Observable triggered when reset has been called and applied to the camera.
  106769. */
  106770. onRestoreStateObservable: Observable<Camera>;
  106771. /**
  106772. * Is this camera a part of a rig system?
  106773. */
  106774. isRigCamera: boolean;
  106775. /**
  106776. * If isRigCamera set to true this will be set with the parent camera.
  106777. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  106778. */
  106779. rigParent?: Camera;
  106780. /** @hidden */
  106781. _cameraRigParams: any;
  106782. /** @hidden */
  106783. _rigCameras: Camera[];
  106784. /** @hidden */
  106785. _rigPostProcess: Nullable<PostProcess>;
  106786. protected _webvrViewMatrix: Matrix;
  106787. /** @hidden */
  106788. _skipRendering: boolean;
  106789. /** @hidden */
  106790. _projectionMatrix: Matrix;
  106791. /** @hidden */
  106792. _postProcesses: Nullable<PostProcess>[];
  106793. /** @hidden */
  106794. _activeMeshes: SmartArray<AbstractMesh>;
  106795. protected _globalPosition: Vector3;
  106796. /** @hidden */
  106797. _computedViewMatrix: Matrix;
  106798. private _doNotComputeProjectionMatrix;
  106799. private _transformMatrix;
  106800. private _frustumPlanes;
  106801. private _refreshFrustumPlanes;
  106802. private _storedFov;
  106803. private _stateStored;
  106804. /**
  106805. * Instantiates a new camera object.
  106806. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  106807. * @see https://doc.babylonjs.com/features/cameras
  106808. * @param name Defines the name of the camera in the scene
  106809. * @param position Defines the position of the camera
  106810. * @param scene Defines the scene the camera belongs too
  106811. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  106812. */
  106813. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  106814. /**
  106815. * Store current camera state (fov, position, etc..)
  106816. * @returns the camera
  106817. */
  106818. storeState(): Camera;
  106819. /**
  106820. * Restores the camera state values if it has been stored. You must call storeState() first
  106821. */
  106822. protected _restoreStateValues(): boolean;
  106823. /**
  106824. * Restored camera state. You must call storeState() first.
  106825. * @returns true if restored and false otherwise
  106826. */
  106827. restoreState(): boolean;
  106828. /**
  106829. * Gets the class name of the camera.
  106830. * @returns the class name
  106831. */
  106832. getClassName(): string;
  106833. /** @hidden */
  106834. readonly _isCamera: boolean;
  106835. /**
  106836. * Gets a string representation of the camera useful for debug purpose.
  106837. * @param fullDetails Defines that a more verboe level of logging is required
  106838. * @returns the string representation
  106839. */
  106840. toString(fullDetails?: boolean): string;
  106841. /**
  106842. * Gets the current world space position of the camera.
  106843. */
  106844. get globalPosition(): Vector3;
  106845. /**
  106846. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  106847. * @returns the active meshe list
  106848. */
  106849. getActiveMeshes(): SmartArray<AbstractMesh>;
  106850. /**
  106851. * Check whether a mesh is part of the current active mesh list of the camera
  106852. * @param mesh Defines the mesh to check
  106853. * @returns true if active, false otherwise
  106854. */
  106855. isActiveMesh(mesh: Mesh): boolean;
  106856. /**
  106857. * Is this camera ready to be used/rendered
  106858. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  106859. * @return true if the camera is ready
  106860. */
  106861. isReady(completeCheck?: boolean): boolean;
  106862. /** @hidden */
  106863. _initCache(): void;
  106864. /** @hidden */
  106865. _updateCache(ignoreParentClass?: boolean): void;
  106866. /** @hidden */
  106867. _isSynchronized(): boolean;
  106868. /** @hidden */
  106869. _isSynchronizedViewMatrix(): boolean;
  106870. /** @hidden */
  106871. _isSynchronizedProjectionMatrix(): boolean;
  106872. /**
  106873. * Attach the input controls to a specific dom element to get the input from.
  106874. * @param element Defines the element the controls should be listened from
  106875. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106876. */
  106877. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106878. /**
  106879. * Detach the current controls from the specified dom element.
  106880. * @param element Defines the element to stop listening the inputs from
  106881. */
  106882. detachControl(element: HTMLElement): void;
  106883. /**
  106884. * Update the camera state according to the different inputs gathered during the frame.
  106885. */
  106886. update(): void;
  106887. /** @hidden */
  106888. _checkInputs(): void;
  106889. /** @hidden */
  106890. get rigCameras(): Camera[];
  106891. /**
  106892. * Gets the post process used by the rig cameras
  106893. */
  106894. get rigPostProcess(): Nullable<PostProcess>;
  106895. /**
  106896. * Internal, gets the first post proces.
  106897. * @returns the first post process to be run on this camera.
  106898. */
  106899. _getFirstPostProcess(): Nullable<PostProcess>;
  106900. private _cascadePostProcessesToRigCams;
  106901. /**
  106902. * Attach a post process to the camera.
  106903. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  106904. * @param postProcess The post process to attach to the camera
  106905. * @param insertAt The position of the post process in case several of them are in use in the scene
  106906. * @returns the position the post process has been inserted at
  106907. */
  106908. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  106909. /**
  106910. * Detach a post process to the camera.
  106911. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  106912. * @param postProcess The post process to detach from the camera
  106913. */
  106914. detachPostProcess(postProcess: PostProcess): void;
  106915. /**
  106916. * Gets the current world matrix of the camera
  106917. */
  106918. getWorldMatrix(): Matrix;
  106919. /** @hidden */
  106920. _getViewMatrix(): Matrix;
  106921. /**
  106922. * Gets the current view matrix of the camera.
  106923. * @param force forces the camera to recompute the matrix without looking at the cached state
  106924. * @returns the view matrix
  106925. */
  106926. getViewMatrix(force?: boolean): Matrix;
  106927. /**
  106928. * Freeze the projection matrix.
  106929. * It will prevent the cache check of the camera projection compute and can speed up perf
  106930. * if no parameter of the camera are meant to change
  106931. * @param projection Defines manually a projection if necessary
  106932. */
  106933. freezeProjectionMatrix(projection?: Matrix): void;
  106934. /**
  106935. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  106936. */
  106937. unfreezeProjectionMatrix(): void;
  106938. /**
  106939. * Gets the current projection matrix of the camera.
  106940. * @param force forces the camera to recompute the matrix without looking at the cached state
  106941. * @returns the projection matrix
  106942. */
  106943. getProjectionMatrix(force?: boolean): Matrix;
  106944. /**
  106945. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  106946. * @returns a Matrix
  106947. */
  106948. getTransformationMatrix(): Matrix;
  106949. private _updateFrustumPlanes;
  106950. /**
  106951. * Checks if a cullable object (mesh...) is in the camera frustum
  106952. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  106953. * @param target The object to check
  106954. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  106955. * @returns true if the object is in frustum otherwise false
  106956. */
  106957. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  106958. /**
  106959. * Checks if a cullable object (mesh...) is in the camera frustum
  106960. * Unlike isInFrustum this cheks the full bounding box
  106961. * @param target The object to check
  106962. * @returns true if the object is in frustum otherwise false
  106963. */
  106964. isCompletelyInFrustum(target: ICullable): boolean;
  106965. /**
  106966. * Gets a ray in the forward direction from the camera.
  106967. * @param length Defines the length of the ray to create
  106968. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  106969. * @param origin Defines the start point of the ray which defaults to the camera position
  106970. * @returns the forward ray
  106971. */
  106972. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  106973. /**
  106974. * Releases resources associated with this node.
  106975. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106976. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106977. */
  106978. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106979. /** @hidden */
  106980. _isLeftCamera: boolean;
  106981. /**
  106982. * Gets the left camera of a rig setup in case of Rigged Camera
  106983. */
  106984. get isLeftCamera(): boolean;
  106985. /** @hidden */
  106986. _isRightCamera: boolean;
  106987. /**
  106988. * Gets the right camera of a rig setup in case of Rigged Camera
  106989. */
  106990. get isRightCamera(): boolean;
  106991. /**
  106992. * Gets the left camera of a rig setup in case of Rigged Camera
  106993. */
  106994. get leftCamera(): Nullable<FreeCamera>;
  106995. /**
  106996. * Gets the right camera of a rig setup in case of Rigged Camera
  106997. */
  106998. get rightCamera(): Nullable<FreeCamera>;
  106999. /**
  107000. * Gets the left camera target of a rig setup in case of Rigged Camera
  107001. * @returns the target position
  107002. */
  107003. getLeftTarget(): Nullable<Vector3>;
  107004. /**
  107005. * Gets the right camera target of a rig setup in case of Rigged Camera
  107006. * @returns the target position
  107007. */
  107008. getRightTarget(): Nullable<Vector3>;
  107009. /**
  107010. * @hidden
  107011. */
  107012. setCameraRigMode(mode: number, rigParams: any): void;
  107013. /** @hidden */
  107014. static _setStereoscopicRigMode(camera: Camera): void;
  107015. /** @hidden */
  107016. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  107017. /** @hidden */
  107018. static _setVRRigMode(camera: Camera, rigParams: any): void;
  107019. /** @hidden */
  107020. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  107021. /** @hidden */
  107022. _getVRProjectionMatrix(): Matrix;
  107023. protected _updateCameraRotationMatrix(): void;
  107024. protected _updateWebVRCameraRotationMatrix(): void;
  107025. /**
  107026. * This function MUST be overwritten by the different WebVR cameras available.
  107027. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  107028. * @hidden
  107029. */
  107030. _getWebVRProjectionMatrix(): Matrix;
  107031. /**
  107032. * This function MUST be overwritten by the different WebVR cameras available.
  107033. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  107034. * @hidden
  107035. */
  107036. _getWebVRViewMatrix(): Matrix;
  107037. /** @hidden */
  107038. setCameraRigParameter(name: string, value: any): void;
  107039. /**
  107040. * needs to be overridden by children so sub has required properties to be copied
  107041. * @hidden
  107042. */
  107043. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  107044. /**
  107045. * May need to be overridden by children
  107046. * @hidden
  107047. */
  107048. _updateRigCameras(): void;
  107049. /** @hidden */
  107050. _setupInputs(): void;
  107051. /**
  107052. * Serialiaze the camera setup to a json represention
  107053. * @returns the JSON representation
  107054. */
  107055. serialize(): any;
  107056. /**
  107057. * Clones the current camera.
  107058. * @param name The cloned camera name
  107059. * @returns the cloned camera
  107060. */
  107061. clone(name: string): Camera;
  107062. /**
  107063. * Gets the direction of the camera relative to a given local axis.
  107064. * @param localAxis Defines the reference axis to provide a relative direction.
  107065. * @return the direction
  107066. */
  107067. getDirection(localAxis: Vector3): Vector3;
  107068. /**
  107069. * Returns the current camera absolute rotation
  107070. */
  107071. get absoluteRotation(): Quaternion;
  107072. /**
  107073. * Gets the direction of the camera relative to a given local axis into a passed vector.
  107074. * @param localAxis Defines the reference axis to provide a relative direction.
  107075. * @param result Defines the vector to store the result in
  107076. */
  107077. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  107078. /**
  107079. * Gets a camera constructor for a given camera type
  107080. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  107081. * @param name The name of the camera the result will be able to instantiate
  107082. * @param scene The scene the result will construct the camera in
  107083. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  107084. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  107085. * @returns a factory method to construc the camera
  107086. */
  107087. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  107088. /**
  107089. * Compute the world matrix of the camera.
  107090. * @returns the camera world matrix
  107091. */
  107092. computeWorldMatrix(): Matrix;
  107093. /**
  107094. * Parse a JSON and creates the camera from the parsed information
  107095. * @param parsedCamera The JSON to parse
  107096. * @param scene The scene to instantiate the camera in
  107097. * @returns the newly constructed camera
  107098. */
  107099. static Parse(parsedCamera: any, scene: Scene): Camera;
  107100. }
  107101. }
  107102. declare module BABYLON {
  107103. /**
  107104. * Class containing static functions to help procedurally build meshes
  107105. */
  107106. export class DiscBuilder {
  107107. /**
  107108. * Creates a plane polygonal mesh. By default, this is a disc
  107109. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  107110. * * 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
  107111. * * 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
  107112. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107113. * * 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
  107114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107115. * @param name defines the name of the mesh
  107116. * @param options defines the options used to create the mesh
  107117. * @param scene defines the hosting scene
  107118. * @returns the plane polygonal mesh
  107119. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  107120. */
  107121. static CreateDisc(name: string, options: {
  107122. radius?: number;
  107123. tessellation?: number;
  107124. arc?: number;
  107125. updatable?: boolean;
  107126. sideOrientation?: number;
  107127. frontUVs?: Vector4;
  107128. backUVs?: Vector4;
  107129. }, scene?: Nullable<Scene>): Mesh;
  107130. }
  107131. }
  107132. declare module BABYLON {
  107133. /**
  107134. * Options to be used when creating a FresnelParameters.
  107135. */
  107136. export type IFresnelParametersCreationOptions = {
  107137. /**
  107138. * Define the color used on edges (grazing angle)
  107139. */
  107140. leftColor?: Color3;
  107141. /**
  107142. * Define the color used on center
  107143. */
  107144. rightColor?: Color3;
  107145. /**
  107146. * Define bias applied to computed fresnel term
  107147. */
  107148. bias?: number;
  107149. /**
  107150. * Defined the power exponent applied to fresnel term
  107151. */
  107152. power?: number;
  107153. /**
  107154. * Define if the fresnel effect is enable or not.
  107155. */
  107156. isEnabled?: boolean;
  107157. };
  107158. /**
  107159. * Serialized format for FresnelParameters.
  107160. */
  107161. export type IFresnelParametersSerialized = {
  107162. /**
  107163. * Define the color used on edges (grazing angle) [as an array]
  107164. */
  107165. leftColor: number[];
  107166. /**
  107167. * Define the color used on center [as an array]
  107168. */
  107169. rightColor: number[];
  107170. /**
  107171. * Define bias applied to computed fresnel term
  107172. */
  107173. bias: number;
  107174. /**
  107175. * Defined the power exponent applied to fresnel term
  107176. */
  107177. power?: number;
  107178. /**
  107179. * Define if the fresnel effect is enable or not.
  107180. */
  107181. isEnabled: boolean;
  107182. };
  107183. /**
  107184. * This represents all the required information to add a fresnel effect on a material:
  107185. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107186. */
  107187. export class FresnelParameters {
  107188. private _isEnabled;
  107189. /**
  107190. * Define if the fresnel effect is enable or not.
  107191. */
  107192. get isEnabled(): boolean;
  107193. set isEnabled(value: boolean);
  107194. /**
  107195. * Define the color used on edges (grazing angle)
  107196. */
  107197. leftColor: Color3;
  107198. /**
  107199. * Define the color used on center
  107200. */
  107201. rightColor: Color3;
  107202. /**
  107203. * Define bias applied to computed fresnel term
  107204. */
  107205. bias: number;
  107206. /**
  107207. * Defined the power exponent applied to fresnel term
  107208. */
  107209. power: number;
  107210. /**
  107211. * Creates a new FresnelParameters object.
  107212. *
  107213. * @param options provide your own settings to optionally to override defaults
  107214. */
  107215. constructor(options?: IFresnelParametersCreationOptions);
  107216. /**
  107217. * Clones the current fresnel and its valuues
  107218. * @returns a clone fresnel configuration
  107219. */
  107220. clone(): FresnelParameters;
  107221. /**
  107222. * Determines equality between FresnelParameters objects
  107223. * @param otherFresnelParameters defines the second operand
  107224. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  107225. */
  107226. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  107227. /**
  107228. * Serializes the current fresnel parameters to a JSON representation.
  107229. * @return the JSON serialization
  107230. */
  107231. serialize(): IFresnelParametersSerialized;
  107232. /**
  107233. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  107234. * @param parsedFresnelParameters Define the JSON representation
  107235. * @returns the parsed parameters
  107236. */
  107237. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  107238. }
  107239. }
  107240. declare module BABYLON {
  107241. /**
  107242. * This groups all the flags used to control the materials channel.
  107243. */
  107244. export class MaterialFlags {
  107245. private static _DiffuseTextureEnabled;
  107246. /**
  107247. * Are diffuse textures enabled in the application.
  107248. */
  107249. static get DiffuseTextureEnabled(): boolean;
  107250. static set DiffuseTextureEnabled(value: boolean);
  107251. private static _DetailTextureEnabled;
  107252. /**
  107253. * Are detail textures enabled in the application.
  107254. */
  107255. static get DetailTextureEnabled(): boolean;
  107256. static set DetailTextureEnabled(value: boolean);
  107257. private static _AmbientTextureEnabled;
  107258. /**
  107259. * Are ambient textures enabled in the application.
  107260. */
  107261. static get AmbientTextureEnabled(): boolean;
  107262. static set AmbientTextureEnabled(value: boolean);
  107263. private static _OpacityTextureEnabled;
  107264. /**
  107265. * Are opacity textures enabled in the application.
  107266. */
  107267. static get OpacityTextureEnabled(): boolean;
  107268. static set OpacityTextureEnabled(value: boolean);
  107269. private static _ReflectionTextureEnabled;
  107270. /**
  107271. * Are reflection textures enabled in the application.
  107272. */
  107273. static get ReflectionTextureEnabled(): boolean;
  107274. static set ReflectionTextureEnabled(value: boolean);
  107275. private static _EmissiveTextureEnabled;
  107276. /**
  107277. * Are emissive textures enabled in the application.
  107278. */
  107279. static get EmissiveTextureEnabled(): boolean;
  107280. static set EmissiveTextureEnabled(value: boolean);
  107281. private static _SpecularTextureEnabled;
  107282. /**
  107283. * Are specular textures enabled in the application.
  107284. */
  107285. static get SpecularTextureEnabled(): boolean;
  107286. static set SpecularTextureEnabled(value: boolean);
  107287. private static _BumpTextureEnabled;
  107288. /**
  107289. * Are bump textures enabled in the application.
  107290. */
  107291. static get BumpTextureEnabled(): boolean;
  107292. static set BumpTextureEnabled(value: boolean);
  107293. private static _LightmapTextureEnabled;
  107294. /**
  107295. * Are lightmap textures enabled in the application.
  107296. */
  107297. static get LightmapTextureEnabled(): boolean;
  107298. static set LightmapTextureEnabled(value: boolean);
  107299. private static _RefractionTextureEnabled;
  107300. /**
  107301. * Are refraction textures enabled in the application.
  107302. */
  107303. static get RefractionTextureEnabled(): boolean;
  107304. static set RefractionTextureEnabled(value: boolean);
  107305. private static _ColorGradingTextureEnabled;
  107306. /**
  107307. * Are color grading textures enabled in the application.
  107308. */
  107309. static get ColorGradingTextureEnabled(): boolean;
  107310. static set ColorGradingTextureEnabled(value: boolean);
  107311. private static _FresnelEnabled;
  107312. /**
  107313. * Are fresnels enabled in the application.
  107314. */
  107315. static get FresnelEnabled(): boolean;
  107316. static set FresnelEnabled(value: boolean);
  107317. private static _ClearCoatTextureEnabled;
  107318. /**
  107319. * Are clear coat textures enabled in the application.
  107320. */
  107321. static get ClearCoatTextureEnabled(): boolean;
  107322. static set ClearCoatTextureEnabled(value: boolean);
  107323. private static _ClearCoatBumpTextureEnabled;
  107324. /**
  107325. * Are clear coat bump textures enabled in the application.
  107326. */
  107327. static get ClearCoatBumpTextureEnabled(): boolean;
  107328. static set ClearCoatBumpTextureEnabled(value: boolean);
  107329. private static _ClearCoatTintTextureEnabled;
  107330. /**
  107331. * Are clear coat tint textures enabled in the application.
  107332. */
  107333. static get ClearCoatTintTextureEnabled(): boolean;
  107334. static set ClearCoatTintTextureEnabled(value: boolean);
  107335. private static _SheenTextureEnabled;
  107336. /**
  107337. * Are sheen textures enabled in the application.
  107338. */
  107339. static get SheenTextureEnabled(): boolean;
  107340. static set SheenTextureEnabled(value: boolean);
  107341. private static _AnisotropicTextureEnabled;
  107342. /**
  107343. * Are anisotropic textures enabled in the application.
  107344. */
  107345. static get AnisotropicTextureEnabled(): boolean;
  107346. static set AnisotropicTextureEnabled(value: boolean);
  107347. private static _ThicknessTextureEnabled;
  107348. /**
  107349. * Are thickness textures enabled in the application.
  107350. */
  107351. static get ThicknessTextureEnabled(): boolean;
  107352. static set ThicknessTextureEnabled(value: boolean);
  107353. }
  107354. }
  107355. declare module BABYLON {
  107356. /** @hidden */
  107357. export var defaultFragmentDeclaration: {
  107358. name: string;
  107359. shader: string;
  107360. };
  107361. }
  107362. declare module BABYLON {
  107363. /** @hidden */
  107364. export var defaultUboDeclaration: {
  107365. name: string;
  107366. shader: string;
  107367. };
  107368. }
  107369. declare module BABYLON {
  107370. /** @hidden */
  107371. export var lightFragmentDeclaration: {
  107372. name: string;
  107373. shader: string;
  107374. };
  107375. }
  107376. declare module BABYLON {
  107377. /** @hidden */
  107378. export var lightUboDeclaration: {
  107379. name: string;
  107380. shader: string;
  107381. };
  107382. }
  107383. declare module BABYLON {
  107384. /** @hidden */
  107385. export var lightsFragmentFunctions: {
  107386. name: string;
  107387. shader: string;
  107388. };
  107389. }
  107390. declare module BABYLON {
  107391. /** @hidden */
  107392. export var shadowsFragmentFunctions: {
  107393. name: string;
  107394. shader: string;
  107395. };
  107396. }
  107397. declare module BABYLON {
  107398. /** @hidden */
  107399. export var fresnelFunction: {
  107400. name: string;
  107401. shader: string;
  107402. };
  107403. }
  107404. declare module BABYLON {
  107405. /** @hidden */
  107406. export var bumpFragmentMainFunctions: {
  107407. name: string;
  107408. shader: string;
  107409. };
  107410. }
  107411. declare module BABYLON {
  107412. /** @hidden */
  107413. export var bumpFragmentFunctions: {
  107414. name: string;
  107415. shader: string;
  107416. };
  107417. }
  107418. declare module BABYLON {
  107419. /** @hidden */
  107420. export var logDepthDeclaration: {
  107421. name: string;
  107422. shader: string;
  107423. };
  107424. }
  107425. declare module BABYLON {
  107426. /** @hidden */
  107427. export var bumpFragment: {
  107428. name: string;
  107429. shader: string;
  107430. };
  107431. }
  107432. declare module BABYLON {
  107433. /** @hidden */
  107434. export var depthPrePass: {
  107435. name: string;
  107436. shader: string;
  107437. };
  107438. }
  107439. declare module BABYLON {
  107440. /** @hidden */
  107441. export var lightFragment: {
  107442. name: string;
  107443. shader: string;
  107444. };
  107445. }
  107446. declare module BABYLON {
  107447. /** @hidden */
  107448. export var logDepthFragment: {
  107449. name: string;
  107450. shader: string;
  107451. };
  107452. }
  107453. declare module BABYLON {
  107454. /** @hidden */
  107455. export var defaultPixelShader: {
  107456. name: string;
  107457. shader: string;
  107458. };
  107459. }
  107460. declare module BABYLON {
  107461. /** @hidden */
  107462. export var defaultVertexDeclaration: {
  107463. name: string;
  107464. shader: string;
  107465. };
  107466. }
  107467. declare module BABYLON {
  107468. /** @hidden */
  107469. export var bumpVertexDeclaration: {
  107470. name: string;
  107471. shader: string;
  107472. };
  107473. }
  107474. declare module BABYLON {
  107475. /** @hidden */
  107476. export var bumpVertex: {
  107477. name: string;
  107478. shader: string;
  107479. };
  107480. }
  107481. declare module BABYLON {
  107482. /** @hidden */
  107483. export var fogVertex: {
  107484. name: string;
  107485. shader: string;
  107486. };
  107487. }
  107488. declare module BABYLON {
  107489. /** @hidden */
  107490. export var shadowsVertex: {
  107491. name: string;
  107492. shader: string;
  107493. };
  107494. }
  107495. declare module BABYLON {
  107496. /** @hidden */
  107497. export var pointCloudVertex: {
  107498. name: string;
  107499. shader: string;
  107500. };
  107501. }
  107502. declare module BABYLON {
  107503. /** @hidden */
  107504. export var logDepthVertex: {
  107505. name: string;
  107506. shader: string;
  107507. };
  107508. }
  107509. declare module BABYLON {
  107510. /** @hidden */
  107511. export var defaultVertexShader: {
  107512. name: string;
  107513. shader: string;
  107514. };
  107515. }
  107516. declare module BABYLON {
  107517. /**
  107518. * @hidden
  107519. */
  107520. export interface IMaterialDetailMapDefines {
  107521. DETAIL: boolean;
  107522. DETAILDIRECTUV: number;
  107523. DETAIL_NORMALBLENDMETHOD: number;
  107524. /** @hidden */
  107525. _areTexturesDirty: boolean;
  107526. }
  107527. /**
  107528. * Define the code related to the detail map parameters of a material
  107529. *
  107530. * Inspired from:
  107531. * Unity: https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@9.0/manual/Mask-Map-and-Detail-Map.html and https://docs.unity3d.com/Manual/StandardShaderMaterialParameterDetail.html
  107532. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  107533. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  107534. */
  107535. export class DetailMapConfiguration {
  107536. private _texture;
  107537. /**
  107538. * The detail texture of the material.
  107539. */
  107540. texture: Nullable<BaseTexture>;
  107541. /**
  107542. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  107543. * Bigger values mean stronger blending
  107544. */
  107545. diffuseBlendLevel: number;
  107546. /**
  107547. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  107548. * Bigger values mean stronger blending. Only used with PBR materials
  107549. */
  107550. roughnessBlendLevel: number;
  107551. /**
  107552. * Defines how strong the bump effect from the detail map is
  107553. * Bigger values mean stronger effect
  107554. */
  107555. bumpLevel: number;
  107556. private _normalBlendMethod;
  107557. /**
  107558. * The method used to blend the bump and detail normals together
  107559. */
  107560. normalBlendMethod: number;
  107561. private _isEnabled;
  107562. /**
  107563. * Enable or disable the detail map on this material
  107564. */
  107565. isEnabled: boolean;
  107566. /** @hidden */
  107567. private _internalMarkAllSubMeshesAsTexturesDirty;
  107568. /** @hidden */
  107569. _markAllSubMeshesAsTexturesDirty(): void;
  107570. /**
  107571. * Instantiate a new detail map
  107572. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107573. */
  107574. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107575. /**
  107576. * Gets whether the submesh is ready to be used or not.
  107577. * @param defines the list of "defines" to update.
  107578. * @param scene defines the scene the material belongs to.
  107579. * @returns - boolean indicating that the submesh is ready or not.
  107580. */
  107581. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  107582. /**
  107583. * Update the defines for detail map usage
  107584. * @param defines the list of "defines" to update.
  107585. * @param scene defines the scene the material belongs to.
  107586. */
  107587. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  107588. /**
  107589. * Binds the material data.
  107590. * @param uniformBuffer defines the Uniform buffer to fill in.
  107591. * @param scene defines the scene the material belongs to.
  107592. * @param isFrozen defines whether the material is frozen or not.
  107593. */
  107594. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107595. /**
  107596. * Checks to see if a texture is used in the material.
  107597. * @param texture - Base texture to use.
  107598. * @returns - Boolean specifying if a texture is used in the material.
  107599. */
  107600. hasTexture(texture: BaseTexture): boolean;
  107601. /**
  107602. * Returns an array of the actively used textures.
  107603. * @param activeTextures Array of BaseTextures
  107604. */
  107605. getActiveTextures(activeTextures: BaseTexture[]): void;
  107606. /**
  107607. * Returns the animatable textures.
  107608. * @param animatables Array of animatable textures.
  107609. */
  107610. getAnimatables(animatables: IAnimatable[]): void;
  107611. /**
  107612. * Disposes the resources of the material.
  107613. * @param forceDisposeTextures - Forces the disposal of all textures.
  107614. */
  107615. dispose(forceDisposeTextures?: boolean): void;
  107616. /**
  107617. * Get the current class name useful for serialization or dynamic coding.
  107618. * @returns "DetailMap"
  107619. */
  107620. getClassName(): string;
  107621. /**
  107622. * Add the required uniforms to the current list.
  107623. * @param uniforms defines the current uniform list.
  107624. */
  107625. static AddUniforms(uniforms: string[]): void;
  107626. /**
  107627. * Add the required samplers to the current list.
  107628. * @param samplers defines the current sampler list.
  107629. */
  107630. static AddSamplers(samplers: string[]): void;
  107631. /**
  107632. * Add the required uniforms to the current buffer.
  107633. * @param uniformBuffer defines the current uniform buffer.
  107634. */
  107635. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107636. /**
  107637. * Makes a duplicate of the current instance into another one.
  107638. * @param detailMap define the instance where to copy the info
  107639. */
  107640. copyTo(detailMap: DetailMapConfiguration): void;
  107641. /**
  107642. * Serializes this detail map instance
  107643. * @returns - An object with the serialized instance.
  107644. */
  107645. serialize(): any;
  107646. /**
  107647. * Parses a detail map setting from a serialized object.
  107648. * @param source - Serialized object.
  107649. * @param scene Defines the scene we are parsing for
  107650. * @param rootUrl Defines the rootUrl to load from
  107651. */
  107652. parse(source: any, scene: Scene, rootUrl: string): void;
  107653. }
  107654. }
  107655. declare module BABYLON {
  107656. /** @hidden */
  107657. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  107658. MAINUV1: boolean;
  107659. MAINUV2: boolean;
  107660. DIFFUSE: boolean;
  107661. DIFFUSEDIRECTUV: number;
  107662. DETAIL: boolean;
  107663. DETAILDIRECTUV: number;
  107664. DETAIL_NORMALBLENDMETHOD: number;
  107665. AMBIENT: boolean;
  107666. AMBIENTDIRECTUV: number;
  107667. OPACITY: boolean;
  107668. OPACITYDIRECTUV: number;
  107669. OPACITYRGB: boolean;
  107670. REFLECTION: boolean;
  107671. EMISSIVE: boolean;
  107672. EMISSIVEDIRECTUV: number;
  107673. SPECULAR: boolean;
  107674. SPECULARDIRECTUV: number;
  107675. BUMP: boolean;
  107676. BUMPDIRECTUV: number;
  107677. PARALLAX: boolean;
  107678. PARALLAXOCCLUSION: boolean;
  107679. SPECULAROVERALPHA: boolean;
  107680. CLIPPLANE: boolean;
  107681. CLIPPLANE2: boolean;
  107682. CLIPPLANE3: boolean;
  107683. CLIPPLANE4: boolean;
  107684. CLIPPLANE5: boolean;
  107685. CLIPPLANE6: boolean;
  107686. ALPHATEST: boolean;
  107687. DEPTHPREPASS: boolean;
  107688. ALPHAFROMDIFFUSE: boolean;
  107689. POINTSIZE: boolean;
  107690. FOG: boolean;
  107691. SPECULARTERM: boolean;
  107692. DIFFUSEFRESNEL: boolean;
  107693. OPACITYFRESNEL: boolean;
  107694. REFLECTIONFRESNEL: boolean;
  107695. REFRACTIONFRESNEL: boolean;
  107696. EMISSIVEFRESNEL: boolean;
  107697. FRESNEL: boolean;
  107698. NORMAL: boolean;
  107699. UV1: boolean;
  107700. UV2: boolean;
  107701. VERTEXCOLOR: boolean;
  107702. VERTEXALPHA: boolean;
  107703. NUM_BONE_INFLUENCERS: number;
  107704. BonesPerMesh: number;
  107705. BONETEXTURE: boolean;
  107706. INSTANCES: boolean;
  107707. THIN_INSTANCES: boolean;
  107708. GLOSSINESS: boolean;
  107709. ROUGHNESS: boolean;
  107710. EMISSIVEASILLUMINATION: boolean;
  107711. LINKEMISSIVEWITHDIFFUSE: boolean;
  107712. REFLECTIONFRESNELFROMSPECULAR: boolean;
  107713. LIGHTMAP: boolean;
  107714. LIGHTMAPDIRECTUV: number;
  107715. OBJECTSPACE_NORMALMAP: boolean;
  107716. USELIGHTMAPASSHADOWMAP: boolean;
  107717. REFLECTIONMAP_3D: boolean;
  107718. REFLECTIONMAP_SPHERICAL: boolean;
  107719. REFLECTIONMAP_PLANAR: boolean;
  107720. REFLECTIONMAP_CUBIC: boolean;
  107721. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  107722. REFLECTIONMAP_PROJECTION: boolean;
  107723. REFLECTIONMAP_SKYBOX: boolean;
  107724. REFLECTIONMAP_EXPLICIT: boolean;
  107725. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  107726. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  107727. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  107728. INVERTCUBICMAP: boolean;
  107729. LOGARITHMICDEPTH: boolean;
  107730. REFRACTION: boolean;
  107731. REFRACTIONMAP_3D: boolean;
  107732. REFLECTIONOVERALPHA: boolean;
  107733. TWOSIDEDLIGHTING: boolean;
  107734. SHADOWFLOAT: boolean;
  107735. MORPHTARGETS: boolean;
  107736. MORPHTARGETS_NORMAL: boolean;
  107737. MORPHTARGETS_TANGENT: boolean;
  107738. MORPHTARGETS_UV: boolean;
  107739. NUM_MORPH_INFLUENCERS: number;
  107740. NONUNIFORMSCALING: boolean;
  107741. PREMULTIPLYALPHA: boolean;
  107742. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  107743. ALPHABLEND: boolean;
  107744. PREPASS: boolean;
  107745. SCENE_MRT_COUNT: number;
  107746. RGBDLIGHTMAP: boolean;
  107747. RGBDREFLECTION: boolean;
  107748. RGBDREFRACTION: boolean;
  107749. IMAGEPROCESSING: boolean;
  107750. VIGNETTE: boolean;
  107751. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107752. VIGNETTEBLENDMODEOPAQUE: boolean;
  107753. TONEMAPPING: boolean;
  107754. TONEMAPPING_ACES: boolean;
  107755. CONTRAST: boolean;
  107756. COLORCURVES: boolean;
  107757. COLORGRADING: boolean;
  107758. COLORGRADING3D: boolean;
  107759. SAMPLER3DGREENDEPTH: boolean;
  107760. SAMPLER3DBGRMAP: boolean;
  107761. IMAGEPROCESSINGPOSTPROCESS: boolean;
  107762. MULTIVIEW: boolean;
  107763. /**
  107764. * If the reflection texture on this material is in linear color space
  107765. * @hidden
  107766. */
  107767. IS_REFLECTION_LINEAR: boolean;
  107768. /**
  107769. * If the refraction texture on this material is in linear color space
  107770. * @hidden
  107771. */
  107772. IS_REFRACTION_LINEAR: boolean;
  107773. EXPOSURE: boolean;
  107774. constructor();
  107775. setReflectionMode(modeToEnable: string): void;
  107776. }
  107777. /**
  107778. * This is the default material used in Babylon. It is the best trade off between quality
  107779. * and performances.
  107780. * @see https://doc.babylonjs.com/babylon101/materials
  107781. */
  107782. export class StandardMaterial extends PushMaterial {
  107783. private _diffuseTexture;
  107784. /**
  107785. * The basic texture of the material as viewed under a light.
  107786. */
  107787. diffuseTexture: Nullable<BaseTexture>;
  107788. private _ambientTexture;
  107789. /**
  107790. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  107791. */
  107792. ambientTexture: Nullable<BaseTexture>;
  107793. private _opacityTexture;
  107794. /**
  107795. * Define the transparency of the material from a texture.
  107796. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  107797. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  107798. */
  107799. opacityTexture: Nullable<BaseTexture>;
  107800. private _reflectionTexture;
  107801. /**
  107802. * Define the texture used to display the reflection.
  107803. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107804. */
  107805. reflectionTexture: Nullable<BaseTexture>;
  107806. private _emissiveTexture;
  107807. /**
  107808. * Define texture of the material as if self lit.
  107809. * This will be mixed in the final result even in the absence of light.
  107810. */
  107811. emissiveTexture: Nullable<BaseTexture>;
  107812. private _specularTexture;
  107813. /**
  107814. * Define how the color and intensity of the highlight given by the light in the material.
  107815. */
  107816. specularTexture: Nullable<BaseTexture>;
  107817. private _bumpTexture;
  107818. /**
  107819. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  107820. * 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.
  107821. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  107822. */
  107823. bumpTexture: Nullable<BaseTexture>;
  107824. private _lightmapTexture;
  107825. /**
  107826. * Complex lighting can be computationally expensive to compute at runtime.
  107827. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  107828. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  107829. */
  107830. lightmapTexture: Nullable<BaseTexture>;
  107831. private _refractionTexture;
  107832. /**
  107833. * Define the texture used to display the refraction.
  107834. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107835. */
  107836. refractionTexture: Nullable<BaseTexture>;
  107837. /**
  107838. * The color of the material lit by the environmental background lighting.
  107839. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  107840. */
  107841. ambientColor: Color3;
  107842. /**
  107843. * The basic color of the material as viewed under a light.
  107844. */
  107845. diffuseColor: Color3;
  107846. /**
  107847. * Define how the color and intensity of the highlight given by the light in the material.
  107848. */
  107849. specularColor: Color3;
  107850. /**
  107851. * Define the color of the material as if self lit.
  107852. * This will be mixed in the final result even in the absence of light.
  107853. */
  107854. emissiveColor: Color3;
  107855. /**
  107856. * Defines how sharp are the highlights in the material.
  107857. * The bigger the value the sharper giving a more glossy feeling to the result.
  107858. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  107859. */
  107860. specularPower: number;
  107861. private _useAlphaFromDiffuseTexture;
  107862. /**
  107863. * Does the transparency come from the diffuse texture alpha channel.
  107864. */
  107865. useAlphaFromDiffuseTexture: boolean;
  107866. private _useEmissiveAsIllumination;
  107867. /**
  107868. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  107869. */
  107870. useEmissiveAsIllumination: boolean;
  107871. private _linkEmissiveWithDiffuse;
  107872. /**
  107873. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  107874. * the emissive level when the final color is close to one.
  107875. */
  107876. linkEmissiveWithDiffuse: boolean;
  107877. private _useSpecularOverAlpha;
  107878. /**
  107879. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107880. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107881. */
  107882. useSpecularOverAlpha: boolean;
  107883. private _useReflectionOverAlpha;
  107884. /**
  107885. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107886. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107887. */
  107888. useReflectionOverAlpha: boolean;
  107889. private _disableLighting;
  107890. /**
  107891. * Does lights from the scene impacts this material.
  107892. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  107893. */
  107894. disableLighting: boolean;
  107895. private _useObjectSpaceNormalMap;
  107896. /**
  107897. * Allows using an object space normal map (instead of tangent space).
  107898. */
  107899. useObjectSpaceNormalMap: boolean;
  107900. private _useParallax;
  107901. /**
  107902. * Is parallax enabled or not.
  107903. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  107904. */
  107905. useParallax: boolean;
  107906. private _useParallaxOcclusion;
  107907. /**
  107908. * Is parallax occlusion enabled or not.
  107909. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  107910. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  107911. */
  107912. useParallaxOcclusion: boolean;
  107913. /**
  107914. * 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.
  107915. */
  107916. parallaxScaleBias: number;
  107917. private _roughness;
  107918. /**
  107919. * Helps to define how blurry the reflections should appears in the material.
  107920. */
  107921. roughness: number;
  107922. /**
  107923. * In case of refraction, define the value of the index of refraction.
  107924. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107925. */
  107926. indexOfRefraction: number;
  107927. /**
  107928. * Invert the refraction texture alongside the y axis.
  107929. * It can be useful with procedural textures or probe for instance.
  107930. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107931. */
  107932. invertRefractionY: boolean;
  107933. /**
  107934. * Defines the alpha limits in alpha test mode.
  107935. */
  107936. alphaCutOff: number;
  107937. private _useLightmapAsShadowmap;
  107938. /**
  107939. * In case of light mapping, define whether the map contains light or shadow informations.
  107940. */
  107941. useLightmapAsShadowmap: boolean;
  107942. private _diffuseFresnelParameters;
  107943. /**
  107944. * Define the diffuse fresnel parameters of the material.
  107945. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107946. */
  107947. diffuseFresnelParameters: FresnelParameters;
  107948. private _opacityFresnelParameters;
  107949. /**
  107950. * Define the opacity fresnel parameters of the material.
  107951. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107952. */
  107953. opacityFresnelParameters: FresnelParameters;
  107954. private _reflectionFresnelParameters;
  107955. /**
  107956. * Define the reflection fresnel parameters of the material.
  107957. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107958. */
  107959. reflectionFresnelParameters: FresnelParameters;
  107960. private _refractionFresnelParameters;
  107961. /**
  107962. * Define the refraction fresnel parameters of the material.
  107963. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107964. */
  107965. refractionFresnelParameters: FresnelParameters;
  107966. private _emissiveFresnelParameters;
  107967. /**
  107968. * Define the emissive fresnel parameters of the material.
  107969. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107970. */
  107971. emissiveFresnelParameters: FresnelParameters;
  107972. private _useReflectionFresnelFromSpecular;
  107973. /**
  107974. * If true automatically deducts the fresnels values from the material specularity.
  107975. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107976. */
  107977. useReflectionFresnelFromSpecular: boolean;
  107978. private _useGlossinessFromSpecularMapAlpha;
  107979. /**
  107980. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  107981. */
  107982. useGlossinessFromSpecularMapAlpha: boolean;
  107983. private _maxSimultaneousLights;
  107984. /**
  107985. * Defines the maximum number of lights that can be used in the material
  107986. */
  107987. maxSimultaneousLights: number;
  107988. private _invertNormalMapX;
  107989. /**
  107990. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107991. */
  107992. invertNormalMapX: boolean;
  107993. private _invertNormalMapY;
  107994. /**
  107995. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107996. */
  107997. invertNormalMapY: boolean;
  107998. private _twoSidedLighting;
  107999. /**
  108000. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108001. */
  108002. twoSidedLighting: boolean;
  108003. /**
  108004. * Default configuration related to image processing available in the standard Material.
  108005. */
  108006. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108007. /**
  108008. * Gets the image processing configuration used either in this material.
  108009. */
  108010. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  108011. /**
  108012. * Sets the Default image processing configuration used either in the this material.
  108013. *
  108014. * If sets to null, the scene one is in use.
  108015. */
  108016. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  108017. /**
  108018. * Keep track of the image processing observer to allow dispose and replace.
  108019. */
  108020. private _imageProcessingObserver;
  108021. /**
  108022. * Attaches a new image processing configuration to the Standard Material.
  108023. * @param configuration
  108024. */
  108025. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108026. /**
  108027. * Gets wether the color curves effect is enabled.
  108028. */
  108029. get cameraColorCurvesEnabled(): boolean;
  108030. /**
  108031. * Sets wether the color curves effect is enabled.
  108032. */
  108033. set cameraColorCurvesEnabled(value: boolean);
  108034. /**
  108035. * Gets wether the color grading effect is enabled.
  108036. */
  108037. get cameraColorGradingEnabled(): boolean;
  108038. /**
  108039. * Gets wether the color grading effect is enabled.
  108040. */
  108041. set cameraColorGradingEnabled(value: boolean);
  108042. /**
  108043. * Gets wether tonemapping is enabled or not.
  108044. */
  108045. get cameraToneMappingEnabled(): boolean;
  108046. /**
  108047. * Sets wether tonemapping is enabled or not
  108048. */
  108049. set cameraToneMappingEnabled(value: boolean);
  108050. /**
  108051. * The camera exposure used on this material.
  108052. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108053. * This corresponds to a photographic exposure.
  108054. */
  108055. get cameraExposure(): number;
  108056. /**
  108057. * The camera exposure used on this material.
  108058. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108059. * This corresponds to a photographic exposure.
  108060. */
  108061. set cameraExposure(value: number);
  108062. /**
  108063. * Gets The camera contrast used on this material.
  108064. */
  108065. get cameraContrast(): number;
  108066. /**
  108067. * Sets The camera contrast used on this material.
  108068. */
  108069. set cameraContrast(value: number);
  108070. /**
  108071. * Gets the Color Grading 2D Lookup Texture.
  108072. */
  108073. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  108074. /**
  108075. * Sets the Color Grading 2D Lookup Texture.
  108076. */
  108077. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  108078. /**
  108079. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108080. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108081. * 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;
  108082. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108083. */
  108084. get cameraColorCurves(): Nullable<ColorCurves>;
  108085. /**
  108086. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108087. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108088. * 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;
  108089. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108090. */
  108091. set cameraColorCurves(value: Nullable<ColorCurves>);
  108092. /**
  108093. * Defines the detail map parameters for the material.
  108094. */
  108095. readonly detailMap: DetailMapConfiguration;
  108096. protected _renderTargets: SmartArray<RenderTargetTexture>;
  108097. protected _worldViewProjectionMatrix: Matrix;
  108098. protected _globalAmbientColor: Color3;
  108099. protected _useLogarithmicDepth: boolean;
  108100. protected _rebuildInParallel: boolean;
  108101. /**
  108102. * Instantiates a new standard material.
  108103. * This is the default material used in Babylon. It is the best trade off between quality
  108104. * and performances.
  108105. * @see https://doc.babylonjs.com/babylon101/materials
  108106. * @param name Define the name of the material in the scene
  108107. * @param scene Define the scene the material belong to
  108108. */
  108109. constructor(name: string, scene: Scene);
  108110. /**
  108111. * Gets a boolean indicating that current material needs to register RTT
  108112. */
  108113. get hasRenderTargetTextures(): boolean;
  108114. /**
  108115. * Gets the current class name of the material e.g. "StandardMaterial"
  108116. * Mainly use in serialization.
  108117. * @returns the class name
  108118. */
  108119. getClassName(): string;
  108120. /**
  108121. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  108122. * You can try switching to logarithmic depth.
  108123. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  108124. */
  108125. get useLogarithmicDepth(): boolean;
  108126. set useLogarithmicDepth(value: boolean);
  108127. /**
  108128. * Specifies if the material will require alpha blending
  108129. * @returns a boolean specifying if alpha blending is needed
  108130. */
  108131. needAlphaBlending(): boolean;
  108132. /**
  108133. * Specifies if this material should be rendered in alpha test mode
  108134. * @returns a boolean specifying if an alpha test is needed.
  108135. */
  108136. needAlphaTesting(): boolean;
  108137. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  108138. /**
  108139. * Get the texture used for alpha test purpose.
  108140. * @returns the diffuse texture in case of the standard material.
  108141. */
  108142. getAlphaTestTexture(): Nullable<BaseTexture>;
  108143. /**
  108144. * Get if the submesh is ready to be used and all its information available.
  108145. * Child classes can use it to update shaders
  108146. * @param mesh defines the mesh to check
  108147. * @param subMesh defines which submesh to check
  108148. * @param useInstances specifies that instances should be used
  108149. * @returns a boolean indicating that the submesh is ready or not
  108150. */
  108151. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108152. /**
  108153. * Builds the material UBO layouts.
  108154. * Used internally during the effect preparation.
  108155. */
  108156. buildUniformLayout(): void;
  108157. /**
  108158. * Unbinds the material from the mesh
  108159. */
  108160. unbind(): void;
  108161. /**
  108162. * Binds the submesh to this material by preparing the effect and shader to draw
  108163. * @param world defines the world transformation matrix
  108164. * @param mesh defines the mesh containing the submesh
  108165. * @param subMesh defines the submesh to bind the material to
  108166. */
  108167. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108168. /**
  108169. * Get the list of animatables in the material.
  108170. * @returns the list of animatables object used in the material
  108171. */
  108172. getAnimatables(): IAnimatable[];
  108173. /**
  108174. * Gets the active textures from the material
  108175. * @returns an array of textures
  108176. */
  108177. getActiveTextures(): BaseTexture[];
  108178. /**
  108179. * Specifies if the material uses a texture
  108180. * @param texture defines the texture to check against the material
  108181. * @returns a boolean specifying if the material uses the texture
  108182. */
  108183. hasTexture(texture: BaseTexture): boolean;
  108184. /**
  108185. * Disposes the material
  108186. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  108187. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  108188. */
  108189. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108190. /**
  108191. * Makes a duplicate of the material, and gives it a new name
  108192. * @param name defines the new name for the duplicated material
  108193. * @returns the cloned material
  108194. */
  108195. clone(name: string): StandardMaterial;
  108196. /**
  108197. * Serializes this material in a JSON representation
  108198. * @returns the serialized material object
  108199. */
  108200. serialize(): any;
  108201. /**
  108202. * Creates a standard material from parsed material data
  108203. * @param source defines the JSON representation of the material
  108204. * @param scene defines the hosting scene
  108205. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  108206. * @returns a new standard material
  108207. */
  108208. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  108209. /**
  108210. * Are diffuse textures enabled in the application.
  108211. */
  108212. static get DiffuseTextureEnabled(): boolean;
  108213. static set DiffuseTextureEnabled(value: boolean);
  108214. /**
  108215. * Are detail textures enabled in the application.
  108216. */
  108217. static get DetailTextureEnabled(): boolean;
  108218. static set DetailTextureEnabled(value: boolean);
  108219. /**
  108220. * Are ambient textures enabled in the application.
  108221. */
  108222. static get AmbientTextureEnabled(): boolean;
  108223. static set AmbientTextureEnabled(value: boolean);
  108224. /**
  108225. * Are opacity textures enabled in the application.
  108226. */
  108227. static get OpacityTextureEnabled(): boolean;
  108228. static set OpacityTextureEnabled(value: boolean);
  108229. /**
  108230. * Are reflection textures enabled in the application.
  108231. */
  108232. static get ReflectionTextureEnabled(): boolean;
  108233. static set ReflectionTextureEnabled(value: boolean);
  108234. /**
  108235. * Are emissive textures enabled in the application.
  108236. */
  108237. static get EmissiveTextureEnabled(): boolean;
  108238. static set EmissiveTextureEnabled(value: boolean);
  108239. /**
  108240. * Are specular textures enabled in the application.
  108241. */
  108242. static get SpecularTextureEnabled(): boolean;
  108243. static set SpecularTextureEnabled(value: boolean);
  108244. /**
  108245. * Are bump textures enabled in the application.
  108246. */
  108247. static get BumpTextureEnabled(): boolean;
  108248. static set BumpTextureEnabled(value: boolean);
  108249. /**
  108250. * Are lightmap textures enabled in the application.
  108251. */
  108252. static get LightmapTextureEnabled(): boolean;
  108253. static set LightmapTextureEnabled(value: boolean);
  108254. /**
  108255. * Are refraction textures enabled in the application.
  108256. */
  108257. static get RefractionTextureEnabled(): boolean;
  108258. static set RefractionTextureEnabled(value: boolean);
  108259. /**
  108260. * Are color grading textures enabled in the application.
  108261. */
  108262. static get ColorGradingTextureEnabled(): boolean;
  108263. static set ColorGradingTextureEnabled(value: boolean);
  108264. /**
  108265. * Are fresnels enabled in the application.
  108266. */
  108267. static get FresnelEnabled(): boolean;
  108268. static set FresnelEnabled(value: boolean);
  108269. }
  108270. }
  108271. declare module BABYLON {
  108272. /**
  108273. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  108274. *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.
  108275. * The SPS is also a particle system. It provides some methods to manage the particles.
  108276. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  108277. *
  108278. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  108279. */
  108280. export class SolidParticleSystem implements IDisposable {
  108281. /**
  108282. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  108283. * Example : var p = SPS.particles[i];
  108284. */
  108285. particles: SolidParticle[];
  108286. /**
  108287. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  108288. */
  108289. nbParticles: number;
  108290. /**
  108291. * If the particles must ever face the camera (default false). Useful for planar particles.
  108292. */
  108293. billboard: boolean;
  108294. /**
  108295. * Recompute normals when adding a shape
  108296. */
  108297. recomputeNormals: boolean;
  108298. /**
  108299. * This a counter ofr your own usage. It's not set by any SPS functions.
  108300. */
  108301. counter: number;
  108302. /**
  108303. * The SPS name. This name is also given to the underlying mesh.
  108304. */
  108305. name: string;
  108306. /**
  108307. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  108308. */
  108309. mesh: Mesh;
  108310. /**
  108311. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  108312. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  108313. */
  108314. vars: any;
  108315. /**
  108316. * This array is populated when the SPS is set as 'pickable'.
  108317. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  108318. * Each element of this array is an object `{idx: int, faceId: int}`.
  108319. * `idx` is the picked particle index in the `SPS.particles` array
  108320. * `faceId` is the picked face index counted within this particle.
  108321. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  108322. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  108323. * Use the method SPS.pickedParticle(pickingInfo) instead.
  108324. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  108325. */
  108326. pickedParticles: {
  108327. idx: number;
  108328. faceId: number;
  108329. }[];
  108330. /**
  108331. * This array is populated when the SPS is set as 'pickable'
  108332. * Each key of this array is a submesh index.
  108333. * Each element of this array is a second array defined like this :
  108334. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  108335. * Each element of this second array is an object `{idx: int, faceId: int}`.
  108336. * `idx` is the picked particle index in the `SPS.particles` array
  108337. * `faceId` is the picked face index counted within this particle.
  108338. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  108339. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  108340. */
  108341. pickedBySubMesh: {
  108342. idx: number;
  108343. faceId: number;
  108344. }[][];
  108345. /**
  108346. * This array is populated when `enableDepthSort` is set to true.
  108347. * Each element of this array is an instance of the class DepthSortedParticle.
  108348. */
  108349. depthSortedParticles: DepthSortedParticle[];
  108350. /**
  108351. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  108352. * @hidden
  108353. */
  108354. _bSphereOnly: boolean;
  108355. /**
  108356. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  108357. * @hidden
  108358. */
  108359. _bSphereRadiusFactor: number;
  108360. private _scene;
  108361. private _positions;
  108362. private _indices;
  108363. private _normals;
  108364. private _colors;
  108365. private _uvs;
  108366. private _indices32;
  108367. private _positions32;
  108368. private _normals32;
  108369. private _fixedNormal32;
  108370. private _colors32;
  108371. private _uvs32;
  108372. private _index;
  108373. private _updatable;
  108374. private _pickable;
  108375. private _isVisibilityBoxLocked;
  108376. private _alwaysVisible;
  108377. private _depthSort;
  108378. private _expandable;
  108379. private _shapeCounter;
  108380. private _copy;
  108381. private _color;
  108382. private _computeParticleColor;
  108383. private _computeParticleTexture;
  108384. private _computeParticleRotation;
  108385. private _computeParticleVertex;
  108386. private _computeBoundingBox;
  108387. private _depthSortParticles;
  108388. private _camera;
  108389. private _mustUnrotateFixedNormals;
  108390. private _particlesIntersect;
  108391. private _needs32Bits;
  108392. private _isNotBuilt;
  108393. private _lastParticleId;
  108394. private _idxOfId;
  108395. private _multimaterialEnabled;
  108396. private _useModelMaterial;
  108397. private _indicesByMaterial;
  108398. private _materialIndexes;
  108399. private _depthSortFunction;
  108400. private _materialSortFunction;
  108401. private _materials;
  108402. private _multimaterial;
  108403. private _materialIndexesById;
  108404. private _defaultMaterial;
  108405. private _autoUpdateSubMeshes;
  108406. private _tmpVertex;
  108407. /**
  108408. * Creates a SPS (Solid Particle System) object.
  108409. * @param name (String) is the SPS name, this will be the underlying mesh name.
  108410. * @param scene (Scene) is the scene in which the SPS is added.
  108411. * @param options defines the options of the sps e.g.
  108412. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  108413. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  108414. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  108415. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  108416. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  108417. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  108418. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  108419. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  108420. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  108421. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  108422. */
  108423. constructor(name: string, scene: Scene, options?: {
  108424. updatable?: boolean;
  108425. isPickable?: boolean;
  108426. enableDepthSort?: boolean;
  108427. particleIntersection?: boolean;
  108428. boundingSphereOnly?: boolean;
  108429. bSphereRadiusFactor?: number;
  108430. expandable?: boolean;
  108431. useModelMaterial?: boolean;
  108432. enableMultiMaterial?: boolean;
  108433. });
  108434. /**
  108435. * Builds the SPS underlying mesh. Returns a standard Mesh.
  108436. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  108437. * @returns the created mesh
  108438. */
  108439. buildMesh(): Mesh;
  108440. /**
  108441. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  108442. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  108443. * Thus the particles generated from `digest()` have their property `position` set yet.
  108444. * @param mesh ( Mesh ) is the mesh to be digested
  108445. * @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
  108446. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  108447. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  108448. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  108449. * @returns the current SPS
  108450. */
  108451. digest(mesh: Mesh, options?: {
  108452. facetNb?: number;
  108453. number?: number;
  108454. delta?: number;
  108455. storage?: [];
  108456. }): SolidParticleSystem;
  108457. /**
  108458. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  108459. * @hidden
  108460. */
  108461. private _unrotateFixedNormals;
  108462. /**
  108463. * Resets the temporary working copy particle
  108464. * @hidden
  108465. */
  108466. private _resetCopy;
  108467. /**
  108468. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  108469. * @param p the current index in the positions array to be updated
  108470. * @param ind the current index in the indices array
  108471. * @param shape a Vector3 array, the shape geometry
  108472. * @param positions the positions array to be updated
  108473. * @param meshInd the shape indices array
  108474. * @param indices the indices array to be updated
  108475. * @param meshUV the shape uv array
  108476. * @param uvs the uv array to be updated
  108477. * @param meshCol the shape color array
  108478. * @param colors the color array to be updated
  108479. * @param meshNor the shape normals array
  108480. * @param normals the normals array to be updated
  108481. * @param idx the particle index
  108482. * @param idxInShape the particle index in its shape
  108483. * @param options the addShape() method passed options
  108484. * @model the particle model
  108485. * @hidden
  108486. */
  108487. private _meshBuilder;
  108488. /**
  108489. * Returns a shape Vector3 array from positions float array
  108490. * @param positions float array
  108491. * @returns a vector3 array
  108492. * @hidden
  108493. */
  108494. private _posToShape;
  108495. /**
  108496. * Returns a shapeUV array from a float uvs (array deep copy)
  108497. * @param uvs as a float array
  108498. * @returns a shapeUV array
  108499. * @hidden
  108500. */
  108501. private _uvsToShapeUV;
  108502. /**
  108503. * Adds a new particle object in the particles array
  108504. * @param idx particle index in particles array
  108505. * @param id particle id
  108506. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  108507. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  108508. * @param model particle ModelShape object
  108509. * @param shapeId model shape identifier
  108510. * @param idxInShape index of the particle in the current model
  108511. * @param bInfo model bounding info object
  108512. * @param storage target storage array, if any
  108513. * @hidden
  108514. */
  108515. private _addParticle;
  108516. /**
  108517. * Adds some particles to the SPS from the model shape. Returns the shape id.
  108518. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  108519. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  108520. * @param nb (positive integer) the number of particles to be created from this model
  108521. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  108522. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  108523. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  108524. * @returns the number of shapes in the system
  108525. */
  108526. addShape(mesh: Mesh, nb: number, options?: {
  108527. positionFunction?: any;
  108528. vertexFunction?: any;
  108529. storage?: [];
  108530. }): number;
  108531. /**
  108532. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  108533. * @hidden
  108534. */
  108535. private _rebuildParticle;
  108536. /**
  108537. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  108538. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  108539. * @returns the SPS.
  108540. */
  108541. rebuildMesh(reset?: boolean): SolidParticleSystem;
  108542. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  108543. * Returns an array with the removed particles.
  108544. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  108545. * The SPS can't be empty so at least one particle needs to remain in place.
  108546. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  108547. * @param start index of the first particle to remove
  108548. * @param end index of the last particle to remove (included)
  108549. * @returns an array populated with the removed particles
  108550. */
  108551. removeParticles(start: number, end: number): SolidParticle[];
  108552. /**
  108553. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  108554. * @param solidParticleArray an array populated with Solid Particles objects
  108555. * @returns the SPS
  108556. */
  108557. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  108558. /**
  108559. * Creates a new particle and modifies the SPS mesh geometry :
  108560. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  108561. * - calls _addParticle() to populate the particle array
  108562. * factorized code from addShape() and insertParticlesFromArray()
  108563. * @param idx particle index in the particles array
  108564. * @param i particle index in its shape
  108565. * @param modelShape particle ModelShape object
  108566. * @param shape shape vertex array
  108567. * @param meshInd shape indices array
  108568. * @param meshUV shape uv array
  108569. * @param meshCol shape color array
  108570. * @param meshNor shape normals array
  108571. * @param bbInfo shape bounding info
  108572. * @param storage target particle storage
  108573. * @options addShape() passed options
  108574. * @hidden
  108575. */
  108576. private _insertNewParticle;
  108577. /**
  108578. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  108579. * This method calls `updateParticle()` for each particle of the SPS.
  108580. * For an animated SPS, it is usually called within the render loop.
  108581. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  108582. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  108583. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  108584. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  108585. * @returns the SPS.
  108586. */
  108587. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  108588. /**
  108589. * Disposes the SPS.
  108590. */
  108591. dispose(): void;
  108592. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  108593. * idx is the particle index in the SPS
  108594. * faceId is the picked face index counted within this particle.
  108595. * Returns null if the pickInfo can't identify a picked particle.
  108596. * @param pickingInfo (PickingInfo object)
  108597. * @returns {idx: number, faceId: number} or null
  108598. */
  108599. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  108600. idx: number;
  108601. faceId: number;
  108602. }>;
  108603. /**
  108604. * Returns a SolidParticle object from its identifier : particle.id
  108605. * @param id (integer) the particle Id
  108606. * @returns the searched particle or null if not found in the SPS.
  108607. */
  108608. getParticleById(id: number): Nullable<SolidParticle>;
  108609. /**
  108610. * Returns a new array populated with the particles having the passed shapeId.
  108611. * @param shapeId (integer) the shape identifier
  108612. * @returns a new solid particle array
  108613. */
  108614. getParticlesByShapeId(shapeId: number): SolidParticle[];
  108615. /**
  108616. * Populates the passed array "ref" with the particles having the passed shapeId.
  108617. * @param shapeId the shape identifier
  108618. * @returns the SPS
  108619. * @param ref
  108620. */
  108621. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  108622. /**
  108623. * Computes the required SubMeshes according the materials assigned to the particles.
  108624. * @returns the solid particle system.
  108625. * Does nothing if called before the SPS mesh is built.
  108626. */
  108627. computeSubMeshes(): SolidParticleSystem;
  108628. /**
  108629. * Sorts the solid particles by material when MultiMaterial is enabled.
  108630. * Updates the indices32 array.
  108631. * Updates the indicesByMaterial array.
  108632. * Updates the mesh indices array.
  108633. * @returns the SPS
  108634. * @hidden
  108635. */
  108636. private _sortParticlesByMaterial;
  108637. /**
  108638. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  108639. * @hidden
  108640. */
  108641. private _setMaterialIndexesById;
  108642. /**
  108643. * Returns an array with unique values of Materials from the passed array
  108644. * @param array the material array to be checked and filtered
  108645. * @hidden
  108646. */
  108647. private _filterUniqueMaterialId;
  108648. /**
  108649. * Sets a new Standard Material as _defaultMaterial if not already set.
  108650. * @hidden
  108651. */
  108652. private _setDefaultMaterial;
  108653. /**
  108654. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  108655. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108656. * @returns the SPS.
  108657. */
  108658. refreshVisibleSize(): SolidParticleSystem;
  108659. /**
  108660. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  108661. * @param size the size (float) of the visibility box
  108662. * note : this doesn't lock the SPS mesh bounding box.
  108663. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108664. */
  108665. setVisibilityBox(size: number): void;
  108666. /**
  108667. * Gets whether the SPS as always visible or not
  108668. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108669. */
  108670. get isAlwaysVisible(): boolean;
  108671. /**
  108672. * Sets the SPS as always visible or not
  108673. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108674. */
  108675. set isAlwaysVisible(val: boolean);
  108676. /**
  108677. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  108678. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108679. */
  108680. set isVisibilityBoxLocked(val: boolean);
  108681. /**
  108682. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  108683. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108684. */
  108685. get isVisibilityBoxLocked(): boolean;
  108686. /**
  108687. * Tells to `setParticles()` to compute the particle rotations or not.
  108688. * Default value : true. The SPS is faster when it's set to false.
  108689. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  108690. */
  108691. set computeParticleRotation(val: boolean);
  108692. /**
  108693. * Tells to `setParticles()` to compute the particle colors or not.
  108694. * Default value : true. The SPS is faster when it's set to false.
  108695. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  108696. */
  108697. set computeParticleColor(val: boolean);
  108698. set computeParticleTexture(val: boolean);
  108699. /**
  108700. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  108701. * Default value : false. The SPS is faster when it's set to false.
  108702. * Note : the particle custom vertex positions aren't stored values.
  108703. */
  108704. set computeParticleVertex(val: boolean);
  108705. /**
  108706. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  108707. */
  108708. set computeBoundingBox(val: boolean);
  108709. /**
  108710. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  108711. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  108712. * Default : `true`
  108713. */
  108714. set depthSortParticles(val: boolean);
  108715. /**
  108716. * Gets if `setParticles()` computes the particle rotations or not.
  108717. * Default value : true. The SPS is faster when it's set to false.
  108718. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  108719. */
  108720. get computeParticleRotation(): boolean;
  108721. /**
  108722. * Gets if `setParticles()` computes the particle colors or not.
  108723. * Default value : true. The SPS is faster when it's set to false.
  108724. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  108725. */
  108726. get computeParticleColor(): boolean;
  108727. /**
  108728. * Gets if `setParticles()` computes the particle textures or not.
  108729. * Default value : true. The SPS is faster when it's set to false.
  108730. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  108731. */
  108732. get computeParticleTexture(): boolean;
  108733. /**
  108734. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  108735. * Default value : false. The SPS is faster when it's set to false.
  108736. * Note : the particle custom vertex positions aren't stored values.
  108737. */
  108738. get computeParticleVertex(): boolean;
  108739. /**
  108740. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  108741. */
  108742. get computeBoundingBox(): boolean;
  108743. /**
  108744. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  108745. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  108746. * Default : `true`
  108747. */
  108748. get depthSortParticles(): boolean;
  108749. /**
  108750. * Gets if the SPS is created as expandable at construction time.
  108751. * Default : `false`
  108752. */
  108753. get expandable(): boolean;
  108754. /**
  108755. * Gets if the SPS supports the Multi Materials
  108756. */
  108757. get multimaterialEnabled(): boolean;
  108758. /**
  108759. * Gets if the SPS uses the model materials for its own multimaterial.
  108760. */
  108761. get useModelMaterial(): boolean;
  108762. /**
  108763. * The SPS used material array.
  108764. */
  108765. get materials(): Material[];
  108766. /**
  108767. * Sets the SPS MultiMaterial from the passed materials.
  108768. * Note : the passed array is internally copied and not used then by reference.
  108769. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  108770. */
  108771. setMultiMaterial(materials: Material[]): void;
  108772. /**
  108773. * The SPS computed multimaterial object
  108774. */
  108775. get multimaterial(): MultiMaterial;
  108776. set multimaterial(mm: MultiMaterial);
  108777. /**
  108778. * If the subMeshes must be updated on the next call to setParticles()
  108779. */
  108780. get autoUpdateSubMeshes(): boolean;
  108781. set autoUpdateSubMeshes(val: boolean);
  108782. /**
  108783. * This function does nothing. It may be overwritten to set all the particle first values.
  108784. * The SPS doesn't call this function, you may have to call it by your own.
  108785. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  108786. */
  108787. initParticles(): void;
  108788. /**
  108789. * This function does nothing. It may be overwritten to recycle a particle.
  108790. * The SPS doesn't call this function, you may have to call it by your own.
  108791. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  108792. * @param particle The particle to recycle
  108793. * @returns the recycled particle
  108794. */
  108795. recycleParticle(particle: SolidParticle): SolidParticle;
  108796. /**
  108797. * Updates a particle : this function should be overwritten by the user.
  108798. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  108799. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  108800. * @example : just set a particle position or velocity and recycle conditions
  108801. * @param particle The particle to update
  108802. * @returns the updated particle
  108803. */
  108804. updateParticle(particle: SolidParticle): SolidParticle;
  108805. /**
  108806. * Updates a vertex of a particle : it can be overwritten by the user.
  108807. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  108808. * @param particle the current particle
  108809. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  108810. * @param pt the index of the current vertex in the particle shape
  108811. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  108812. * @example : just set a vertex particle position or color
  108813. * @returns the sps
  108814. */
  108815. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  108816. /**
  108817. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  108818. * This does nothing and may be overwritten by the user.
  108819. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108820. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108821. * @param update the boolean update value actually passed to setParticles()
  108822. */
  108823. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  108824. /**
  108825. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  108826. * This will be passed three parameters.
  108827. * This does nothing and may be overwritten by the user.
  108828. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108829. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108830. * @param update the boolean update value actually passed to setParticles()
  108831. */
  108832. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  108833. }
  108834. }
  108835. declare module BABYLON {
  108836. /**
  108837. * Represents one particle of a solid particle system.
  108838. */
  108839. export class SolidParticle {
  108840. /**
  108841. * particle global index
  108842. */
  108843. idx: number;
  108844. /**
  108845. * particle identifier
  108846. */
  108847. id: number;
  108848. /**
  108849. * The color of the particle
  108850. */
  108851. color: Nullable<Color4>;
  108852. /**
  108853. * The world space position of the particle.
  108854. */
  108855. position: Vector3;
  108856. /**
  108857. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  108858. */
  108859. rotation: Vector3;
  108860. /**
  108861. * The world space rotation quaternion of the particle.
  108862. */
  108863. rotationQuaternion: Nullable<Quaternion>;
  108864. /**
  108865. * The scaling of the particle.
  108866. */
  108867. scaling: Vector3;
  108868. /**
  108869. * The uvs of the particle.
  108870. */
  108871. uvs: Vector4;
  108872. /**
  108873. * The current speed of the particle.
  108874. */
  108875. velocity: Vector3;
  108876. /**
  108877. * The pivot point in the particle local space.
  108878. */
  108879. pivot: Vector3;
  108880. /**
  108881. * Must the particle be translated from its pivot point in its local space ?
  108882. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  108883. * Default : false
  108884. */
  108885. translateFromPivot: boolean;
  108886. /**
  108887. * Is the particle active or not ?
  108888. */
  108889. alive: boolean;
  108890. /**
  108891. * Is the particle visible or not ?
  108892. */
  108893. isVisible: boolean;
  108894. /**
  108895. * Index of this particle in the global "positions" array (Internal use)
  108896. * @hidden
  108897. */
  108898. _pos: number;
  108899. /**
  108900. * @hidden Index of this particle in the global "indices" array (Internal use)
  108901. */
  108902. _ind: number;
  108903. /**
  108904. * @hidden ModelShape of this particle (Internal use)
  108905. */
  108906. _model: ModelShape;
  108907. /**
  108908. * ModelShape id of this particle
  108909. */
  108910. shapeId: number;
  108911. /**
  108912. * Index of the particle in its shape id
  108913. */
  108914. idxInShape: number;
  108915. /**
  108916. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  108917. */
  108918. _modelBoundingInfo: BoundingInfo;
  108919. /**
  108920. * @hidden Particle BoundingInfo object (Internal use)
  108921. */
  108922. _boundingInfo: BoundingInfo;
  108923. /**
  108924. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  108925. */
  108926. _sps: SolidParticleSystem;
  108927. /**
  108928. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  108929. */
  108930. _stillInvisible: boolean;
  108931. /**
  108932. * @hidden Last computed particle rotation matrix
  108933. */
  108934. _rotationMatrix: number[];
  108935. /**
  108936. * Parent particle Id, if any.
  108937. * Default null.
  108938. */
  108939. parentId: Nullable<number>;
  108940. /**
  108941. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  108942. */
  108943. materialIndex: Nullable<number>;
  108944. /**
  108945. * Custom object or properties.
  108946. */
  108947. props: Nullable<any>;
  108948. /**
  108949. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  108950. * The possible values are :
  108951. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  108952. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108953. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  108954. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  108955. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108956. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  108957. * */
  108958. cullingStrategy: number;
  108959. /**
  108960. * @hidden Internal global position in the SPS.
  108961. */
  108962. _globalPosition: Vector3;
  108963. /**
  108964. * Creates a Solid Particle object.
  108965. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  108966. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  108967. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  108968. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  108969. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  108970. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  108971. * @param shapeId (integer) is the model shape identifier in the SPS.
  108972. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  108973. * @param sps defines the sps it is associated to
  108974. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  108975. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  108976. */
  108977. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  108978. /**
  108979. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  108980. * @param target the particle target
  108981. * @returns the current particle
  108982. */
  108983. copyToRef(target: SolidParticle): SolidParticle;
  108984. /**
  108985. * Legacy support, changed scale to scaling
  108986. */
  108987. get scale(): Vector3;
  108988. /**
  108989. * Legacy support, changed scale to scaling
  108990. */
  108991. set scale(scale: Vector3);
  108992. /**
  108993. * Legacy support, changed quaternion to rotationQuaternion
  108994. */
  108995. get quaternion(): Nullable<Quaternion>;
  108996. /**
  108997. * Legacy support, changed quaternion to rotationQuaternion
  108998. */
  108999. set quaternion(q: Nullable<Quaternion>);
  109000. /**
  109001. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  109002. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  109003. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  109004. * @returns true if it intersects
  109005. */
  109006. intersectsMesh(target: Mesh | SolidParticle): boolean;
  109007. /**
  109008. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  109009. * A particle is in the frustum if its bounding box intersects the frustum
  109010. * @param frustumPlanes defines the frustum to test
  109011. * @returns true if the particle is in the frustum planes
  109012. */
  109013. isInFrustum(frustumPlanes: Plane[]): boolean;
  109014. /**
  109015. * get the rotation matrix of the particle
  109016. * @hidden
  109017. */
  109018. getRotationMatrix(m: Matrix): void;
  109019. }
  109020. /**
  109021. * Represents the shape of the model used by one particle of a solid particle system.
  109022. * SPS internal tool, don't use it manually.
  109023. */
  109024. export class ModelShape {
  109025. /**
  109026. * The shape id
  109027. * @hidden
  109028. */
  109029. shapeID: number;
  109030. /**
  109031. * flat array of model positions (internal use)
  109032. * @hidden
  109033. */
  109034. _shape: Vector3[];
  109035. /**
  109036. * flat array of model UVs (internal use)
  109037. * @hidden
  109038. */
  109039. _shapeUV: number[];
  109040. /**
  109041. * color array of the model
  109042. * @hidden
  109043. */
  109044. _shapeColors: number[];
  109045. /**
  109046. * indices array of the model
  109047. * @hidden
  109048. */
  109049. _indices: number[];
  109050. /**
  109051. * normals array of the model
  109052. * @hidden
  109053. */
  109054. _normals: number[];
  109055. /**
  109056. * length of the shape in the model indices array (internal use)
  109057. * @hidden
  109058. */
  109059. _indicesLength: number;
  109060. /**
  109061. * Custom position function (internal use)
  109062. * @hidden
  109063. */
  109064. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  109065. /**
  109066. * Custom vertex function (internal use)
  109067. * @hidden
  109068. */
  109069. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  109070. /**
  109071. * Model material (internal use)
  109072. * @hidden
  109073. */
  109074. _material: Nullable<Material>;
  109075. /**
  109076. * 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.
  109077. * SPS internal tool, don't use it manually.
  109078. * @hidden
  109079. */
  109080. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  109081. }
  109082. /**
  109083. * Represents a Depth Sorted Particle in the solid particle system.
  109084. * @hidden
  109085. */
  109086. export class DepthSortedParticle {
  109087. /**
  109088. * Particle index
  109089. */
  109090. idx: number;
  109091. /**
  109092. * Index of the particle in the "indices" array
  109093. */
  109094. ind: number;
  109095. /**
  109096. * Length of the particle shape in the "indices" array
  109097. */
  109098. indicesLength: number;
  109099. /**
  109100. * Squared distance from the particle to the camera
  109101. */
  109102. sqDistance: number;
  109103. /**
  109104. * Material index when used with MultiMaterials
  109105. */
  109106. materialIndex: number;
  109107. /**
  109108. * Creates a new sorted particle
  109109. * @param materialIndex
  109110. */
  109111. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  109112. }
  109113. /**
  109114. * Represents a solid particle vertex
  109115. */
  109116. export class SolidParticleVertex {
  109117. /**
  109118. * Vertex position
  109119. */
  109120. position: Vector3;
  109121. /**
  109122. * Vertex color
  109123. */
  109124. color: Color4;
  109125. /**
  109126. * Vertex UV
  109127. */
  109128. uv: Vector2;
  109129. /**
  109130. * Creates a new solid particle vertex
  109131. */
  109132. constructor();
  109133. /** Vertex x coordinate */
  109134. get x(): number;
  109135. set x(val: number);
  109136. /** Vertex y coordinate */
  109137. get y(): number;
  109138. set y(val: number);
  109139. /** Vertex z coordinate */
  109140. get z(): number;
  109141. set z(val: number);
  109142. }
  109143. }
  109144. declare module BABYLON {
  109145. /**
  109146. * @hidden
  109147. */
  109148. export class _MeshCollisionData {
  109149. _checkCollisions: boolean;
  109150. _collisionMask: number;
  109151. _collisionGroup: number;
  109152. _surroundingMeshes: Nullable<AbstractMesh[]>;
  109153. _collider: Nullable<Collider>;
  109154. _oldPositionForCollisions: Vector3;
  109155. _diffPositionForCollisions: Vector3;
  109156. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  109157. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  109158. }
  109159. }
  109160. declare module BABYLON {
  109161. /** @hidden */
  109162. class _FacetDataStorage {
  109163. facetPositions: Vector3[];
  109164. facetNormals: Vector3[];
  109165. facetPartitioning: number[][];
  109166. facetNb: number;
  109167. partitioningSubdivisions: number;
  109168. partitioningBBoxRatio: number;
  109169. facetDataEnabled: boolean;
  109170. facetParameters: any;
  109171. bbSize: Vector3;
  109172. subDiv: {
  109173. max: number;
  109174. X: number;
  109175. Y: number;
  109176. Z: number;
  109177. };
  109178. facetDepthSort: boolean;
  109179. facetDepthSortEnabled: boolean;
  109180. depthSortedIndices: IndicesArray;
  109181. depthSortedFacets: {
  109182. ind: number;
  109183. sqDistance: number;
  109184. }[];
  109185. facetDepthSortFunction: (f1: {
  109186. ind: number;
  109187. sqDistance: number;
  109188. }, f2: {
  109189. ind: number;
  109190. sqDistance: number;
  109191. }) => number;
  109192. facetDepthSortFrom: Vector3;
  109193. facetDepthSortOrigin: Vector3;
  109194. invertedMatrix: Matrix;
  109195. }
  109196. /**
  109197. * @hidden
  109198. **/
  109199. class _InternalAbstractMeshDataInfo {
  109200. _hasVertexAlpha: boolean;
  109201. _useVertexColors: boolean;
  109202. _numBoneInfluencers: number;
  109203. _applyFog: boolean;
  109204. _receiveShadows: boolean;
  109205. _facetData: _FacetDataStorage;
  109206. _visibility: number;
  109207. _skeleton: Nullable<Skeleton>;
  109208. _layerMask: number;
  109209. _computeBonesUsingShaders: boolean;
  109210. _isActive: boolean;
  109211. _onlyForInstances: boolean;
  109212. _isActiveIntermediate: boolean;
  109213. _onlyForInstancesIntermediate: boolean;
  109214. _actAsRegularMesh: boolean;
  109215. }
  109216. /**
  109217. * Class used to store all common mesh properties
  109218. */
  109219. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  109220. /** No occlusion */
  109221. static OCCLUSION_TYPE_NONE: number;
  109222. /** Occlusion set to optimisitic */
  109223. static OCCLUSION_TYPE_OPTIMISTIC: number;
  109224. /** Occlusion set to strict */
  109225. static OCCLUSION_TYPE_STRICT: number;
  109226. /** Use an accurante occlusion algorithm */
  109227. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  109228. /** Use a conservative occlusion algorithm */
  109229. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  109230. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  109231. * Test order :
  109232. * Is the bounding sphere outside the frustum ?
  109233. * If not, are the bounding box vertices outside the frustum ?
  109234. * It not, then the cullable object is in the frustum.
  109235. */
  109236. static readonly CULLINGSTRATEGY_STANDARD: number;
  109237. /** Culling strategy : Bounding Sphere Only.
  109238. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  109239. * It's also less accurate than the standard because some not visible objects can still be selected.
  109240. * Test : is the bounding sphere outside the frustum ?
  109241. * If not, then the cullable object is in the frustum.
  109242. */
  109243. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  109244. /** Culling strategy : Optimistic Inclusion.
  109245. * This in an inclusion test first, then the standard exclusion test.
  109246. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  109247. * 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.
  109248. * Anyway, it's as accurate as the standard strategy.
  109249. * Test :
  109250. * Is the cullable object bounding sphere center in the frustum ?
  109251. * If not, apply the default culling strategy.
  109252. */
  109253. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  109254. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  109255. * This in an inclusion test first, then the bounding sphere only exclusion test.
  109256. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  109257. * 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.
  109258. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  109259. * Test :
  109260. * Is the cullable object bounding sphere center in the frustum ?
  109261. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  109262. */
  109263. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  109264. /**
  109265. * No billboard
  109266. */
  109267. static get BILLBOARDMODE_NONE(): number;
  109268. /** Billboard on X axis */
  109269. static get BILLBOARDMODE_X(): number;
  109270. /** Billboard on Y axis */
  109271. static get BILLBOARDMODE_Y(): number;
  109272. /** Billboard on Z axis */
  109273. static get BILLBOARDMODE_Z(): number;
  109274. /** Billboard on all axes */
  109275. static get BILLBOARDMODE_ALL(): number;
  109276. /** Billboard on using position instead of orientation */
  109277. static get BILLBOARDMODE_USE_POSITION(): number;
  109278. /** @hidden */
  109279. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  109280. /**
  109281. * The culling strategy to use to check whether the mesh must be rendered or not.
  109282. * This value can be changed at any time and will be used on the next render mesh selection.
  109283. * The possible values are :
  109284. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  109285. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  109286. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  109287. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  109288. * Please read each static variable documentation to get details about the culling process.
  109289. * */
  109290. cullingStrategy: number;
  109291. /**
  109292. * Gets the number of facets in the mesh
  109293. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  109294. */
  109295. get facetNb(): number;
  109296. /**
  109297. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  109298. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  109299. */
  109300. get partitioningSubdivisions(): number;
  109301. set partitioningSubdivisions(nb: number);
  109302. /**
  109303. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  109304. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  109305. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  109306. */
  109307. get partitioningBBoxRatio(): number;
  109308. set partitioningBBoxRatio(ratio: number);
  109309. /**
  109310. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  109311. * Works only for updatable meshes.
  109312. * Doesn't work with multi-materials
  109313. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  109314. */
  109315. get mustDepthSortFacets(): boolean;
  109316. set mustDepthSortFacets(sort: boolean);
  109317. /**
  109318. * The location (Vector3) where the facet depth sort must be computed from.
  109319. * By default, the active camera position.
  109320. * Used only when facet depth sort is enabled
  109321. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  109322. */
  109323. get facetDepthSortFrom(): Vector3;
  109324. set facetDepthSortFrom(location: Vector3);
  109325. /**
  109326. * gets a boolean indicating if facetData is enabled
  109327. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  109328. */
  109329. get isFacetDataEnabled(): boolean;
  109330. /** @hidden */
  109331. _updateNonUniformScalingState(value: boolean): boolean;
  109332. /**
  109333. * An event triggered when this mesh collides with another one
  109334. */
  109335. onCollideObservable: Observable<AbstractMesh>;
  109336. /** Set a function to call when this mesh collides with another one */
  109337. set onCollide(callback: () => void);
  109338. /**
  109339. * An event triggered when the collision's position changes
  109340. */
  109341. onCollisionPositionChangeObservable: Observable<Vector3>;
  109342. /** Set a function to call when the collision's position changes */
  109343. set onCollisionPositionChange(callback: () => void);
  109344. /**
  109345. * An event triggered when material is changed
  109346. */
  109347. onMaterialChangedObservable: Observable<AbstractMesh>;
  109348. /**
  109349. * Gets or sets the orientation for POV movement & rotation
  109350. */
  109351. definedFacingForward: boolean;
  109352. /** @hidden */
  109353. _occlusionQuery: Nullable<WebGLQuery>;
  109354. /** @hidden */
  109355. _renderingGroup: Nullable<RenderingGroup>;
  109356. /**
  109357. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  109358. */
  109359. get visibility(): number;
  109360. /**
  109361. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  109362. */
  109363. set visibility(value: number);
  109364. /** Gets or sets the alpha index used to sort transparent meshes
  109365. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  109366. */
  109367. alphaIndex: number;
  109368. /**
  109369. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  109370. */
  109371. isVisible: boolean;
  109372. /**
  109373. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  109374. */
  109375. isPickable: boolean;
  109376. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  109377. showSubMeshesBoundingBox: boolean;
  109378. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  109379. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  109380. */
  109381. isBlocker: boolean;
  109382. /**
  109383. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  109384. */
  109385. enablePointerMoveEvents: boolean;
  109386. /**
  109387. * Specifies the rendering group id for this mesh (0 by default)
  109388. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  109389. */
  109390. renderingGroupId: number;
  109391. private _material;
  109392. /** Gets or sets current material */
  109393. get material(): Nullable<Material>;
  109394. set material(value: Nullable<Material>);
  109395. /**
  109396. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  109397. * @see https://doc.babylonjs.com/babylon101/shadows
  109398. */
  109399. get receiveShadows(): boolean;
  109400. set receiveShadows(value: boolean);
  109401. /** Defines color to use when rendering outline */
  109402. outlineColor: Color3;
  109403. /** Define width to use when rendering outline */
  109404. outlineWidth: number;
  109405. /** Defines color to use when rendering overlay */
  109406. overlayColor: Color3;
  109407. /** Defines alpha to use when rendering overlay */
  109408. overlayAlpha: number;
  109409. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  109410. get hasVertexAlpha(): boolean;
  109411. set hasVertexAlpha(value: boolean);
  109412. /** 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) */
  109413. get useVertexColors(): boolean;
  109414. set useVertexColors(value: boolean);
  109415. /**
  109416. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  109417. */
  109418. get computeBonesUsingShaders(): boolean;
  109419. set computeBonesUsingShaders(value: boolean);
  109420. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  109421. get numBoneInfluencers(): number;
  109422. set numBoneInfluencers(value: number);
  109423. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  109424. get applyFog(): boolean;
  109425. set applyFog(value: boolean);
  109426. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  109427. useOctreeForRenderingSelection: boolean;
  109428. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  109429. useOctreeForPicking: boolean;
  109430. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  109431. useOctreeForCollisions: boolean;
  109432. /**
  109433. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  109434. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  109435. */
  109436. get layerMask(): number;
  109437. set layerMask(value: number);
  109438. /**
  109439. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  109440. */
  109441. alwaysSelectAsActiveMesh: boolean;
  109442. /**
  109443. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  109444. */
  109445. doNotSyncBoundingInfo: boolean;
  109446. /**
  109447. * Gets or sets the current action manager
  109448. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  109449. */
  109450. actionManager: Nullable<AbstractActionManager>;
  109451. private _meshCollisionData;
  109452. /**
  109453. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  109454. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109455. */
  109456. ellipsoid: Vector3;
  109457. /**
  109458. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  109459. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109460. */
  109461. ellipsoidOffset: Vector3;
  109462. /**
  109463. * Gets or sets a collision mask used to mask collisions (default is -1).
  109464. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  109465. */
  109466. get collisionMask(): number;
  109467. set collisionMask(mask: number);
  109468. /**
  109469. * Gets or sets the current collision group mask (-1 by default).
  109470. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  109471. */
  109472. get collisionGroup(): number;
  109473. set collisionGroup(mask: number);
  109474. /**
  109475. * Gets or sets current surrounding meshes (null by default).
  109476. *
  109477. * By default collision detection is tested against every mesh in the scene.
  109478. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  109479. * meshes will be tested for the collision.
  109480. *
  109481. * Note: if set to an empty array no collision will happen when this mesh is moved.
  109482. */
  109483. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  109484. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  109485. /**
  109486. * Defines edge width used when edgesRenderer is enabled
  109487. * @see https://www.babylonjs-playground.com/#10OJSG#13
  109488. */
  109489. edgesWidth: number;
  109490. /**
  109491. * Defines edge color used when edgesRenderer is enabled
  109492. * @see https://www.babylonjs-playground.com/#10OJSG#13
  109493. */
  109494. edgesColor: Color4;
  109495. /** @hidden */
  109496. _edgesRenderer: Nullable<IEdgesRenderer>;
  109497. /** @hidden */
  109498. _masterMesh: Nullable<AbstractMesh>;
  109499. /** @hidden */
  109500. _boundingInfo: Nullable<BoundingInfo>;
  109501. /** @hidden */
  109502. _renderId: number;
  109503. /**
  109504. * Gets or sets the list of subMeshes
  109505. * @see https://doc.babylonjs.com/how_to/multi_materials
  109506. */
  109507. subMeshes: SubMesh[];
  109508. /** @hidden */
  109509. _intersectionsInProgress: AbstractMesh[];
  109510. /** @hidden */
  109511. _unIndexed: boolean;
  109512. /** @hidden */
  109513. _lightSources: Light[];
  109514. /** Gets the list of lights affecting that mesh */
  109515. get lightSources(): Light[];
  109516. /** @hidden */
  109517. get _positions(): Nullable<Vector3[]>;
  109518. /** @hidden */
  109519. _waitingData: {
  109520. lods: Nullable<any>;
  109521. actions: Nullable<any>;
  109522. freezeWorldMatrix: Nullable<boolean>;
  109523. };
  109524. /** @hidden */
  109525. _bonesTransformMatrices: Nullable<Float32Array>;
  109526. /** @hidden */
  109527. _transformMatrixTexture: Nullable<RawTexture>;
  109528. /**
  109529. * Gets or sets a skeleton to apply skining transformations
  109530. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  109531. */
  109532. set skeleton(value: Nullable<Skeleton>);
  109533. get skeleton(): Nullable<Skeleton>;
  109534. /**
  109535. * An event triggered when the mesh is rebuilt.
  109536. */
  109537. onRebuildObservable: Observable<AbstractMesh>;
  109538. /**
  109539. * Creates a new AbstractMesh
  109540. * @param name defines the name of the mesh
  109541. * @param scene defines the hosting scene
  109542. */
  109543. constructor(name: string, scene?: Nullable<Scene>);
  109544. /**
  109545. * Returns the string "AbstractMesh"
  109546. * @returns "AbstractMesh"
  109547. */
  109548. getClassName(): string;
  109549. /**
  109550. * Gets a string representation of the current mesh
  109551. * @param fullDetails defines a boolean indicating if full details must be included
  109552. * @returns a string representation of the current mesh
  109553. */
  109554. toString(fullDetails?: boolean): string;
  109555. /**
  109556. * @hidden
  109557. */
  109558. protected _getEffectiveParent(): Nullable<Node>;
  109559. /** @hidden */
  109560. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  109561. /** @hidden */
  109562. _rebuild(): void;
  109563. /** @hidden */
  109564. _resyncLightSources(): void;
  109565. /** @hidden */
  109566. _resyncLightSource(light: Light): void;
  109567. /** @hidden */
  109568. _unBindEffect(): void;
  109569. /** @hidden */
  109570. _removeLightSource(light: Light, dispose: boolean): void;
  109571. private _markSubMeshesAsDirty;
  109572. /** @hidden */
  109573. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  109574. /** @hidden */
  109575. _markSubMeshesAsAttributesDirty(): void;
  109576. /** @hidden */
  109577. _markSubMeshesAsMiscDirty(): void;
  109578. /**
  109579. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  109580. */
  109581. get scaling(): Vector3;
  109582. set scaling(newScaling: Vector3);
  109583. /**
  109584. * Returns true if the mesh is blocked. Implemented by child classes
  109585. */
  109586. get isBlocked(): boolean;
  109587. /**
  109588. * Returns the mesh itself by default. Implemented by child classes
  109589. * @param camera defines the camera to use to pick the right LOD level
  109590. * @returns the currentAbstractMesh
  109591. */
  109592. getLOD(camera: Camera): Nullable<AbstractMesh>;
  109593. /**
  109594. * Returns 0 by default. Implemented by child classes
  109595. * @returns an integer
  109596. */
  109597. getTotalVertices(): number;
  109598. /**
  109599. * Returns a positive integer : the total number of indices in this mesh geometry.
  109600. * @returns the numner of indices or zero if the mesh has no geometry.
  109601. */
  109602. getTotalIndices(): number;
  109603. /**
  109604. * Returns null by default. Implemented by child classes
  109605. * @returns null
  109606. */
  109607. getIndices(): Nullable<IndicesArray>;
  109608. /**
  109609. * Returns the array of the requested vertex data kind. Implemented by child classes
  109610. * @param kind defines the vertex data kind to use
  109611. * @returns null
  109612. */
  109613. getVerticesData(kind: string): Nullable<FloatArray>;
  109614. /**
  109615. * Sets the vertex data of the mesh geometry for the requested `kind`.
  109616. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  109617. * Note that a new underlying VertexBuffer object is created each call.
  109618. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  109619. * @param kind defines vertex data kind:
  109620. * * VertexBuffer.PositionKind
  109621. * * VertexBuffer.UVKind
  109622. * * VertexBuffer.UV2Kind
  109623. * * VertexBuffer.UV3Kind
  109624. * * VertexBuffer.UV4Kind
  109625. * * VertexBuffer.UV5Kind
  109626. * * VertexBuffer.UV6Kind
  109627. * * VertexBuffer.ColorKind
  109628. * * VertexBuffer.MatricesIndicesKind
  109629. * * VertexBuffer.MatricesIndicesExtraKind
  109630. * * VertexBuffer.MatricesWeightsKind
  109631. * * VertexBuffer.MatricesWeightsExtraKind
  109632. * @param data defines the data source
  109633. * @param updatable defines if the data must be flagged as updatable (or static)
  109634. * @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
  109635. * @returns the current mesh
  109636. */
  109637. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  109638. /**
  109639. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  109640. * If the mesh has no geometry, it is simply returned as it is.
  109641. * @param kind defines vertex data kind:
  109642. * * VertexBuffer.PositionKind
  109643. * * VertexBuffer.UVKind
  109644. * * VertexBuffer.UV2Kind
  109645. * * VertexBuffer.UV3Kind
  109646. * * VertexBuffer.UV4Kind
  109647. * * VertexBuffer.UV5Kind
  109648. * * VertexBuffer.UV6Kind
  109649. * * VertexBuffer.ColorKind
  109650. * * VertexBuffer.MatricesIndicesKind
  109651. * * VertexBuffer.MatricesIndicesExtraKind
  109652. * * VertexBuffer.MatricesWeightsKind
  109653. * * VertexBuffer.MatricesWeightsExtraKind
  109654. * @param data defines the data source
  109655. * @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
  109656. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  109657. * @returns the current mesh
  109658. */
  109659. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  109660. /**
  109661. * Sets the mesh indices,
  109662. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  109663. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  109664. * @param totalVertices Defines the total number of vertices
  109665. * @returns the current mesh
  109666. */
  109667. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  109668. /**
  109669. * Gets a boolean indicating if specific vertex data is present
  109670. * @param kind defines the vertex data kind to use
  109671. * @returns true is data kind is present
  109672. */
  109673. isVerticesDataPresent(kind: string): boolean;
  109674. /**
  109675. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  109676. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  109677. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  109678. * @returns a BoundingInfo
  109679. */
  109680. getBoundingInfo(): BoundingInfo;
  109681. /**
  109682. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  109683. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  109684. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  109685. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  109686. * @returns the current mesh
  109687. */
  109688. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  109689. /**
  109690. * Overwrite the current bounding info
  109691. * @param boundingInfo defines the new bounding info
  109692. * @returns the current mesh
  109693. */
  109694. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  109695. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  109696. get useBones(): boolean;
  109697. /** @hidden */
  109698. _preActivate(): void;
  109699. /** @hidden */
  109700. _preActivateForIntermediateRendering(renderId: number): void;
  109701. /** @hidden */
  109702. _activate(renderId: number, intermediateRendering: boolean): boolean;
  109703. /** @hidden */
  109704. _postActivate(): void;
  109705. /** @hidden */
  109706. _freeze(): void;
  109707. /** @hidden */
  109708. _unFreeze(): void;
  109709. /**
  109710. * Gets the current world matrix
  109711. * @returns a Matrix
  109712. */
  109713. getWorldMatrix(): Matrix;
  109714. /** @hidden */
  109715. _getWorldMatrixDeterminant(): number;
  109716. /**
  109717. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  109718. */
  109719. get isAnInstance(): boolean;
  109720. /**
  109721. * Gets a boolean indicating if this mesh has instances
  109722. */
  109723. get hasInstances(): boolean;
  109724. /**
  109725. * Gets a boolean indicating if this mesh has thin instances
  109726. */
  109727. get hasThinInstances(): boolean;
  109728. /**
  109729. * Perform relative position change from the point of view of behind the front of the mesh.
  109730. * This is performed taking into account the meshes current rotation, so you do not have to care.
  109731. * Supports definition of mesh facing forward or backward
  109732. * @param amountRight defines the distance on the right axis
  109733. * @param amountUp defines the distance on the up axis
  109734. * @param amountForward defines the distance on the forward axis
  109735. * @returns the current mesh
  109736. */
  109737. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  109738. /**
  109739. * Calculate relative position change from the point of view of behind the front of the mesh.
  109740. * This is performed taking into account the meshes current rotation, so you do not have to care.
  109741. * Supports definition of mesh facing forward or backward
  109742. * @param amountRight defines the distance on the right axis
  109743. * @param amountUp defines the distance on the up axis
  109744. * @param amountForward defines the distance on the forward axis
  109745. * @returns the new displacement vector
  109746. */
  109747. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  109748. /**
  109749. * Perform relative rotation change from the point of view of behind the front of the mesh.
  109750. * Supports definition of mesh facing forward or backward
  109751. * @param flipBack defines the flip
  109752. * @param twirlClockwise defines the twirl
  109753. * @param tiltRight defines the tilt
  109754. * @returns the current mesh
  109755. */
  109756. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  109757. /**
  109758. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  109759. * Supports definition of mesh facing forward or backward.
  109760. * @param flipBack defines the flip
  109761. * @param twirlClockwise defines the twirl
  109762. * @param tiltRight defines the tilt
  109763. * @returns the new rotation vector
  109764. */
  109765. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  109766. /**
  109767. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  109768. * This means the mesh underlying bounding box and sphere are recomputed.
  109769. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  109770. * @returns the current mesh
  109771. */
  109772. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  109773. /** @hidden */
  109774. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  109775. /** @hidden */
  109776. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  109777. /** @hidden */
  109778. _updateBoundingInfo(): AbstractMesh;
  109779. /** @hidden */
  109780. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  109781. /** @hidden */
  109782. protected _afterComputeWorldMatrix(): void;
  109783. /** @hidden */
  109784. get _effectiveMesh(): AbstractMesh;
  109785. /**
  109786. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  109787. * A mesh is in the frustum if its bounding box intersects the frustum
  109788. * @param frustumPlanes defines the frustum to test
  109789. * @returns true if the mesh is in the frustum planes
  109790. */
  109791. isInFrustum(frustumPlanes: Plane[]): boolean;
  109792. /**
  109793. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  109794. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  109795. * @param frustumPlanes defines the frustum to test
  109796. * @returns true if the mesh is completely in the frustum planes
  109797. */
  109798. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  109799. /**
  109800. * True if the mesh intersects another mesh or a SolidParticle object
  109801. * @param mesh defines a target mesh or SolidParticle to test
  109802. * @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)
  109803. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  109804. * @returns true if there is an intersection
  109805. */
  109806. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  109807. /**
  109808. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  109809. * @param point defines the point to test
  109810. * @returns true if there is an intersection
  109811. */
  109812. intersectsPoint(point: Vector3): boolean;
  109813. /**
  109814. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  109815. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109816. */
  109817. get checkCollisions(): boolean;
  109818. set checkCollisions(collisionEnabled: boolean);
  109819. /**
  109820. * Gets Collider object used to compute collisions (not physics)
  109821. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109822. */
  109823. get collider(): Nullable<Collider>;
  109824. /**
  109825. * Move the mesh using collision engine
  109826. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109827. * @param displacement defines the requested displacement vector
  109828. * @returns the current mesh
  109829. */
  109830. moveWithCollisions(displacement: Vector3): AbstractMesh;
  109831. private _onCollisionPositionChange;
  109832. /** @hidden */
  109833. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  109834. /** @hidden */
  109835. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  109836. /** @hidden */
  109837. _checkCollision(collider: Collider): AbstractMesh;
  109838. /** @hidden */
  109839. _generatePointsArray(): boolean;
  109840. /**
  109841. * Checks if the passed Ray intersects with the mesh
  109842. * @param ray defines the ray to use
  109843. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  109844. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109845. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  109846. * @returns the picking info
  109847. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  109848. */
  109849. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  109850. /**
  109851. * Clones the current mesh
  109852. * @param name defines the mesh name
  109853. * @param newParent defines the new mesh parent
  109854. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  109855. * @returns the new mesh
  109856. */
  109857. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  109858. /**
  109859. * Disposes all the submeshes of the current meshnp
  109860. * @returns the current mesh
  109861. */
  109862. releaseSubMeshes(): AbstractMesh;
  109863. /**
  109864. * Releases resources associated with this abstract mesh.
  109865. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109866. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109867. */
  109868. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109869. /**
  109870. * Adds the passed mesh as a child to the current mesh
  109871. * @param mesh defines the child mesh
  109872. * @returns the current mesh
  109873. */
  109874. addChild(mesh: AbstractMesh): AbstractMesh;
  109875. /**
  109876. * Removes the passed mesh from the current mesh children list
  109877. * @param mesh defines the child mesh
  109878. * @returns the current mesh
  109879. */
  109880. removeChild(mesh: AbstractMesh): AbstractMesh;
  109881. /** @hidden */
  109882. private _initFacetData;
  109883. /**
  109884. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  109885. * This method can be called within the render loop.
  109886. * 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
  109887. * @returns the current mesh
  109888. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109889. */
  109890. updateFacetData(): AbstractMesh;
  109891. /**
  109892. * Returns the facetLocalNormals array.
  109893. * The normals are expressed in the mesh local spac
  109894. * @returns an array of Vector3
  109895. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109896. */
  109897. getFacetLocalNormals(): Vector3[];
  109898. /**
  109899. * Returns the facetLocalPositions array.
  109900. * The facet positions are expressed in the mesh local space
  109901. * @returns an array of Vector3
  109902. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109903. */
  109904. getFacetLocalPositions(): Vector3[];
  109905. /**
  109906. * Returns the facetLocalPartioning array
  109907. * @returns an array of array of numbers
  109908. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109909. */
  109910. getFacetLocalPartitioning(): number[][];
  109911. /**
  109912. * Returns the i-th facet position in the world system.
  109913. * This method allocates a new Vector3 per call
  109914. * @param i defines the facet index
  109915. * @returns a new Vector3
  109916. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109917. */
  109918. getFacetPosition(i: number): Vector3;
  109919. /**
  109920. * Sets the reference Vector3 with the i-th facet position in the world system
  109921. * @param i defines the facet index
  109922. * @param ref defines the target vector
  109923. * @returns the current mesh
  109924. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109925. */
  109926. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  109927. /**
  109928. * Returns the i-th facet normal in the world system.
  109929. * This method allocates a new Vector3 per call
  109930. * @param i defines the facet index
  109931. * @returns a new Vector3
  109932. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109933. */
  109934. getFacetNormal(i: number): Vector3;
  109935. /**
  109936. * Sets the reference Vector3 with the i-th facet normal in the world system
  109937. * @param i defines the facet index
  109938. * @param ref defines the target vector
  109939. * @returns the current mesh
  109940. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109941. */
  109942. getFacetNormalToRef(i: number, ref: Vector3): this;
  109943. /**
  109944. * 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)
  109945. * @param x defines x coordinate
  109946. * @param y defines y coordinate
  109947. * @param z defines z coordinate
  109948. * @returns the array of facet indexes
  109949. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109950. */
  109951. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  109952. /**
  109953. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  109954. * @param projected sets as the (x,y,z) world projection on the facet
  109955. * @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
  109956. * @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
  109957. * @param x defines x coordinate
  109958. * @param y defines y coordinate
  109959. * @param z defines z coordinate
  109960. * @returns the face index if found (or null instead)
  109961. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109962. */
  109963. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  109964. /**
  109965. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  109966. * @param projected sets as the (x,y,z) local projection on the facet
  109967. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  109968. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  109969. * @param x defines x coordinate
  109970. * @param y defines y coordinate
  109971. * @param z defines z coordinate
  109972. * @returns the face index if found (or null instead)
  109973. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109974. */
  109975. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  109976. /**
  109977. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  109978. * @returns the parameters
  109979. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109980. */
  109981. getFacetDataParameters(): any;
  109982. /**
  109983. * Disables the feature FacetData and frees the related memory
  109984. * @returns the current mesh
  109985. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109986. */
  109987. disableFacetData(): AbstractMesh;
  109988. /**
  109989. * Updates the AbstractMesh indices array
  109990. * @param indices defines the data source
  109991. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  109992. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  109993. * @returns the current mesh
  109994. */
  109995. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  109996. /**
  109997. * Creates new normals data for the mesh
  109998. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  109999. * @returns the current mesh
  110000. */
  110001. createNormals(updatable: boolean): AbstractMesh;
  110002. /**
  110003. * Align the mesh with a normal
  110004. * @param normal defines the normal to use
  110005. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  110006. * @returns the current mesh
  110007. */
  110008. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  110009. /** @hidden */
  110010. _checkOcclusionQuery(): boolean;
  110011. /**
  110012. * Disables the mesh edge rendering mode
  110013. * @returns the currentAbstractMesh
  110014. */
  110015. disableEdgesRendering(): AbstractMesh;
  110016. /**
  110017. * Enables the edge rendering mode on the mesh.
  110018. * This mode makes the mesh edges visible
  110019. * @param epsilon defines the maximal distance between two angles to detect a face
  110020. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  110021. * @returns the currentAbstractMesh
  110022. * @see https://www.babylonjs-playground.com/#19O9TU#0
  110023. */
  110024. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  110025. /**
  110026. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  110027. * @returns an array of particle systems in the scene that use the mesh as an emitter
  110028. */
  110029. getConnectedParticleSystems(): IParticleSystem[];
  110030. }
  110031. }
  110032. declare module BABYLON {
  110033. /**
  110034. * Interface used to define ActionEvent
  110035. */
  110036. export interface IActionEvent {
  110037. /** The mesh or sprite that triggered the action */
  110038. source: any;
  110039. /** The X mouse cursor position at the time of the event */
  110040. pointerX: number;
  110041. /** The Y mouse cursor position at the time of the event */
  110042. pointerY: number;
  110043. /** The mesh that is currently pointed at (can be null) */
  110044. meshUnderPointer: Nullable<AbstractMesh>;
  110045. /** the original (browser) event that triggered the ActionEvent */
  110046. sourceEvent?: any;
  110047. /** additional data for the event */
  110048. additionalData?: any;
  110049. }
  110050. /**
  110051. * ActionEvent is the event being sent when an action is triggered.
  110052. */
  110053. export class ActionEvent implements IActionEvent {
  110054. /** The mesh or sprite that triggered the action */
  110055. source: any;
  110056. /** The X mouse cursor position at the time of the event */
  110057. pointerX: number;
  110058. /** The Y mouse cursor position at the time of the event */
  110059. pointerY: number;
  110060. /** The mesh that is currently pointed at (can be null) */
  110061. meshUnderPointer: Nullable<AbstractMesh>;
  110062. /** the original (browser) event that triggered the ActionEvent */
  110063. sourceEvent?: any;
  110064. /** additional data for the event */
  110065. additionalData?: any;
  110066. /**
  110067. * Creates a new ActionEvent
  110068. * @param source The mesh or sprite that triggered the action
  110069. * @param pointerX The X mouse cursor position at the time of the event
  110070. * @param pointerY The Y mouse cursor position at the time of the event
  110071. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  110072. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  110073. * @param additionalData additional data for the event
  110074. */
  110075. constructor(
  110076. /** The mesh or sprite that triggered the action */
  110077. source: any,
  110078. /** The X mouse cursor position at the time of the event */
  110079. pointerX: number,
  110080. /** The Y mouse cursor position at the time of the event */
  110081. pointerY: number,
  110082. /** The mesh that is currently pointed at (can be null) */
  110083. meshUnderPointer: Nullable<AbstractMesh>,
  110084. /** the original (browser) event that triggered the ActionEvent */
  110085. sourceEvent?: any,
  110086. /** additional data for the event */
  110087. additionalData?: any);
  110088. /**
  110089. * Helper function to auto-create an ActionEvent from a source mesh.
  110090. * @param source The source mesh that triggered the event
  110091. * @param evt The original (browser) event
  110092. * @param additionalData additional data for the event
  110093. * @returns the new ActionEvent
  110094. */
  110095. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  110096. /**
  110097. * Helper function to auto-create an ActionEvent from a source sprite
  110098. * @param source The source sprite that triggered the event
  110099. * @param scene Scene associated with the sprite
  110100. * @param evt The original (browser) event
  110101. * @param additionalData additional data for the event
  110102. * @returns the new ActionEvent
  110103. */
  110104. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  110105. /**
  110106. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  110107. * @param scene the scene where the event occurred
  110108. * @param evt The original (browser) event
  110109. * @returns the new ActionEvent
  110110. */
  110111. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  110112. /**
  110113. * Helper function to auto-create an ActionEvent from a primitive
  110114. * @param prim defines the target primitive
  110115. * @param pointerPos defines the pointer position
  110116. * @param evt The original (browser) event
  110117. * @param additionalData additional data for the event
  110118. * @returns the new ActionEvent
  110119. */
  110120. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  110121. }
  110122. }
  110123. declare module BABYLON {
  110124. /**
  110125. * Abstract class used to decouple action Manager from scene and meshes.
  110126. * Do not instantiate.
  110127. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  110128. */
  110129. export abstract class AbstractActionManager implements IDisposable {
  110130. /** Gets the list of active triggers */
  110131. static Triggers: {
  110132. [key: string]: number;
  110133. };
  110134. /** Gets the cursor to use when hovering items */
  110135. hoverCursor: string;
  110136. /** Gets the list of actions */
  110137. actions: IAction[];
  110138. /**
  110139. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  110140. */
  110141. isRecursive: boolean;
  110142. /**
  110143. * Releases all associated resources
  110144. */
  110145. abstract dispose(): void;
  110146. /**
  110147. * Does this action manager has pointer triggers
  110148. */
  110149. abstract get hasPointerTriggers(): boolean;
  110150. /**
  110151. * Does this action manager has pick triggers
  110152. */
  110153. abstract get hasPickTriggers(): boolean;
  110154. /**
  110155. * Process a specific trigger
  110156. * @param trigger defines the trigger to process
  110157. * @param evt defines the event details to be processed
  110158. */
  110159. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  110160. /**
  110161. * Does this action manager handles actions of any of the given triggers
  110162. * @param triggers defines the triggers to be tested
  110163. * @return a boolean indicating whether one (or more) of the triggers is handled
  110164. */
  110165. abstract hasSpecificTriggers(triggers: number[]): boolean;
  110166. /**
  110167. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  110168. * speed.
  110169. * @param triggerA defines the trigger to be tested
  110170. * @param triggerB defines the trigger to be tested
  110171. * @return a boolean indicating whether one (or more) of the triggers is handled
  110172. */
  110173. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  110174. /**
  110175. * Does this action manager handles actions of a given trigger
  110176. * @param trigger defines the trigger to be tested
  110177. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  110178. * @return whether the trigger is handled
  110179. */
  110180. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  110181. /**
  110182. * Serialize this manager to a JSON object
  110183. * @param name defines the property name to store this manager
  110184. * @returns a JSON representation of this manager
  110185. */
  110186. abstract serialize(name: string): any;
  110187. /**
  110188. * Registers an action to this action manager
  110189. * @param action defines the action to be registered
  110190. * @return the action amended (prepared) after registration
  110191. */
  110192. abstract registerAction(action: IAction): Nullable<IAction>;
  110193. /**
  110194. * Unregisters an action to this action manager
  110195. * @param action defines the action to be unregistered
  110196. * @return a boolean indicating whether the action has been unregistered
  110197. */
  110198. abstract unregisterAction(action: IAction): Boolean;
  110199. /**
  110200. * Does exist one action manager with at least one trigger
  110201. **/
  110202. static get HasTriggers(): boolean;
  110203. /**
  110204. * Does exist one action manager with at least one pick trigger
  110205. **/
  110206. static get HasPickTriggers(): boolean;
  110207. /**
  110208. * Does exist one action manager that handles actions of a given trigger
  110209. * @param trigger defines the trigger to be tested
  110210. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  110211. **/
  110212. static HasSpecificTrigger(trigger: number): boolean;
  110213. }
  110214. }
  110215. declare module BABYLON {
  110216. /**
  110217. * Defines how a node can be built from a string name.
  110218. */
  110219. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  110220. /**
  110221. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  110222. */
  110223. export class Node implements IBehaviorAware<Node> {
  110224. /** @hidden */
  110225. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  110226. private static _NodeConstructors;
  110227. /**
  110228. * Add a new node constructor
  110229. * @param type defines the type name of the node to construct
  110230. * @param constructorFunc defines the constructor function
  110231. */
  110232. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  110233. /**
  110234. * Returns a node constructor based on type name
  110235. * @param type defines the type name
  110236. * @param name defines the new node name
  110237. * @param scene defines the hosting scene
  110238. * @param options defines optional options to transmit to constructors
  110239. * @returns the new constructor or null
  110240. */
  110241. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  110242. /**
  110243. * Gets or sets the name of the node
  110244. */
  110245. name: string;
  110246. /**
  110247. * Gets or sets the id of the node
  110248. */
  110249. id: string;
  110250. /**
  110251. * Gets or sets the unique id of the node
  110252. */
  110253. uniqueId: number;
  110254. /**
  110255. * Gets or sets a string used to store user defined state for the node
  110256. */
  110257. state: string;
  110258. /**
  110259. * Gets or sets an object used to store user defined information for the node
  110260. */
  110261. metadata: any;
  110262. /**
  110263. * For internal use only. Please do not use.
  110264. */
  110265. reservedDataStore: any;
  110266. /**
  110267. * List of inspectable custom properties (used by the Inspector)
  110268. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  110269. */
  110270. inspectableCustomProperties: IInspectable[];
  110271. private _doNotSerialize;
  110272. /**
  110273. * Gets or sets a boolean used to define if the node must be serialized
  110274. */
  110275. get doNotSerialize(): boolean;
  110276. set doNotSerialize(value: boolean);
  110277. /** @hidden */
  110278. _isDisposed: boolean;
  110279. /**
  110280. * Gets a list of Animations associated with the node
  110281. */
  110282. animations: Animation[];
  110283. protected _ranges: {
  110284. [name: string]: Nullable<AnimationRange>;
  110285. };
  110286. /**
  110287. * Callback raised when the node is ready to be used
  110288. */
  110289. onReady: Nullable<(node: Node) => void>;
  110290. private _isEnabled;
  110291. private _isParentEnabled;
  110292. private _isReady;
  110293. /** @hidden */
  110294. _currentRenderId: number;
  110295. private _parentUpdateId;
  110296. /** @hidden */
  110297. _childUpdateId: number;
  110298. /** @hidden */
  110299. _waitingParentId: Nullable<string>;
  110300. /** @hidden */
  110301. _scene: Scene;
  110302. /** @hidden */
  110303. _cache: any;
  110304. private _parentNode;
  110305. private _children;
  110306. /** @hidden */
  110307. _worldMatrix: Matrix;
  110308. /** @hidden */
  110309. _worldMatrixDeterminant: number;
  110310. /** @hidden */
  110311. _worldMatrixDeterminantIsDirty: boolean;
  110312. /** @hidden */
  110313. private _sceneRootNodesIndex;
  110314. /**
  110315. * Gets a boolean indicating if the node has been disposed
  110316. * @returns true if the node was disposed
  110317. */
  110318. isDisposed(): boolean;
  110319. /**
  110320. * Gets or sets the parent of the node (without keeping the current position in the scene)
  110321. * @see https://doc.babylonjs.com/how_to/parenting
  110322. */
  110323. set parent(parent: Nullable<Node>);
  110324. get parent(): Nullable<Node>;
  110325. /** @hidden */
  110326. _addToSceneRootNodes(): void;
  110327. /** @hidden */
  110328. _removeFromSceneRootNodes(): void;
  110329. private _animationPropertiesOverride;
  110330. /**
  110331. * Gets or sets the animation properties override
  110332. */
  110333. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  110334. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  110335. /**
  110336. * Gets a string idenfifying the name of the class
  110337. * @returns "Node" string
  110338. */
  110339. getClassName(): string;
  110340. /** @hidden */
  110341. readonly _isNode: boolean;
  110342. /**
  110343. * An event triggered when the mesh is disposed
  110344. */
  110345. onDisposeObservable: Observable<Node>;
  110346. private _onDisposeObserver;
  110347. /**
  110348. * Sets a callback that will be raised when the node will be disposed
  110349. */
  110350. set onDispose(callback: () => void);
  110351. /**
  110352. * Creates a new Node
  110353. * @param name the name and id to be given to this node
  110354. * @param scene the scene this node will be added to
  110355. */
  110356. constructor(name: string, scene?: Nullable<Scene>);
  110357. /**
  110358. * Gets the scene of the node
  110359. * @returns a scene
  110360. */
  110361. getScene(): Scene;
  110362. /**
  110363. * Gets the engine of the node
  110364. * @returns a Engine
  110365. */
  110366. getEngine(): Engine;
  110367. private _behaviors;
  110368. /**
  110369. * Attach a behavior to the node
  110370. * @see https://doc.babylonjs.com/features/behaviour
  110371. * @param behavior defines the behavior to attach
  110372. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  110373. * @returns the current Node
  110374. */
  110375. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  110376. /**
  110377. * Remove an attached behavior
  110378. * @see https://doc.babylonjs.com/features/behaviour
  110379. * @param behavior defines the behavior to attach
  110380. * @returns the current Node
  110381. */
  110382. removeBehavior(behavior: Behavior<Node>): Node;
  110383. /**
  110384. * Gets the list of attached behaviors
  110385. * @see https://doc.babylonjs.com/features/behaviour
  110386. */
  110387. get behaviors(): Behavior<Node>[];
  110388. /**
  110389. * Gets an attached behavior by name
  110390. * @param name defines the name of the behavior to look for
  110391. * @see https://doc.babylonjs.com/features/behaviour
  110392. * @returns null if behavior was not found else the requested behavior
  110393. */
  110394. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  110395. /**
  110396. * Returns the latest update of the World matrix
  110397. * @returns a Matrix
  110398. */
  110399. getWorldMatrix(): Matrix;
  110400. /** @hidden */
  110401. _getWorldMatrixDeterminant(): number;
  110402. /**
  110403. * Returns directly the latest state of the mesh World matrix.
  110404. * A Matrix is returned.
  110405. */
  110406. get worldMatrixFromCache(): Matrix;
  110407. /** @hidden */
  110408. _initCache(): void;
  110409. /** @hidden */
  110410. updateCache(force?: boolean): void;
  110411. /** @hidden */
  110412. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  110413. /** @hidden */
  110414. _updateCache(ignoreParentClass?: boolean): void;
  110415. /** @hidden */
  110416. _isSynchronized(): boolean;
  110417. /** @hidden */
  110418. _markSyncedWithParent(): void;
  110419. /** @hidden */
  110420. isSynchronizedWithParent(): boolean;
  110421. /** @hidden */
  110422. isSynchronized(): boolean;
  110423. /**
  110424. * Is this node ready to be used/rendered
  110425. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  110426. * @return true if the node is ready
  110427. */
  110428. isReady(completeCheck?: boolean): boolean;
  110429. /**
  110430. * Is this node enabled?
  110431. * 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
  110432. * @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
  110433. * @return whether this node (and its parent) is enabled
  110434. */
  110435. isEnabled(checkAncestors?: boolean): boolean;
  110436. /** @hidden */
  110437. protected _syncParentEnabledState(): void;
  110438. /**
  110439. * Set the enabled state of this node
  110440. * @param value defines the new enabled state
  110441. */
  110442. setEnabled(value: boolean): void;
  110443. /**
  110444. * Is this node a descendant of the given node?
  110445. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  110446. * @param ancestor defines the parent node to inspect
  110447. * @returns a boolean indicating if this node is a descendant of the given node
  110448. */
  110449. isDescendantOf(ancestor: Node): boolean;
  110450. /** @hidden */
  110451. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  110452. /**
  110453. * Will return all nodes that have this node as ascendant
  110454. * @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
  110455. * @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
  110456. * @return all children nodes of all types
  110457. */
  110458. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  110459. /**
  110460. * Get all child-meshes of this node
  110461. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  110462. * @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
  110463. * @returns an array of AbstractMesh
  110464. */
  110465. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  110466. /**
  110467. * Get all direct children of this node
  110468. * @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
  110469. * @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)
  110470. * @returns an array of Node
  110471. */
  110472. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  110473. /** @hidden */
  110474. _setReady(state: boolean): void;
  110475. /**
  110476. * Get an animation by name
  110477. * @param name defines the name of the animation to look for
  110478. * @returns null if not found else the requested animation
  110479. */
  110480. getAnimationByName(name: string): Nullable<Animation>;
  110481. /**
  110482. * Creates an animation range for this node
  110483. * @param name defines the name of the range
  110484. * @param from defines the starting key
  110485. * @param to defines the end key
  110486. */
  110487. createAnimationRange(name: string, from: number, to: number): void;
  110488. /**
  110489. * Delete a specific animation range
  110490. * @param name defines the name of the range to delete
  110491. * @param deleteFrames defines if animation frames from the range must be deleted as well
  110492. */
  110493. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  110494. /**
  110495. * Get an animation range by name
  110496. * @param name defines the name of the animation range to look for
  110497. * @returns null if not found else the requested animation range
  110498. */
  110499. getAnimationRange(name: string): Nullable<AnimationRange>;
  110500. /**
  110501. * Gets the list of all animation ranges defined on this node
  110502. * @returns an array
  110503. */
  110504. getAnimationRanges(): Nullable<AnimationRange>[];
  110505. /**
  110506. * Will start the animation sequence
  110507. * @param name defines the range frames for animation sequence
  110508. * @param loop defines if the animation should loop (false by default)
  110509. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  110510. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  110511. * @returns the object created for this animation. If range does not exist, it will return null
  110512. */
  110513. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  110514. /**
  110515. * Serialize animation ranges into a JSON compatible object
  110516. * @returns serialization object
  110517. */
  110518. serializeAnimationRanges(): any;
  110519. /**
  110520. * Computes the world matrix of the node
  110521. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  110522. * @returns the world matrix
  110523. */
  110524. computeWorldMatrix(force?: boolean): Matrix;
  110525. /**
  110526. * Releases resources associated with this node.
  110527. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110528. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110529. */
  110530. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110531. /**
  110532. * Parse animation range data from a serialization object and store them into a given node
  110533. * @param node defines where to store the animation ranges
  110534. * @param parsedNode defines the serialization object to read data from
  110535. * @param scene defines the hosting scene
  110536. */
  110537. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  110538. /**
  110539. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  110540. * @param includeDescendants Include bounding info from descendants as well (true by default)
  110541. * @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
  110542. * @returns the new bounding vectors
  110543. */
  110544. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  110545. min: Vector3;
  110546. max: Vector3;
  110547. };
  110548. }
  110549. }
  110550. declare module BABYLON {
  110551. /**
  110552. * @hidden
  110553. */
  110554. export class _IAnimationState {
  110555. key: number;
  110556. repeatCount: number;
  110557. workValue?: any;
  110558. loopMode?: number;
  110559. offsetValue?: any;
  110560. highLimitValue?: any;
  110561. }
  110562. /**
  110563. * Class used to store any kind of animation
  110564. */
  110565. export class Animation {
  110566. /**Name of the animation */
  110567. name: string;
  110568. /**Property to animate */
  110569. targetProperty: string;
  110570. /**The frames per second of the animation */
  110571. framePerSecond: number;
  110572. /**The data type of the animation */
  110573. dataType: number;
  110574. /**The loop mode of the animation */
  110575. loopMode?: number | undefined;
  110576. /**Specifies if blending should be enabled */
  110577. enableBlending?: boolean | undefined;
  110578. /**
  110579. * Use matrix interpolation instead of using direct key value when animating matrices
  110580. */
  110581. static AllowMatricesInterpolation: boolean;
  110582. /**
  110583. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  110584. */
  110585. static AllowMatrixDecomposeForInterpolation: boolean;
  110586. /** Define the Url to load snippets */
  110587. static SnippetUrl: string;
  110588. /** Snippet ID if the animation was created from the snippet server */
  110589. snippetId: string;
  110590. /**
  110591. * Stores the key frames of the animation
  110592. */
  110593. private _keys;
  110594. /**
  110595. * Stores the easing function of the animation
  110596. */
  110597. private _easingFunction;
  110598. /**
  110599. * @hidden Internal use only
  110600. */
  110601. _runtimeAnimations: RuntimeAnimation[];
  110602. /**
  110603. * The set of event that will be linked to this animation
  110604. */
  110605. private _events;
  110606. /**
  110607. * Stores an array of target property paths
  110608. */
  110609. targetPropertyPath: string[];
  110610. /**
  110611. * Stores the blending speed of the animation
  110612. */
  110613. blendingSpeed: number;
  110614. /**
  110615. * Stores the animation ranges for the animation
  110616. */
  110617. private _ranges;
  110618. /**
  110619. * @hidden Internal use
  110620. */
  110621. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  110622. /**
  110623. * Sets up an animation
  110624. * @param property The property to animate
  110625. * @param animationType The animation type to apply
  110626. * @param framePerSecond The frames per second of the animation
  110627. * @param easingFunction The easing function used in the animation
  110628. * @returns The created animation
  110629. */
  110630. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  110631. /**
  110632. * Create and start an animation on a node
  110633. * @param name defines the name of the global animation that will be run on all nodes
  110634. * @param node defines the root node where the animation will take place
  110635. * @param targetProperty defines property to animate
  110636. * @param framePerSecond defines the number of frame per second yo use
  110637. * @param totalFrame defines the number of frames in total
  110638. * @param from defines the initial value
  110639. * @param to defines the final value
  110640. * @param loopMode defines which loop mode you want to use (off by default)
  110641. * @param easingFunction defines the easing function to use (linear by default)
  110642. * @param onAnimationEnd defines the callback to call when animation end
  110643. * @returns the animatable created for this animation
  110644. */
  110645. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  110646. /**
  110647. * Create and start an animation on a node and its descendants
  110648. * @param name defines the name of the global animation that will be run on all nodes
  110649. * @param node defines the root node where the animation will take place
  110650. * @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
  110651. * @param targetProperty defines property to animate
  110652. * @param framePerSecond defines the number of frame per second to use
  110653. * @param totalFrame defines the number of frames in total
  110654. * @param from defines the initial value
  110655. * @param to defines the final value
  110656. * @param loopMode defines which loop mode you want to use (off by default)
  110657. * @param easingFunction defines the easing function to use (linear by default)
  110658. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  110659. * @returns the list of animatables created for all nodes
  110660. * @example https://www.babylonjs-playground.com/#MH0VLI
  110661. */
  110662. 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[]>;
  110663. /**
  110664. * Creates a new animation, merges it with the existing animations and starts it
  110665. * @param name Name of the animation
  110666. * @param node Node which contains the scene that begins the animations
  110667. * @param targetProperty Specifies which property to animate
  110668. * @param framePerSecond The frames per second of the animation
  110669. * @param totalFrame The total number of frames
  110670. * @param from The frame at the beginning of the animation
  110671. * @param to The frame at the end of the animation
  110672. * @param loopMode Specifies the loop mode of the animation
  110673. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  110674. * @param onAnimationEnd Callback to run once the animation is complete
  110675. * @returns Nullable animation
  110676. */
  110677. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  110678. /**
  110679. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  110680. * @param sourceAnimation defines the Animation containing keyframes to convert
  110681. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  110682. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  110683. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  110684. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  110685. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  110686. */
  110687. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  110688. /**
  110689. * Transition property of an host to the target Value
  110690. * @param property The property to transition
  110691. * @param targetValue The target Value of the property
  110692. * @param host The object where the property to animate belongs
  110693. * @param scene Scene used to run the animation
  110694. * @param frameRate Framerate (in frame/s) to use
  110695. * @param transition The transition type we want to use
  110696. * @param duration The duration of the animation, in milliseconds
  110697. * @param onAnimationEnd Callback trigger at the end of the animation
  110698. * @returns Nullable animation
  110699. */
  110700. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  110701. /**
  110702. * Return the array of runtime animations currently using this animation
  110703. */
  110704. get runtimeAnimations(): RuntimeAnimation[];
  110705. /**
  110706. * Specifies if any of the runtime animations are currently running
  110707. */
  110708. get hasRunningRuntimeAnimations(): boolean;
  110709. /**
  110710. * Initializes the animation
  110711. * @param name Name of the animation
  110712. * @param targetProperty Property to animate
  110713. * @param framePerSecond The frames per second of the animation
  110714. * @param dataType The data type of the animation
  110715. * @param loopMode The loop mode of the animation
  110716. * @param enableBlending Specifies if blending should be enabled
  110717. */
  110718. constructor(
  110719. /**Name of the animation */
  110720. name: string,
  110721. /**Property to animate */
  110722. targetProperty: string,
  110723. /**The frames per second of the animation */
  110724. framePerSecond: number,
  110725. /**The data type of the animation */
  110726. dataType: number,
  110727. /**The loop mode of the animation */
  110728. loopMode?: number | undefined,
  110729. /**Specifies if blending should be enabled */
  110730. enableBlending?: boolean | undefined);
  110731. /**
  110732. * Converts the animation to a string
  110733. * @param fullDetails support for multiple levels of logging within scene loading
  110734. * @returns String form of the animation
  110735. */
  110736. toString(fullDetails?: boolean): string;
  110737. /**
  110738. * Add an event to this animation
  110739. * @param event Event to add
  110740. */
  110741. addEvent(event: AnimationEvent): void;
  110742. /**
  110743. * Remove all events found at the given frame
  110744. * @param frame The frame to remove events from
  110745. */
  110746. removeEvents(frame: number): void;
  110747. /**
  110748. * Retrieves all the events from the animation
  110749. * @returns Events from the animation
  110750. */
  110751. getEvents(): AnimationEvent[];
  110752. /**
  110753. * Creates an animation range
  110754. * @param name Name of the animation range
  110755. * @param from Starting frame of the animation range
  110756. * @param to Ending frame of the animation
  110757. */
  110758. createRange(name: string, from: number, to: number): void;
  110759. /**
  110760. * Deletes an animation range by name
  110761. * @param name Name of the animation range to delete
  110762. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  110763. */
  110764. deleteRange(name: string, deleteFrames?: boolean): void;
  110765. /**
  110766. * Gets the animation range by name, or null if not defined
  110767. * @param name Name of the animation range
  110768. * @returns Nullable animation range
  110769. */
  110770. getRange(name: string): Nullable<AnimationRange>;
  110771. /**
  110772. * Gets the key frames from the animation
  110773. * @returns The key frames of the animation
  110774. */
  110775. getKeys(): Array<IAnimationKey>;
  110776. /**
  110777. * Gets the highest frame rate of the animation
  110778. * @returns Highest frame rate of the animation
  110779. */
  110780. getHighestFrame(): number;
  110781. /**
  110782. * Gets the easing function of the animation
  110783. * @returns Easing function of the animation
  110784. */
  110785. getEasingFunction(): IEasingFunction;
  110786. /**
  110787. * Sets the easing function of the animation
  110788. * @param easingFunction A custom mathematical formula for animation
  110789. */
  110790. setEasingFunction(easingFunction: EasingFunction): void;
  110791. /**
  110792. * Interpolates a scalar linearly
  110793. * @param startValue Start value of the animation curve
  110794. * @param endValue End value of the animation curve
  110795. * @param gradient Scalar amount to interpolate
  110796. * @returns Interpolated scalar value
  110797. */
  110798. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  110799. /**
  110800. * Interpolates a scalar cubically
  110801. * @param startValue Start value of the animation curve
  110802. * @param outTangent End tangent of the animation
  110803. * @param endValue End value of the animation curve
  110804. * @param inTangent Start tangent of the animation curve
  110805. * @param gradient Scalar amount to interpolate
  110806. * @returns Interpolated scalar value
  110807. */
  110808. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  110809. /**
  110810. * Interpolates a quaternion using a spherical linear interpolation
  110811. * @param startValue Start value of the animation curve
  110812. * @param endValue End value of the animation curve
  110813. * @param gradient Scalar amount to interpolate
  110814. * @returns Interpolated quaternion value
  110815. */
  110816. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  110817. /**
  110818. * Interpolates a quaternion cubically
  110819. * @param startValue Start value of the animation curve
  110820. * @param outTangent End tangent of the animation curve
  110821. * @param endValue End value of the animation curve
  110822. * @param inTangent Start tangent of the animation curve
  110823. * @param gradient Scalar amount to interpolate
  110824. * @returns Interpolated quaternion value
  110825. */
  110826. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  110827. /**
  110828. * Interpolates a Vector3 linearl
  110829. * @param startValue Start value of the animation curve
  110830. * @param endValue End value of the animation curve
  110831. * @param gradient Scalar amount to interpolate
  110832. * @returns Interpolated scalar value
  110833. */
  110834. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  110835. /**
  110836. * Interpolates a Vector3 cubically
  110837. * @param startValue Start value of the animation curve
  110838. * @param outTangent End tangent of the animation
  110839. * @param endValue End value of the animation curve
  110840. * @param inTangent Start tangent of the animation curve
  110841. * @param gradient Scalar amount to interpolate
  110842. * @returns InterpolatedVector3 value
  110843. */
  110844. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  110845. /**
  110846. * Interpolates a Vector2 linearly
  110847. * @param startValue Start value of the animation curve
  110848. * @param endValue End value of the animation curve
  110849. * @param gradient Scalar amount to interpolate
  110850. * @returns Interpolated Vector2 value
  110851. */
  110852. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  110853. /**
  110854. * Interpolates a Vector2 cubically
  110855. * @param startValue Start value of the animation curve
  110856. * @param outTangent End tangent of the animation
  110857. * @param endValue End value of the animation curve
  110858. * @param inTangent Start tangent of the animation curve
  110859. * @param gradient Scalar amount to interpolate
  110860. * @returns Interpolated Vector2 value
  110861. */
  110862. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  110863. /**
  110864. * Interpolates a size linearly
  110865. * @param startValue Start value of the animation curve
  110866. * @param endValue End value of the animation curve
  110867. * @param gradient Scalar amount to interpolate
  110868. * @returns Interpolated Size value
  110869. */
  110870. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  110871. /**
  110872. * Interpolates a Color3 linearly
  110873. * @param startValue Start value of the animation curve
  110874. * @param endValue End value of the animation curve
  110875. * @param gradient Scalar amount to interpolate
  110876. * @returns Interpolated Color3 value
  110877. */
  110878. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  110879. /**
  110880. * Interpolates a Color4 linearly
  110881. * @param startValue Start value of the animation curve
  110882. * @param endValue End value of the animation curve
  110883. * @param gradient Scalar amount to interpolate
  110884. * @returns Interpolated Color3 value
  110885. */
  110886. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  110887. /**
  110888. * @hidden Internal use only
  110889. */
  110890. _getKeyValue(value: any): any;
  110891. /**
  110892. * @hidden Internal use only
  110893. */
  110894. _interpolate(currentFrame: number, state: _IAnimationState): any;
  110895. /**
  110896. * Defines the function to use to interpolate matrices
  110897. * @param startValue defines the start matrix
  110898. * @param endValue defines the end matrix
  110899. * @param gradient defines the gradient between both matrices
  110900. * @param result defines an optional target matrix where to store the interpolation
  110901. * @returns the interpolated matrix
  110902. */
  110903. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  110904. /**
  110905. * Makes a copy of the animation
  110906. * @returns Cloned animation
  110907. */
  110908. clone(): Animation;
  110909. /**
  110910. * Sets the key frames of the animation
  110911. * @param values The animation key frames to set
  110912. */
  110913. setKeys(values: Array<IAnimationKey>): void;
  110914. /**
  110915. * Serializes the animation to an object
  110916. * @returns Serialized object
  110917. */
  110918. serialize(): any;
  110919. /**
  110920. * Float animation type
  110921. */
  110922. static readonly ANIMATIONTYPE_FLOAT: number;
  110923. /**
  110924. * Vector3 animation type
  110925. */
  110926. static readonly ANIMATIONTYPE_VECTOR3: number;
  110927. /**
  110928. * Quaternion animation type
  110929. */
  110930. static readonly ANIMATIONTYPE_QUATERNION: number;
  110931. /**
  110932. * Matrix animation type
  110933. */
  110934. static readonly ANIMATIONTYPE_MATRIX: number;
  110935. /**
  110936. * Color3 animation type
  110937. */
  110938. static readonly ANIMATIONTYPE_COLOR3: number;
  110939. /**
  110940. * Color3 animation type
  110941. */
  110942. static readonly ANIMATIONTYPE_COLOR4: number;
  110943. /**
  110944. * Vector2 animation type
  110945. */
  110946. static readonly ANIMATIONTYPE_VECTOR2: number;
  110947. /**
  110948. * Size animation type
  110949. */
  110950. static readonly ANIMATIONTYPE_SIZE: number;
  110951. /**
  110952. * Relative Loop Mode
  110953. */
  110954. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  110955. /**
  110956. * Cycle Loop Mode
  110957. */
  110958. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  110959. /**
  110960. * Constant Loop Mode
  110961. */
  110962. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  110963. /** @hidden */
  110964. static _UniversalLerp(left: any, right: any, amount: number): any;
  110965. /**
  110966. * Parses an animation object and creates an animation
  110967. * @param parsedAnimation Parsed animation object
  110968. * @returns Animation object
  110969. */
  110970. static Parse(parsedAnimation: any): Animation;
  110971. /**
  110972. * Appends the serialized animations from the source animations
  110973. * @param source Source containing the animations
  110974. * @param destination Target to store the animations
  110975. */
  110976. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  110977. /**
  110978. * Creates a new animation or an array of animations from a snippet saved in a remote file
  110979. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  110980. * @param url defines the url to load from
  110981. * @returns a promise that will resolve to the new animation or an array of animations
  110982. */
  110983. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  110984. /**
  110985. * Creates an animation or an array of animations from a snippet saved by the Inspector
  110986. * @param snippetId defines the snippet to load
  110987. * @returns a promise that will resolve to the new animation or a new array of animations
  110988. */
  110989. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  110990. }
  110991. }
  110992. declare module BABYLON {
  110993. /**
  110994. * Interface containing an array of animations
  110995. */
  110996. export interface IAnimatable {
  110997. /**
  110998. * Array of animations
  110999. */
  111000. animations: Nullable<Array<Animation>>;
  111001. }
  111002. }
  111003. declare module BABYLON {
  111004. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  111005. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111006. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111007. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111008. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111009. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111010. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111011. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111012. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111013. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111014. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111015. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111016. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111017. /**
  111018. * Decorator used to define property that can be serialized as reference to a camera
  111019. * @param sourceName defines the name of the property to decorate
  111020. */
  111021. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111022. /**
  111023. * Class used to help serialization objects
  111024. */
  111025. export class SerializationHelper {
  111026. /** @hidden */
  111027. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  111028. /** @hidden */
  111029. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  111030. /** @hidden */
  111031. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  111032. /** @hidden */
  111033. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  111034. /**
  111035. * Appends the serialized animations from the source animations
  111036. * @param source Source containing the animations
  111037. * @param destination Target to store the animations
  111038. */
  111039. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  111040. /**
  111041. * Static function used to serialized a specific entity
  111042. * @param entity defines the entity to serialize
  111043. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  111044. * @returns a JSON compatible object representing the serialization of the entity
  111045. */
  111046. static Serialize<T>(entity: T, serializationObject?: any): any;
  111047. /**
  111048. * Creates a new entity from a serialization data object
  111049. * @param creationFunction defines a function used to instanciated the new entity
  111050. * @param source defines the source serialization data
  111051. * @param scene defines the hosting scene
  111052. * @param rootUrl defines the root url for resources
  111053. * @returns a new entity
  111054. */
  111055. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  111056. /**
  111057. * Clones an object
  111058. * @param creationFunction defines the function used to instanciate the new object
  111059. * @param source defines the source object
  111060. * @returns the cloned object
  111061. */
  111062. static Clone<T>(creationFunction: () => T, source: T): T;
  111063. /**
  111064. * Instanciates a new object based on a source one (some data will be shared between both object)
  111065. * @param creationFunction defines the function used to instanciate the new object
  111066. * @param source defines the source object
  111067. * @returns the new object
  111068. */
  111069. static Instanciate<T>(creationFunction: () => T, source: T): T;
  111070. }
  111071. }
  111072. declare module BABYLON {
  111073. /**
  111074. * Base class of all the textures in babylon.
  111075. * It groups all the common properties the materials, post process, lights... might need
  111076. * in order to make a correct use of the texture.
  111077. */
  111078. export class BaseTexture implements IAnimatable {
  111079. /**
  111080. * Default anisotropic filtering level for the application.
  111081. * It is set to 4 as a good tradeoff between perf and quality.
  111082. */
  111083. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  111084. /**
  111085. * Gets or sets the unique id of the texture
  111086. */
  111087. uniqueId: number;
  111088. /**
  111089. * Define the name of the texture.
  111090. */
  111091. name: string;
  111092. /**
  111093. * Gets or sets an object used to store user defined information.
  111094. */
  111095. metadata: any;
  111096. /**
  111097. * For internal use only. Please do not use.
  111098. */
  111099. reservedDataStore: any;
  111100. private _hasAlpha;
  111101. /**
  111102. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  111103. */
  111104. set hasAlpha(value: boolean);
  111105. get hasAlpha(): boolean;
  111106. /**
  111107. * Defines if the alpha value should be determined via the rgb values.
  111108. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  111109. */
  111110. getAlphaFromRGB: boolean;
  111111. /**
  111112. * Intensity or strength of the texture.
  111113. * It is commonly used by materials to fine tune the intensity of the texture
  111114. */
  111115. level: number;
  111116. /**
  111117. * Define the UV chanel to use starting from 0 and defaulting to 0.
  111118. * This is part of the texture as textures usually maps to one uv set.
  111119. */
  111120. coordinatesIndex: number;
  111121. private _coordinatesMode;
  111122. /**
  111123. * How a texture is mapped.
  111124. *
  111125. * | Value | Type | Description |
  111126. * | ----- | ----------------------------------- | ----------- |
  111127. * | 0 | EXPLICIT_MODE | |
  111128. * | 1 | SPHERICAL_MODE | |
  111129. * | 2 | PLANAR_MODE | |
  111130. * | 3 | CUBIC_MODE | |
  111131. * | 4 | PROJECTION_MODE | |
  111132. * | 5 | SKYBOX_MODE | |
  111133. * | 6 | INVCUBIC_MODE | |
  111134. * | 7 | EQUIRECTANGULAR_MODE | |
  111135. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  111136. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  111137. */
  111138. set coordinatesMode(value: number);
  111139. get coordinatesMode(): number;
  111140. /**
  111141. * | Value | Type | Description |
  111142. * | ----- | ------------------ | ----------- |
  111143. * | 0 | CLAMP_ADDRESSMODE | |
  111144. * | 1 | WRAP_ADDRESSMODE | |
  111145. * | 2 | MIRROR_ADDRESSMODE | |
  111146. */
  111147. wrapU: number;
  111148. /**
  111149. * | Value | Type | Description |
  111150. * | ----- | ------------------ | ----------- |
  111151. * | 0 | CLAMP_ADDRESSMODE | |
  111152. * | 1 | WRAP_ADDRESSMODE | |
  111153. * | 2 | MIRROR_ADDRESSMODE | |
  111154. */
  111155. wrapV: number;
  111156. /**
  111157. * | Value | Type | Description |
  111158. * | ----- | ------------------ | ----------- |
  111159. * | 0 | CLAMP_ADDRESSMODE | |
  111160. * | 1 | WRAP_ADDRESSMODE | |
  111161. * | 2 | MIRROR_ADDRESSMODE | |
  111162. */
  111163. wrapR: number;
  111164. /**
  111165. * With compliant hardware and browser (supporting anisotropic filtering)
  111166. * this defines the level of anisotropic filtering in the texture.
  111167. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  111168. */
  111169. anisotropicFilteringLevel: number;
  111170. /**
  111171. * Define if the texture is a cube texture or if false a 2d texture.
  111172. */
  111173. get isCube(): boolean;
  111174. set isCube(value: boolean);
  111175. /**
  111176. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  111177. */
  111178. get is3D(): boolean;
  111179. set is3D(value: boolean);
  111180. /**
  111181. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  111182. */
  111183. get is2DArray(): boolean;
  111184. set is2DArray(value: boolean);
  111185. /**
  111186. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  111187. * HDR texture are usually stored in linear space.
  111188. * This only impacts the PBR and Background materials
  111189. */
  111190. gammaSpace: boolean;
  111191. /**
  111192. * Gets or sets whether or not the texture contains RGBD data.
  111193. */
  111194. get isRGBD(): boolean;
  111195. set isRGBD(value: boolean);
  111196. /**
  111197. * Is Z inverted in the texture (useful in a cube texture).
  111198. */
  111199. invertZ: boolean;
  111200. /**
  111201. * Are mip maps generated for this texture or not.
  111202. */
  111203. get noMipmap(): boolean;
  111204. /**
  111205. * @hidden
  111206. */
  111207. lodLevelInAlpha: boolean;
  111208. /**
  111209. * With prefiltered texture, defined the offset used during the prefiltering steps.
  111210. */
  111211. get lodGenerationOffset(): number;
  111212. set lodGenerationOffset(value: number);
  111213. /**
  111214. * With prefiltered texture, defined the scale used during the prefiltering steps.
  111215. */
  111216. get lodGenerationScale(): number;
  111217. set lodGenerationScale(value: number);
  111218. /**
  111219. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  111220. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  111221. * average roughness values.
  111222. */
  111223. get linearSpecularLOD(): boolean;
  111224. set linearSpecularLOD(value: boolean);
  111225. /**
  111226. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  111227. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  111228. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  111229. */
  111230. get irradianceTexture(): Nullable<BaseTexture>;
  111231. set irradianceTexture(value: Nullable<BaseTexture>);
  111232. /**
  111233. * Define if the texture is a render target.
  111234. */
  111235. isRenderTarget: boolean;
  111236. /**
  111237. * Define the unique id of the texture in the scene.
  111238. */
  111239. get uid(): string;
  111240. /** @hidden */
  111241. _prefiltered: boolean;
  111242. /**
  111243. * Return a string representation of the texture.
  111244. * @returns the texture as a string
  111245. */
  111246. toString(): string;
  111247. /**
  111248. * Get the class name of the texture.
  111249. * @returns "BaseTexture"
  111250. */
  111251. getClassName(): string;
  111252. /**
  111253. * Define the list of animation attached to the texture.
  111254. */
  111255. animations: Animation[];
  111256. /**
  111257. * An event triggered when the texture is disposed.
  111258. */
  111259. onDisposeObservable: Observable<BaseTexture>;
  111260. private _onDisposeObserver;
  111261. /**
  111262. * Callback triggered when the texture has been disposed.
  111263. * Kept for back compatibility, you can use the onDisposeObservable instead.
  111264. */
  111265. set onDispose(callback: () => void);
  111266. /**
  111267. * Define the current state of the loading sequence when in delayed load mode.
  111268. */
  111269. delayLoadState: number;
  111270. private _scene;
  111271. private _engine;
  111272. /** @hidden */
  111273. _texture: Nullable<InternalTexture>;
  111274. private _uid;
  111275. /**
  111276. * Define if the texture is preventinga material to render or not.
  111277. * If not and the texture is not ready, the engine will use a default black texture instead.
  111278. */
  111279. get isBlocking(): boolean;
  111280. /**
  111281. * Instantiates a new BaseTexture.
  111282. * Base class of all the textures in babylon.
  111283. * It groups all the common properties the materials, post process, lights... might need
  111284. * in order to make a correct use of the texture.
  111285. * @param sceneOrEngine Define the scene or engine the texture blongs to
  111286. */
  111287. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  111288. /**
  111289. * Get the scene the texture belongs to.
  111290. * @returns the scene or null if undefined
  111291. */
  111292. getScene(): Nullable<Scene>;
  111293. /** @hidden */
  111294. protected _getEngine(): Nullable<ThinEngine>;
  111295. /**
  111296. * Get the texture transform matrix used to offset tile the texture for istance.
  111297. * @returns the transformation matrix
  111298. */
  111299. getTextureMatrix(): Matrix;
  111300. /**
  111301. * Get the texture reflection matrix used to rotate/transform the reflection.
  111302. * @returns the reflection matrix
  111303. */
  111304. getReflectionTextureMatrix(): Matrix;
  111305. /**
  111306. * Get the underlying lower level texture from Babylon.
  111307. * @returns the insternal texture
  111308. */
  111309. getInternalTexture(): Nullable<InternalTexture>;
  111310. /**
  111311. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  111312. * @returns true if ready or not blocking
  111313. */
  111314. isReadyOrNotBlocking(): boolean;
  111315. /**
  111316. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  111317. * @returns true if fully ready
  111318. */
  111319. isReady(): boolean;
  111320. private _cachedSize;
  111321. /**
  111322. * Get the size of the texture.
  111323. * @returns the texture size.
  111324. */
  111325. getSize(): ISize;
  111326. /**
  111327. * Get the base size of the texture.
  111328. * It can be different from the size if the texture has been resized for POT for instance
  111329. * @returns the base size
  111330. */
  111331. getBaseSize(): ISize;
  111332. /**
  111333. * Update the sampling mode of the texture.
  111334. * Default is Trilinear mode.
  111335. *
  111336. * | Value | Type | Description |
  111337. * | ----- | ------------------ | ----------- |
  111338. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  111339. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  111340. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  111341. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  111342. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  111343. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  111344. * | 7 | NEAREST_LINEAR | |
  111345. * | 8 | NEAREST_NEAREST | |
  111346. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  111347. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  111348. * | 11 | LINEAR_LINEAR | |
  111349. * | 12 | LINEAR_NEAREST | |
  111350. *
  111351. * > _mag_: magnification filter (close to the viewer)
  111352. * > _min_: minification filter (far from the viewer)
  111353. * > _mip_: filter used between mip map levels
  111354. *@param samplingMode Define the new sampling mode of the texture
  111355. */
  111356. updateSamplingMode(samplingMode: number): void;
  111357. /**
  111358. * Scales the texture if is `canRescale()`
  111359. * @param ratio the resize factor we want to use to rescale
  111360. */
  111361. scale(ratio: number): void;
  111362. /**
  111363. * Get if the texture can rescale.
  111364. */
  111365. get canRescale(): boolean;
  111366. /** @hidden */
  111367. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  111368. /** @hidden */
  111369. _rebuild(): void;
  111370. /**
  111371. * Triggers the load sequence in delayed load mode.
  111372. */
  111373. delayLoad(): void;
  111374. /**
  111375. * Clones the texture.
  111376. * @returns the cloned texture
  111377. */
  111378. clone(): Nullable<BaseTexture>;
  111379. /**
  111380. * Get the texture underlying type (INT, FLOAT...)
  111381. */
  111382. get textureType(): number;
  111383. /**
  111384. * Get the texture underlying format (RGB, RGBA...)
  111385. */
  111386. get textureFormat(): number;
  111387. /**
  111388. * Indicates that textures need to be re-calculated for all materials
  111389. */
  111390. protected _markAllSubMeshesAsTexturesDirty(): void;
  111391. /**
  111392. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  111393. * This will returns an RGBA array buffer containing either in values (0-255) or
  111394. * float values (0-1) depending of the underlying buffer type.
  111395. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  111396. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  111397. * @param buffer defines a user defined buffer to fill with data (can be null)
  111398. * @returns The Array buffer containing the pixels data.
  111399. */
  111400. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  111401. /**
  111402. * Release and destroy the underlying lower level texture aka internalTexture.
  111403. */
  111404. releaseInternalTexture(): void;
  111405. /** @hidden */
  111406. get _lodTextureHigh(): Nullable<BaseTexture>;
  111407. /** @hidden */
  111408. get _lodTextureMid(): Nullable<BaseTexture>;
  111409. /** @hidden */
  111410. get _lodTextureLow(): Nullable<BaseTexture>;
  111411. /**
  111412. * Dispose the texture and release its associated resources.
  111413. */
  111414. dispose(): void;
  111415. /**
  111416. * Serialize the texture into a JSON representation that can be parsed later on.
  111417. * @returns the JSON representation of the texture
  111418. */
  111419. serialize(): any;
  111420. /**
  111421. * Helper function to be called back once a list of texture contains only ready textures.
  111422. * @param textures Define the list of textures to wait for
  111423. * @param callback Define the callback triggered once the entire list will be ready
  111424. */
  111425. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  111426. private static _isScene;
  111427. }
  111428. }
  111429. declare module BABYLON {
  111430. /**
  111431. * Options to be used when creating an effect.
  111432. */
  111433. export interface IEffectCreationOptions {
  111434. /**
  111435. * Atrributes that will be used in the shader.
  111436. */
  111437. attributes: string[];
  111438. /**
  111439. * Uniform varible names that will be set in the shader.
  111440. */
  111441. uniformsNames: string[];
  111442. /**
  111443. * Uniform buffer variable names that will be set in the shader.
  111444. */
  111445. uniformBuffersNames: string[];
  111446. /**
  111447. * Sampler texture variable names that will be set in the shader.
  111448. */
  111449. samplers: string[];
  111450. /**
  111451. * Define statements that will be set in the shader.
  111452. */
  111453. defines: any;
  111454. /**
  111455. * Possible fallbacks for this effect to improve performance when needed.
  111456. */
  111457. fallbacks: Nullable<IEffectFallbacks>;
  111458. /**
  111459. * Callback that will be called when the shader is compiled.
  111460. */
  111461. onCompiled: Nullable<(effect: Effect) => void>;
  111462. /**
  111463. * Callback that will be called if an error occurs during shader compilation.
  111464. */
  111465. onError: Nullable<(effect: Effect, errors: string) => void>;
  111466. /**
  111467. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  111468. */
  111469. indexParameters?: any;
  111470. /**
  111471. * Max number of lights that can be used in the shader.
  111472. */
  111473. maxSimultaneousLights?: number;
  111474. /**
  111475. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  111476. */
  111477. transformFeedbackVaryings?: Nullable<string[]>;
  111478. /**
  111479. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  111480. */
  111481. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  111482. /**
  111483. * Is this effect rendering to several color attachments ?
  111484. */
  111485. multiTarget?: boolean;
  111486. }
  111487. /**
  111488. * Effect containing vertex and fragment shader that can be executed on an object.
  111489. */
  111490. export class Effect implements IDisposable {
  111491. /**
  111492. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  111493. */
  111494. static ShadersRepository: string;
  111495. /**
  111496. * Enable logging of the shader code when a compilation error occurs
  111497. */
  111498. static LogShaderCodeOnCompilationError: boolean;
  111499. /**
  111500. * Name of the effect.
  111501. */
  111502. name: any;
  111503. /**
  111504. * String container all the define statements that should be set on the shader.
  111505. */
  111506. defines: string;
  111507. /**
  111508. * Callback that will be called when the shader is compiled.
  111509. */
  111510. onCompiled: Nullable<(effect: Effect) => void>;
  111511. /**
  111512. * Callback that will be called if an error occurs during shader compilation.
  111513. */
  111514. onError: Nullable<(effect: Effect, errors: string) => void>;
  111515. /**
  111516. * Callback that will be called when effect is bound.
  111517. */
  111518. onBind: Nullable<(effect: Effect) => void>;
  111519. /**
  111520. * Unique ID of the effect.
  111521. */
  111522. uniqueId: number;
  111523. /**
  111524. * Observable that will be called when the shader is compiled.
  111525. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  111526. */
  111527. onCompileObservable: Observable<Effect>;
  111528. /**
  111529. * Observable that will be called if an error occurs during shader compilation.
  111530. */
  111531. onErrorObservable: Observable<Effect>;
  111532. /** @hidden */
  111533. _onBindObservable: Nullable<Observable<Effect>>;
  111534. /**
  111535. * @hidden
  111536. * Specifies if the effect was previously ready
  111537. */
  111538. _wasPreviouslyReady: boolean;
  111539. /**
  111540. * Observable that will be called when effect is bound.
  111541. */
  111542. get onBindObservable(): Observable<Effect>;
  111543. /** @hidden */
  111544. _bonesComputationForcedToCPU: boolean;
  111545. /** @hidden */
  111546. _multiTarget: boolean;
  111547. private static _uniqueIdSeed;
  111548. private _engine;
  111549. private _uniformBuffersNames;
  111550. private _uniformBuffersNamesList;
  111551. private _uniformsNames;
  111552. private _samplerList;
  111553. private _samplers;
  111554. private _isReady;
  111555. private _compilationError;
  111556. private _allFallbacksProcessed;
  111557. private _attributesNames;
  111558. private _attributes;
  111559. private _attributeLocationByName;
  111560. private _uniforms;
  111561. /**
  111562. * Key for the effect.
  111563. * @hidden
  111564. */
  111565. _key: string;
  111566. private _indexParameters;
  111567. private _fallbacks;
  111568. private _vertexSourceCode;
  111569. private _fragmentSourceCode;
  111570. private _vertexSourceCodeOverride;
  111571. private _fragmentSourceCodeOverride;
  111572. private _transformFeedbackVaryings;
  111573. /**
  111574. * Compiled shader to webGL program.
  111575. * @hidden
  111576. */
  111577. _pipelineContext: Nullable<IPipelineContext>;
  111578. private _valueCache;
  111579. private static _baseCache;
  111580. /**
  111581. * Instantiates an effect.
  111582. * An effect can be used to create/manage/execute vertex and fragment shaders.
  111583. * @param baseName Name of the effect.
  111584. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  111585. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  111586. * @param samplers List of sampler variables that will be passed to the shader.
  111587. * @param engine Engine to be used to render the effect
  111588. * @param defines Define statements to be added to the shader.
  111589. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  111590. * @param onCompiled Callback that will be called when the shader is compiled.
  111591. * @param onError Callback that will be called if an error occurs during shader compilation.
  111592. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  111593. */
  111594. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  111595. private _useFinalCode;
  111596. /**
  111597. * Unique key for this effect
  111598. */
  111599. get key(): string;
  111600. /**
  111601. * If the effect has been compiled and prepared.
  111602. * @returns if the effect is compiled and prepared.
  111603. */
  111604. isReady(): boolean;
  111605. private _isReadyInternal;
  111606. /**
  111607. * The engine the effect was initialized with.
  111608. * @returns the engine.
  111609. */
  111610. getEngine(): Engine;
  111611. /**
  111612. * The pipeline context for this effect
  111613. * @returns the associated pipeline context
  111614. */
  111615. getPipelineContext(): Nullable<IPipelineContext>;
  111616. /**
  111617. * The set of names of attribute variables for the shader.
  111618. * @returns An array of attribute names.
  111619. */
  111620. getAttributesNames(): string[];
  111621. /**
  111622. * Returns the attribute at the given index.
  111623. * @param index The index of the attribute.
  111624. * @returns The location of the attribute.
  111625. */
  111626. getAttributeLocation(index: number): number;
  111627. /**
  111628. * Returns the attribute based on the name of the variable.
  111629. * @param name of the attribute to look up.
  111630. * @returns the attribute location.
  111631. */
  111632. getAttributeLocationByName(name: string): number;
  111633. /**
  111634. * The number of attributes.
  111635. * @returns the numnber of attributes.
  111636. */
  111637. getAttributesCount(): number;
  111638. /**
  111639. * Gets the index of a uniform variable.
  111640. * @param uniformName of the uniform to look up.
  111641. * @returns the index.
  111642. */
  111643. getUniformIndex(uniformName: string): number;
  111644. /**
  111645. * Returns the attribute based on the name of the variable.
  111646. * @param uniformName of the uniform to look up.
  111647. * @returns the location of the uniform.
  111648. */
  111649. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  111650. /**
  111651. * Returns an array of sampler variable names
  111652. * @returns The array of sampler variable names.
  111653. */
  111654. getSamplers(): string[];
  111655. /**
  111656. * Returns an array of uniform variable names
  111657. * @returns The array of uniform variable names.
  111658. */
  111659. getUniformNames(): string[];
  111660. /**
  111661. * Returns an array of uniform buffer variable names
  111662. * @returns The array of uniform buffer variable names.
  111663. */
  111664. getUniformBuffersNames(): string[];
  111665. /**
  111666. * Returns the index parameters used to create the effect
  111667. * @returns The index parameters object
  111668. */
  111669. getIndexParameters(): any;
  111670. /**
  111671. * The error from the last compilation.
  111672. * @returns the error string.
  111673. */
  111674. getCompilationError(): string;
  111675. /**
  111676. * Gets a boolean indicating that all fallbacks were used during compilation
  111677. * @returns true if all fallbacks were used
  111678. */
  111679. allFallbacksProcessed(): boolean;
  111680. /**
  111681. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  111682. * @param func The callback to be used.
  111683. */
  111684. executeWhenCompiled(func: (effect: Effect) => void): void;
  111685. private _checkIsReady;
  111686. private _loadShader;
  111687. /**
  111688. * Gets the vertex shader source code of this effect
  111689. */
  111690. get vertexSourceCode(): string;
  111691. /**
  111692. * Gets the fragment shader source code of this effect
  111693. */
  111694. get fragmentSourceCode(): string;
  111695. /**
  111696. * Recompiles the webGL program
  111697. * @param vertexSourceCode The source code for the vertex shader.
  111698. * @param fragmentSourceCode The source code for the fragment shader.
  111699. * @param onCompiled Callback called when completed.
  111700. * @param onError Callback called on error.
  111701. * @hidden
  111702. */
  111703. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  111704. /**
  111705. * Prepares the effect
  111706. * @hidden
  111707. */
  111708. _prepareEffect(): void;
  111709. private _getShaderCodeAndErrorLine;
  111710. private _processCompilationErrors;
  111711. /**
  111712. * Checks if the effect is supported. (Must be called after compilation)
  111713. */
  111714. get isSupported(): boolean;
  111715. /**
  111716. * Binds a texture to the engine to be used as output of the shader.
  111717. * @param channel Name of the output variable.
  111718. * @param texture Texture to bind.
  111719. * @hidden
  111720. */
  111721. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  111722. /**
  111723. * Sets a texture on the engine to be used in the shader.
  111724. * @param channel Name of the sampler variable.
  111725. * @param texture Texture to set.
  111726. */
  111727. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  111728. /**
  111729. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  111730. * @param channel Name of the sampler variable.
  111731. * @param texture Texture to set.
  111732. */
  111733. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  111734. /**
  111735. * Sets an array of textures on the engine to be used in the shader.
  111736. * @param channel Name of the variable.
  111737. * @param textures Textures to set.
  111738. */
  111739. setTextureArray(channel: string, textures: BaseTexture[]): void;
  111740. /**
  111741. * 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)
  111742. * @param channel Name of the sampler variable.
  111743. * @param postProcess Post process to get the input texture from.
  111744. */
  111745. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  111746. /**
  111747. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  111748. * 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)
  111749. * @param channel Name of the sampler variable.
  111750. * @param postProcess Post process to get the output texture from.
  111751. */
  111752. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  111753. /** @hidden */
  111754. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  111755. /** @hidden */
  111756. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  111757. /** @hidden */
  111758. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  111759. /** @hidden */
  111760. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  111761. /**
  111762. * Binds a buffer to a uniform.
  111763. * @param buffer Buffer to bind.
  111764. * @param name Name of the uniform variable to bind to.
  111765. */
  111766. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  111767. /**
  111768. * Binds block to a uniform.
  111769. * @param blockName Name of the block to bind.
  111770. * @param index Index to bind.
  111771. */
  111772. bindUniformBlock(blockName: string, index: number): void;
  111773. /**
  111774. * Sets an interger value on a uniform variable.
  111775. * @param uniformName Name of the variable.
  111776. * @param value Value to be set.
  111777. * @returns this effect.
  111778. */
  111779. setInt(uniformName: string, value: number): Effect;
  111780. /**
  111781. * Sets an int array on a uniform variable.
  111782. * @param uniformName Name of the variable.
  111783. * @param array array to be set.
  111784. * @returns this effect.
  111785. */
  111786. setIntArray(uniformName: string, array: Int32Array): Effect;
  111787. /**
  111788. * 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)
  111789. * @param uniformName Name of the variable.
  111790. * @param array array to be set.
  111791. * @returns this effect.
  111792. */
  111793. setIntArray2(uniformName: string, array: Int32Array): Effect;
  111794. /**
  111795. * 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)
  111796. * @param uniformName Name of the variable.
  111797. * @param array array to be set.
  111798. * @returns this effect.
  111799. */
  111800. setIntArray3(uniformName: string, array: Int32Array): Effect;
  111801. /**
  111802. * 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)
  111803. * @param uniformName Name of the variable.
  111804. * @param array array to be set.
  111805. * @returns this effect.
  111806. */
  111807. setIntArray4(uniformName: string, array: Int32Array): Effect;
  111808. /**
  111809. * Sets an float array on a uniform variable.
  111810. * @param uniformName Name of the variable.
  111811. * @param array array to be set.
  111812. * @returns this effect.
  111813. */
  111814. setFloatArray(uniformName: string, array: Float32Array): Effect;
  111815. /**
  111816. * 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)
  111817. * @param uniformName Name of the variable.
  111818. * @param array array to be set.
  111819. * @returns this effect.
  111820. */
  111821. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  111822. /**
  111823. * 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)
  111824. * @param uniformName Name of the variable.
  111825. * @param array array to be set.
  111826. * @returns this effect.
  111827. */
  111828. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  111829. /**
  111830. * 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)
  111831. * @param uniformName Name of the variable.
  111832. * @param array array to be set.
  111833. * @returns this effect.
  111834. */
  111835. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  111836. /**
  111837. * Sets an array on a uniform variable.
  111838. * @param uniformName Name of the variable.
  111839. * @param array array to be set.
  111840. * @returns this effect.
  111841. */
  111842. setArray(uniformName: string, array: number[]): Effect;
  111843. /**
  111844. * 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)
  111845. * @param uniformName Name of the variable.
  111846. * @param array array to be set.
  111847. * @returns this effect.
  111848. */
  111849. setArray2(uniformName: string, array: number[]): Effect;
  111850. /**
  111851. * 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)
  111852. * @param uniformName Name of the variable.
  111853. * @param array array to be set.
  111854. * @returns this effect.
  111855. */
  111856. setArray3(uniformName: string, array: number[]): Effect;
  111857. /**
  111858. * 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)
  111859. * @param uniformName Name of the variable.
  111860. * @param array array to be set.
  111861. * @returns this effect.
  111862. */
  111863. setArray4(uniformName: string, array: number[]): Effect;
  111864. /**
  111865. * Sets matrices on a uniform variable.
  111866. * @param uniformName Name of the variable.
  111867. * @param matrices matrices to be set.
  111868. * @returns this effect.
  111869. */
  111870. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  111871. /**
  111872. * Sets matrix on a uniform variable.
  111873. * @param uniformName Name of the variable.
  111874. * @param matrix matrix to be set.
  111875. * @returns this effect.
  111876. */
  111877. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  111878. /**
  111879. * 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)
  111880. * @param uniformName Name of the variable.
  111881. * @param matrix matrix to be set.
  111882. * @returns this effect.
  111883. */
  111884. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  111885. /**
  111886. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  111887. * @param uniformName Name of the variable.
  111888. * @param matrix matrix to be set.
  111889. * @returns this effect.
  111890. */
  111891. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  111892. /**
  111893. * Sets a float on a uniform variable.
  111894. * @param uniformName Name of the variable.
  111895. * @param value value to be set.
  111896. * @returns this effect.
  111897. */
  111898. setFloat(uniformName: string, value: number): Effect;
  111899. /**
  111900. * Sets a boolean on a uniform variable.
  111901. * @param uniformName Name of the variable.
  111902. * @param bool value to be set.
  111903. * @returns this effect.
  111904. */
  111905. setBool(uniformName: string, bool: boolean): Effect;
  111906. /**
  111907. * Sets a Vector2 on a uniform variable.
  111908. * @param uniformName Name of the variable.
  111909. * @param vector2 vector2 to be set.
  111910. * @returns this effect.
  111911. */
  111912. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  111913. /**
  111914. * Sets a float2 on a uniform variable.
  111915. * @param uniformName Name of the variable.
  111916. * @param x First float in float2.
  111917. * @param y Second float in float2.
  111918. * @returns this effect.
  111919. */
  111920. setFloat2(uniformName: string, x: number, y: number): Effect;
  111921. /**
  111922. * Sets a Vector3 on a uniform variable.
  111923. * @param uniformName Name of the variable.
  111924. * @param vector3 Value to be set.
  111925. * @returns this effect.
  111926. */
  111927. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  111928. /**
  111929. * Sets a float3 on a uniform variable.
  111930. * @param uniformName Name of the variable.
  111931. * @param x First float in float3.
  111932. * @param y Second float in float3.
  111933. * @param z Third float in float3.
  111934. * @returns this effect.
  111935. */
  111936. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  111937. /**
  111938. * Sets a Vector4 on a uniform variable.
  111939. * @param uniformName Name of the variable.
  111940. * @param vector4 Value to be set.
  111941. * @returns this effect.
  111942. */
  111943. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  111944. /**
  111945. * Sets a float4 on a uniform variable.
  111946. * @param uniformName Name of the variable.
  111947. * @param x First float in float4.
  111948. * @param y Second float in float4.
  111949. * @param z Third float in float4.
  111950. * @param w Fourth float in float4.
  111951. * @returns this effect.
  111952. */
  111953. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  111954. /**
  111955. * Sets a Color3 on a uniform variable.
  111956. * @param uniformName Name of the variable.
  111957. * @param color3 Value to be set.
  111958. * @returns this effect.
  111959. */
  111960. setColor3(uniformName: string, color3: IColor3Like): Effect;
  111961. /**
  111962. * Sets a Color4 on a uniform variable.
  111963. * @param uniformName Name of the variable.
  111964. * @param color3 Value to be set.
  111965. * @param alpha Alpha value to be set.
  111966. * @returns this effect.
  111967. */
  111968. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  111969. /**
  111970. * Sets a Color4 on a uniform variable
  111971. * @param uniformName defines the name of the variable
  111972. * @param color4 defines the value to be set
  111973. * @returns this effect.
  111974. */
  111975. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  111976. /** Release all associated resources */
  111977. dispose(): void;
  111978. /**
  111979. * This function will add a new shader to the shader store
  111980. * @param name the name of the shader
  111981. * @param pixelShader optional pixel shader content
  111982. * @param vertexShader optional vertex shader content
  111983. */
  111984. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  111985. /**
  111986. * Store of each shader (The can be looked up using effect.key)
  111987. */
  111988. static ShadersStore: {
  111989. [key: string]: string;
  111990. };
  111991. /**
  111992. * Store of each included file for a shader (The can be looked up using effect.key)
  111993. */
  111994. static IncludesShadersStore: {
  111995. [key: string]: string;
  111996. };
  111997. /**
  111998. * Resets the cache of effects.
  111999. */
  112000. static ResetCache(): void;
  112001. }
  112002. }
  112003. declare module BABYLON {
  112004. /**
  112005. * Interface used to describe the capabilities of the engine relatively to the current browser
  112006. */
  112007. export interface EngineCapabilities {
  112008. /** Maximum textures units per fragment shader */
  112009. maxTexturesImageUnits: number;
  112010. /** Maximum texture units per vertex shader */
  112011. maxVertexTextureImageUnits: number;
  112012. /** Maximum textures units in the entire pipeline */
  112013. maxCombinedTexturesImageUnits: number;
  112014. /** Maximum texture size */
  112015. maxTextureSize: number;
  112016. /** Maximum texture samples */
  112017. maxSamples?: number;
  112018. /** Maximum cube texture size */
  112019. maxCubemapTextureSize: number;
  112020. /** Maximum render texture size */
  112021. maxRenderTextureSize: number;
  112022. /** Maximum number of vertex attributes */
  112023. maxVertexAttribs: number;
  112024. /** Maximum number of varyings */
  112025. maxVaryingVectors: number;
  112026. /** Maximum number of uniforms per vertex shader */
  112027. maxVertexUniformVectors: number;
  112028. /** Maximum number of uniforms per fragment shader */
  112029. maxFragmentUniformVectors: number;
  112030. /** Defines if standard derivates (dx/dy) are supported */
  112031. standardDerivatives: boolean;
  112032. /** Defines if s3tc texture compression is supported */
  112033. s3tc?: WEBGL_compressed_texture_s3tc;
  112034. /** Defines if pvrtc texture compression is supported */
  112035. pvrtc: any;
  112036. /** Defines if etc1 texture compression is supported */
  112037. etc1: any;
  112038. /** Defines if etc2 texture compression is supported */
  112039. etc2: any;
  112040. /** Defines if astc texture compression is supported */
  112041. astc: any;
  112042. /** Defines if float textures are supported */
  112043. textureFloat: boolean;
  112044. /** Defines if vertex array objects are supported */
  112045. vertexArrayObject: boolean;
  112046. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  112047. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  112048. /** Gets the maximum level of anisotropy supported */
  112049. maxAnisotropy: number;
  112050. /** Defines if instancing is supported */
  112051. instancedArrays: boolean;
  112052. /** Defines if 32 bits indices are supported */
  112053. uintIndices: boolean;
  112054. /** Defines if high precision shaders are supported */
  112055. highPrecisionShaderSupported: boolean;
  112056. /** Defines if depth reading in the fragment shader is supported */
  112057. fragmentDepthSupported: boolean;
  112058. /** Defines if float texture linear filtering is supported*/
  112059. textureFloatLinearFiltering: boolean;
  112060. /** Defines if rendering to float textures is supported */
  112061. textureFloatRender: boolean;
  112062. /** Defines if half float textures are supported*/
  112063. textureHalfFloat: boolean;
  112064. /** Defines if half float texture linear filtering is supported*/
  112065. textureHalfFloatLinearFiltering: boolean;
  112066. /** Defines if rendering to half float textures is supported */
  112067. textureHalfFloatRender: boolean;
  112068. /** Defines if textureLOD shader command is supported */
  112069. textureLOD: boolean;
  112070. /** Defines if draw buffers extension is supported */
  112071. drawBuffersExtension: boolean;
  112072. /** Defines if depth textures are supported */
  112073. depthTextureExtension: boolean;
  112074. /** Defines if float color buffer are supported */
  112075. colorBufferFloat: boolean;
  112076. /** Gets disjoint timer query extension (null if not supported) */
  112077. timerQuery?: EXT_disjoint_timer_query;
  112078. /** Defines if timestamp can be used with timer query */
  112079. canUseTimestampForTimerQuery: boolean;
  112080. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  112081. multiview?: any;
  112082. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  112083. oculusMultiview?: any;
  112084. /** Function used to let the system compiles shaders in background */
  112085. parallelShaderCompile?: {
  112086. COMPLETION_STATUS_KHR: number;
  112087. };
  112088. /** Max number of texture samples for MSAA */
  112089. maxMSAASamples: number;
  112090. /** Defines if the blend min max extension is supported */
  112091. blendMinMax: boolean;
  112092. }
  112093. }
  112094. declare module BABYLON {
  112095. /**
  112096. * @hidden
  112097. **/
  112098. export class DepthCullingState {
  112099. private _isDepthTestDirty;
  112100. private _isDepthMaskDirty;
  112101. private _isDepthFuncDirty;
  112102. private _isCullFaceDirty;
  112103. private _isCullDirty;
  112104. private _isZOffsetDirty;
  112105. private _isFrontFaceDirty;
  112106. private _depthTest;
  112107. private _depthMask;
  112108. private _depthFunc;
  112109. private _cull;
  112110. private _cullFace;
  112111. private _zOffset;
  112112. private _frontFace;
  112113. /**
  112114. * Initializes the state.
  112115. */
  112116. constructor();
  112117. get isDirty(): boolean;
  112118. get zOffset(): number;
  112119. set zOffset(value: number);
  112120. get cullFace(): Nullable<number>;
  112121. set cullFace(value: Nullable<number>);
  112122. get cull(): Nullable<boolean>;
  112123. set cull(value: Nullable<boolean>);
  112124. get depthFunc(): Nullable<number>;
  112125. set depthFunc(value: Nullable<number>);
  112126. get depthMask(): boolean;
  112127. set depthMask(value: boolean);
  112128. get depthTest(): boolean;
  112129. set depthTest(value: boolean);
  112130. get frontFace(): Nullable<number>;
  112131. set frontFace(value: Nullable<number>);
  112132. reset(): void;
  112133. apply(gl: WebGLRenderingContext): void;
  112134. }
  112135. }
  112136. declare module BABYLON {
  112137. /**
  112138. * @hidden
  112139. **/
  112140. export class StencilState {
  112141. /** 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 */
  112142. static readonly ALWAYS: number;
  112143. /** Passed to stencilOperation to specify that stencil value must be kept */
  112144. static readonly KEEP: number;
  112145. /** Passed to stencilOperation to specify that stencil value must be replaced */
  112146. static readonly REPLACE: number;
  112147. private _isStencilTestDirty;
  112148. private _isStencilMaskDirty;
  112149. private _isStencilFuncDirty;
  112150. private _isStencilOpDirty;
  112151. private _stencilTest;
  112152. private _stencilMask;
  112153. private _stencilFunc;
  112154. private _stencilFuncRef;
  112155. private _stencilFuncMask;
  112156. private _stencilOpStencilFail;
  112157. private _stencilOpDepthFail;
  112158. private _stencilOpStencilDepthPass;
  112159. get isDirty(): boolean;
  112160. get stencilFunc(): number;
  112161. set stencilFunc(value: number);
  112162. get stencilFuncRef(): number;
  112163. set stencilFuncRef(value: number);
  112164. get stencilFuncMask(): number;
  112165. set stencilFuncMask(value: number);
  112166. get stencilOpStencilFail(): number;
  112167. set stencilOpStencilFail(value: number);
  112168. get stencilOpDepthFail(): number;
  112169. set stencilOpDepthFail(value: number);
  112170. get stencilOpStencilDepthPass(): number;
  112171. set stencilOpStencilDepthPass(value: number);
  112172. get stencilMask(): number;
  112173. set stencilMask(value: number);
  112174. get stencilTest(): boolean;
  112175. set stencilTest(value: boolean);
  112176. constructor();
  112177. reset(): void;
  112178. apply(gl: WebGLRenderingContext): void;
  112179. }
  112180. }
  112181. declare module BABYLON {
  112182. /**
  112183. * @hidden
  112184. **/
  112185. export class AlphaState {
  112186. private _isAlphaBlendDirty;
  112187. private _isBlendFunctionParametersDirty;
  112188. private _isBlendEquationParametersDirty;
  112189. private _isBlendConstantsDirty;
  112190. private _alphaBlend;
  112191. private _blendFunctionParameters;
  112192. private _blendEquationParameters;
  112193. private _blendConstants;
  112194. /**
  112195. * Initializes the state.
  112196. */
  112197. constructor();
  112198. get isDirty(): boolean;
  112199. get alphaBlend(): boolean;
  112200. set alphaBlend(value: boolean);
  112201. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  112202. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  112203. setAlphaEquationParameters(rgb: number, alpha: number): void;
  112204. reset(): void;
  112205. apply(gl: WebGLRenderingContext): void;
  112206. }
  112207. }
  112208. declare module BABYLON {
  112209. /** @hidden */
  112210. export class WebGL2ShaderProcessor implements IShaderProcessor {
  112211. attributeProcessor(attribute: string): string;
  112212. varyingProcessor(varying: string, isFragment: boolean): string;
  112213. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  112214. }
  112215. }
  112216. declare module BABYLON {
  112217. /**
  112218. * Interface for attribute information associated with buffer instanciation
  112219. */
  112220. export interface InstancingAttributeInfo {
  112221. /**
  112222. * Name of the GLSL attribute
  112223. * if attribute index is not specified, this is used to retrieve the index from the effect
  112224. */
  112225. attributeName: string;
  112226. /**
  112227. * Index/offset of the attribute in the vertex shader
  112228. * if not specified, this will be computes from the name.
  112229. */
  112230. index?: number;
  112231. /**
  112232. * size of the attribute, 1, 2, 3 or 4
  112233. */
  112234. attributeSize: number;
  112235. /**
  112236. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  112237. */
  112238. offset: number;
  112239. /**
  112240. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  112241. * default to 1
  112242. */
  112243. divisor?: number;
  112244. /**
  112245. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  112246. * default is FLOAT
  112247. */
  112248. attributeType?: number;
  112249. /**
  112250. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  112251. */
  112252. normalized?: boolean;
  112253. }
  112254. }
  112255. declare module BABYLON {
  112256. interface ThinEngine {
  112257. /**
  112258. * Update a video texture
  112259. * @param texture defines the texture to update
  112260. * @param video defines the video element to use
  112261. * @param invertY defines if data must be stored with Y axis inverted
  112262. */
  112263. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  112264. }
  112265. }
  112266. declare module BABYLON {
  112267. interface ThinEngine {
  112268. /**
  112269. * Creates a dynamic texture
  112270. * @param width defines the width of the texture
  112271. * @param height defines the height of the texture
  112272. * @param generateMipMaps defines if the engine should generate the mip levels
  112273. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  112274. * @returns the dynamic texture inside an InternalTexture
  112275. */
  112276. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  112277. /**
  112278. * Update the content of a dynamic texture
  112279. * @param texture defines the texture to update
  112280. * @param canvas defines the canvas containing the source
  112281. * @param invertY defines if data must be stored with Y axis inverted
  112282. * @param premulAlpha defines if alpha is stored as premultiplied
  112283. * @param format defines the format of the data
  112284. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  112285. */
  112286. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  112287. }
  112288. }
  112289. declare module BABYLON {
  112290. /**
  112291. * Settings for finer control over video usage
  112292. */
  112293. export interface VideoTextureSettings {
  112294. /**
  112295. * Applies `autoplay` to video, if specified
  112296. */
  112297. autoPlay?: boolean;
  112298. /**
  112299. * Applies `loop` to video, if specified
  112300. */
  112301. loop?: boolean;
  112302. /**
  112303. * Automatically updates internal texture from video at every frame in the render loop
  112304. */
  112305. autoUpdateTexture: boolean;
  112306. /**
  112307. * Image src displayed during the video loading or until the user interacts with the video.
  112308. */
  112309. poster?: string;
  112310. }
  112311. /**
  112312. * If you want to display a video in your scene, this is the special texture for that.
  112313. * This special texture works similar to other textures, with the exception of a few parameters.
  112314. * @see https://doc.babylonjs.com/how_to/video_texture
  112315. */
  112316. export class VideoTexture extends Texture {
  112317. /**
  112318. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  112319. */
  112320. readonly autoUpdateTexture: boolean;
  112321. /**
  112322. * The video instance used by the texture internally
  112323. */
  112324. readonly video: HTMLVideoElement;
  112325. private _onUserActionRequestedObservable;
  112326. /**
  112327. * Event triggerd when a dom action is required by the user to play the video.
  112328. * This happens due to recent changes in browser policies preventing video to auto start.
  112329. */
  112330. get onUserActionRequestedObservable(): Observable<Texture>;
  112331. private _generateMipMaps;
  112332. private _stillImageCaptured;
  112333. private _displayingPosterTexture;
  112334. private _settings;
  112335. private _createInternalTextureOnEvent;
  112336. private _frameId;
  112337. private _currentSrc;
  112338. /**
  112339. * Creates a video texture.
  112340. * If you want to display a video in your scene, this is the special texture for that.
  112341. * This special texture works similar to other textures, with the exception of a few parameters.
  112342. * @see https://doc.babylonjs.com/how_to/video_texture
  112343. * @param name optional name, will detect from video source, if not defined
  112344. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  112345. * @param scene is obviously the current scene.
  112346. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  112347. * @param invertY is false by default but can be used to invert video on Y axis
  112348. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  112349. * @param settings allows finer control over video usage
  112350. */
  112351. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  112352. private _getName;
  112353. private _getVideo;
  112354. private _createInternalTexture;
  112355. private reset;
  112356. /**
  112357. * @hidden Internal method to initiate `update`.
  112358. */
  112359. _rebuild(): void;
  112360. /**
  112361. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  112362. */
  112363. update(): void;
  112364. /**
  112365. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  112366. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  112367. */
  112368. updateTexture(isVisible: boolean): void;
  112369. protected _updateInternalTexture: () => void;
  112370. /**
  112371. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  112372. * @param url New url.
  112373. */
  112374. updateURL(url: string): void;
  112375. /**
  112376. * Clones the texture.
  112377. * @returns the cloned texture
  112378. */
  112379. clone(): VideoTexture;
  112380. /**
  112381. * Dispose the texture and release its associated resources.
  112382. */
  112383. dispose(): void;
  112384. /**
  112385. * Creates a video texture straight from a stream.
  112386. * @param scene Define the scene the texture should be created in
  112387. * @param stream Define the stream the texture should be created from
  112388. * @returns The created video texture as a promise
  112389. */
  112390. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  112391. /**
  112392. * Creates a video texture straight from your WebCam video feed.
  112393. * @param scene Define the scene the texture should be created in
  112394. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  112395. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  112396. * @returns The created video texture as a promise
  112397. */
  112398. static CreateFromWebCamAsync(scene: Scene, constraints: {
  112399. minWidth: number;
  112400. maxWidth: number;
  112401. minHeight: number;
  112402. maxHeight: number;
  112403. deviceId: string;
  112404. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  112405. /**
  112406. * Creates a video texture straight from your WebCam video feed.
  112407. * @param scene Define the scene the texture should be created in
  112408. * @param onReady Define a callback to triggered once the texture will be ready
  112409. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  112410. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  112411. */
  112412. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  112413. minWidth: number;
  112414. maxWidth: number;
  112415. minHeight: number;
  112416. maxHeight: number;
  112417. deviceId: string;
  112418. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  112419. }
  112420. }
  112421. declare module BABYLON {
  112422. /**
  112423. * Defines the interface used by objects working like Scene
  112424. * @hidden
  112425. */
  112426. export interface ISceneLike {
  112427. _addPendingData(data: any): void;
  112428. _removePendingData(data: any): void;
  112429. offlineProvider: IOfflineProvider;
  112430. }
  112431. /** Interface defining initialization parameters for Engine class */
  112432. export interface EngineOptions extends WebGLContextAttributes {
  112433. /**
  112434. * Defines if the engine should no exceed a specified device ratio
  112435. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  112436. */
  112437. limitDeviceRatio?: number;
  112438. /**
  112439. * Defines if webvr should be enabled automatically
  112440. * @see https://doc.babylonjs.com/how_to/webvr_camera
  112441. */
  112442. autoEnableWebVR?: boolean;
  112443. /**
  112444. * Defines if webgl2 should be turned off even if supported
  112445. * @see https://doc.babylonjs.com/features/webgl2
  112446. */
  112447. disableWebGL2Support?: boolean;
  112448. /**
  112449. * Defines if webaudio should be initialized as well
  112450. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  112451. */
  112452. audioEngine?: boolean;
  112453. /**
  112454. * Defines if animations should run using a deterministic lock step
  112455. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112456. */
  112457. deterministicLockstep?: boolean;
  112458. /** Defines the maximum steps to use with deterministic lock step mode */
  112459. lockstepMaxSteps?: number;
  112460. /** Defines the seconds between each deterministic lock step */
  112461. timeStep?: number;
  112462. /**
  112463. * Defines that engine should ignore context lost events
  112464. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  112465. */
  112466. doNotHandleContextLost?: boolean;
  112467. /**
  112468. * Defines that engine should ignore modifying touch action attribute and style
  112469. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  112470. */
  112471. doNotHandleTouchAction?: boolean;
  112472. /**
  112473. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  112474. */
  112475. useHighPrecisionFloats?: boolean;
  112476. /**
  112477. * Make the canvas XR Compatible for XR sessions
  112478. */
  112479. xrCompatible?: boolean;
  112480. }
  112481. /**
  112482. * The base engine class (root of all engines)
  112483. */
  112484. export class ThinEngine {
  112485. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  112486. static ExceptionList: ({
  112487. key: string;
  112488. capture: string;
  112489. captureConstraint: number;
  112490. targets: string[];
  112491. } | {
  112492. key: string;
  112493. capture: null;
  112494. captureConstraint: null;
  112495. targets: string[];
  112496. })[];
  112497. /** @hidden */
  112498. static _TextureLoaders: IInternalTextureLoader[];
  112499. /**
  112500. * Returns the current npm package of the sdk
  112501. */
  112502. static get NpmPackage(): string;
  112503. /**
  112504. * Returns the current version of the framework
  112505. */
  112506. static get Version(): string;
  112507. /**
  112508. * Returns a string describing the current engine
  112509. */
  112510. get description(): string;
  112511. /**
  112512. * Gets or sets the epsilon value used by collision engine
  112513. */
  112514. static CollisionsEpsilon: number;
  112515. /**
  112516. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  112517. */
  112518. static get ShadersRepository(): string;
  112519. static set ShadersRepository(value: string);
  112520. /** @hidden */
  112521. _shaderProcessor: IShaderProcessor;
  112522. /**
  112523. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  112524. */
  112525. forcePOTTextures: boolean;
  112526. /**
  112527. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  112528. */
  112529. isFullscreen: boolean;
  112530. /**
  112531. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  112532. */
  112533. cullBackFaces: boolean;
  112534. /**
  112535. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  112536. */
  112537. renderEvenInBackground: boolean;
  112538. /**
  112539. * Gets or sets a boolean indicating that cache can be kept between frames
  112540. */
  112541. preventCacheWipeBetweenFrames: boolean;
  112542. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  112543. validateShaderPrograms: boolean;
  112544. /**
  112545. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  112546. * This can provide greater z depth for distant objects.
  112547. */
  112548. useReverseDepthBuffer: boolean;
  112549. /**
  112550. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  112551. */
  112552. disableUniformBuffers: boolean;
  112553. /** @hidden */
  112554. _uniformBuffers: UniformBuffer[];
  112555. /**
  112556. * Gets a boolean indicating that the engine supports uniform buffers
  112557. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  112558. */
  112559. get supportsUniformBuffers(): boolean;
  112560. /** @hidden */
  112561. _gl: WebGLRenderingContext;
  112562. /** @hidden */
  112563. _webGLVersion: number;
  112564. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  112565. protected _windowIsBackground: boolean;
  112566. protected _creationOptions: EngineOptions;
  112567. protected _highPrecisionShadersAllowed: boolean;
  112568. /** @hidden */
  112569. get _shouldUseHighPrecisionShader(): boolean;
  112570. /**
  112571. * Gets a boolean indicating that only power of 2 textures are supported
  112572. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  112573. */
  112574. get needPOTTextures(): boolean;
  112575. /** @hidden */
  112576. _badOS: boolean;
  112577. /** @hidden */
  112578. _badDesktopOS: boolean;
  112579. private _hardwareScalingLevel;
  112580. /** @hidden */
  112581. _caps: EngineCapabilities;
  112582. private _isStencilEnable;
  112583. private _glVersion;
  112584. private _glRenderer;
  112585. private _glVendor;
  112586. /** @hidden */
  112587. _videoTextureSupported: boolean;
  112588. protected _renderingQueueLaunched: boolean;
  112589. protected _activeRenderLoops: (() => void)[];
  112590. /**
  112591. * Observable signaled when a context lost event is raised
  112592. */
  112593. onContextLostObservable: Observable<ThinEngine>;
  112594. /**
  112595. * Observable signaled when a context restored event is raised
  112596. */
  112597. onContextRestoredObservable: Observable<ThinEngine>;
  112598. private _onContextLost;
  112599. private _onContextRestored;
  112600. protected _contextWasLost: boolean;
  112601. /** @hidden */
  112602. _doNotHandleContextLost: boolean;
  112603. /**
  112604. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  112605. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  112606. */
  112607. get doNotHandleContextLost(): boolean;
  112608. set doNotHandleContextLost(value: boolean);
  112609. /**
  112610. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  112611. */
  112612. disableVertexArrayObjects: boolean;
  112613. /** @hidden */
  112614. protected _colorWrite: boolean;
  112615. /** @hidden */
  112616. protected _colorWriteChanged: boolean;
  112617. /** @hidden */
  112618. protected _depthCullingState: DepthCullingState;
  112619. /** @hidden */
  112620. protected _stencilState: StencilState;
  112621. /** @hidden */
  112622. _alphaState: AlphaState;
  112623. /** @hidden */
  112624. _alphaMode: number;
  112625. /** @hidden */
  112626. _alphaEquation: number;
  112627. /** @hidden */
  112628. _internalTexturesCache: InternalTexture[];
  112629. /** @hidden */
  112630. protected _activeChannel: number;
  112631. private _currentTextureChannel;
  112632. /** @hidden */
  112633. protected _boundTexturesCache: {
  112634. [key: string]: Nullable<InternalTexture>;
  112635. };
  112636. /** @hidden */
  112637. protected _currentEffect: Nullable<Effect>;
  112638. /** @hidden */
  112639. protected _currentProgram: Nullable<WebGLProgram>;
  112640. private _compiledEffects;
  112641. private _vertexAttribArraysEnabled;
  112642. /** @hidden */
  112643. protected _cachedViewport: Nullable<IViewportLike>;
  112644. private _cachedVertexArrayObject;
  112645. /** @hidden */
  112646. protected _cachedVertexBuffers: any;
  112647. /** @hidden */
  112648. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  112649. /** @hidden */
  112650. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  112651. /** @hidden */
  112652. _currentRenderTarget: Nullable<InternalTexture>;
  112653. private _uintIndicesCurrentlySet;
  112654. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  112655. /** @hidden */
  112656. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  112657. /** @hidden */
  112658. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  112659. private _currentBufferPointers;
  112660. private _currentInstanceLocations;
  112661. private _currentInstanceBuffers;
  112662. private _textureUnits;
  112663. /** @hidden */
  112664. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  112665. /** @hidden */
  112666. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  112667. /** @hidden */
  112668. _boundRenderFunction: any;
  112669. private _vaoRecordInProgress;
  112670. private _mustWipeVertexAttributes;
  112671. private _emptyTexture;
  112672. private _emptyCubeTexture;
  112673. private _emptyTexture3D;
  112674. private _emptyTexture2DArray;
  112675. /** @hidden */
  112676. _frameHandler: number;
  112677. private _nextFreeTextureSlots;
  112678. private _maxSimultaneousTextures;
  112679. private _activeRequests;
  112680. /** @hidden */
  112681. _transformTextureUrl: Nullable<(url: string) => string>;
  112682. protected get _supportsHardwareTextureRescaling(): boolean;
  112683. private _framebufferDimensionsObject;
  112684. /**
  112685. * sets the object from which width and height will be taken from when getting render width and height
  112686. * Will fallback to the gl object
  112687. * @param dimensions the framebuffer width and height that will be used.
  112688. */
  112689. set framebufferDimensionsObject(dimensions: Nullable<{
  112690. framebufferWidth: number;
  112691. framebufferHeight: number;
  112692. }>);
  112693. /**
  112694. * Gets the current viewport
  112695. */
  112696. get currentViewport(): Nullable<IViewportLike>;
  112697. /**
  112698. * Gets the default empty texture
  112699. */
  112700. get emptyTexture(): InternalTexture;
  112701. /**
  112702. * Gets the default empty 3D texture
  112703. */
  112704. get emptyTexture3D(): InternalTexture;
  112705. /**
  112706. * Gets the default empty 2D array texture
  112707. */
  112708. get emptyTexture2DArray(): InternalTexture;
  112709. /**
  112710. * Gets the default empty cube texture
  112711. */
  112712. get emptyCubeTexture(): InternalTexture;
  112713. /**
  112714. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  112715. */
  112716. readonly premultipliedAlpha: boolean;
  112717. /**
  112718. * Observable event triggered before each texture is initialized
  112719. */
  112720. onBeforeTextureInitObservable: Observable<Texture>;
  112721. /**
  112722. * Creates a new engine
  112723. * @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
  112724. * @param antialias defines enable antialiasing (default: false)
  112725. * @param options defines further options to be sent to the getContext() function
  112726. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  112727. */
  112728. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  112729. private _rebuildInternalTextures;
  112730. private _rebuildEffects;
  112731. /**
  112732. * Gets a boolean indicating if all created effects are ready
  112733. * @returns true if all effects are ready
  112734. */
  112735. areAllEffectsReady(): boolean;
  112736. protected _rebuildBuffers(): void;
  112737. protected _initGLContext(): void;
  112738. /**
  112739. * Gets version of the current webGL context
  112740. */
  112741. get webGLVersion(): number;
  112742. /**
  112743. * Gets a string idenfifying the name of the class
  112744. * @returns "Engine" string
  112745. */
  112746. getClassName(): string;
  112747. /**
  112748. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  112749. */
  112750. get isStencilEnable(): boolean;
  112751. /** @hidden */
  112752. _prepareWorkingCanvas(): void;
  112753. /**
  112754. * Reset the texture cache to empty state
  112755. */
  112756. resetTextureCache(): void;
  112757. /**
  112758. * Gets an object containing information about the current webGL context
  112759. * @returns an object containing the vender, the renderer and the version of the current webGL context
  112760. */
  112761. getGlInfo(): {
  112762. vendor: string;
  112763. renderer: string;
  112764. version: string;
  112765. };
  112766. /**
  112767. * Defines the hardware scaling level.
  112768. * By default the hardware scaling level is computed from the window device ratio.
  112769. * 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.
  112770. * @param level defines the level to use
  112771. */
  112772. setHardwareScalingLevel(level: number): void;
  112773. /**
  112774. * Gets the current hardware scaling level.
  112775. * By default the hardware scaling level is computed from the window device ratio.
  112776. * 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.
  112777. * @returns a number indicating the current hardware scaling level
  112778. */
  112779. getHardwareScalingLevel(): number;
  112780. /**
  112781. * Gets the list of loaded textures
  112782. * @returns an array containing all loaded textures
  112783. */
  112784. getLoadedTexturesCache(): InternalTexture[];
  112785. /**
  112786. * Gets the object containing all engine capabilities
  112787. * @returns the EngineCapabilities object
  112788. */
  112789. getCaps(): EngineCapabilities;
  112790. /**
  112791. * stop executing a render loop function and remove it from the execution array
  112792. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  112793. */
  112794. stopRenderLoop(renderFunction?: () => void): void;
  112795. /** @hidden */
  112796. _renderLoop(): void;
  112797. /**
  112798. * Gets the HTML canvas attached with the current webGL context
  112799. * @returns a HTML canvas
  112800. */
  112801. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  112802. /**
  112803. * Gets host window
  112804. * @returns the host window object
  112805. */
  112806. getHostWindow(): Nullable<Window>;
  112807. /**
  112808. * Gets the current render width
  112809. * @param useScreen defines if screen size must be used (or the current render target if any)
  112810. * @returns a number defining the current render width
  112811. */
  112812. getRenderWidth(useScreen?: boolean): number;
  112813. /**
  112814. * Gets the current render height
  112815. * @param useScreen defines if screen size must be used (or the current render target if any)
  112816. * @returns a number defining the current render height
  112817. */
  112818. getRenderHeight(useScreen?: boolean): number;
  112819. /**
  112820. * Can be used to override the current requestAnimationFrame requester.
  112821. * @hidden
  112822. */
  112823. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  112824. /**
  112825. * Register and execute a render loop. The engine can have more than one render function
  112826. * @param renderFunction defines the function to continuously execute
  112827. */
  112828. runRenderLoop(renderFunction: () => void): void;
  112829. /**
  112830. * Clear the current render buffer or the current render target (if any is set up)
  112831. * @param color defines the color to use
  112832. * @param backBuffer defines if the back buffer must be cleared
  112833. * @param depth defines if the depth buffer must be cleared
  112834. * @param stencil defines if the stencil buffer must be cleared
  112835. */
  112836. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  112837. private _viewportCached;
  112838. /** @hidden */
  112839. _viewport(x: number, y: number, width: number, height: number): void;
  112840. /**
  112841. * Set the WebGL's viewport
  112842. * @param viewport defines the viewport element to be used
  112843. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  112844. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  112845. */
  112846. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  112847. /**
  112848. * Begin a new frame
  112849. */
  112850. beginFrame(): void;
  112851. /**
  112852. * Enf the current frame
  112853. */
  112854. endFrame(): void;
  112855. /**
  112856. * Resize the view according to the canvas' size
  112857. */
  112858. resize(): void;
  112859. /**
  112860. * Force a specific size of the canvas
  112861. * @param width defines the new canvas' width
  112862. * @param height defines the new canvas' height
  112863. * @returns true if the size was changed
  112864. */
  112865. setSize(width: number, height: number): boolean;
  112866. /**
  112867. * Binds the frame buffer to the specified texture.
  112868. * @param texture The texture to render to or null for the default canvas
  112869. * @param faceIndex The face of the texture to render to in case of cube texture
  112870. * @param requiredWidth The width of the target to render to
  112871. * @param requiredHeight The height of the target to render to
  112872. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  112873. * @param lodLevel defines the lod level to bind to the frame buffer
  112874. * @param layer defines the 2d array index to bind to frame buffer to
  112875. */
  112876. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  112877. /** @hidden */
  112878. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  112879. /**
  112880. * Unbind the current render target texture from the webGL context
  112881. * @param texture defines the render target texture to unbind
  112882. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  112883. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  112884. */
  112885. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  112886. /**
  112887. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  112888. */
  112889. flushFramebuffer(): void;
  112890. /**
  112891. * Unbind the current render target and bind the default framebuffer
  112892. */
  112893. restoreDefaultFramebuffer(): void;
  112894. /** @hidden */
  112895. protected _resetVertexBufferBinding(): void;
  112896. /**
  112897. * Creates a vertex buffer
  112898. * @param data the data for the vertex buffer
  112899. * @returns the new WebGL static buffer
  112900. */
  112901. createVertexBuffer(data: DataArray): DataBuffer;
  112902. private _createVertexBuffer;
  112903. /**
  112904. * Creates a dynamic vertex buffer
  112905. * @param data the data for the dynamic vertex buffer
  112906. * @returns the new WebGL dynamic buffer
  112907. */
  112908. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  112909. protected _resetIndexBufferBinding(): void;
  112910. /**
  112911. * Creates a new index buffer
  112912. * @param indices defines the content of the index buffer
  112913. * @param updatable defines if the index buffer must be updatable
  112914. * @returns a new webGL buffer
  112915. */
  112916. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  112917. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  112918. /**
  112919. * Bind a webGL buffer to the webGL context
  112920. * @param buffer defines the buffer to bind
  112921. */
  112922. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  112923. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  112924. private bindBuffer;
  112925. /**
  112926. * update the bound buffer with the given data
  112927. * @param data defines the data to update
  112928. */
  112929. updateArrayBuffer(data: Float32Array): void;
  112930. private _vertexAttribPointer;
  112931. /** @hidden */
  112932. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  112933. private _bindVertexBuffersAttributes;
  112934. /**
  112935. * Records a vertex array object
  112936. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  112937. * @param vertexBuffers defines the list of vertex buffers to store
  112938. * @param indexBuffer defines the index buffer to store
  112939. * @param effect defines the effect to store
  112940. * @returns the new vertex array object
  112941. */
  112942. recordVertexArrayObject(vertexBuffers: {
  112943. [key: string]: VertexBuffer;
  112944. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  112945. /**
  112946. * Bind a specific vertex array object
  112947. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  112948. * @param vertexArrayObject defines the vertex array object to bind
  112949. * @param indexBuffer defines the index buffer to bind
  112950. */
  112951. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  112952. /**
  112953. * Bind webGl buffers directly to the webGL context
  112954. * @param vertexBuffer defines the vertex buffer to bind
  112955. * @param indexBuffer defines the index buffer to bind
  112956. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  112957. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  112958. * @param effect defines the effect associated with the vertex buffer
  112959. */
  112960. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  112961. private _unbindVertexArrayObject;
  112962. /**
  112963. * Bind a list of vertex buffers to the webGL context
  112964. * @param vertexBuffers defines the list of vertex buffers to bind
  112965. * @param indexBuffer defines the index buffer to bind
  112966. * @param effect defines the effect associated with the vertex buffers
  112967. */
  112968. bindBuffers(vertexBuffers: {
  112969. [key: string]: Nullable<VertexBuffer>;
  112970. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  112971. /**
  112972. * Unbind all instance attributes
  112973. */
  112974. unbindInstanceAttributes(): void;
  112975. /**
  112976. * Release and free the memory of a vertex array object
  112977. * @param vao defines the vertex array object to delete
  112978. */
  112979. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  112980. /** @hidden */
  112981. _releaseBuffer(buffer: DataBuffer): boolean;
  112982. protected _deleteBuffer(buffer: DataBuffer): void;
  112983. /**
  112984. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  112985. * @param instancesBuffer defines the webGL buffer to update and bind
  112986. * @param data defines the data to store in the buffer
  112987. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  112988. */
  112989. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  112990. /**
  112991. * Bind the content of a webGL buffer used with instantiation
  112992. * @param instancesBuffer defines the webGL buffer to bind
  112993. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  112994. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  112995. */
  112996. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  112997. /**
  112998. * Disable the instance attribute corresponding to the name in parameter
  112999. * @param name defines the name of the attribute to disable
  113000. */
  113001. disableInstanceAttributeByName(name: string): void;
  113002. /**
  113003. * Disable the instance attribute corresponding to the location in parameter
  113004. * @param attributeLocation defines the attribute location of the attribute to disable
  113005. */
  113006. disableInstanceAttribute(attributeLocation: number): void;
  113007. /**
  113008. * Disable the attribute corresponding to the location in parameter
  113009. * @param attributeLocation defines the attribute location of the attribute to disable
  113010. */
  113011. disableAttributeByIndex(attributeLocation: number): void;
  113012. /**
  113013. * Send a draw order
  113014. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  113015. * @param indexStart defines the starting index
  113016. * @param indexCount defines the number of index to draw
  113017. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113018. */
  113019. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  113020. /**
  113021. * Draw a list of points
  113022. * @param verticesStart defines the index of first vertex to draw
  113023. * @param verticesCount defines the count of vertices to draw
  113024. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113025. */
  113026. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113027. /**
  113028. * Draw a list of unindexed primitives
  113029. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  113030. * @param verticesStart defines the index of first vertex to draw
  113031. * @param verticesCount defines the count of vertices to draw
  113032. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113033. */
  113034. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113035. /**
  113036. * Draw a list of indexed primitives
  113037. * @param fillMode defines the primitive to use
  113038. * @param indexStart defines the starting index
  113039. * @param indexCount defines the number of index to draw
  113040. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113041. */
  113042. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  113043. /**
  113044. * Draw a list of unindexed primitives
  113045. * @param fillMode defines the primitive to use
  113046. * @param verticesStart defines the index of first vertex to draw
  113047. * @param verticesCount defines the count of vertices to draw
  113048. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113049. */
  113050. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113051. private _drawMode;
  113052. /** @hidden */
  113053. protected _reportDrawCall(): void;
  113054. /** @hidden */
  113055. _releaseEffect(effect: Effect): void;
  113056. /** @hidden */
  113057. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  113058. /**
  113059. * Create a new effect (used to store vertex/fragment shaders)
  113060. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  113061. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  113062. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  113063. * @param samplers defines an array of string used to represent textures
  113064. * @param defines defines the string containing the defines to use to compile the shaders
  113065. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  113066. * @param onCompiled defines a function to call when the effect creation is successful
  113067. * @param onError defines a function to call when the effect creation has failed
  113068. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  113069. * @returns the new Effect
  113070. */
  113071. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  113072. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  113073. private _compileShader;
  113074. private _compileRawShader;
  113075. /** @hidden */
  113076. _getShaderSource(shader: WebGLShader): Nullable<string>;
  113077. /**
  113078. * Directly creates a webGL program
  113079. * @param pipelineContext defines the pipeline context to attach to
  113080. * @param vertexCode defines the vertex shader code to use
  113081. * @param fragmentCode defines the fragment shader code to use
  113082. * @param context defines the webGL context to use (if not set, the current one will be used)
  113083. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  113084. * @returns the new webGL program
  113085. */
  113086. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  113087. /**
  113088. * Creates a webGL program
  113089. * @param pipelineContext defines the pipeline context to attach to
  113090. * @param vertexCode defines the vertex shader code to use
  113091. * @param fragmentCode defines the fragment shader code to use
  113092. * @param defines defines the string containing the defines to use to compile the shaders
  113093. * @param context defines the webGL context to use (if not set, the current one will be used)
  113094. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  113095. * @returns the new webGL program
  113096. */
  113097. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  113098. /**
  113099. * Creates a new pipeline context
  113100. * @returns the new pipeline
  113101. */
  113102. createPipelineContext(): IPipelineContext;
  113103. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  113104. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  113105. /** @hidden */
  113106. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  113107. /** @hidden */
  113108. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  113109. /** @hidden */
  113110. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  113111. /**
  113112. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  113113. * @param pipelineContext defines the pipeline context to use
  113114. * @param uniformsNames defines the list of uniform names
  113115. * @returns an array of webGL uniform locations
  113116. */
  113117. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  113118. /**
  113119. * Gets the lsit of active attributes for a given webGL program
  113120. * @param pipelineContext defines the pipeline context to use
  113121. * @param attributesNames defines the list of attribute names to get
  113122. * @returns an array of indices indicating the offset of each attribute
  113123. */
  113124. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  113125. /**
  113126. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  113127. * @param effect defines the effect to activate
  113128. */
  113129. enableEffect(effect: Nullable<Effect>): void;
  113130. /**
  113131. * Set the value of an uniform to a number (int)
  113132. * @param uniform defines the webGL uniform location where to store the value
  113133. * @param value defines the int number to store
  113134. */
  113135. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  113136. /**
  113137. * Set the value of an uniform to an array of int32
  113138. * @param uniform defines the webGL uniform location where to store the value
  113139. * @param array defines the array of int32 to store
  113140. */
  113141. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  113142. /**
  113143. * Set the value of an uniform to an array of int32 (stored as vec2)
  113144. * @param uniform defines the webGL uniform location where to store the value
  113145. * @param array defines the array of int32 to store
  113146. */
  113147. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  113148. /**
  113149. * Set the value of an uniform to an array of int32 (stored as vec3)
  113150. * @param uniform defines the webGL uniform location where to store the value
  113151. * @param array defines the array of int32 to store
  113152. */
  113153. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  113154. /**
  113155. * Set the value of an uniform to an array of int32 (stored as vec4)
  113156. * @param uniform defines the webGL uniform location where to store the value
  113157. * @param array defines the array of int32 to store
  113158. */
  113159. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  113160. /**
  113161. * Set the value of an uniform to an array of number
  113162. * @param uniform defines the webGL uniform location where to store the value
  113163. * @param array defines the array of number to store
  113164. */
  113165. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  113166. /**
  113167. * Set the value of an uniform to an array of number (stored as vec2)
  113168. * @param uniform defines the webGL uniform location where to store the value
  113169. * @param array defines the array of number to store
  113170. */
  113171. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  113172. /**
  113173. * Set the value of an uniform to an array of number (stored as vec3)
  113174. * @param uniform defines the webGL uniform location where to store the value
  113175. * @param array defines the array of number to store
  113176. */
  113177. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  113178. /**
  113179. * Set the value of an uniform to an array of number (stored as vec4)
  113180. * @param uniform defines the webGL uniform location where to store the value
  113181. * @param array defines the array of number to store
  113182. */
  113183. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  113184. /**
  113185. * Set the value of an uniform to an array of float32 (stored as matrices)
  113186. * @param uniform defines the webGL uniform location where to store the value
  113187. * @param matrices defines the array of float32 to store
  113188. */
  113189. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  113190. /**
  113191. * Set the value of an uniform to a matrix (3x3)
  113192. * @param uniform defines the webGL uniform location where to store the value
  113193. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  113194. */
  113195. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  113196. /**
  113197. * Set the value of an uniform to a matrix (2x2)
  113198. * @param uniform defines the webGL uniform location where to store the value
  113199. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  113200. */
  113201. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  113202. /**
  113203. * Set the value of an uniform to a number (float)
  113204. * @param uniform defines the webGL uniform location where to store the value
  113205. * @param value defines the float number to store
  113206. */
  113207. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  113208. /**
  113209. * Set the value of an uniform to a vec2
  113210. * @param uniform defines the webGL uniform location where to store the value
  113211. * @param x defines the 1st component of the value
  113212. * @param y defines the 2nd component of the value
  113213. */
  113214. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  113215. /**
  113216. * Set the value of an uniform to a vec3
  113217. * @param uniform defines the webGL uniform location where to store the value
  113218. * @param x defines the 1st component of the value
  113219. * @param y defines the 2nd component of the value
  113220. * @param z defines the 3rd component of the value
  113221. */
  113222. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  113223. /**
  113224. * Set the value of an uniform to a vec4
  113225. * @param uniform defines the webGL uniform location where to store the value
  113226. * @param x defines the 1st component of the value
  113227. * @param y defines the 2nd component of the value
  113228. * @param z defines the 3rd component of the value
  113229. * @param w defines the 4th component of the value
  113230. */
  113231. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  113232. /**
  113233. * Apply all cached states (depth, culling, stencil and alpha)
  113234. */
  113235. applyStates(): void;
  113236. /**
  113237. * Enable or disable color writing
  113238. * @param enable defines the state to set
  113239. */
  113240. setColorWrite(enable: boolean): void;
  113241. /**
  113242. * Gets a boolean indicating if color writing is enabled
  113243. * @returns the current color writing state
  113244. */
  113245. getColorWrite(): boolean;
  113246. /**
  113247. * Gets the depth culling state manager
  113248. */
  113249. get depthCullingState(): DepthCullingState;
  113250. /**
  113251. * Gets the alpha state manager
  113252. */
  113253. get alphaState(): AlphaState;
  113254. /**
  113255. * Gets the stencil state manager
  113256. */
  113257. get stencilState(): StencilState;
  113258. /**
  113259. * Clears the list of texture accessible through engine.
  113260. * This can help preventing texture load conflict due to name collision.
  113261. */
  113262. clearInternalTexturesCache(): void;
  113263. /**
  113264. * Force the entire cache to be cleared
  113265. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  113266. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  113267. */
  113268. wipeCaches(bruteForce?: boolean): void;
  113269. /** @hidden */
  113270. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  113271. min: number;
  113272. mag: number;
  113273. };
  113274. /** @hidden */
  113275. _createTexture(): WebGLTexture;
  113276. /**
  113277. * Usually called from Texture.ts.
  113278. * Passed information to create a WebGLTexture
  113279. * @param url defines a value which contains one of the following:
  113280. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  113281. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  113282. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  113283. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  113284. * @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)
  113285. * @param scene needed for loading to the correct scene
  113286. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  113287. * @param onLoad optional callback to be called upon successful completion
  113288. * @param onError optional callback to be called upon failure
  113289. * @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
  113290. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  113291. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  113292. * @param forcedExtension defines the extension to use to pick the right loader
  113293. * @param mimeType defines an optional mime type
  113294. * @returns a InternalTexture for assignment back into BABYLON.Texture
  113295. */
  113296. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  113297. /**
  113298. * Loads an image as an HTMLImageElement.
  113299. * @param input url string, ArrayBuffer, or Blob to load
  113300. * @param onLoad callback called when the image successfully loads
  113301. * @param onError callback called when the image fails to load
  113302. * @param offlineProvider offline provider for caching
  113303. * @param mimeType optional mime type
  113304. * @returns the HTMLImageElement of the loaded image
  113305. * @hidden
  113306. */
  113307. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  113308. /**
  113309. * @hidden
  113310. */
  113311. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  113312. private _unpackFlipYCached;
  113313. /**
  113314. * In case you are sharing the context with other applications, it might
  113315. * be interested to not cache the unpack flip y state to ensure a consistent
  113316. * value would be set.
  113317. */
  113318. enableUnpackFlipYCached: boolean;
  113319. /** @hidden */
  113320. _unpackFlipY(value: boolean): void;
  113321. /** @hidden */
  113322. _getUnpackAlignement(): number;
  113323. private _getTextureTarget;
  113324. /**
  113325. * Update the sampling mode of a given texture
  113326. * @param samplingMode defines the required sampling mode
  113327. * @param texture defines the texture to update
  113328. * @param generateMipMaps defines whether to generate mipmaps for the texture
  113329. */
  113330. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  113331. /**
  113332. * Update the sampling mode of a given texture
  113333. * @param texture defines the texture to update
  113334. * @param wrapU defines the texture wrap mode of the u coordinates
  113335. * @param wrapV defines the texture wrap mode of the v coordinates
  113336. * @param wrapR defines the texture wrap mode of the r coordinates
  113337. */
  113338. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  113339. /** @hidden */
  113340. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  113341. width: number;
  113342. height: number;
  113343. layers?: number;
  113344. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  113345. /** @hidden */
  113346. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113347. /** @hidden */
  113348. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  113349. /**
  113350. * Update a portion of an internal texture
  113351. * @param texture defines the texture to update
  113352. * @param imageData defines the data to store into the texture
  113353. * @param xOffset defines the x coordinates of the update rectangle
  113354. * @param yOffset defines the y coordinates of the update rectangle
  113355. * @param width defines the width of the update rectangle
  113356. * @param height defines the height of the update rectangle
  113357. * @param faceIndex defines the face index if texture is a cube (0 by default)
  113358. * @param lod defines the lod level to update (0 by default)
  113359. */
  113360. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  113361. /** @hidden */
  113362. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113363. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  113364. private _prepareWebGLTexture;
  113365. /** @hidden */
  113366. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  113367. private _getDepthStencilBuffer;
  113368. /** @hidden */
  113369. _releaseFramebufferObjects(texture: InternalTexture): void;
  113370. /** @hidden */
  113371. _releaseTexture(texture: InternalTexture): void;
  113372. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  113373. protected _setProgram(program: WebGLProgram): void;
  113374. protected _boundUniforms: {
  113375. [key: number]: WebGLUniformLocation;
  113376. };
  113377. /**
  113378. * Binds an effect to the webGL context
  113379. * @param effect defines the effect to bind
  113380. */
  113381. bindSamplers(effect: Effect): void;
  113382. private _activateCurrentTexture;
  113383. /** @hidden */
  113384. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  113385. /** @hidden */
  113386. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  113387. /**
  113388. * Unbind all textures from the webGL context
  113389. */
  113390. unbindAllTextures(): void;
  113391. /**
  113392. * Sets a texture to the according uniform.
  113393. * @param channel The texture channel
  113394. * @param uniform The uniform to set
  113395. * @param texture The texture to apply
  113396. */
  113397. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  113398. private _bindSamplerUniformToChannel;
  113399. private _getTextureWrapMode;
  113400. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  113401. /**
  113402. * Sets an array of texture to the webGL context
  113403. * @param channel defines the channel where the texture array must be set
  113404. * @param uniform defines the associated uniform location
  113405. * @param textures defines the array of textures to bind
  113406. */
  113407. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  113408. /** @hidden */
  113409. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  113410. private _setTextureParameterFloat;
  113411. private _setTextureParameterInteger;
  113412. /**
  113413. * Unbind all vertex attributes from the webGL context
  113414. */
  113415. unbindAllAttributes(): void;
  113416. /**
  113417. * 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
  113418. */
  113419. releaseEffects(): void;
  113420. /**
  113421. * Dispose and release all associated resources
  113422. */
  113423. dispose(): void;
  113424. /**
  113425. * Attach a new callback raised when context lost event is fired
  113426. * @param callback defines the callback to call
  113427. */
  113428. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  113429. /**
  113430. * Attach a new callback raised when context restored event is fired
  113431. * @param callback defines the callback to call
  113432. */
  113433. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  113434. /**
  113435. * Get the current error code of the webGL context
  113436. * @returns the error code
  113437. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  113438. */
  113439. getError(): number;
  113440. private _canRenderToFloatFramebuffer;
  113441. private _canRenderToHalfFloatFramebuffer;
  113442. private _canRenderToFramebuffer;
  113443. /** @hidden */
  113444. _getWebGLTextureType(type: number): number;
  113445. /** @hidden */
  113446. _getInternalFormat(format: number): number;
  113447. /** @hidden */
  113448. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  113449. /** @hidden */
  113450. _getRGBAMultiSampleBufferFormat(type: number): number;
  113451. /** @hidden */
  113452. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  113453. /**
  113454. * Loads a file from a url
  113455. * @param url url to load
  113456. * @param onSuccess callback called when the file successfully loads
  113457. * @param onProgress callback called while file is loading (if the server supports this mode)
  113458. * @param offlineProvider defines the offline provider for caching
  113459. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  113460. * @param onError callback called when the file fails to load
  113461. * @returns a file request object
  113462. * @hidden
  113463. */
  113464. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  113465. /**
  113466. * Reads pixels from the current frame buffer. Please note that this function can be slow
  113467. * @param x defines the x coordinate of the rectangle where pixels must be read
  113468. * @param y defines the y coordinate of the rectangle where pixels must be read
  113469. * @param width defines the width of the rectangle where pixels must be read
  113470. * @param height defines the height of the rectangle where pixels must be read
  113471. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  113472. * @returns a Uint8Array containing RGBA colors
  113473. */
  113474. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  113475. private static _isSupported;
  113476. /**
  113477. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  113478. * @returns true if the engine can be created
  113479. * @ignorenaming
  113480. */
  113481. static isSupported(): boolean;
  113482. /**
  113483. * Find the next highest power of two.
  113484. * @param x Number to start search from.
  113485. * @return Next highest power of two.
  113486. */
  113487. static CeilingPOT(x: number): number;
  113488. /**
  113489. * Find the next lowest power of two.
  113490. * @param x Number to start search from.
  113491. * @return Next lowest power of two.
  113492. */
  113493. static FloorPOT(x: number): number;
  113494. /**
  113495. * Find the nearest power of two.
  113496. * @param x Number to start search from.
  113497. * @return Next nearest power of two.
  113498. */
  113499. static NearestPOT(x: number): number;
  113500. /**
  113501. * Get the closest exponent of two
  113502. * @param value defines the value to approximate
  113503. * @param max defines the maximum value to return
  113504. * @param mode defines how to define the closest value
  113505. * @returns closest exponent of two of the given value
  113506. */
  113507. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  113508. /**
  113509. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  113510. * @param func - the function to be called
  113511. * @param requester - the object that will request the next frame. Falls back to window.
  113512. * @returns frame number
  113513. */
  113514. static QueueNewFrame(func: () => void, requester?: any): number;
  113515. /**
  113516. * Gets host document
  113517. * @returns the host document object
  113518. */
  113519. getHostDocument(): Nullable<Document>;
  113520. }
  113521. }
  113522. declare module BABYLON {
  113523. /**
  113524. * Class representing spherical harmonics coefficients to the 3rd degree
  113525. */
  113526. export class SphericalHarmonics {
  113527. /**
  113528. * Defines whether or not the harmonics have been prescaled for rendering.
  113529. */
  113530. preScaled: boolean;
  113531. /**
  113532. * The l0,0 coefficients of the spherical harmonics
  113533. */
  113534. l00: Vector3;
  113535. /**
  113536. * The l1,-1 coefficients of the spherical harmonics
  113537. */
  113538. l1_1: Vector3;
  113539. /**
  113540. * The l1,0 coefficients of the spherical harmonics
  113541. */
  113542. l10: Vector3;
  113543. /**
  113544. * The l1,1 coefficients of the spherical harmonics
  113545. */
  113546. l11: Vector3;
  113547. /**
  113548. * The l2,-2 coefficients of the spherical harmonics
  113549. */
  113550. l2_2: Vector3;
  113551. /**
  113552. * The l2,-1 coefficients of the spherical harmonics
  113553. */
  113554. l2_1: Vector3;
  113555. /**
  113556. * The l2,0 coefficients of the spherical harmonics
  113557. */
  113558. l20: Vector3;
  113559. /**
  113560. * The l2,1 coefficients of the spherical harmonics
  113561. */
  113562. l21: Vector3;
  113563. /**
  113564. * The l2,2 coefficients of the spherical harmonics
  113565. */
  113566. l22: Vector3;
  113567. /**
  113568. * Adds a light to the spherical harmonics
  113569. * @param direction the direction of the light
  113570. * @param color the color of the light
  113571. * @param deltaSolidAngle the delta solid angle of the light
  113572. */
  113573. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  113574. /**
  113575. * Scales the spherical harmonics by the given amount
  113576. * @param scale the amount to scale
  113577. */
  113578. scaleInPlace(scale: number): void;
  113579. /**
  113580. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  113581. *
  113582. * ```
  113583. * E_lm = A_l * L_lm
  113584. * ```
  113585. *
  113586. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  113587. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  113588. * the scaling factors are given in equation 9.
  113589. */
  113590. convertIncidentRadianceToIrradiance(): void;
  113591. /**
  113592. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  113593. *
  113594. * ```
  113595. * L = (1/pi) * E * rho
  113596. * ```
  113597. *
  113598. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  113599. */
  113600. convertIrradianceToLambertianRadiance(): void;
  113601. /**
  113602. * Integrates the reconstruction coefficients directly in to the SH preventing further
  113603. * required operations at run time.
  113604. *
  113605. * This is simply done by scaling back the SH with Ylm constants parameter.
  113606. * The trigonometric part being applied by the shader at run time.
  113607. */
  113608. preScaleForRendering(): void;
  113609. /**
  113610. * Constructs a spherical harmonics from an array.
  113611. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  113612. * @returns the spherical harmonics
  113613. */
  113614. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  113615. /**
  113616. * Gets the spherical harmonics from polynomial
  113617. * @param polynomial the spherical polynomial
  113618. * @returns the spherical harmonics
  113619. */
  113620. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  113621. }
  113622. /**
  113623. * Class representing spherical polynomial coefficients to the 3rd degree
  113624. */
  113625. export class SphericalPolynomial {
  113626. private _harmonics;
  113627. /**
  113628. * The spherical harmonics used to create the polynomials.
  113629. */
  113630. get preScaledHarmonics(): SphericalHarmonics;
  113631. /**
  113632. * The x coefficients of the spherical polynomial
  113633. */
  113634. x: Vector3;
  113635. /**
  113636. * The y coefficients of the spherical polynomial
  113637. */
  113638. y: Vector3;
  113639. /**
  113640. * The z coefficients of the spherical polynomial
  113641. */
  113642. z: Vector3;
  113643. /**
  113644. * The xx coefficients of the spherical polynomial
  113645. */
  113646. xx: Vector3;
  113647. /**
  113648. * The yy coefficients of the spherical polynomial
  113649. */
  113650. yy: Vector3;
  113651. /**
  113652. * The zz coefficients of the spherical polynomial
  113653. */
  113654. zz: Vector3;
  113655. /**
  113656. * The xy coefficients of the spherical polynomial
  113657. */
  113658. xy: Vector3;
  113659. /**
  113660. * The yz coefficients of the spherical polynomial
  113661. */
  113662. yz: Vector3;
  113663. /**
  113664. * The zx coefficients of the spherical polynomial
  113665. */
  113666. zx: Vector3;
  113667. /**
  113668. * Adds an ambient color to the spherical polynomial
  113669. * @param color the color to add
  113670. */
  113671. addAmbient(color: Color3): void;
  113672. /**
  113673. * Scales the spherical polynomial by the given amount
  113674. * @param scale the amount to scale
  113675. */
  113676. scaleInPlace(scale: number): void;
  113677. /**
  113678. * Gets the spherical polynomial from harmonics
  113679. * @param harmonics the spherical harmonics
  113680. * @returns the spherical polynomial
  113681. */
  113682. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  113683. /**
  113684. * Constructs a spherical polynomial from an array.
  113685. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  113686. * @returns the spherical polynomial
  113687. */
  113688. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  113689. }
  113690. }
  113691. declare module BABYLON {
  113692. /**
  113693. * Defines the source of the internal texture
  113694. */
  113695. export enum InternalTextureSource {
  113696. /**
  113697. * The source of the texture data is unknown
  113698. */
  113699. Unknown = 0,
  113700. /**
  113701. * Texture data comes from an URL
  113702. */
  113703. Url = 1,
  113704. /**
  113705. * Texture data is only used for temporary storage
  113706. */
  113707. Temp = 2,
  113708. /**
  113709. * Texture data comes from raw data (ArrayBuffer)
  113710. */
  113711. Raw = 3,
  113712. /**
  113713. * Texture content is dynamic (video or dynamic texture)
  113714. */
  113715. Dynamic = 4,
  113716. /**
  113717. * Texture content is generated by rendering to it
  113718. */
  113719. RenderTarget = 5,
  113720. /**
  113721. * Texture content is part of a multi render target process
  113722. */
  113723. MultiRenderTarget = 6,
  113724. /**
  113725. * Texture data comes from a cube data file
  113726. */
  113727. Cube = 7,
  113728. /**
  113729. * Texture data comes from a raw cube data
  113730. */
  113731. CubeRaw = 8,
  113732. /**
  113733. * Texture data come from a prefiltered cube data file
  113734. */
  113735. CubePrefiltered = 9,
  113736. /**
  113737. * Texture content is raw 3D data
  113738. */
  113739. Raw3D = 10,
  113740. /**
  113741. * Texture content is raw 2D array data
  113742. */
  113743. Raw2DArray = 11,
  113744. /**
  113745. * Texture content is a depth texture
  113746. */
  113747. Depth = 12,
  113748. /**
  113749. * Texture data comes from a raw cube data encoded with RGBD
  113750. */
  113751. CubeRawRGBD = 13
  113752. }
  113753. /**
  113754. * Class used to store data associated with WebGL texture data for the engine
  113755. * This class should not be used directly
  113756. */
  113757. export class InternalTexture {
  113758. /** @hidden */
  113759. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  113760. /**
  113761. * Defines if the texture is ready
  113762. */
  113763. isReady: boolean;
  113764. /**
  113765. * Defines if the texture is a cube texture
  113766. */
  113767. isCube: boolean;
  113768. /**
  113769. * Defines if the texture contains 3D data
  113770. */
  113771. is3D: boolean;
  113772. /**
  113773. * Defines if the texture contains 2D array data
  113774. */
  113775. is2DArray: boolean;
  113776. /**
  113777. * Defines if the texture contains multiview data
  113778. */
  113779. isMultiview: boolean;
  113780. /**
  113781. * Gets the URL used to load this texture
  113782. */
  113783. url: string;
  113784. /**
  113785. * Gets the sampling mode of the texture
  113786. */
  113787. samplingMode: number;
  113788. /**
  113789. * Gets a boolean indicating if the texture needs mipmaps generation
  113790. */
  113791. generateMipMaps: boolean;
  113792. /**
  113793. * Gets the number of samples used by the texture (WebGL2+ only)
  113794. */
  113795. samples: number;
  113796. /**
  113797. * Gets the type of the texture (int, float...)
  113798. */
  113799. type: number;
  113800. /**
  113801. * Gets the format of the texture (RGB, RGBA...)
  113802. */
  113803. format: number;
  113804. /**
  113805. * Observable called when the texture is loaded
  113806. */
  113807. onLoadedObservable: Observable<InternalTexture>;
  113808. /**
  113809. * Gets the width of the texture
  113810. */
  113811. width: number;
  113812. /**
  113813. * Gets the height of the texture
  113814. */
  113815. height: number;
  113816. /**
  113817. * Gets the depth of the texture
  113818. */
  113819. depth: number;
  113820. /**
  113821. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  113822. */
  113823. baseWidth: number;
  113824. /**
  113825. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  113826. */
  113827. baseHeight: number;
  113828. /**
  113829. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  113830. */
  113831. baseDepth: number;
  113832. /**
  113833. * Gets a boolean indicating if the texture is inverted on Y axis
  113834. */
  113835. invertY: boolean;
  113836. /** @hidden */
  113837. _invertVScale: boolean;
  113838. /** @hidden */
  113839. _associatedChannel: number;
  113840. /** @hidden */
  113841. _source: InternalTextureSource;
  113842. /** @hidden */
  113843. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  113844. /** @hidden */
  113845. _bufferView: Nullable<ArrayBufferView>;
  113846. /** @hidden */
  113847. _bufferViewArray: Nullable<ArrayBufferView[]>;
  113848. /** @hidden */
  113849. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  113850. /** @hidden */
  113851. _size: number;
  113852. /** @hidden */
  113853. _extension: string;
  113854. /** @hidden */
  113855. _files: Nullable<string[]>;
  113856. /** @hidden */
  113857. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  113858. /** @hidden */
  113859. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  113860. /** @hidden */
  113861. _framebuffer: Nullable<WebGLFramebuffer>;
  113862. /** @hidden */
  113863. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  113864. /** @hidden */
  113865. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  113866. /** @hidden */
  113867. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  113868. /** @hidden */
  113869. _attachments: Nullable<number[]>;
  113870. /** @hidden */
  113871. _textureArray: Nullable<InternalTexture[]>;
  113872. /** @hidden */
  113873. _cachedCoordinatesMode: Nullable<number>;
  113874. /** @hidden */
  113875. _cachedWrapU: Nullable<number>;
  113876. /** @hidden */
  113877. _cachedWrapV: Nullable<number>;
  113878. /** @hidden */
  113879. _cachedWrapR: Nullable<number>;
  113880. /** @hidden */
  113881. _cachedAnisotropicFilteringLevel: Nullable<number>;
  113882. /** @hidden */
  113883. _isDisabled: boolean;
  113884. /** @hidden */
  113885. _compression: Nullable<string>;
  113886. /** @hidden */
  113887. _generateStencilBuffer: boolean;
  113888. /** @hidden */
  113889. _generateDepthBuffer: boolean;
  113890. /** @hidden */
  113891. _comparisonFunction: number;
  113892. /** @hidden */
  113893. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  113894. /** @hidden */
  113895. _lodGenerationScale: number;
  113896. /** @hidden */
  113897. _lodGenerationOffset: number;
  113898. /** @hidden */
  113899. _depthStencilTexture: Nullable<InternalTexture>;
  113900. /** @hidden */
  113901. _colorTextureArray: Nullable<WebGLTexture>;
  113902. /** @hidden */
  113903. _depthStencilTextureArray: Nullable<WebGLTexture>;
  113904. /** @hidden */
  113905. _lodTextureHigh: Nullable<BaseTexture>;
  113906. /** @hidden */
  113907. _lodTextureMid: Nullable<BaseTexture>;
  113908. /** @hidden */
  113909. _lodTextureLow: Nullable<BaseTexture>;
  113910. /** @hidden */
  113911. _isRGBD: boolean;
  113912. /** @hidden */
  113913. _linearSpecularLOD: boolean;
  113914. /** @hidden */
  113915. _irradianceTexture: Nullable<BaseTexture>;
  113916. /** @hidden */
  113917. _webGLTexture: Nullable<WebGLTexture>;
  113918. /** @hidden */
  113919. _references: number;
  113920. private _engine;
  113921. /**
  113922. * Gets the Engine the texture belongs to.
  113923. * @returns The babylon engine
  113924. */
  113925. getEngine(): ThinEngine;
  113926. /**
  113927. * Gets the data source type of the texture
  113928. */
  113929. get source(): InternalTextureSource;
  113930. /**
  113931. * Creates a new InternalTexture
  113932. * @param engine defines the engine to use
  113933. * @param source defines the type of data that will be used
  113934. * @param delayAllocation if the texture allocation should be delayed (default: false)
  113935. */
  113936. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  113937. /**
  113938. * Increments the number of references (ie. the number of Texture that point to it)
  113939. */
  113940. incrementReferences(): void;
  113941. /**
  113942. * Change the size of the texture (not the size of the content)
  113943. * @param width defines the new width
  113944. * @param height defines the new height
  113945. * @param depth defines the new depth (1 by default)
  113946. */
  113947. updateSize(width: int, height: int, depth?: int): void;
  113948. /** @hidden */
  113949. _rebuild(): void;
  113950. /** @hidden */
  113951. _swapAndDie(target: InternalTexture): void;
  113952. /**
  113953. * Dispose the current allocated resources
  113954. */
  113955. dispose(): void;
  113956. }
  113957. }
  113958. declare module BABYLON {
  113959. /**
  113960. * Class used to work with sound analyzer using fast fourier transform (FFT)
  113961. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  113962. */
  113963. export class Analyser {
  113964. /**
  113965. * Gets or sets the smoothing
  113966. * @ignorenaming
  113967. */
  113968. SMOOTHING: number;
  113969. /**
  113970. * Gets or sets the FFT table size
  113971. * @ignorenaming
  113972. */
  113973. FFT_SIZE: number;
  113974. /**
  113975. * Gets or sets the bar graph amplitude
  113976. * @ignorenaming
  113977. */
  113978. BARGRAPHAMPLITUDE: number;
  113979. /**
  113980. * Gets or sets the position of the debug canvas
  113981. * @ignorenaming
  113982. */
  113983. DEBUGCANVASPOS: {
  113984. x: number;
  113985. y: number;
  113986. };
  113987. /**
  113988. * Gets or sets the debug canvas size
  113989. * @ignorenaming
  113990. */
  113991. DEBUGCANVASSIZE: {
  113992. width: number;
  113993. height: number;
  113994. };
  113995. private _byteFreqs;
  113996. private _byteTime;
  113997. private _floatFreqs;
  113998. private _webAudioAnalyser;
  113999. private _debugCanvas;
  114000. private _debugCanvasContext;
  114001. private _scene;
  114002. private _registerFunc;
  114003. private _audioEngine;
  114004. /**
  114005. * Creates a new analyser
  114006. * @param scene defines hosting scene
  114007. */
  114008. constructor(scene: Scene);
  114009. /**
  114010. * Get the number of data values you will have to play with for the visualization
  114011. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  114012. * @returns a number
  114013. */
  114014. getFrequencyBinCount(): number;
  114015. /**
  114016. * Gets the current frequency data as a byte array
  114017. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  114018. * @returns a Uint8Array
  114019. */
  114020. getByteFrequencyData(): Uint8Array;
  114021. /**
  114022. * Gets the current waveform as a byte array
  114023. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  114024. * @returns a Uint8Array
  114025. */
  114026. getByteTimeDomainData(): Uint8Array;
  114027. /**
  114028. * Gets the current frequency data as a float array
  114029. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  114030. * @returns a Float32Array
  114031. */
  114032. getFloatFrequencyData(): Float32Array;
  114033. /**
  114034. * Renders the debug canvas
  114035. */
  114036. drawDebugCanvas(): void;
  114037. /**
  114038. * Stops rendering the debug canvas and removes it
  114039. */
  114040. stopDebugCanvas(): void;
  114041. /**
  114042. * Connects two audio nodes
  114043. * @param inputAudioNode defines first node to connect
  114044. * @param outputAudioNode defines second node to connect
  114045. */
  114046. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  114047. /**
  114048. * Releases all associated resources
  114049. */
  114050. dispose(): void;
  114051. }
  114052. }
  114053. declare module BABYLON {
  114054. /**
  114055. * This represents an audio engine and it is responsible
  114056. * to play, synchronize and analyse sounds throughout the application.
  114057. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  114058. */
  114059. export interface IAudioEngine extends IDisposable {
  114060. /**
  114061. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  114062. */
  114063. readonly canUseWebAudio: boolean;
  114064. /**
  114065. * Gets the current AudioContext if available.
  114066. */
  114067. readonly audioContext: Nullable<AudioContext>;
  114068. /**
  114069. * The master gain node defines the global audio volume of your audio engine.
  114070. */
  114071. readonly masterGain: GainNode;
  114072. /**
  114073. * Gets whether or not mp3 are supported by your browser.
  114074. */
  114075. readonly isMP3supported: boolean;
  114076. /**
  114077. * Gets whether or not ogg are supported by your browser.
  114078. */
  114079. readonly isOGGsupported: boolean;
  114080. /**
  114081. * Defines if Babylon should emit a warning if WebAudio is not supported.
  114082. * @ignoreNaming
  114083. */
  114084. WarnedWebAudioUnsupported: boolean;
  114085. /**
  114086. * Defines if the audio engine relies on a custom unlocked button.
  114087. * In this case, the embedded button will not be displayed.
  114088. */
  114089. useCustomUnlockedButton: boolean;
  114090. /**
  114091. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  114092. */
  114093. readonly unlocked: boolean;
  114094. /**
  114095. * Event raised when audio has been unlocked on the browser.
  114096. */
  114097. onAudioUnlockedObservable: Observable<AudioEngine>;
  114098. /**
  114099. * Event raised when audio has been locked on the browser.
  114100. */
  114101. onAudioLockedObservable: Observable<AudioEngine>;
  114102. /**
  114103. * Flags the audio engine in Locked state.
  114104. * This happens due to new browser policies preventing audio to autoplay.
  114105. */
  114106. lock(): void;
  114107. /**
  114108. * Unlocks the audio engine once a user action has been done on the dom.
  114109. * This is helpful to resume play once browser policies have been satisfied.
  114110. */
  114111. unlock(): void;
  114112. /**
  114113. * Gets the global volume sets on the master gain.
  114114. * @returns the global volume if set or -1 otherwise
  114115. */
  114116. getGlobalVolume(): number;
  114117. /**
  114118. * Sets the global volume of your experience (sets on the master gain).
  114119. * @param newVolume Defines the new global volume of the application
  114120. */
  114121. setGlobalVolume(newVolume: number): void;
  114122. /**
  114123. * Connect the audio engine to an audio analyser allowing some amazing
  114124. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  114125. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  114126. * @param analyser The analyser to connect to the engine
  114127. */
  114128. connectToAnalyser(analyser: Analyser): void;
  114129. }
  114130. /**
  114131. * This represents the default audio engine used in babylon.
  114132. * It is responsible to play, synchronize and analyse sounds throughout the application.
  114133. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  114134. */
  114135. export class AudioEngine implements IAudioEngine {
  114136. private _audioContext;
  114137. private _audioContextInitialized;
  114138. private _muteButton;
  114139. private _hostElement;
  114140. /**
  114141. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  114142. */
  114143. canUseWebAudio: boolean;
  114144. /**
  114145. * The master gain node defines the global audio volume of your audio engine.
  114146. */
  114147. masterGain: GainNode;
  114148. /**
  114149. * Defines if Babylon should emit a warning if WebAudio is not supported.
  114150. * @ignoreNaming
  114151. */
  114152. WarnedWebAudioUnsupported: boolean;
  114153. /**
  114154. * Gets whether or not mp3 are supported by your browser.
  114155. */
  114156. isMP3supported: boolean;
  114157. /**
  114158. * Gets whether or not ogg are supported by your browser.
  114159. */
  114160. isOGGsupported: boolean;
  114161. /**
  114162. * Gets whether audio has been unlocked on the device.
  114163. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  114164. * a user interaction has happened.
  114165. */
  114166. unlocked: boolean;
  114167. /**
  114168. * Defines if the audio engine relies on a custom unlocked button.
  114169. * In this case, the embedded button will not be displayed.
  114170. */
  114171. useCustomUnlockedButton: boolean;
  114172. /**
  114173. * Event raised when audio has been unlocked on the browser.
  114174. */
  114175. onAudioUnlockedObservable: Observable<AudioEngine>;
  114176. /**
  114177. * Event raised when audio has been locked on the browser.
  114178. */
  114179. onAudioLockedObservable: Observable<AudioEngine>;
  114180. /**
  114181. * Gets the current AudioContext if available.
  114182. */
  114183. get audioContext(): Nullable<AudioContext>;
  114184. private _connectedAnalyser;
  114185. /**
  114186. * Instantiates a new audio engine.
  114187. *
  114188. * There should be only one per page as some browsers restrict the number
  114189. * of audio contexts you can create.
  114190. * @param hostElement defines the host element where to display the mute icon if necessary
  114191. */
  114192. constructor(hostElement?: Nullable<HTMLElement>);
  114193. /**
  114194. * Flags the audio engine in Locked state.
  114195. * This happens due to new browser policies preventing audio to autoplay.
  114196. */
  114197. lock(): void;
  114198. /**
  114199. * Unlocks the audio engine once a user action has been done on the dom.
  114200. * This is helpful to resume play once browser policies have been satisfied.
  114201. */
  114202. unlock(): void;
  114203. private _resumeAudioContext;
  114204. private _initializeAudioContext;
  114205. private _tryToRun;
  114206. private _triggerRunningState;
  114207. private _triggerSuspendedState;
  114208. private _displayMuteButton;
  114209. private _moveButtonToTopLeft;
  114210. private _onResize;
  114211. private _hideMuteButton;
  114212. /**
  114213. * Destroy and release the resources associated with the audio ccontext.
  114214. */
  114215. dispose(): void;
  114216. /**
  114217. * Gets the global volume sets on the master gain.
  114218. * @returns the global volume if set or -1 otherwise
  114219. */
  114220. getGlobalVolume(): number;
  114221. /**
  114222. * Sets the global volume of your experience (sets on the master gain).
  114223. * @param newVolume Defines the new global volume of the application
  114224. */
  114225. setGlobalVolume(newVolume: number): void;
  114226. /**
  114227. * Connect the audio engine to an audio analyser allowing some amazing
  114228. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  114229. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  114230. * @param analyser The analyser to connect to the engine
  114231. */
  114232. connectToAnalyser(analyser: Analyser): void;
  114233. }
  114234. }
  114235. declare module BABYLON {
  114236. /**
  114237. * Interface used to present a loading screen while loading a scene
  114238. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114239. */
  114240. export interface ILoadingScreen {
  114241. /**
  114242. * Function called to display the loading screen
  114243. */
  114244. displayLoadingUI: () => void;
  114245. /**
  114246. * Function called to hide the loading screen
  114247. */
  114248. hideLoadingUI: () => void;
  114249. /**
  114250. * Gets or sets the color to use for the background
  114251. */
  114252. loadingUIBackgroundColor: string;
  114253. /**
  114254. * Gets or sets the text to display while loading
  114255. */
  114256. loadingUIText: string;
  114257. }
  114258. /**
  114259. * Class used for the default loading screen
  114260. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114261. */
  114262. export class DefaultLoadingScreen implements ILoadingScreen {
  114263. private _renderingCanvas;
  114264. private _loadingText;
  114265. private _loadingDivBackgroundColor;
  114266. private _loadingDiv;
  114267. private _loadingTextDiv;
  114268. /** Gets or sets the logo url to use for the default loading screen */
  114269. static DefaultLogoUrl: string;
  114270. /** Gets or sets the spinner url to use for the default loading screen */
  114271. static DefaultSpinnerUrl: string;
  114272. /**
  114273. * Creates a new default loading screen
  114274. * @param _renderingCanvas defines the canvas used to render the scene
  114275. * @param _loadingText defines the default text to display
  114276. * @param _loadingDivBackgroundColor defines the default background color
  114277. */
  114278. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  114279. /**
  114280. * Function called to display the loading screen
  114281. */
  114282. displayLoadingUI(): void;
  114283. /**
  114284. * Function called to hide the loading screen
  114285. */
  114286. hideLoadingUI(): void;
  114287. /**
  114288. * Gets or sets the text to display while loading
  114289. */
  114290. set loadingUIText(text: string);
  114291. get loadingUIText(): string;
  114292. /**
  114293. * Gets or sets the color to use for the background
  114294. */
  114295. get loadingUIBackgroundColor(): string;
  114296. set loadingUIBackgroundColor(color: string);
  114297. private _resizeLoadingUI;
  114298. }
  114299. }
  114300. declare module BABYLON {
  114301. /**
  114302. * Interface for any object that can request an animation frame
  114303. */
  114304. export interface ICustomAnimationFrameRequester {
  114305. /**
  114306. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  114307. */
  114308. renderFunction?: Function;
  114309. /**
  114310. * Called to request the next frame to render to
  114311. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  114312. */
  114313. requestAnimationFrame: Function;
  114314. /**
  114315. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  114316. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  114317. */
  114318. requestID?: number;
  114319. }
  114320. }
  114321. declare module BABYLON {
  114322. /**
  114323. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  114324. */
  114325. export class PerformanceMonitor {
  114326. private _enabled;
  114327. private _rollingFrameTime;
  114328. private _lastFrameTimeMs;
  114329. /**
  114330. * constructor
  114331. * @param frameSampleSize The number of samples required to saturate the sliding window
  114332. */
  114333. constructor(frameSampleSize?: number);
  114334. /**
  114335. * Samples current frame
  114336. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  114337. */
  114338. sampleFrame(timeMs?: number): void;
  114339. /**
  114340. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  114341. */
  114342. get averageFrameTime(): number;
  114343. /**
  114344. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  114345. */
  114346. get averageFrameTimeVariance(): number;
  114347. /**
  114348. * Returns the frame time of the most recent frame
  114349. */
  114350. get instantaneousFrameTime(): number;
  114351. /**
  114352. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  114353. */
  114354. get averageFPS(): number;
  114355. /**
  114356. * Returns the average framerate in frames per second using the most recent frame time
  114357. */
  114358. get instantaneousFPS(): number;
  114359. /**
  114360. * Returns true if enough samples have been taken to completely fill the sliding window
  114361. */
  114362. get isSaturated(): boolean;
  114363. /**
  114364. * Enables contributions to the sliding window sample set
  114365. */
  114366. enable(): void;
  114367. /**
  114368. * Disables contributions to the sliding window sample set
  114369. * Samples will not be interpolated over the disabled period
  114370. */
  114371. disable(): void;
  114372. /**
  114373. * Returns true if sampling is enabled
  114374. */
  114375. get isEnabled(): boolean;
  114376. /**
  114377. * Resets performance monitor
  114378. */
  114379. reset(): void;
  114380. }
  114381. /**
  114382. * RollingAverage
  114383. *
  114384. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  114385. */
  114386. export class RollingAverage {
  114387. /**
  114388. * Current average
  114389. */
  114390. average: number;
  114391. /**
  114392. * Current variance
  114393. */
  114394. variance: number;
  114395. protected _samples: Array<number>;
  114396. protected _sampleCount: number;
  114397. protected _pos: number;
  114398. protected _m2: number;
  114399. /**
  114400. * constructor
  114401. * @param length The number of samples required to saturate the sliding window
  114402. */
  114403. constructor(length: number);
  114404. /**
  114405. * Adds a sample to the sample set
  114406. * @param v The sample value
  114407. */
  114408. add(v: number): void;
  114409. /**
  114410. * Returns previously added values or null if outside of history or outside the sliding window domain
  114411. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  114412. * @return Value previously recorded with add() or null if outside of range
  114413. */
  114414. history(i: number): number;
  114415. /**
  114416. * Returns true if enough samples have been taken to completely fill the sliding window
  114417. * @return true if sample-set saturated
  114418. */
  114419. isSaturated(): boolean;
  114420. /**
  114421. * Resets the rolling average (equivalent to 0 samples taken so far)
  114422. */
  114423. reset(): void;
  114424. /**
  114425. * Wraps a value around the sample range boundaries
  114426. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  114427. * @return Wrapped position in sample range
  114428. */
  114429. protected _wrapPosition(i: number): number;
  114430. }
  114431. }
  114432. declare module BABYLON {
  114433. /**
  114434. * This class is used to track a performance counter which is number based.
  114435. * The user has access to many properties which give statistics of different nature.
  114436. *
  114437. * The implementer can track two kinds of Performance Counter: time and count.
  114438. * 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.
  114439. * 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.
  114440. */
  114441. export class PerfCounter {
  114442. /**
  114443. * Gets or sets a global boolean to turn on and off all the counters
  114444. */
  114445. static Enabled: boolean;
  114446. /**
  114447. * Returns the smallest value ever
  114448. */
  114449. get min(): number;
  114450. /**
  114451. * Returns the biggest value ever
  114452. */
  114453. get max(): number;
  114454. /**
  114455. * Returns the average value since the performance counter is running
  114456. */
  114457. get average(): number;
  114458. /**
  114459. * Returns the average value of the last second the counter was monitored
  114460. */
  114461. get lastSecAverage(): number;
  114462. /**
  114463. * Returns the current value
  114464. */
  114465. get current(): number;
  114466. /**
  114467. * Gets the accumulated total
  114468. */
  114469. get total(): number;
  114470. /**
  114471. * Gets the total value count
  114472. */
  114473. get count(): number;
  114474. /**
  114475. * Creates a new counter
  114476. */
  114477. constructor();
  114478. /**
  114479. * Call this method to start monitoring a new frame.
  114480. * 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.
  114481. */
  114482. fetchNewFrame(): void;
  114483. /**
  114484. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  114485. * @param newCount the count value to add to the monitored count
  114486. * @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.
  114487. */
  114488. addCount(newCount: number, fetchResult: boolean): void;
  114489. /**
  114490. * Start monitoring this performance counter
  114491. */
  114492. beginMonitoring(): void;
  114493. /**
  114494. * Compute the time lapsed since the previous beginMonitoring() call.
  114495. * @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
  114496. */
  114497. endMonitoring(newFrame?: boolean): void;
  114498. private _fetchResult;
  114499. private _startMonitoringTime;
  114500. private _min;
  114501. private _max;
  114502. private _average;
  114503. private _current;
  114504. private _totalValueCount;
  114505. private _totalAccumulated;
  114506. private _lastSecAverage;
  114507. private _lastSecAccumulated;
  114508. private _lastSecTime;
  114509. private _lastSecValueCount;
  114510. }
  114511. }
  114512. declare module BABYLON {
  114513. interface ThinEngine {
  114514. /**
  114515. * Sets alpha constants used by some alpha blending modes
  114516. * @param r defines the red component
  114517. * @param g defines the green component
  114518. * @param b defines the blue component
  114519. * @param a defines the alpha component
  114520. */
  114521. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  114522. /**
  114523. * Sets the current alpha mode
  114524. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  114525. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  114526. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114527. */
  114528. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  114529. /**
  114530. * Gets the current alpha mode
  114531. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114532. * @returns the current alpha mode
  114533. */
  114534. getAlphaMode(): number;
  114535. /**
  114536. * Sets the current alpha equation
  114537. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  114538. */
  114539. setAlphaEquation(equation: number): void;
  114540. /**
  114541. * Gets the current alpha equation.
  114542. * @returns the current alpha equation
  114543. */
  114544. getAlphaEquation(): number;
  114545. }
  114546. }
  114547. declare module BABYLON {
  114548. interface ThinEngine {
  114549. /** @hidden */
  114550. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  114551. }
  114552. }
  114553. declare module BABYLON {
  114554. /**
  114555. * Defines the interface used by display changed events
  114556. */
  114557. export interface IDisplayChangedEventArgs {
  114558. /** Gets the vrDisplay object (if any) */
  114559. vrDisplay: Nullable<any>;
  114560. /** Gets a boolean indicating if webVR is supported */
  114561. vrSupported: boolean;
  114562. }
  114563. /**
  114564. * Defines the interface used by objects containing a viewport (like a camera)
  114565. */
  114566. interface IViewportOwnerLike {
  114567. /**
  114568. * Gets or sets the viewport
  114569. */
  114570. viewport: IViewportLike;
  114571. }
  114572. /**
  114573. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  114574. */
  114575. export class Engine extends ThinEngine {
  114576. /** Defines that alpha blending is disabled */
  114577. static readonly ALPHA_DISABLE: number;
  114578. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  114579. static readonly ALPHA_ADD: number;
  114580. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  114581. static readonly ALPHA_COMBINE: number;
  114582. /** Defines that alpha blending to DEST - SRC * DEST */
  114583. static readonly ALPHA_SUBTRACT: number;
  114584. /** Defines that alpha blending to SRC * DEST */
  114585. static readonly ALPHA_MULTIPLY: number;
  114586. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  114587. static readonly ALPHA_MAXIMIZED: number;
  114588. /** Defines that alpha blending to SRC + DEST */
  114589. static readonly ALPHA_ONEONE: number;
  114590. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  114591. static readonly ALPHA_PREMULTIPLIED: number;
  114592. /**
  114593. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  114594. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  114595. */
  114596. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  114597. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  114598. static readonly ALPHA_INTERPOLATE: number;
  114599. /**
  114600. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  114601. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  114602. */
  114603. static readonly ALPHA_SCREENMODE: number;
  114604. /** Defines that the ressource is not delayed*/
  114605. static readonly DELAYLOADSTATE_NONE: number;
  114606. /** Defines that the ressource was successfully delay loaded */
  114607. static readonly DELAYLOADSTATE_LOADED: number;
  114608. /** Defines that the ressource is currently delay loading */
  114609. static readonly DELAYLOADSTATE_LOADING: number;
  114610. /** Defines that the ressource is delayed and has not started loading */
  114611. static readonly DELAYLOADSTATE_NOTLOADED: number;
  114612. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  114613. static readonly NEVER: number;
  114614. /** 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 */
  114615. static readonly ALWAYS: number;
  114616. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  114617. static readonly LESS: number;
  114618. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  114619. static readonly EQUAL: number;
  114620. /** 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 */
  114621. static readonly LEQUAL: number;
  114622. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  114623. static readonly GREATER: number;
  114624. /** 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 */
  114625. static readonly GEQUAL: number;
  114626. /** 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 */
  114627. static readonly NOTEQUAL: number;
  114628. /** Passed to stencilOperation to specify that stencil value must be kept */
  114629. static readonly KEEP: number;
  114630. /** Passed to stencilOperation to specify that stencil value must be replaced */
  114631. static readonly REPLACE: number;
  114632. /** Passed to stencilOperation to specify that stencil value must be incremented */
  114633. static readonly INCR: number;
  114634. /** Passed to stencilOperation to specify that stencil value must be decremented */
  114635. static readonly DECR: number;
  114636. /** Passed to stencilOperation to specify that stencil value must be inverted */
  114637. static readonly INVERT: number;
  114638. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  114639. static readonly INCR_WRAP: number;
  114640. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  114641. static readonly DECR_WRAP: number;
  114642. /** Texture is not repeating outside of 0..1 UVs */
  114643. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  114644. /** Texture is repeating outside of 0..1 UVs */
  114645. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  114646. /** Texture is repeating and mirrored */
  114647. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  114648. /** ALPHA */
  114649. static readonly TEXTUREFORMAT_ALPHA: number;
  114650. /** LUMINANCE */
  114651. static readonly TEXTUREFORMAT_LUMINANCE: number;
  114652. /** LUMINANCE_ALPHA */
  114653. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  114654. /** RGB */
  114655. static readonly TEXTUREFORMAT_RGB: number;
  114656. /** RGBA */
  114657. static readonly TEXTUREFORMAT_RGBA: number;
  114658. /** RED */
  114659. static readonly TEXTUREFORMAT_RED: number;
  114660. /** RED (2nd reference) */
  114661. static readonly TEXTUREFORMAT_R: number;
  114662. /** RG */
  114663. static readonly TEXTUREFORMAT_RG: number;
  114664. /** RED_INTEGER */
  114665. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  114666. /** RED_INTEGER (2nd reference) */
  114667. static readonly TEXTUREFORMAT_R_INTEGER: number;
  114668. /** RG_INTEGER */
  114669. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  114670. /** RGB_INTEGER */
  114671. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  114672. /** RGBA_INTEGER */
  114673. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  114674. /** UNSIGNED_BYTE */
  114675. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  114676. /** UNSIGNED_BYTE (2nd reference) */
  114677. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  114678. /** FLOAT */
  114679. static readonly TEXTURETYPE_FLOAT: number;
  114680. /** HALF_FLOAT */
  114681. static readonly TEXTURETYPE_HALF_FLOAT: number;
  114682. /** BYTE */
  114683. static readonly TEXTURETYPE_BYTE: number;
  114684. /** SHORT */
  114685. static readonly TEXTURETYPE_SHORT: number;
  114686. /** UNSIGNED_SHORT */
  114687. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  114688. /** INT */
  114689. static readonly TEXTURETYPE_INT: number;
  114690. /** UNSIGNED_INT */
  114691. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  114692. /** UNSIGNED_SHORT_4_4_4_4 */
  114693. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  114694. /** UNSIGNED_SHORT_5_5_5_1 */
  114695. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  114696. /** UNSIGNED_SHORT_5_6_5 */
  114697. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  114698. /** UNSIGNED_INT_2_10_10_10_REV */
  114699. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  114700. /** UNSIGNED_INT_24_8 */
  114701. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  114702. /** UNSIGNED_INT_10F_11F_11F_REV */
  114703. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  114704. /** UNSIGNED_INT_5_9_9_9_REV */
  114705. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  114706. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  114707. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  114708. /** nearest is mag = nearest and min = nearest and mip = linear */
  114709. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  114710. /** Bilinear is mag = linear and min = linear and mip = nearest */
  114711. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  114712. /** Trilinear is mag = linear and min = linear and mip = linear */
  114713. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  114714. /** nearest is mag = nearest and min = nearest and mip = linear */
  114715. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  114716. /** Bilinear is mag = linear and min = linear and mip = nearest */
  114717. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  114718. /** Trilinear is mag = linear and min = linear and mip = linear */
  114719. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  114720. /** mag = nearest and min = nearest and mip = nearest */
  114721. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  114722. /** mag = nearest and min = linear and mip = nearest */
  114723. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  114724. /** mag = nearest and min = linear and mip = linear */
  114725. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  114726. /** mag = nearest and min = linear and mip = none */
  114727. static readonly TEXTURE_NEAREST_LINEAR: number;
  114728. /** mag = nearest and min = nearest and mip = none */
  114729. static readonly TEXTURE_NEAREST_NEAREST: number;
  114730. /** mag = linear and min = nearest and mip = nearest */
  114731. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  114732. /** mag = linear and min = nearest and mip = linear */
  114733. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  114734. /** mag = linear and min = linear and mip = none */
  114735. static readonly TEXTURE_LINEAR_LINEAR: number;
  114736. /** mag = linear and min = nearest and mip = none */
  114737. static readonly TEXTURE_LINEAR_NEAREST: number;
  114738. /** Explicit coordinates mode */
  114739. static readonly TEXTURE_EXPLICIT_MODE: number;
  114740. /** Spherical coordinates mode */
  114741. static readonly TEXTURE_SPHERICAL_MODE: number;
  114742. /** Planar coordinates mode */
  114743. static readonly TEXTURE_PLANAR_MODE: number;
  114744. /** Cubic coordinates mode */
  114745. static readonly TEXTURE_CUBIC_MODE: number;
  114746. /** Projection coordinates mode */
  114747. static readonly TEXTURE_PROJECTION_MODE: number;
  114748. /** Skybox coordinates mode */
  114749. static readonly TEXTURE_SKYBOX_MODE: number;
  114750. /** Inverse Cubic coordinates mode */
  114751. static readonly TEXTURE_INVCUBIC_MODE: number;
  114752. /** Equirectangular coordinates mode */
  114753. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  114754. /** Equirectangular Fixed coordinates mode */
  114755. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  114756. /** Equirectangular Fixed Mirrored coordinates mode */
  114757. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  114758. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  114759. static readonly SCALEMODE_FLOOR: number;
  114760. /** Defines that texture rescaling will look for the nearest power of 2 size */
  114761. static readonly SCALEMODE_NEAREST: number;
  114762. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  114763. static readonly SCALEMODE_CEILING: number;
  114764. /**
  114765. * Returns the current npm package of the sdk
  114766. */
  114767. static get NpmPackage(): string;
  114768. /**
  114769. * Returns the current version of the framework
  114770. */
  114771. static get Version(): string;
  114772. /** Gets the list of created engines */
  114773. static get Instances(): Engine[];
  114774. /**
  114775. * Gets the latest created engine
  114776. */
  114777. static get LastCreatedEngine(): Nullable<Engine>;
  114778. /**
  114779. * Gets the latest created scene
  114780. */
  114781. static get LastCreatedScene(): Nullable<Scene>;
  114782. /**
  114783. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  114784. * @param flag defines which part of the materials must be marked as dirty
  114785. * @param predicate defines a predicate used to filter which materials should be affected
  114786. */
  114787. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  114788. /**
  114789. * Method called to create the default loading screen.
  114790. * This can be overriden in your own app.
  114791. * @param canvas The rendering canvas element
  114792. * @returns The loading screen
  114793. */
  114794. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  114795. /**
  114796. * Method called to create the default rescale post process on each engine.
  114797. */
  114798. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  114799. /**
  114800. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  114801. **/
  114802. enableOfflineSupport: boolean;
  114803. /**
  114804. * 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)
  114805. **/
  114806. disableManifestCheck: boolean;
  114807. /**
  114808. * Gets the list of created scenes
  114809. */
  114810. scenes: Scene[];
  114811. /**
  114812. * Event raised when a new scene is created
  114813. */
  114814. onNewSceneAddedObservable: Observable<Scene>;
  114815. /**
  114816. * Gets the list of created postprocesses
  114817. */
  114818. postProcesses: PostProcess[];
  114819. /**
  114820. * Gets a boolean indicating if the pointer is currently locked
  114821. */
  114822. isPointerLock: boolean;
  114823. /**
  114824. * Observable event triggered each time the rendering canvas is resized
  114825. */
  114826. onResizeObservable: Observable<Engine>;
  114827. /**
  114828. * Observable event triggered each time the canvas loses focus
  114829. */
  114830. onCanvasBlurObservable: Observable<Engine>;
  114831. /**
  114832. * Observable event triggered each time the canvas gains focus
  114833. */
  114834. onCanvasFocusObservable: Observable<Engine>;
  114835. /**
  114836. * Observable event triggered each time the canvas receives pointerout event
  114837. */
  114838. onCanvasPointerOutObservable: Observable<PointerEvent>;
  114839. /**
  114840. * Observable raised when the engine begins a new frame
  114841. */
  114842. onBeginFrameObservable: Observable<Engine>;
  114843. /**
  114844. * If set, will be used to request the next animation frame for the render loop
  114845. */
  114846. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  114847. /**
  114848. * Observable raised when the engine ends the current frame
  114849. */
  114850. onEndFrameObservable: Observable<Engine>;
  114851. /**
  114852. * Observable raised when the engine is about to compile a shader
  114853. */
  114854. onBeforeShaderCompilationObservable: Observable<Engine>;
  114855. /**
  114856. * Observable raised when the engine has jsut compiled a shader
  114857. */
  114858. onAfterShaderCompilationObservable: Observable<Engine>;
  114859. /**
  114860. * Gets the audio engine
  114861. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  114862. * @ignorenaming
  114863. */
  114864. static audioEngine: IAudioEngine;
  114865. /**
  114866. * Default AudioEngine factory responsible of creating the Audio Engine.
  114867. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  114868. */
  114869. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  114870. /**
  114871. * Default offline support factory responsible of creating a tool used to store data locally.
  114872. * By default, this will create a Database object if the workload has been embedded.
  114873. */
  114874. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  114875. private _loadingScreen;
  114876. private _pointerLockRequested;
  114877. private _rescalePostProcess;
  114878. private _deterministicLockstep;
  114879. private _lockstepMaxSteps;
  114880. private _timeStep;
  114881. protected get _supportsHardwareTextureRescaling(): boolean;
  114882. private _fps;
  114883. private _deltaTime;
  114884. /** @hidden */
  114885. _drawCalls: PerfCounter;
  114886. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  114887. canvasTabIndex: number;
  114888. /**
  114889. * Turn this value on if you want to pause FPS computation when in background
  114890. */
  114891. disablePerformanceMonitorInBackground: boolean;
  114892. private _performanceMonitor;
  114893. /**
  114894. * Gets the performance monitor attached to this engine
  114895. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114896. */
  114897. get performanceMonitor(): PerformanceMonitor;
  114898. private _onFocus;
  114899. private _onBlur;
  114900. private _onCanvasPointerOut;
  114901. private _onCanvasBlur;
  114902. private _onCanvasFocus;
  114903. private _onFullscreenChange;
  114904. private _onPointerLockChange;
  114905. /**
  114906. * Gets the HTML element used to attach event listeners
  114907. * @returns a HTML element
  114908. */
  114909. getInputElement(): Nullable<HTMLElement>;
  114910. /**
  114911. * Creates a new engine
  114912. * @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
  114913. * @param antialias defines enable antialiasing (default: false)
  114914. * @param options defines further options to be sent to the getContext() function
  114915. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  114916. */
  114917. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  114918. /**
  114919. * Gets current aspect ratio
  114920. * @param viewportOwner defines the camera to use to get the aspect ratio
  114921. * @param useScreen defines if screen size must be used (or the current render target if any)
  114922. * @returns a number defining the aspect ratio
  114923. */
  114924. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  114925. /**
  114926. * Gets current screen aspect ratio
  114927. * @returns a number defining the aspect ratio
  114928. */
  114929. getScreenAspectRatio(): number;
  114930. /**
  114931. * Gets the client rect of the HTML canvas attached with the current webGL context
  114932. * @returns a client rectanglee
  114933. */
  114934. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  114935. /**
  114936. * Gets the client rect of the HTML element used for events
  114937. * @returns a client rectanglee
  114938. */
  114939. getInputElementClientRect(): Nullable<ClientRect>;
  114940. /**
  114941. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  114942. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114943. * @returns true if engine is in deterministic lock step mode
  114944. */
  114945. isDeterministicLockStep(): boolean;
  114946. /**
  114947. * Gets the max steps when engine is running in deterministic lock step
  114948. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114949. * @returns the max steps
  114950. */
  114951. getLockstepMaxSteps(): number;
  114952. /**
  114953. * Returns the time in ms between steps when using deterministic lock step.
  114954. * @returns time step in (ms)
  114955. */
  114956. getTimeStep(): number;
  114957. /**
  114958. * Force the mipmap generation for the given render target texture
  114959. * @param texture defines the render target texture to use
  114960. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  114961. */
  114962. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  114963. /** States */
  114964. /**
  114965. * Set various states to the webGL context
  114966. * @param culling defines backface culling state
  114967. * @param zOffset defines the value to apply to zOffset (0 by default)
  114968. * @param force defines if states must be applied even if cache is up to date
  114969. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  114970. */
  114971. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  114972. /**
  114973. * Set the z offset to apply to current rendering
  114974. * @param value defines the offset to apply
  114975. */
  114976. setZOffset(value: number): void;
  114977. /**
  114978. * Gets the current value of the zOffset
  114979. * @returns the current zOffset state
  114980. */
  114981. getZOffset(): number;
  114982. /**
  114983. * Enable or disable depth buffering
  114984. * @param enable defines the state to set
  114985. */
  114986. setDepthBuffer(enable: boolean): void;
  114987. /**
  114988. * Gets a boolean indicating if depth writing is enabled
  114989. * @returns the current depth writing state
  114990. */
  114991. getDepthWrite(): boolean;
  114992. /**
  114993. * Enable or disable depth writing
  114994. * @param enable defines the state to set
  114995. */
  114996. setDepthWrite(enable: boolean): void;
  114997. /**
  114998. * Gets a boolean indicating if stencil buffer is enabled
  114999. * @returns the current stencil buffer state
  115000. */
  115001. getStencilBuffer(): boolean;
  115002. /**
  115003. * Enable or disable the stencil buffer
  115004. * @param enable defines if the stencil buffer must be enabled or disabled
  115005. */
  115006. setStencilBuffer(enable: boolean): void;
  115007. /**
  115008. * Gets the current stencil mask
  115009. * @returns a number defining the new stencil mask to use
  115010. */
  115011. getStencilMask(): number;
  115012. /**
  115013. * Sets the current stencil mask
  115014. * @param mask defines the new stencil mask to use
  115015. */
  115016. setStencilMask(mask: number): void;
  115017. /**
  115018. * Gets the current stencil function
  115019. * @returns a number defining the stencil function to use
  115020. */
  115021. getStencilFunction(): number;
  115022. /**
  115023. * Gets the current stencil reference value
  115024. * @returns a number defining the stencil reference value to use
  115025. */
  115026. getStencilFunctionReference(): number;
  115027. /**
  115028. * Gets the current stencil mask
  115029. * @returns a number defining the stencil mask to use
  115030. */
  115031. getStencilFunctionMask(): number;
  115032. /**
  115033. * Sets the current stencil function
  115034. * @param stencilFunc defines the new stencil function to use
  115035. */
  115036. setStencilFunction(stencilFunc: number): void;
  115037. /**
  115038. * Sets the current stencil reference
  115039. * @param reference defines the new stencil reference to use
  115040. */
  115041. setStencilFunctionReference(reference: number): void;
  115042. /**
  115043. * Sets the current stencil mask
  115044. * @param mask defines the new stencil mask to use
  115045. */
  115046. setStencilFunctionMask(mask: number): void;
  115047. /**
  115048. * Gets the current stencil operation when stencil fails
  115049. * @returns a number defining stencil operation to use when stencil fails
  115050. */
  115051. getStencilOperationFail(): number;
  115052. /**
  115053. * Gets the current stencil operation when depth fails
  115054. * @returns a number defining stencil operation to use when depth fails
  115055. */
  115056. getStencilOperationDepthFail(): number;
  115057. /**
  115058. * Gets the current stencil operation when stencil passes
  115059. * @returns a number defining stencil operation to use when stencil passes
  115060. */
  115061. getStencilOperationPass(): number;
  115062. /**
  115063. * Sets the stencil operation to use when stencil fails
  115064. * @param operation defines the stencil operation to use when stencil fails
  115065. */
  115066. setStencilOperationFail(operation: number): void;
  115067. /**
  115068. * Sets the stencil operation to use when depth fails
  115069. * @param operation defines the stencil operation to use when depth fails
  115070. */
  115071. setStencilOperationDepthFail(operation: number): void;
  115072. /**
  115073. * Sets the stencil operation to use when stencil passes
  115074. * @param operation defines the stencil operation to use when stencil passes
  115075. */
  115076. setStencilOperationPass(operation: number): void;
  115077. /**
  115078. * Sets a boolean indicating if the dithering state is enabled or disabled
  115079. * @param value defines the dithering state
  115080. */
  115081. setDitheringState(value: boolean): void;
  115082. /**
  115083. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  115084. * @param value defines the rasterizer state
  115085. */
  115086. setRasterizerState(value: boolean): void;
  115087. /**
  115088. * Gets the current depth function
  115089. * @returns a number defining the depth function
  115090. */
  115091. getDepthFunction(): Nullable<number>;
  115092. /**
  115093. * Sets the current depth function
  115094. * @param depthFunc defines the function to use
  115095. */
  115096. setDepthFunction(depthFunc: number): void;
  115097. /**
  115098. * Sets the current depth function to GREATER
  115099. */
  115100. setDepthFunctionToGreater(): void;
  115101. /**
  115102. * Sets the current depth function to GEQUAL
  115103. */
  115104. setDepthFunctionToGreaterOrEqual(): void;
  115105. /**
  115106. * Sets the current depth function to LESS
  115107. */
  115108. setDepthFunctionToLess(): void;
  115109. /**
  115110. * Sets the current depth function to LEQUAL
  115111. */
  115112. setDepthFunctionToLessOrEqual(): void;
  115113. private _cachedStencilBuffer;
  115114. private _cachedStencilFunction;
  115115. private _cachedStencilMask;
  115116. private _cachedStencilOperationPass;
  115117. private _cachedStencilOperationFail;
  115118. private _cachedStencilOperationDepthFail;
  115119. private _cachedStencilReference;
  115120. /**
  115121. * Caches the the state of the stencil buffer
  115122. */
  115123. cacheStencilState(): void;
  115124. /**
  115125. * Restores the state of the stencil buffer
  115126. */
  115127. restoreStencilState(): void;
  115128. /**
  115129. * Directly set the WebGL Viewport
  115130. * @param x defines the x coordinate of the viewport (in screen space)
  115131. * @param y defines the y coordinate of the viewport (in screen space)
  115132. * @param width defines the width of the viewport (in screen space)
  115133. * @param height defines the height of the viewport (in screen space)
  115134. * @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
  115135. */
  115136. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  115137. /**
  115138. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  115139. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  115140. * @param y defines the y-coordinate of the corner of the clear rectangle
  115141. * @param width defines the width of the clear rectangle
  115142. * @param height defines the height of the clear rectangle
  115143. * @param clearColor defines the clear color
  115144. */
  115145. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  115146. /**
  115147. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  115148. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  115149. * @param y defines the y-coordinate of the corner of the clear rectangle
  115150. * @param width defines the width of the clear rectangle
  115151. * @param height defines the height of the clear rectangle
  115152. */
  115153. enableScissor(x: number, y: number, width: number, height: number): void;
  115154. /**
  115155. * Disable previously set scissor test rectangle
  115156. */
  115157. disableScissor(): void;
  115158. protected _reportDrawCall(): void;
  115159. /**
  115160. * Initializes a webVR display and starts listening to display change events
  115161. * The onVRDisplayChangedObservable will be notified upon these changes
  115162. * @returns The onVRDisplayChangedObservable
  115163. */
  115164. initWebVR(): Observable<IDisplayChangedEventArgs>;
  115165. /** @hidden */
  115166. _prepareVRComponent(): void;
  115167. /** @hidden */
  115168. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  115169. /** @hidden */
  115170. _submitVRFrame(): void;
  115171. /**
  115172. * Call this function to leave webVR mode
  115173. * Will do nothing if webVR is not supported or if there is no webVR device
  115174. * @see https://doc.babylonjs.com/how_to/webvr_camera
  115175. */
  115176. disableVR(): void;
  115177. /**
  115178. * Gets a boolean indicating that the system is in VR mode and is presenting
  115179. * @returns true if VR mode is engaged
  115180. */
  115181. isVRPresenting(): boolean;
  115182. /** @hidden */
  115183. _requestVRFrame(): void;
  115184. /** @hidden */
  115185. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  115186. /**
  115187. * Gets the source code of the vertex shader associated with a specific webGL program
  115188. * @param program defines the program to use
  115189. * @returns a string containing the source code of the vertex shader associated with the program
  115190. */
  115191. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  115192. /**
  115193. * Gets the source code of the fragment shader associated with a specific webGL program
  115194. * @param program defines the program to use
  115195. * @returns a string containing the source code of the fragment shader associated with the program
  115196. */
  115197. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  115198. /**
  115199. * Sets a depth stencil texture from a render target to the according uniform.
  115200. * @param channel The texture channel
  115201. * @param uniform The uniform to set
  115202. * @param texture The render target texture containing the depth stencil texture to apply
  115203. */
  115204. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  115205. /**
  115206. * Sets a texture to the webGL context from a postprocess
  115207. * @param channel defines the channel to use
  115208. * @param postProcess defines the source postprocess
  115209. */
  115210. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  115211. /**
  115212. * Binds the output of the passed in post process to the texture channel specified
  115213. * @param channel The channel the texture should be bound to
  115214. * @param postProcess The post process which's output should be bound
  115215. */
  115216. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  115217. protected _rebuildBuffers(): void;
  115218. /** @hidden */
  115219. _renderFrame(): void;
  115220. _renderLoop(): void;
  115221. /** @hidden */
  115222. _renderViews(): boolean;
  115223. /**
  115224. * Toggle full screen mode
  115225. * @param requestPointerLock defines if a pointer lock should be requested from the user
  115226. */
  115227. switchFullscreen(requestPointerLock: boolean): void;
  115228. /**
  115229. * Enters full screen mode
  115230. * @param requestPointerLock defines if a pointer lock should be requested from the user
  115231. */
  115232. enterFullscreen(requestPointerLock: boolean): void;
  115233. /**
  115234. * Exits full screen mode
  115235. */
  115236. exitFullscreen(): void;
  115237. /**
  115238. * Enters Pointerlock mode
  115239. */
  115240. enterPointerlock(): void;
  115241. /**
  115242. * Exits Pointerlock mode
  115243. */
  115244. exitPointerlock(): void;
  115245. /**
  115246. * Begin a new frame
  115247. */
  115248. beginFrame(): void;
  115249. /**
  115250. * Enf the current frame
  115251. */
  115252. endFrame(): void;
  115253. resize(): void;
  115254. /**
  115255. * Force a specific size of the canvas
  115256. * @param width defines the new canvas' width
  115257. * @param height defines the new canvas' height
  115258. * @returns true if the size was changed
  115259. */
  115260. setSize(width: number, height: number): boolean;
  115261. /**
  115262. * Updates a dynamic vertex buffer.
  115263. * @param vertexBuffer the vertex buffer to update
  115264. * @param data the data used to update the vertex buffer
  115265. * @param byteOffset the byte offset of the data
  115266. * @param byteLength the byte length of the data
  115267. */
  115268. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  115269. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  115270. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115271. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115272. _releaseTexture(texture: InternalTexture): void;
  115273. /**
  115274. * @hidden
  115275. * Rescales a texture
  115276. * @param source input texutre
  115277. * @param destination destination texture
  115278. * @param scene scene to use to render the resize
  115279. * @param internalFormat format to use when resizing
  115280. * @param onComplete callback to be called when resize has completed
  115281. */
  115282. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  115283. /**
  115284. * Gets the current framerate
  115285. * @returns a number representing the framerate
  115286. */
  115287. getFps(): number;
  115288. /**
  115289. * Gets the time spent between current and previous frame
  115290. * @returns a number representing the delta time in ms
  115291. */
  115292. getDeltaTime(): number;
  115293. private _measureFps;
  115294. /** @hidden */
  115295. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  115296. /**
  115297. * Update a dynamic index buffer
  115298. * @param indexBuffer defines the target index buffer
  115299. * @param indices defines the data to update
  115300. * @param offset defines the offset in the target index buffer where update should start
  115301. */
  115302. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  115303. /**
  115304. * Updates the sample count of a render target texture
  115305. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  115306. * @param texture defines the texture to update
  115307. * @param samples defines the sample count to set
  115308. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  115309. */
  115310. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  115311. /**
  115312. * Updates a depth texture Comparison Mode and Function.
  115313. * If the comparison Function is equal to 0, the mode will be set to none.
  115314. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  115315. * @param texture The texture to set the comparison function for
  115316. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  115317. */
  115318. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  115319. /**
  115320. * Creates a webGL buffer to use with instanciation
  115321. * @param capacity defines the size of the buffer
  115322. * @returns the webGL buffer
  115323. */
  115324. createInstancesBuffer(capacity: number): DataBuffer;
  115325. /**
  115326. * Delete a webGL buffer used with instanciation
  115327. * @param buffer defines the webGL buffer to delete
  115328. */
  115329. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  115330. private _clientWaitAsync;
  115331. /** @hidden */
  115332. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  115333. dispose(): void;
  115334. private _disableTouchAction;
  115335. /**
  115336. * Display the loading screen
  115337. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115338. */
  115339. displayLoadingUI(): void;
  115340. /**
  115341. * Hide the loading screen
  115342. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115343. */
  115344. hideLoadingUI(): void;
  115345. /**
  115346. * Gets the current loading screen object
  115347. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115348. */
  115349. get loadingScreen(): ILoadingScreen;
  115350. /**
  115351. * Sets the current loading screen object
  115352. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115353. */
  115354. set loadingScreen(loadingScreen: ILoadingScreen);
  115355. /**
  115356. * Sets the current loading screen text
  115357. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115358. */
  115359. set loadingUIText(text: string);
  115360. /**
  115361. * Sets the current loading screen background color
  115362. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115363. */
  115364. set loadingUIBackgroundColor(color: string);
  115365. /** Pointerlock and fullscreen */
  115366. /**
  115367. * Ask the browser to promote the current element to pointerlock mode
  115368. * @param element defines the DOM element to promote
  115369. */
  115370. static _RequestPointerlock(element: HTMLElement): void;
  115371. /**
  115372. * Asks the browser to exit pointerlock mode
  115373. */
  115374. static _ExitPointerlock(): void;
  115375. /**
  115376. * Ask the browser to promote the current element to fullscreen rendering mode
  115377. * @param element defines the DOM element to promote
  115378. */
  115379. static _RequestFullscreen(element: HTMLElement): void;
  115380. /**
  115381. * Asks the browser to exit fullscreen mode
  115382. */
  115383. static _ExitFullscreen(): void;
  115384. }
  115385. }
  115386. declare module BABYLON {
  115387. /**
  115388. * The engine store class is responsible to hold all the instances of Engine and Scene created
  115389. * during the life time of the application.
  115390. */
  115391. export class EngineStore {
  115392. /** Gets the list of created engines */
  115393. static Instances: Engine[];
  115394. /** @hidden */
  115395. static _LastCreatedScene: Nullable<Scene>;
  115396. /**
  115397. * Gets the latest created engine
  115398. */
  115399. static get LastCreatedEngine(): Nullable<Engine>;
  115400. /**
  115401. * Gets the latest created scene
  115402. */
  115403. static get LastCreatedScene(): Nullable<Scene>;
  115404. /**
  115405. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  115406. * @ignorenaming
  115407. */
  115408. static UseFallbackTexture: boolean;
  115409. /**
  115410. * Texture content used if a texture cannot loaded
  115411. * @ignorenaming
  115412. */
  115413. static FallbackTexture: string;
  115414. }
  115415. }
  115416. declare module BABYLON {
  115417. /**
  115418. * Helper class that provides a small promise polyfill
  115419. */
  115420. export class PromisePolyfill {
  115421. /**
  115422. * Static function used to check if the polyfill is required
  115423. * If this is the case then the function will inject the polyfill to window.Promise
  115424. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  115425. */
  115426. static Apply(force?: boolean): void;
  115427. }
  115428. }
  115429. declare module BABYLON {
  115430. /**
  115431. * Interface for screenshot methods with describe argument called `size` as object with options
  115432. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  115433. */
  115434. export interface IScreenshotSize {
  115435. /**
  115436. * number in pixels for canvas height
  115437. */
  115438. height?: number;
  115439. /**
  115440. * multiplier allowing render at a higher or lower resolution
  115441. * If value is defined then height and width will be ignored and taken from camera
  115442. */
  115443. precision?: number;
  115444. /**
  115445. * number in pixels for canvas width
  115446. */
  115447. width?: number;
  115448. }
  115449. }
  115450. declare module BABYLON {
  115451. interface IColor4Like {
  115452. r: float;
  115453. g: float;
  115454. b: float;
  115455. a: float;
  115456. }
  115457. /**
  115458. * Class containing a set of static utilities functions
  115459. */
  115460. export class Tools {
  115461. /**
  115462. * Gets or sets the base URL to use to load assets
  115463. */
  115464. static get BaseUrl(): string;
  115465. static set BaseUrl(value: string);
  115466. /**
  115467. * Enable/Disable Custom HTTP Request Headers globally.
  115468. * default = false
  115469. * @see CustomRequestHeaders
  115470. */
  115471. static UseCustomRequestHeaders: boolean;
  115472. /**
  115473. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  115474. * i.e. when loading files, where the server/service expects an Authorization header
  115475. */
  115476. static CustomRequestHeaders: {
  115477. [key: string]: string;
  115478. };
  115479. /**
  115480. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  115481. */
  115482. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  115483. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  115484. /**
  115485. * Default behaviour for cors in the application.
  115486. * It can be a string if the expected behavior is identical in the entire app.
  115487. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  115488. */
  115489. static get CorsBehavior(): string | ((url: string | string[]) => string);
  115490. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  115491. /**
  115492. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  115493. * @ignorenaming
  115494. */
  115495. static get UseFallbackTexture(): boolean;
  115496. static set UseFallbackTexture(value: boolean);
  115497. /**
  115498. * Use this object to register external classes like custom textures or material
  115499. * to allow the laoders to instantiate them
  115500. */
  115501. static get RegisteredExternalClasses(): {
  115502. [key: string]: Object;
  115503. };
  115504. static set RegisteredExternalClasses(classes: {
  115505. [key: string]: Object;
  115506. });
  115507. /**
  115508. * Texture content used if a texture cannot loaded
  115509. * @ignorenaming
  115510. */
  115511. static get fallbackTexture(): string;
  115512. static set fallbackTexture(value: string);
  115513. /**
  115514. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  115515. * @param u defines the coordinate on X axis
  115516. * @param v defines the coordinate on Y axis
  115517. * @param width defines the width of the source data
  115518. * @param height defines the height of the source data
  115519. * @param pixels defines the source byte array
  115520. * @param color defines the output color
  115521. */
  115522. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  115523. /**
  115524. * Interpolates between a and b via alpha
  115525. * @param a The lower value (returned when alpha = 0)
  115526. * @param b The upper value (returned when alpha = 1)
  115527. * @param alpha The interpolation-factor
  115528. * @return The mixed value
  115529. */
  115530. static Mix(a: number, b: number, alpha: number): number;
  115531. /**
  115532. * Tries to instantiate a new object from a given class name
  115533. * @param className defines the class name to instantiate
  115534. * @returns the new object or null if the system was not able to do the instantiation
  115535. */
  115536. static Instantiate(className: string): any;
  115537. /**
  115538. * Provides a slice function that will work even on IE
  115539. * @param data defines the array to slice
  115540. * @param start defines the start of the data (optional)
  115541. * @param end defines the end of the data (optional)
  115542. * @returns the new sliced array
  115543. */
  115544. static Slice<T>(data: T, start?: number, end?: number): T;
  115545. /**
  115546. * Polyfill for setImmediate
  115547. * @param action defines the action to execute after the current execution block
  115548. */
  115549. static SetImmediate(action: () => void): void;
  115550. /**
  115551. * Function indicating if a number is an exponent of 2
  115552. * @param value defines the value to test
  115553. * @returns true if the value is an exponent of 2
  115554. */
  115555. static IsExponentOfTwo(value: number): boolean;
  115556. private static _tmpFloatArray;
  115557. /**
  115558. * Returns the nearest 32-bit single precision float representation of a Number
  115559. * @param value A Number. If the parameter is of a different type, it will get converted
  115560. * to a number or to NaN if it cannot be converted
  115561. * @returns number
  115562. */
  115563. static FloatRound(value: number): number;
  115564. /**
  115565. * Extracts the filename from a path
  115566. * @param path defines the path to use
  115567. * @returns the filename
  115568. */
  115569. static GetFilename(path: string): string;
  115570. /**
  115571. * Extracts the "folder" part of a path (everything before the filename).
  115572. * @param uri The URI to extract the info from
  115573. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  115574. * @returns The "folder" part of the path
  115575. */
  115576. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  115577. /**
  115578. * Extracts text content from a DOM element hierarchy
  115579. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  115580. */
  115581. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  115582. /**
  115583. * Convert an angle in radians to degrees
  115584. * @param angle defines the angle to convert
  115585. * @returns the angle in degrees
  115586. */
  115587. static ToDegrees(angle: number): number;
  115588. /**
  115589. * Convert an angle in degrees to radians
  115590. * @param angle defines the angle to convert
  115591. * @returns the angle in radians
  115592. */
  115593. static ToRadians(angle: number): number;
  115594. /**
  115595. * Returns an array if obj is not an array
  115596. * @param obj defines the object to evaluate as an array
  115597. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  115598. * @returns either obj directly if obj is an array or a new array containing obj
  115599. */
  115600. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  115601. /**
  115602. * Gets the pointer prefix to use
  115603. * @param engine defines the engine we are finding the prefix for
  115604. * @returns "pointer" if touch is enabled. Else returns "mouse"
  115605. */
  115606. static GetPointerPrefix(engine: Engine): string;
  115607. /**
  115608. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  115609. * @param url define the url we are trying
  115610. * @param element define the dom element where to configure the cors policy
  115611. */
  115612. static SetCorsBehavior(url: string | string[], element: {
  115613. crossOrigin: string | null;
  115614. }): void;
  115615. /**
  115616. * Removes unwanted characters from an url
  115617. * @param url defines the url to clean
  115618. * @returns the cleaned url
  115619. */
  115620. static CleanUrl(url: string): string;
  115621. /**
  115622. * Gets or sets a function used to pre-process url before using them to load assets
  115623. */
  115624. static get PreprocessUrl(): (url: string) => string;
  115625. static set PreprocessUrl(processor: (url: string) => string);
  115626. /**
  115627. * Loads an image as an HTMLImageElement.
  115628. * @param input url string, ArrayBuffer, or Blob to load
  115629. * @param onLoad callback called when the image successfully loads
  115630. * @param onError callback called when the image fails to load
  115631. * @param offlineProvider offline provider for caching
  115632. * @param mimeType optional mime type
  115633. * @returns the HTMLImageElement of the loaded image
  115634. */
  115635. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  115636. /**
  115637. * Loads a file from a url
  115638. * @param url url string, ArrayBuffer, or Blob to load
  115639. * @param onSuccess callback called when the file successfully loads
  115640. * @param onProgress callback called while file is loading (if the server supports this mode)
  115641. * @param offlineProvider defines the offline provider for caching
  115642. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115643. * @param onError callback called when the file fails to load
  115644. * @returns a file request object
  115645. */
  115646. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  115647. /**
  115648. * Loads a file from a url
  115649. * @param url the file url to load
  115650. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115651. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  115652. */
  115653. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  115654. /**
  115655. * Load a script (identified by an url). When the url returns, the
  115656. * content of this file is added into a new script element, attached to the DOM (body element)
  115657. * @param scriptUrl defines the url of the script to laod
  115658. * @param onSuccess defines the callback called when the script is loaded
  115659. * @param onError defines the callback to call if an error occurs
  115660. * @param scriptId defines the id of the script element
  115661. */
  115662. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  115663. /**
  115664. * Load an asynchronous script (identified by an url). When the url returns, the
  115665. * content of this file is added into a new script element, attached to the DOM (body element)
  115666. * @param scriptUrl defines the url of the script to laod
  115667. * @param scriptId defines the id of the script element
  115668. * @returns a promise request object
  115669. */
  115670. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  115671. /**
  115672. * Loads a file from a blob
  115673. * @param fileToLoad defines the blob to use
  115674. * @param callback defines the callback to call when data is loaded
  115675. * @param progressCallback defines the callback to call during loading process
  115676. * @returns a file request object
  115677. */
  115678. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  115679. /**
  115680. * Reads a file from a File object
  115681. * @param file defines the file to load
  115682. * @param onSuccess defines the callback to call when data is loaded
  115683. * @param onProgress defines the callback to call during loading process
  115684. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  115685. * @param onError defines the callback to call when an error occurs
  115686. * @returns a file request object
  115687. */
  115688. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  115689. /**
  115690. * Creates a data url from a given string content
  115691. * @param content defines the content to convert
  115692. * @returns the new data url link
  115693. */
  115694. static FileAsURL(content: string): string;
  115695. /**
  115696. * Format the given number to a specific decimal format
  115697. * @param value defines the number to format
  115698. * @param decimals defines the number of decimals to use
  115699. * @returns the formatted string
  115700. */
  115701. static Format(value: number, decimals?: number): string;
  115702. /**
  115703. * Tries to copy an object by duplicating every property
  115704. * @param source defines the source object
  115705. * @param destination defines the target object
  115706. * @param doNotCopyList defines a list of properties to avoid
  115707. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  115708. */
  115709. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  115710. /**
  115711. * Gets a boolean indicating if the given object has no own property
  115712. * @param obj defines the object to test
  115713. * @returns true if object has no own property
  115714. */
  115715. static IsEmpty(obj: any): boolean;
  115716. /**
  115717. * Function used to register events at window level
  115718. * @param windowElement defines the Window object to use
  115719. * @param events defines the events to register
  115720. */
  115721. static RegisterTopRootEvents(windowElement: Window, events: {
  115722. name: string;
  115723. handler: Nullable<(e: FocusEvent) => any>;
  115724. }[]): void;
  115725. /**
  115726. * Function used to unregister events from window level
  115727. * @param windowElement defines the Window object to use
  115728. * @param events defines the events to unregister
  115729. */
  115730. static UnregisterTopRootEvents(windowElement: Window, events: {
  115731. name: string;
  115732. handler: Nullable<(e: FocusEvent) => any>;
  115733. }[]): void;
  115734. /**
  115735. * @ignore
  115736. */
  115737. static _ScreenshotCanvas: HTMLCanvasElement;
  115738. /**
  115739. * Dumps the current bound framebuffer
  115740. * @param width defines the rendering width
  115741. * @param height defines the rendering height
  115742. * @param engine defines the hosting engine
  115743. * @param successCallback defines the callback triggered once the data are available
  115744. * @param mimeType defines the mime type of the result
  115745. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  115746. */
  115747. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  115748. /**
  115749. * Converts the canvas data to blob.
  115750. * This acts as a polyfill for browsers not supporting the to blob function.
  115751. * @param canvas Defines the canvas to extract the data from
  115752. * @param successCallback Defines the callback triggered once the data are available
  115753. * @param mimeType Defines the mime type of the result
  115754. */
  115755. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  115756. /**
  115757. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  115758. * @param successCallback defines the callback triggered once the data are available
  115759. * @param mimeType defines the mime type of the result
  115760. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  115761. */
  115762. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  115763. /**
  115764. * Downloads a blob in the browser
  115765. * @param blob defines the blob to download
  115766. * @param fileName defines the name of the downloaded file
  115767. */
  115768. static Download(blob: Blob, fileName: string): void;
  115769. /**
  115770. * Captures a screenshot of the current rendering
  115771. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  115772. * @param engine defines the rendering engine
  115773. * @param camera defines the source camera
  115774. * @param size This parameter can be set to a single number or to an object with the
  115775. * following (optional) properties: precision, width, height. If a single number is passed,
  115776. * it will be used for both width and height. If an object is passed, the screenshot size
  115777. * will be derived from the parameters. The precision property is a multiplier allowing
  115778. * rendering at a higher or lower resolution
  115779. * @param successCallback defines the callback receives a single parameter which contains the
  115780. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115781. * src parameter of an <img> to display it
  115782. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  115783. * Check your browser for supported MIME types
  115784. */
  115785. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  115786. /**
  115787. * Captures a screenshot of the current rendering
  115788. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  115789. * @param engine defines the rendering engine
  115790. * @param camera defines the source camera
  115791. * @param size This parameter can be set to a single number or to an object with the
  115792. * following (optional) properties: precision, width, height. If a single number is passed,
  115793. * it will be used for both width and height. If an object is passed, the screenshot size
  115794. * will be derived from the parameters. The precision property is a multiplier allowing
  115795. * rendering at a higher or lower resolution
  115796. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  115797. * Check your browser for supported MIME types
  115798. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  115799. * to the src parameter of an <img> to display it
  115800. */
  115801. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  115802. /**
  115803. * Generates an image screenshot from the specified camera.
  115804. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  115805. * @param engine The engine to use for rendering
  115806. * @param camera The camera to use for rendering
  115807. * @param size This parameter can be set to a single number or to an object with the
  115808. * following (optional) properties: precision, width, height. If a single number is passed,
  115809. * it will be used for both width and height. If an object is passed, the screenshot size
  115810. * will be derived from the parameters. The precision property is a multiplier allowing
  115811. * rendering at a higher or lower resolution
  115812. * @param successCallback The callback receives a single parameter which contains the
  115813. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115814. * src parameter of an <img> to display it
  115815. * @param mimeType The MIME type of the screenshot image (default: image/png).
  115816. * Check your browser for supported MIME types
  115817. * @param samples Texture samples (default: 1)
  115818. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  115819. * @param fileName A name for for the downloaded file.
  115820. */
  115821. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  115822. /**
  115823. * Generates an image screenshot from the specified camera.
  115824. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  115825. * @param engine The engine to use for rendering
  115826. * @param camera The camera to use for rendering
  115827. * @param size This parameter can be set to a single number or to an object with the
  115828. * following (optional) properties: precision, width, height. If a single number is passed,
  115829. * it will be used for both width and height. If an object is passed, the screenshot size
  115830. * will be derived from the parameters. The precision property is a multiplier allowing
  115831. * rendering at a higher or lower resolution
  115832. * @param mimeType The MIME type of the screenshot image (default: image/png).
  115833. * Check your browser for supported MIME types
  115834. * @param samples Texture samples (default: 1)
  115835. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  115836. * @param fileName A name for for the downloaded file.
  115837. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  115838. * to the src parameter of an <img> to display it
  115839. */
  115840. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  115841. /**
  115842. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  115843. * Be aware Math.random() could cause collisions, but:
  115844. * "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"
  115845. * @returns a pseudo random id
  115846. */
  115847. static RandomId(): string;
  115848. /**
  115849. * Test if the given uri is a base64 string
  115850. * @param uri The uri to test
  115851. * @return True if the uri is a base64 string or false otherwise
  115852. */
  115853. static IsBase64(uri: string): boolean;
  115854. /**
  115855. * Decode the given base64 uri.
  115856. * @param uri The uri to decode
  115857. * @return The decoded base64 data.
  115858. */
  115859. static DecodeBase64(uri: string): ArrayBuffer;
  115860. /**
  115861. * Gets the absolute url.
  115862. * @param url the input url
  115863. * @return the absolute url
  115864. */
  115865. static GetAbsoluteUrl(url: string): string;
  115866. /**
  115867. * No log
  115868. */
  115869. static readonly NoneLogLevel: number;
  115870. /**
  115871. * Only message logs
  115872. */
  115873. static readonly MessageLogLevel: number;
  115874. /**
  115875. * Only warning logs
  115876. */
  115877. static readonly WarningLogLevel: number;
  115878. /**
  115879. * Only error logs
  115880. */
  115881. static readonly ErrorLogLevel: number;
  115882. /**
  115883. * All logs
  115884. */
  115885. static readonly AllLogLevel: number;
  115886. /**
  115887. * Gets a value indicating the number of loading errors
  115888. * @ignorenaming
  115889. */
  115890. static get errorsCount(): number;
  115891. /**
  115892. * Callback called when a new log is added
  115893. */
  115894. static OnNewCacheEntry: (entry: string) => void;
  115895. /**
  115896. * Log a message to the console
  115897. * @param message defines the message to log
  115898. */
  115899. static Log(message: string): void;
  115900. /**
  115901. * Write a warning message to the console
  115902. * @param message defines the message to log
  115903. */
  115904. static Warn(message: string): void;
  115905. /**
  115906. * Write an error message to the console
  115907. * @param message defines the message to log
  115908. */
  115909. static Error(message: string): void;
  115910. /**
  115911. * Gets current log cache (list of logs)
  115912. */
  115913. static get LogCache(): string;
  115914. /**
  115915. * Clears the log cache
  115916. */
  115917. static ClearLogCache(): void;
  115918. /**
  115919. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  115920. */
  115921. static set LogLevels(level: number);
  115922. /**
  115923. * Checks if the window object exists
  115924. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  115925. */
  115926. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  115927. /**
  115928. * No performance log
  115929. */
  115930. static readonly PerformanceNoneLogLevel: number;
  115931. /**
  115932. * Use user marks to log performance
  115933. */
  115934. static readonly PerformanceUserMarkLogLevel: number;
  115935. /**
  115936. * Log performance to the console
  115937. */
  115938. static readonly PerformanceConsoleLogLevel: number;
  115939. private static _performance;
  115940. /**
  115941. * Sets the current performance log level
  115942. */
  115943. static set PerformanceLogLevel(level: number);
  115944. private static _StartPerformanceCounterDisabled;
  115945. private static _EndPerformanceCounterDisabled;
  115946. private static _StartUserMark;
  115947. private static _EndUserMark;
  115948. private static _StartPerformanceConsole;
  115949. private static _EndPerformanceConsole;
  115950. /**
  115951. * Starts a performance counter
  115952. */
  115953. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  115954. /**
  115955. * Ends a specific performance coutner
  115956. */
  115957. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  115958. /**
  115959. * Gets either window.performance.now() if supported or Date.now() else
  115960. */
  115961. static get Now(): number;
  115962. /**
  115963. * This method will return the name of the class used to create the instance of the given object.
  115964. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  115965. * @param object the object to get the class name from
  115966. * @param isType defines if the object is actually a type
  115967. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  115968. */
  115969. static GetClassName(object: any, isType?: boolean): string;
  115970. /**
  115971. * Gets the first element of an array satisfying a given predicate
  115972. * @param array defines the array to browse
  115973. * @param predicate defines the predicate to use
  115974. * @returns null if not found or the element
  115975. */
  115976. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  115977. /**
  115978. * This method will return the name of the full name of the class, including its owning module (if any).
  115979. * 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).
  115980. * @param object the object to get the class name from
  115981. * @param isType defines if the object is actually a type
  115982. * @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.
  115983. * @ignorenaming
  115984. */
  115985. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  115986. /**
  115987. * Returns a promise that resolves after the given amount of time.
  115988. * @param delay Number of milliseconds to delay
  115989. * @returns Promise that resolves after the given amount of time
  115990. */
  115991. static DelayAsync(delay: number): Promise<void>;
  115992. /**
  115993. * Utility function to detect if the current user agent is Safari
  115994. * @returns whether or not the current user agent is safari
  115995. */
  115996. static IsSafari(): boolean;
  115997. }
  115998. /**
  115999. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  116000. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  116001. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  116002. * @param name The name of the class, case should be preserved
  116003. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  116004. */
  116005. export function className(name: string, module?: string): (target: Object) => void;
  116006. /**
  116007. * An implementation of a loop for asynchronous functions.
  116008. */
  116009. export class AsyncLoop {
  116010. /**
  116011. * Defines the number of iterations for the loop
  116012. */
  116013. iterations: number;
  116014. /**
  116015. * Defines the current index of the loop.
  116016. */
  116017. index: number;
  116018. private _done;
  116019. private _fn;
  116020. private _successCallback;
  116021. /**
  116022. * Constructor.
  116023. * @param iterations the number of iterations.
  116024. * @param func the function to run each iteration
  116025. * @param successCallback the callback that will be called upon succesful execution
  116026. * @param offset starting offset.
  116027. */
  116028. constructor(
  116029. /**
  116030. * Defines the number of iterations for the loop
  116031. */
  116032. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  116033. /**
  116034. * Execute the next iteration. Must be called after the last iteration was finished.
  116035. */
  116036. executeNext(): void;
  116037. /**
  116038. * Break the loop and run the success callback.
  116039. */
  116040. breakLoop(): void;
  116041. /**
  116042. * Create and run an async loop.
  116043. * @param iterations the number of iterations.
  116044. * @param fn the function to run each iteration
  116045. * @param successCallback the callback that will be called upon succesful execution
  116046. * @param offset starting offset.
  116047. * @returns the created async loop object
  116048. */
  116049. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  116050. /**
  116051. * A for-loop that will run a given number of iterations synchronous and the rest async.
  116052. * @param iterations total number of iterations
  116053. * @param syncedIterations number of synchronous iterations in each async iteration.
  116054. * @param fn the function to call each iteration.
  116055. * @param callback a success call back that will be called when iterating stops.
  116056. * @param breakFunction a break condition (optional)
  116057. * @param timeout timeout settings for the setTimeout function. default - 0.
  116058. * @returns the created async loop object
  116059. */
  116060. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  116061. }
  116062. }
  116063. declare module BABYLON {
  116064. /**
  116065. * This class implement a typical dictionary using a string as key and the generic type T as value.
  116066. * The underlying implementation relies on an associative array to ensure the best performances.
  116067. * The value can be anything including 'null' but except 'undefined'
  116068. */
  116069. export class StringDictionary<T> {
  116070. /**
  116071. * This will clear this dictionary and copy the content from the 'source' one.
  116072. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  116073. * @param source the dictionary to take the content from and copy to this dictionary
  116074. */
  116075. copyFrom(source: StringDictionary<T>): void;
  116076. /**
  116077. * Get a value based from its key
  116078. * @param key the given key to get the matching value from
  116079. * @return the value if found, otherwise undefined is returned
  116080. */
  116081. get(key: string): T | undefined;
  116082. /**
  116083. * Get a value from its key or add it if it doesn't exist.
  116084. * This method will ensure you that a given key/data will be present in the dictionary.
  116085. * @param key the given key to get the matching value from
  116086. * @param factory the factory that will create the value if the key is not present in the dictionary.
  116087. * The factory will only be invoked if there's no data for the given key.
  116088. * @return the value corresponding to the key.
  116089. */
  116090. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  116091. /**
  116092. * Get a value from its key if present in the dictionary otherwise add it
  116093. * @param key the key to get the value from
  116094. * @param val if there's no such key/value pair in the dictionary add it with this value
  116095. * @return the value corresponding to the key
  116096. */
  116097. getOrAdd(key: string, val: T): T;
  116098. /**
  116099. * Check if there's a given key in the dictionary
  116100. * @param key the key to check for
  116101. * @return true if the key is present, false otherwise
  116102. */
  116103. contains(key: string): boolean;
  116104. /**
  116105. * Add a new key and its corresponding value
  116106. * @param key the key to add
  116107. * @param value the value corresponding to the key
  116108. * @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
  116109. */
  116110. add(key: string, value: T): boolean;
  116111. /**
  116112. * Update a specific value associated to a key
  116113. * @param key defines the key to use
  116114. * @param value defines the value to store
  116115. * @returns true if the value was updated (or false if the key was not found)
  116116. */
  116117. set(key: string, value: T): boolean;
  116118. /**
  116119. * Get the element of the given key and remove it from the dictionary
  116120. * @param key defines the key to search
  116121. * @returns the value associated with the key or null if not found
  116122. */
  116123. getAndRemove(key: string): Nullable<T>;
  116124. /**
  116125. * Remove a key/value from the dictionary.
  116126. * @param key the key to remove
  116127. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  116128. */
  116129. remove(key: string): boolean;
  116130. /**
  116131. * Clear the whole content of the dictionary
  116132. */
  116133. clear(): void;
  116134. /**
  116135. * Gets the current count
  116136. */
  116137. get count(): number;
  116138. /**
  116139. * Execute a callback on each key/val of the dictionary.
  116140. * Note that you can remove any element in this dictionary in the callback implementation
  116141. * @param callback the callback to execute on a given key/value pair
  116142. */
  116143. forEach(callback: (key: string, val: T) => void): void;
  116144. /**
  116145. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  116146. * If the callback returns null or undefined the method will iterate to the next key/value pair
  116147. * Note that you can remove any element in this dictionary in the callback implementation
  116148. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  116149. * @returns the first item
  116150. */
  116151. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  116152. private _count;
  116153. private _data;
  116154. }
  116155. }
  116156. declare module BABYLON {
  116157. /** @hidden */
  116158. export interface ICollisionCoordinator {
  116159. createCollider(): Collider;
  116160. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  116161. init(scene: Scene): void;
  116162. }
  116163. /** @hidden */
  116164. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  116165. private _scene;
  116166. private _scaledPosition;
  116167. private _scaledVelocity;
  116168. private _finalPosition;
  116169. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  116170. createCollider(): Collider;
  116171. init(scene: Scene): void;
  116172. private _collideWithWorld;
  116173. }
  116174. }
  116175. declare module BABYLON {
  116176. /**
  116177. * Class used to manage all inputs for the scene.
  116178. */
  116179. export class InputManager {
  116180. /** The distance in pixel that you have to move to prevent some events */
  116181. static DragMovementThreshold: number;
  116182. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  116183. static LongPressDelay: number;
  116184. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  116185. static DoubleClickDelay: number;
  116186. /** If you need to check double click without raising a single click at first click, enable this flag */
  116187. static ExclusiveDoubleClickMode: boolean;
  116188. private _wheelEventName;
  116189. private _onPointerMove;
  116190. private _onPointerDown;
  116191. private _onPointerUp;
  116192. private _initClickEvent;
  116193. private _initActionManager;
  116194. private _delayedSimpleClick;
  116195. private _delayedSimpleClickTimeout;
  116196. private _previousDelayedSimpleClickTimeout;
  116197. private _meshPickProceed;
  116198. private _previousButtonPressed;
  116199. private _currentPickResult;
  116200. private _previousPickResult;
  116201. private _totalPointersPressed;
  116202. private _doubleClickOccured;
  116203. private _pointerOverMesh;
  116204. private _pickedDownMesh;
  116205. private _pickedUpMesh;
  116206. private _pointerX;
  116207. private _pointerY;
  116208. private _unTranslatedPointerX;
  116209. private _unTranslatedPointerY;
  116210. private _startingPointerPosition;
  116211. private _previousStartingPointerPosition;
  116212. private _startingPointerTime;
  116213. private _previousStartingPointerTime;
  116214. private _pointerCaptures;
  116215. private _onKeyDown;
  116216. private _onKeyUp;
  116217. private _onCanvasFocusObserver;
  116218. private _onCanvasBlurObserver;
  116219. private _scene;
  116220. /**
  116221. * Creates a new InputManager
  116222. * @param scene defines the hosting scene
  116223. */
  116224. constructor(scene: Scene);
  116225. /**
  116226. * Gets the mesh that is currently under the pointer
  116227. */
  116228. get meshUnderPointer(): Nullable<AbstractMesh>;
  116229. /**
  116230. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  116231. */
  116232. get unTranslatedPointer(): Vector2;
  116233. /**
  116234. * Gets or sets the current on-screen X position of the pointer
  116235. */
  116236. get pointerX(): number;
  116237. set pointerX(value: number);
  116238. /**
  116239. * Gets or sets the current on-screen Y position of the pointer
  116240. */
  116241. get pointerY(): number;
  116242. set pointerY(value: number);
  116243. private _updatePointerPosition;
  116244. private _processPointerMove;
  116245. private _setRayOnPointerInfo;
  116246. private _checkPrePointerObservable;
  116247. /**
  116248. * Use this method to simulate a pointer move on a mesh
  116249. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116250. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116251. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116252. */
  116253. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  116254. /**
  116255. * Use this method to simulate a pointer down on a mesh
  116256. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116257. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116258. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116259. */
  116260. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  116261. private _processPointerDown;
  116262. /** @hidden */
  116263. _isPointerSwiping(): boolean;
  116264. /**
  116265. * Use this method to simulate a pointer up on a mesh
  116266. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116267. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116268. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116269. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  116270. */
  116271. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  116272. private _processPointerUp;
  116273. /**
  116274. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  116275. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  116276. * @returns true if the pointer was captured
  116277. */
  116278. isPointerCaptured(pointerId?: number): boolean;
  116279. /**
  116280. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  116281. * @param attachUp defines if you want to attach events to pointerup
  116282. * @param attachDown defines if you want to attach events to pointerdown
  116283. * @param attachMove defines if you want to attach events to pointermove
  116284. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  116285. */
  116286. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  116287. /**
  116288. * Detaches all event handlers
  116289. */
  116290. detachControl(): void;
  116291. /**
  116292. * Force the value of meshUnderPointer
  116293. * @param mesh defines the mesh to use
  116294. */
  116295. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  116296. /**
  116297. * Gets the mesh under the pointer
  116298. * @returns a Mesh or null if no mesh is under the pointer
  116299. */
  116300. getPointerOverMesh(): Nullable<AbstractMesh>;
  116301. }
  116302. }
  116303. declare module BABYLON {
  116304. /**
  116305. * This class defines the direct association between an animation and a target
  116306. */
  116307. export class TargetedAnimation {
  116308. /**
  116309. * Animation to perform
  116310. */
  116311. animation: Animation;
  116312. /**
  116313. * Target to animate
  116314. */
  116315. target: any;
  116316. /**
  116317. * Returns the string "TargetedAnimation"
  116318. * @returns "TargetedAnimation"
  116319. */
  116320. getClassName(): string;
  116321. /**
  116322. * Serialize the object
  116323. * @returns the JSON object representing the current entity
  116324. */
  116325. serialize(): any;
  116326. }
  116327. /**
  116328. * Use this class to create coordinated animations on multiple targets
  116329. */
  116330. export class AnimationGroup implements IDisposable {
  116331. /** The name of the animation group */
  116332. name: string;
  116333. private _scene;
  116334. private _targetedAnimations;
  116335. private _animatables;
  116336. private _from;
  116337. private _to;
  116338. private _isStarted;
  116339. private _isPaused;
  116340. private _speedRatio;
  116341. private _loopAnimation;
  116342. private _isAdditive;
  116343. /**
  116344. * Gets or sets the unique id of the node
  116345. */
  116346. uniqueId: number;
  116347. /**
  116348. * This observable will notify when one animation have ended
  116349. */
  116350. onAnimationEndObservable: Observable<TargetedAnimation>;
  116351. /**
  116352. * Observer raised when one animation loops
  116353. */
  116354. onAnimationLoopObservable: Observable<TargetedAnimation>;
  116355. /**
  116356. * Observer raised when all animations have looped
  116357. */
  116358. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  116359. /**
  116360. * This observable will notify when all animations have ended.
  116361. */
  116362. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  116363. /**
  116364. * This observable will notify when all animations have paused.
  116365. */
  116366. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  116367. /**
  116368. * This observable will notify when all animations are playing.
  116369. */
  116370. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  116371. /**
  116372. * Gets the first frame
  116373. */
  116374. get from(): number;
  116375. /**
  116376. * Gets the last frame
  116377. */
  116378. get to(): number;
  116379. /**
  116380. * Define if the animations are started
  116381. */
  116382. get isStarted(): boolean;
  116383. /**
  116384. * Gets a value indicating that the current group is playing
  116385. */
  116386. get isPlaying(): boolean;
  116387. /**
  116388. * Gets or sets the speed ratio to use for all animations
  116389. */
  116390. get speedRatio(): number;
  116391. /**
  116392. * Gets or sets the speed ratio to use for all animations
  116393. */
  116394. set speedRatio(value: number);
  116395. /**
  116396. * Gets or sets if all animations should loop or not
  116397. */
  116398. get loopAnimation(): boolean;
  116399. set loopAnimation(value: boolean);
  116400. /**
  116401. * Gets or sets if all animations should be evaluated additively
  116402. */
  116403. get isAdditive(): boolean;
  116404. set isAdditive(value: boolean);
  116405. /**
  116406. * Gets the targeted animations for this animation group
  116407. */
  116408. get targetedAnimations(): Array<TargetedAnimation>;
  116409. /**
  116410. * returning the list of animatables controlled by this animation group.
  116411. */
  116412. get animatables(): Array<Animatable>;
  116413. /**
  116414. * Gets the list of target animations
  116415. */
  116416. get children(): TargetedAnimation[];
  116417. /**
  116418. * Instantiates a new Animation Group.
  116419. * This helps managing several animations at once.
  116420. * @see https://doc.babylonjs.com/how_to/group
  116421. * @param name Defines the name of the group
  116422. * @param scene Defines the scene the group belongs to
  116423. */
  116424. constructor(
  116425. /** The name of the animation group */
  116426. name: string, scene?: Nullable<Scene>);
  116427. /**
  116428. * Add an animation (with its target) in the group
  116429. * @param animation defines the animation we want to add
  116430. * @param target defines the target of the animation
  116431. * @returns the TargetedAnimation object
  116432. */
  116433. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  116434. /**
  116435. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  116436. * It can add constant keys at begin or end
  116437. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  116438. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  116439. * @returns the animation group
  116440. */
  116441. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  116442. private _animationLoopCount;
  116443. private _animationLoopFlags;
  116444. private _processLoop;
  116445. /**
  116446. * Start all animations on given targets
  116447. * @param loop defines if animations must loop
  116448. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  116449. * @param from defines the from key (optional)
  116450. * @param to defines the to key (optional)
  116451. * @param isAdditive defines the additive state for the resulting animatables (optional)
  116452. * @returns the current animation group
  116453. */
  116454. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  116455. /**
  116456. * Pause all animations
  116457. * @returns the animation group
  116458. */
  116459. pause(): AnimationGroup;
  116460. /**
  116461. * Play all animations to initial state
  116462. * This function will start() the animations if they were not started or will restart() them if they were paused
  116463. * @param loop defines if animations must loop
  116464. * @returns the animation group
  116465. */
  116466. play(loop?: boolean): AnimationGroup;
  116467. /**
  116468. * Reset all animations to initial state
  116469. * @returns the animation group
  116470. */
  116471. reset(): AnimationGroup;
  116472. /**
  116473. * Restart animations from key 0
  116474. * @returns the animation group
  116475. */
  116476. restart(): AnimationGroup;
  116477. /**
  116478. * Stop all animations
  116479. * @returns the animation group
  116480. */
  116481. stop(): AnimationGroup;
  116482. /**
  116483. * Set animation weight for all animatables
  116484. * @param weight defines the weight to use
  116485. * @return the animationGroup
  116486. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  116487. */
  116488. setWeightForAllAnimatables(weight: number): AnimationGroup;
  116489. /**
  116490. * Synchronize and normalize all animatables with a source animatable
  116491. * @param root defines the root animatable to synchronize with
  116492. * @return the animationGroup
  116493. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  116494. */
  116495. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  116496. /**
  116497. * Goes to a specific frame in this animation group
  116498. * @param frame the frame number to go to
  116499. * @return the animationGroup
  116500. */
  116501. goToFrame(frame: number): AnimationGroup;
  116502. /**
  116503. * Dispose all associated resources
  116504. */
  116505. dispose(): void;
  116506. private _checkAnimationGroupEnded;
  116507. /**
  116508. * Clone the current animation group and returns a copy
  116509. * @param newName defines the name of the new group
  116510. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  116511. * @returns the new aniamtion group
  116512. */
  116513. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  116514. /**
  116515. * Serializes the animationGroup to an object
  116516. * @returns Serialized object
  116517. */
  116518. serialize(): any;
  116519. /**
  116520. * Returns a new AnimationGroup object parsed from the source provided.
  116521. * @param parsedAnimationGroup defines the source
  116522. * @param scene defines the scene that will receive the animationGroup
  116523. * @returns a new AnimationGroup
  116524. */
  116525. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  116526. /**
  116527. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  116528. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  116529. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  116530. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  116531. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  116532. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  116533. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  116534. */
  116535. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  116536. /**
  116537. * Returns the string "AnimationGroup"
  116538. * @returns "AnimationGroup"
  116539. */
  116540. getClassName(): string;
  116541. /**
  116542. * Creates a detailled string about the object
  116543. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  116544. * @returns a string representing the object
  116545. */
  116546. toString(fullDetails?: boolean): string;
  116547. }
  116548. }
  116549. declare module BABYLON {
  116550. /**
  116551. * Define an interface for all classes that will hold resources
  116552. */
  116553. export interface IDisposable {
  116554. /**
  116555. * Releases all held resources
  116556. */
  116557. dispose(): void;
  116558. }
  116559. /** Interface defining initialization parameters for Scene class */
  116560. export interface SceneOptions {
  116561. /**
  116562. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  116563. * It will improve performance when the number of geometries becomes important.
  116564. */
  116565. useGeometryUniqueIdsMap?: boolean;
  116566. /**
  116567. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  116568. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  116569. */
  116570. useMaterialMeshMap?: boolean;
  116571. /**
  116572. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  116573. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  116574. */
  116575. useClonedMeshMap?: boolean;
  116576. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  116577. virtual?: boolean;
  116578. }
  116579. /**
  116580. * Represents a scene to be rendered by the engine.
  116581. * @see https://doc.babylonjs.com/features/scene
  116582. */
  116583. export class Scene extends AbstractScene implements IAnimatable {
  116584. /** The fog is deactivated */
  116585. static readonly FOGMODE_NONE: number;
  116586. /** The fog density is following an exponential function */
  116587. static readonly FOGMODE_EXP: number;
  116588. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  116589. static readonly FOGMODE_EXP2: number;
  116590. /** The fog density is following a linear function. */
  116591. static readonly FOGMODE_LINEAR: number;
  116592. /**
  116593. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  116594. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116595. */
  116596. static MinDeltaTime: number;
  116597. /**
  116598. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  116599. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116600. */
  116601. static MaxDeltaTime: number;
  116602. /**
  116603. * Factory used to create the default material.
  116604. * @param name The name of the material to create
  116605. * @param scene The scene to create the material for
  116606. * @returns The default material
  116607. */
  116608. static DefaultMaterialFactory(scene: Scene): Material;
  116609. /**
  116610. * Factory used to create the a collision coordinator.
  116611. * @returns The collision coordinator
  116612. */
  116613. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  116614. /** @hidden */
  116615. _inputManager: InputManager;
  116616. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  116617. cameraToUseForPointers: Nullable<Camera>;
  116618. /** @hidden */
  116619. readonly _isScene: boolean;
  116620. /** @hidden */
  116621. _blockEntityCollection: boolean;
  116622. /**
  116623. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  116624. */
  116625. autoClear: boolean;
  116626. /**
  116627. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  116628. */
  116629. autoClearDepthAndStencil: boolean;
  116630. /**
  116631. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  116632. */
  116633. clearColor: Color4;
  116634. /**
  116635. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  116636. */
  116637. ambientColor: Color3;
  116638. /**
  116639. * This is use to store the default BRDF lookup for PBR materials in your scene.
  116640. * It should only be one of the following (if not the default embedded one):
  116641. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  116642. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  116643. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  116644. * The material properties need to be setup according to the type of texture in use.
  116645. */
  116646. environmentBRDFTexture: BaseTexture;
  116647. /** @hidden */
  116648. protected _environmentTexture: Nullable<BaseTexture>;
  116649. /**
  116650. * Texture used in all pbr material as the reflection texture.
  116651. * As in the majority of the scene they are the same (exception for multi room and so on),
  116652. * this is easier to reference from here than from all the materials.
  116653. */
  116654. get environmentTexture(): Nullable<BaseTexture>;
  116655. /**
  116656. * Texture used in all pbr material as the reflection texture.
  116657. * As in the majority of the scene they are the same (exception for multi room and so on),
  116658. * this is easier to set here than in all the materials.
  116659. */
  116660. set environmentTexture(value: Nullable<BaseTexture>);
  116661. /** @hidden */
  116662. protected _environmentIntensity: number;
  116663. /**
  116664. * Intensity of the environment in all pbr material.
  116665. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  116666. * As in the majority of the scene they are the same (exception for multi room and so on),
  116667. * this is easier to reference from here than from all the materials.
  116668. */
  116669. get environmentIntensity(): number;
  116670. /**
  116671. * Intensity of the environment in all pbr material.
  116672. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  116673. * As in the majority of the scene they are the same (exception for multi room and so on),
  116674. * this is easier to set here than in all the materials.
  116675. */
  116676. set environmentIntensity(value: number);
  116677. /** @hidden */
  116678. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116679. /**
  116680. * Default image processing configuration used either in the rendering
  116681. * Forward main pass or through the imageProcessingPostProcess if present.
  116682. * As in the majority of the scene they are the same (exception for multi camera),
  116683. * this is easier to reference from here than from all the materials and post process.
  116684. *
  116685. * No setter as we it is a shared configuration, you can set the values instead.
  116686. */
  116687. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  116688. private _forceWireframe;
  116689. /**
  116690. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  116691. */
  116692. set forceWireframe(value: boolean);
  116693. get forceWireframe(): boolean;
  116694. private _skipFrustumClipping;
  116695. /**
  116696. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  116697. */
  116698. set skipFrustumClipping(value: boolean);
  116699. get skipFrustumClipping(): boolean;
  116700. private _forcePointsCloud;
  116701. /**
  116702. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  116703. */
  116704. set forcePointsCloud(value: boolean);
  116705. get forcePointsCloud(): boolean;
  116706. /**
  116707. * Gets or sets the active clipplane 1
  116708. */
  116709. clipPlane: Nullable<Plane>;
  116710. /**
  116711. * Gets or sets the active clipplane 2
  116712. */
  116713. clipPlane2: Nullable<Plane>;
  116714. /**
  116715. * Gets or sets the active clipplane 3
  116716. */
  116717. clipPlane3: Nullable<Plane>;
  116718. /**
  116719. * Gets or sets the active clipplane 4
  116720. */
  116721. clipPlane4: Nullable<Plane>;
  116722. /**
  116723. * Gets or sets the active clipplane 5
  116724. */
  116725. clipPlane5: Nullable<Plane>;
  116726. /**
  116727. * Gets or sets the active clipplane 6
  116728. */
  116729. clipPlane6: Nullable<Plane>;
  116730. /**
  116731. * Gets or sets a boolean indicating if animations are enabled
  116732. */
  116733. animationsEnabled: boolean;
  116734. private _animationPropertiesOverride;
  116735. /**
  116736. * Gets or sets the animation properties override
  116737. */
  116738. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  116739. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  116740. /**
  116741. * Gets or sets a boolean indicating if a constant deltatime has to be used
  116742. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  116743. */
  116744. useConstantAnimationDeltaTime: boolean;
  116745. /**
  116746. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  116747. * Please note that it requires to run a ray cast through the scene on every frame
  116748. */
  116749. constantlyUpdateMeshUnderPointer: boolean;
  116750. /**
  116751. * Defines the HTML cursor to use when hovering over interactive elements
  116752. */
  116753. hoverCursor: string;
  116754. /**
  116755. * Defines the HTML default cursor to use (empty by default)
  116756. */
  116757. defaultCursor: string;
  116758. /**
  116759. * Defines whether cursors are handled by the scene.
  116760. */
  116761. doNotHandleCursors: boolean;
  116762. /**
  116763. * This is used to call preventDefault() on pointer down
  116764. * in order to block unwanted artifacts like system double clicks
  116765. */
  116766. preventDefaultOnPointerDown: boolean;
  116767. /**
  116768. * This is used to call preventDefault() on pointer up
  116769. * in order to block unwanted artifacts like system double clicks
  116770. */
  116771. preventDefaultOnPointerUp: boolean;
  116772. /**
  116773. * Gets or sets user defined metadata
  116774. */
  116775. metadata: any;
  116776. /**
  116777. * For internal use only. Please do not use.
  116778. */
  116779. reservedDataStore: any;
  116780. /**
  116781. * Gets the name of the plugin used to load this scene (null by default)
  116782. */
  116783. loadingPluginName: string;
  116784. /**
  116785. * Use this array to add regular expressions used to disable offline support for specific urls
  116786. */
  116787. disableOfflineSupportExceptionRules: RegExp[];
  116788. /**
  116789. * An event triggered when the scene is disposed.
  116790. */
  116791. onDisposeObservable: Observable<Scene>;
  116792. private _onDisposeObserver;
  116793. /** Sets a function to be executed when this scene is disposed. */
  116794. set onDispose(callback: () => void);
  116795. /**
  116796. * An event triggered before rendering the scene (right after animations and physics)
  116797. */
  116798. onBeforeRenderObservable: Observable<Scene>;
  116799. private _onBeforeRenderObserver;
  116800. /** Sets a function to be executed before rendering this scene */
  116801. set beforeRender(callback: Nullable<() => void>);
  116802. /**
  116803. * An event triggered after rendering the scene
  116804. */
  116805. onAfterRenderObservable: Observable<Scene>;
  116806. /**
  116807. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  116808. */
  116809. onAfterRenderCameraObservable: Observable<Camera>;
  116810. private _onAfterRenderObserver;
  116811. /** Sets a function to be executed after rendering this scene */
  116812. set afterRender(callback: Nullable<() => void>);
  116813. /**
  116814. * An event triggered before animating the scene
  116815. */
  116816. onBeforeAnimationsObservable: Observable<Scene>;
  116817. /**
  116818. * An event triggered after animations processing
  116819. */
  116820. onAfterAnimationsObservable: Observable<Scene>;
  116821. /**
  116822. * An event triggered before draw calls are ready to be sent
  116823. */
  116824. onBeforeDrawPhaseObservable: Observable<Scene>;
  116825. /**
  116826. * An event triggered after draw calls have been sent
  116827. */
  116828. onAfterDrawPhaseObservable: Observable<Scene>;
  116829. /**
  116830. * An event triggered when the scene is ready
  116831. */
  116832. onReadyObservable: Observable<Scene>;
  116833. /**
  116834. * An event triggered before rendering a camera
  116835. */
  116836. onBeforeCameraRenderObservable: Observable<Camera>;
  116837. private _onBeforeCameraRenderObserver;
  116838. /** Sets a function to be executed before rendering a camera*/
  116839. set beforeCameraRender(callback: () => void);
  116840. /**
  116841. * An event triggered after rendering a camera
  116842. */
  116843. onAfterCameraRenderObservable: Observable<Camera>;
  116844. private _onAfterCameraRenderObserver;
  116845. /** Sets a function to be executed after rendering a camera*/
  116846. set afterCameraRender(callback: () => void);
  116847. /**
  116848. * An event triggered when active meshes evaluation is about to start
  116849. */
  116850. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  116851. /**
  116852. * An event triggered when active meshes evaluation is done
  116853. */
  116854. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  116855. /**
  116856. * An event triggered when particles rendering is about to start
  116857. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  116858. */
  116859. onBeforeParticlesRenderingObservable: Observable<Scene>;
  116860. /**
  116861. * An event triggered when particles rendering is done
  116862. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  116863. */
  116864. onAfterParticlesRenderingObservable: Observable<Scene>;
  116865. /**
  116866. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  116867. */
  116868. onDataLoadedObservable: Observable<Scene>;
  116869. /**
  116870. * An event triggered when a camera is created
  116871. */
  116872. onNewCameraAddedObservable: Observable<Camera>;
  116873. /**
  116874. * An event triggered when a camera is removed
  116875. */
  116876. onCameraRemovedObservable: Observable<Camera>;
  116877. /**
  116878. * An event triggered when a light is created
  116879. */
  116880. onNewLightAddedObservable: Observable<Light>;
  116881. /**
  116882. * An event triggered when a light is removed
  116883. */
  116884. onLightRemovedObservable: Observable<Light>;
  116885. /**
  116886. * An event triggered when a geometry is created
  116887. */
  116888. onNewGeometryAddedObservable: Observable<Geometry>;
  116889. /**
  116890. * An event triggered when a geometry is removed
  116891. */
  116892. onGeometryRemovedObservable: Observable<Geometry>;
  116893. /**
  116894. * An event triggered when a transform node is created
  116895. */
  116896. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  116897. /**
  116898. * An event triggered when a transform node is removed
  116899. */
  116900. onTransformNodeRemovedObservable: Observable<TransformNode>;
  116901. /**
  116902. * An event triggered when a mesh is created
  116903. */
  116904. onNewMeshAddedObservable: Observable<AbstractMesh>;
  116905. /**
  116906. * An event triggered when a mesh is removed
  116907. */
  116908. onMeshRemovedObservable: Observable<AbstractMesh>;
  116909. /**
  116910. * An event triggered when a skeleton is created
  116911. */
  116912. onNewSkeletonAddedObservable: Observable<Skeleton>;
  116913. /**
  116914. * An event triggered when a skeleton is removed
  116915. */
  116916. onSkeletonRemovedObservable: Observable<Skeleton>;
  116917. /**
  116918. * An event triggered when a material is created
  116919. */
  116920. onNewMaterialAddedObservable: Observable<Material>;
  116921. /**
  116922. * An event triggered when a material is removed
  116923. */
  116924. onMaterialRemovedObservable: Observable<Material>;
  116925. /**
  116926. * An event triggered when a texture is created
  116927. */
  116928. onNewTextureAddedObservable: Observable<BaseTexture>;
  116929. /**
  116930. * An event triggered when a texture is removed
  116931. */
  116932. onTextureRemovedObservable: Observable<BaseTexture>;
  116933. /**
  116934. * An event triggered when render targets are about to be rendered
  116935. * Can happen multiple times per frame.
  116936. */
  116937. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  116938. /**
  116939. * An event triggered when render targets were rendered.
  116940. * Can happen multiple times per frame.
  116941. */
  116942. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  116943. /**
  116944. * An event triggered before calculating deterministic simulation step
  116945. */
  116946. onBeforeStepObservable: Observable<Scene>;
  116947. /**
  116948. * An event triggered after calculating deterministic simulation step
  116949. */
  116950. onAfterStepObservable: Observable<Scene>;
  116951. /**
  116952. * An event triggered when the activeCamera property is updated
  116953. */
  116954. onActiveCameraChanged: Observable<Scene>;
  116955. /**
  116956. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  116957. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  116958. * 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)
  116959. */
  116960. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  116961. /**
  116962. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  116963. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  116964. * 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)
  116965. */
  116966. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  116967. /**
  116968. * This Observable will when a mesh has been imported into the scene.
  116969. */
  116970. onMeshImportedObservable: Observable<AbstractMesh>;
  116971. /**
  116972. * This Observable will when an animation file has been imported into the scene.
  116973. */
  116974. onAnimationFileImportedObservable: Observable<Scene>;
  116975. /**
  116976. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  116977. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  116978. */
  116979. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  116980. /** @hidden */
  116981. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  116982. /**
  116983. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  116984. */
  116985. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  116986. /**
  116987. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  116988. */
  116989. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  116990. /**
  116991. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  116992. */
  116993. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  116994. /** Callback called when a pointer move is detected */
  116995. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  116996. /** Callback called when a pointer down is detected */
  116997. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  116998. /** Callback called when a pointer up is detected */
  116999. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  117000. /** Callback called when a pointer pick is detected */
  117001. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  117002. /**
  117003. * 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).
  117004. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  117005. */
  117006. onPrePointerObservable: Observable<PointerInfoPre>;
  117007. /**
  117008. * Observable event triggered each time an input event is received from the rendering canvas
  117009. */
  117010. onPointerObservable: Observable<PointerInfo>;
  117011. /**
  117012. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  117013. */
  117014. get unTranslatedPointer(): Vector2;
  117015. /**
  117016. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  117017. */
  117018. static get DragMovementThreshold(): number;
  117019. static set DragMovementThreshold(value: number);
  117020. /**
  117021. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  117022. */
  117023. static get LongPressDelay(): number;
  117024. static set LongPressDelay(value: number);
  117025. /**
  117026. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  117027. */
  117028. static get DoubleClickDelay(): number;
  117029. static set DoubleClickDelay(value: number);
  117030. /** If you need to check double click without raising a single click at first click, enable this flag */
  117031. static get ExclusiveDoubleClickMode(): boolean;
  117032. static set ExclusiveDoubleClickMode(value: boolean);
  117033. /** @hidden */
  117034. _mirroredCameraPosition: Nullable<Vector3>;
  117035. /**
  117036. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  117037. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  117038. */
  117039. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  117040. /**
  117041. * Observable event triggered each time an keyboard event is received from the hosting window
  117042. */
  117043. onKeyboardObservable: Observable<KeyboardInfo>;
  117044. private _useRightHandedSystem;
  117045. /**
  117046. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  117047. */
  117048. set useRightHandedSystem(value: boolean);
  117049. get useRightHandedSystem(): boolean;
  117050. private _timeAccumulator;
  117051. private _currentStepId;
  117052. private _currentInternalStep;
  117053. /**
  117054. * Sets the step Id used by deterministic lock step
  117055. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117056. * @param newStepId defines the step Id
  117057. */
  117058. setStepId(newStepId: number): void;
  117059. /**
  117060. * Gets the step Id used by deterministic lock step
  117061. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117062. * @returns the step Id
  117063. */
  117064. getStepId(): number;
  117065. /**
  117066. * Gets the internal step used by deterministic lock step
  117067. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117068. * @returns the internal step
  117069. */
  117070. getInternalStep(): number;
  117071. private _fogEnabled;
  117072. /**
  117073. * Gets or sets a boolean indicating if fog is enabled on this scene
  117074. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117075. * (Default is true)
  117076. */
  117077. set fogEnabled(value: boolean);
  117078. get fogEnabled(): boolean;
  117079. private _fogMode;
  117080. /**
  117081. * Gets or sets the fog mode to use
  117082. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117083. * | mode | value |
  117084. * | --- | --- |
  117085. * | FOGMODE_NONE | 0 |
  117086. * | FOGMODE_EXP | 1 |
  117087. * | FOGMODE_EXP2 | 2 |
  117088. * | FOGMODE_LINEAR | 3 |
  117089. */
  117090. set fogMode(value: number);
  117091. get fogMode(): number;
  117092. /**
  117093. * Gets or sets the fog color to use
  117094. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117095. * (Default is Color3(0.2, 0.2, 0.3))
  117096. */
  117097. fogColor: Color3;
  117098. /**
  117099. * Gets or sets the fog density to use
  117100. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117101. * (Default is 0.1)
  117102. */
  117103. fogDensity: number;
  117104. /**
  117105. * Gets or sets the fog start distance to use
  117106. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117107. * (Default is 0)
  117108. */
  117109. fogStart: number;
  117110. /**
  117111. * Gets or sets the fog end distance to use
  117112. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117113. * (Default is 1000)
  117114. */
  117115. fogEnd: number;
  117116. /**
  117117. * Flag indicating that the frame buffer binding is handled by another component
  117118. */
  117119. prePass: boolean;
  117120. private _shadowsEnabled;
  117121. /**
  117122. * Gets or sets a boolean indicating if shadows are enabled on this scene
  117123. */
  117124. set shadowsEnabled(value: boolean);
  117125. get shadowsEnabled(): boolean;
  117126. private _lightsEnabled;
  117127. /**
  117128. * Gets or sets a boolean indicating if lights are enabled on this scene
  117129. */
  117130. set lightsEnabled(value: boolean);
  117131. get lightsEnabled(): boolean;
  117132. /** All of the active cameras added to this scene. */
  117133. activeCameras: Camera[];
  117134. /** @hidden */
  117135. _activeCamera: Nullable<Camera>;
  117136. /** Gets or sets the current active camera */
  117137. get activeCamera(): Nullable<Camera>;
  117138. set activeCamera(value: Nullable<Camera>);
  117139. private _defaultMaterial;
  117140. /** The default material used on meshes when no material is affected */
  117141. get defaultMaterial(): Material;
  117142. /** The default material used on meshes when no material is affected */
  117143. set defaultMaterial(value: Material);
  117144. private _texturesEnabled;
  117145. /**
  117146. * Gets or sets a boolean indicating if textures are enabled on this scene
  117147. */
  117148. set texturesEnabled(value: boolean);
  117149. get texturesEnabled(): boolean;
  117150. /**
  117151. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  117152. */
  117153. physicsEnabled: boolean;
  117154. /**
  117155. * Gets or sets a boolean indicating if particles are enabled on this scene
  117156. */
  117157. particlesEnabled: boolean;
  117158. /**
  117159. * Gets or sets a boolean indicating if sprites are enabled on this scene
  117160. */
  117161. spritesEnabled: boolean;
  117162. private _skeletonsEnabled;
  117163. /**
  117164. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  117165. */
  117166. set skeletonsEnabled(value: boolean);
  117167. get skeletonsEnabled(): boolean;
  117168. /**
  117169. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  117170. */
  117171. lensFlaresEnabled: boolean;
  117172. /**
  117173. * Gets or sets a boolean indicating if collisions are enabled on this scene
  117174. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117175. */
  117176. collisionsEnabled: boolean;
  117177. private _collisionCoordinator;
  117178. /** @hidden */
  117179. get collisionCoordinator(): ICollisionCoordinator;
  117180. /**
  117181. * Defines the gravity applied to this scene (used only for collisions)
  117182. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117183. */
  117184. gravity: Vector3;
  117185. /**
  117186. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  117187. */
  117188. postProcessesEnabled: boolean;
  117189. /**
  117190. * The list of postprocesses added to the scene
  117191. */
  117192. postProcesses: PostProcess[];
  117193. /**
  117194. * Gets the current postprocess manager
  117195. */
  117196. postProcessManager: PostProcessManager;
  117197. /**
  117198. * Gets or sets a boolean indicating if render targets are enabled on this scene
  117199. */
  117200. renderTargetsEnabled: boolean;
  117201. /**
  117202. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  117203. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  117204. */
  117205. dumpNextRenderTargets: boolean;
  117206. /**
  117207. * The list of user defined render targets added to the scene
  117208. */
  117209. customRenderTargets: RenderTargetTexture[];
  117210. /**
  117211. * Defines if texture loading must be delayed
  117212. * If true, textures will only be loaded when they need to be rendered
  117213. */
  117214. useDelayedTextureLoading: boolean;
  117215. /**
  117216. * Gets the list of meshes imported to the scene through SceneLoader
  117217. */
  117218. importedMeshesFiles: String[];
  117219. /**
  117220. * Gets or sets a boolean indicating if probes are enabled on this scene
  117221. */
  117222. probesEnabled: boolean;
  117223. /**
  117224. * Gets or sets the current offline provider to use to store scene data
  117225. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  117226. */
  117227. offlineProvider: IOfflineProvider;
  117228. /**
  117229. * Gets or sets the action manager associated with the scene
  117230. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  117231. */
  117232. actionManager: AbstractActionManager;
  117233. private _meshesForIntersections;
  117234. /**
  117235. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  117236. */
  117237. proceduralTexturesEnabled: boolean;
  117238. private _engine;
  117239. private _totalVertices;
  117240. /** @hidden */
  117241. _activeIndices: PerfCounter;
  117242. /** @hidden */
  117243. _activeParticles: PerfCounter;
  117244. /** @hidden */
  117245. _activeBones: PerfCounter;
  117246. private _animationRatio;
  117247. /** @hidden */
  117248. _animationTimeLast: number;
  117249. /** @hidden */
  117250. _animationTime: number;
  117251. /**
  117252. * Gets or sets a general scale for animation speed
  117253. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  117254. */
  117255. animationTimeScale: number;
  117256. /** @hidden */
  117257. _cachedMaterial: Nullable<Material>;
  117258. /** @hidden */
  117259. _cachedEffect: Nullable<Effect>;
  117260. /** @hidden */
  117261. _cachedVisibility: Nullable<number>;
  117262. private _renderId;
  117263. private _frameId;
  117264. private _executeWhenReadyTimeoutId;
  117265. private _intermediateRendering;
  117266. private _viewUpdateFlag;
  117267. private _projectionUpdateFlag;
  117268. /** @hidden */
  117269. _toBeDisposed: Nullable<IDisposable>[];
  117270. private _activeRequests;
  117271. /** @hidden */
  117272. _pendingData: any[];
  117273. private _isDisposed;
  117274. /**
  117275. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  117276. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  117277. */
  117278. dispatchAllSubMeshesOfActiveMeshes: boolean;
  117279. private _activeMeshes;
  117280. private _processedMaterials;
  117281. private _renderTargets;
  117282. /** @hidden */
  117283. _activeParticleSystems: SmartArray<IParticleSystem>;
  117284. private _activeSkeletons;
  117285. private _softwareSkinnedMeshes;
  117286. private _renderingManager;
  117287. /** @hidden */
  117288. _activeAnimatables: Animatable[];
  117289. private _transformMatrix;
  117290. private _sceneUbo;
  117291. /** @hidden */
  117292. _viewMatrix: Matrix;
  117293. private _projectionMatrix;
  117294. /** @hidden */
  117295. _forcedViewPosition: Nullable<Vector3>;
  117296. /** @hidden */
  117297. _frustumPlanes: Plane[];
  117298. /**
  117299. * Gets the list of frustum planes (built from the active camera)
  117300. */
  117301. get frustumPlanes(): Plane[];
  117302. /**
  117303. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  117304. * This is useful if there are more lights that the maximum simulteanous authorized
  117305. */
  117306. requireLightSorting: boolean;
  117307. /** @hidden */
  117308. readonly useMaterialMeshMap: boolean;
  117309. /** @hidden */
  117310. readonly useClonedMeshMap: boolean;
  117311. private _externalData;
  117312. private _uid;
  117313. /**
  117314. * @hidden
  117315. * Backing store of defined scene components.
  117316. */
  117317. _components: ISceneComponent[];
  117318. /**
  117319. * @hidden
  117320. * Backing store of defined scene components.
  117321. */
  117322. _serializableComponents: ISceneSerializableComponent[];
  117323. /**
  117324. * List of components to register on the next registration step.
  117325. */
  117326. private _transientComponents;
  117327. /**
  117328. * Registers the transient components if needed.
  117329. */
  117330. private _registerTransientComponents;
  117331. /**
  117332. * @hidden
  117333. * Add a component to the scene.
  117334. * Note that the ccomponent could be registered on th next frame if this is called after
  117335. * the register component stage.
  117336. * @param component Defines the component to add to the scene
  117337. */
  117338. _addComponent(component: ISceneComponent): void;
  117339. /**
  117340. * @hidden
  117341. * Gets a component from the scene.
  117342. * @param name defines the name of the component to retrieve
  117343. * @returns the component or null if not present
  117344. */
  117345. _getComponent(name: string): Nullable<ISceneComponent>;
  117346. /**
  117347. * @hidden
  117348. * Defines the actions happening before camera updates.
  117349. */
  117350. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  117351. /**
  117352. * @hidden
  117353. * Defines the actions happening before clear the canvas.
  117354. */
  117355. _beforeClearStage: Stage<SimpleStageAction>;
  117356. /**
  117357. * @hidden
  117358. * Defines the actions when collecting render targets for the frame.
  117359. */
  117360. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  117361. /**
  117362. * @hidden
  117363. * Defines the actions happening for one camera in the frame.
  117364. */
  117365. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  117366. /**
  117367. * @hidden
  117368. * Defines the actions happening during the per mesh ready checks.
  117369. */
  117370. _isReadyForMeshStage: Stage<MeshStageAction>;
  117371. /**
  117372. * @hidden
  117373. * Defines the actions happening before evaluate active mesh checks.
  117374. */
  117375. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  117376. /**
  117377. * @hidden
  117378. * Defines the actions happening during the evaluate sub mesh checks.
  117379. */
  117380. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  117381. /**
  117382. * @hidden
  117383. * Defines the actions happening during the active mesh stage.
  117384. */
  117385. _activeMeshStage: Stage<ActiveMeshStageAction>;
  117386. /**
  117387. * @hidden
  117388. * Defines the actions happening during the per camera render target step.
  117389. */
  117390. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  117391. /**
  117392. * @hidden
  117393. * Defines the actions happening just before the active camera is drawing.
  117394. */
  117395. _beforeCameraDrawStage: Stage<CameraStageAction>;
  117396. /**
  117397. * @hidden
  117398. * Defines the actions happening just before a render target is drawing.
  117399. */
  117400. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  117401. /**
  117402. * @hidden
  117403. * Defines the actions happening just before a rendering group is drawing.
  117404. */
  117405. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  117406. /**
  117407. * @hidden
  117408. * Defines the actions happening just before a mesh is drawing.
  117409. */
  117410. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  117411. /**
  117412. * @hidden
  117413. * Defines the actions happening just after a mesh has been drawn.
  117414. */
  117415. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  117416. /**
  117417. * @hidden
  117418. * Defines the actions happening just after a rendering group has been drawn.
  117419. */
  117420. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  117421. /**
  117422. * @hidden
  117423. * Defines the actions happening just after the active camera has been drawn.
  117424. */
  117425. _afterCameraDrawStage: Stage<CameraStageAction>;
  117426. /**
  117427. * @hidden
  117428. * Defines the actions happening just after a render target has been drawn.
  117429. */
  117430. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  117431. /**
  117432. * @hidden
  117433. * Defines the actions happening just after rendering all cameras and computing intersections.
  117434. */
  117435. _afterRenderStage: Stage<SimpleStageAction>;
  117436. /**
  117437. * @hidden
  117438. * Defines the actions happening when a pointer move event happens.
  117439. */
  117440. _pointerMoveStage: Stage<PointerMoveStageAction>;
  117441. /**
  117442. * @hidden
  117443. * Defines the actions happening when a pointer down event happens.
  117444. */
  117445. _pointerDownStage: Stage<PointerUpDownStageAction>;
  117446. /**
  117447. * @hidden
  117448. * Defines the actions happening when a pointer up event happens.
  117449. */
  117450. _pointerUpStage: Stage<PointerUpDownStageAction>;
  117451. /**
  117452. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  117453. */
  117454. private geometriesByUniqueId;
  117455. /**
  117456. * Creates a new Scene
  117457. * @param engine defines the engine to use to render this scene
  117458. * @param options defines the scene options
  117459. */
  117460. constructor(engine: Engine, options?: SceneOptions);
  117461. /**
  117462. * Gets a string idenfifying the name of the class
  117463. * @returns "Scene" string
  117464. */
  117465. getClassName(): string;
  117466. private _defaultMeshCandidates;
  117467. /**
  117468. * @hidden
  117469. */
  117470. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  117471. private _defaultSubMeshCandidates;
  117472. /**
  117473. * @hidden
  117474. */
  117475. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  117476. /**
  117477. * Sets the default candidate providers for the scene.
  117478. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  117479. * and getCollidingSubMeshCandidates to their default function
  117480. */
  117481. setDefaultCandidateProviders(): void;
  117482. /**
  117483. * Gets the mesh that is currently under the pointer
  117484. */
  117485. get meshUnderPointer(): Nullable<AbstractMesh>;
  117486. /**
  117487. * Gets or sets the current on-screen X position of the pointer
  117488. */
  117489. get pointerX(): number;
  117490. set pointerX(value: number);
  117491. /**
  117492. * Gets or sets the current on-screen Y position of the pointer
  117493. */
  117494. get pointerY(): number;
  117495. set pointerY(value: number);
  117496. /**
  117497. * Gets the cached material (ie. the latest rendered one)
  117498. * @returns the cached material
  117499. */
  117500. getCachedMaterial(): Nullable<Material>;
  117501. /**
  117502. * Gets the cached effect (ie. the latest rendered one)
  117503. * @returns the cached effect
  117504. */
  117505. getCachedEffect(): Nullable<Effect>;
  117506. /**
  117507. * Gets the cached visibility state (ie. the latest rendered one)
  117508. * @returns the cached visibility state
  117509. */
  117510. getCachedVisibility(): Nullable<number>;
  117511. /**
  117512. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  117513. * @param material defines the current material
  117514. * @param effect defines the current effect
  117515. * @param visibility defines the current visibility state
  117516. * @returns true if one parameter is not cached
  117517. */
  117518. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  117519. /**
  117520. * Gets the engine associated with the scene
  117521. * @returns an Engine
  117522. */
  117523. getEngine(): Engine;
  117524. /**
  117525. * Gets the total number of vertices rendered per frame
  117526. * @returns the total number of vertices rendered per frame
  117527. */
  117528. getTotalVertices(): number;
  117529. /**
  117530. * Gets the performance counter for total vertices
  117531. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117532. */
  117533. get totalVerticesPerfCounter(): PerfCounter;
  117534. /**
  117535. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  117536. * @returns the total number of active indices rendered per frame
  117537. */
  117538. getActiveIndices(): number;
  117539. /**
  117540. * Gets the performance counter for active indices
  117541. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117542. */
  117543. get totalActiveIndicesPerfCounter(): PerfCounter;
  117544. /**
  117545. * Gets the total number of active particles rendered per frame
  117546. * @returns the total number of active particles rendered per frame
  117547. */
  117548. getActiveParticles(): number;
  117549. /**
  117550. * Gets the performance counter for active particles
  117551. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117552. */
  117553. get activeParticlesPerfCounter(): PerfCounter;
  117554. /**
  117555. * Gets the total number of active bones rendered per frame
  117556. * @returns the total number of active bones rendered per frame
  117557. */
  117558. getActiveBones(): number;
  117559. /**
  117560. * Gets the performance counter for active bones
  117561. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117562. */
  117563. get activeBonesPerfCounter(): PerfCounter;
  117564. /**
  117565. * Gets the array of active meshes
  117566. * @returns an array of AbstractMesh
  117567. */
  117568. getActiveMeshes(): SmartArray<AbstractMesh>;
  117569. /**
  117570. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  117571. * @returns a number
  117572. */
  117573. getAnimationRatio(): number;
  117574. /**
  117575. * Gets an unique Id for the current render phase
  117576. * @returns a number
  117577. */
  117578. getRenderId(): number;
  117579. /**
  117580. * Gets an unique Id for the current frame
  117581. * @returns a number
  117582. */
  117583. getFrameId(): number;
  117584. /** Call this function if you want to manually increment the render Id*/
  117585. incrementRenderId(): void;
  117586. private _createUbo;
  117587. /**
  117588. * Use this method to simulate a pointer move on a mesh
  117589. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117590. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117591. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117592. * @returns the current scene
  117593. */
  117594. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  117595. /**
  117596. * Use this method to simulate a pointer down on a mesh
  117597. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117598. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117599. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117600. * @returns the current scene
  117601. */
  117602. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  117603. /**
  117604. * Use this method to simulate a pointer up on a mesh
  117605. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117606. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117607. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117608. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  117609. * @returns the current scene
  117610. */
  117611. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  117612. /**
  117613. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  117614. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  117615. * @returns true if the pointer was captured
  117616. */
  117617. isPointerCaptured(pointerId?: number): boolean;
  117618. /**
  117619. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  117620. * @param attachUp defines if you want to attach events to pointerup
  117621. * @param attachDown defines if you want to attach events to pointerdown
  117622. * @param attachMove defines if you want to attach events to pointermove
  117623. */
  117624. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  117625. /** Detaches all event handlers*/
  117626. detachControl(): void;
  117627. /**
  117628. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  117629. * Delay loaded resources are not taking in account
  117630. * @return true if all required resources are ready
  117631. */
  117632. isReady(): boolean;
  117633. /** Resets all cached information relative to material (including effect and visibility) */
  117634. resetCachedMaterial(): void;
  117635. /**
  117636. * Registers a function to be called before every frame render
  117637. * @param func defines the function to register
  117638. */
  117639. registerBeforeRender(func: () => void): void;
  117640. /**
  117641. * Unregisters a function called before every frame render
  117642. * @param func defines the function to unregister
  117643. */
  117644. unregisterBeforeRender(func: () => void): void;
  117645. /**
  117646. * Registers a function to be called after every frame render
  117647. * @param func defines the function to register
  117648. */
  117649. registerAfterRender(func: () => void): void;
  117650. /**
  117651. * Unregisters a function called after every frame render
  117652. * @param func defines the function to unregister
  117653. */
  117654. unregisterAfterRender(func: () => void): void;
  117655. private _executeOnceBeforeRender;
  117656. /**
  117657. * The provided function will run before render once and will be disposed afterwards.
  117658. * A timeout delay can be provided so that the function will be executed in N ms.
  117659. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  117660. * @param func The function to be executed.
  117661. * @param timeout optional delay in ms
  117662. */
  117663. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  117664. /** @hidden */
  117665. _addPendingData(data: any): void;
  117666. /** @hidden */
  117667. _removePendingData(data: any): void;
  117668. /**
  117669. * Returns the number of items waiting to be loaded
  117670. * @returns the number of items waiting to be loaded
  117671. */
  117672. getWaitingItemsCount(): number;
  117673. /**
  117674. * Returns a boolean indicating if the scene is still loading data
  117675. */
  117676. get isLoading(): boolean;
  117677. /**
  117678. * Registers a function to be executed when the scene is ready
  117679. * @param {Function} func - the function to be executed
  117680. */
  117681. executeWhenReady(func: () => void): void;
  117682. /**
  117683. * Returns a promise that resolves when the scene is ready
  117684. * @returns A promise that resolves when the scene is ready
  117685. */
  117686. whenReadyAsync(): Promise<void>;
  117687. /** @hidden */
  117688. _checkIsReady(): void;
  117689. /**
  117690. * Gets all animatable attached to the scene
  117691. */
  117692. get animatables(): Animatable[];
  117693. /**
  117694. * Resets the last animation time frame.
  117695. * Useful to override when animations start running when loading a scene for the first time.
  117696. */
  117697. resetLastAnimationTimeFrame(): void;
  117698. /**
  117699. * Gets the current view matrix
  117700. * @returns a Matrix
  117701. */
  117702. getViewMatrix(): Matrix;
  117703. /**
  117704. * Gets the current projection matrix
  117705. * @returns a Matrix
  117706. */
  117707. getProjectionMatrix(): Matrix;
  117708. /**
  117709. * Gets the current transform matrix
  117710. * @returns a Matrix made of View * Projection
  117711. */
  117712. getTransformMatrix(): Matrix;
  117713. /**
  117714. * Sets the current transform matrix
  117715. * @param viewL defines the View matrix to use
  117716. * @param projectionL defines the Projection matrix to use
  117717. * @param viewR defines the right View matrix to use (if provided)
  117718. * @param projectionR defines the right Projection matrix to use (if provided)
  117719. */
  117720. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  117721. /**
  117722. * Gets the uniform buffer used to store scene data
  117723. * @returns a UniformBuffer
  117724. */
  117725. getSceneUniformBuffer(): UniformBuffer;
  117726. /**
  117727. * Gets an unique (relatively to the current scene) Id
  117728. * @returns an unique number for the scene
  117729. */
  117730. getUniqueId(): number;
  117731. /**
  117732. * Add a mesh to the list of scene's meshes
  117733. * @param newMesh defines the mesh to add
  117734. * @param recursive if all child meshes should also be added to the scene
  117735. */
  117736. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  117737. /**
  117738. * Remove a mesh for the list of scene's meshes
  117739. * @param toRemove defines the mesh to remove
  117740. * @param recursive if all child meshes should also be removed from the scene
  117741. * @returns the index where the mesh was in the mesh list
  117742. */
  117743. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  117744. /**
  117745. * Add a transform node to the list of scene's transform nodes
  117746. * @param newTransformNode defines the transform node to add
  117747. */
  117748. addTransformNode(newTransformNode: TransformNode): void;
  117749. /**
  117750. * Remove a transform node for the list of scene's transform nodes
  117751. * @param toRemove defines the transform node to remove
  117752. * @returns the index where the transform node was in the transform node list
  117753. */
  117754. removeTransformNode(toRemove: TransformNode): number;
  117755. /**
  117756. * Remove a skeleton for the list of scene's skeletons
  117757. * @param toRemove defines the skeleton to remove
  117758. * @returns the index where the skeleton was in the skeleton list
  117759. */
  117760. removeSkeleton(toRemove: Skeleton): number;
  117761. /**
  117762. * Remove a morph target for the list of scene's morph targets
  117763. * @param toRemove defines the morph target to remove
  117764. * @returns the index where the morph target was in the morph target list
  117765. */
  117766. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  117767. /**
  117768. * Remove a light for the list of scene's lights
  117769. * @param toRemove defines the light to remove
  117770. * @returns the index where the light was in the light list
  117771. */
  117772. removeLight(toRemove: Light): number;
  117773. /**
  117774. * Remove a camera for the list of scene's cameras
  117775. * @param toRemove defines the camera to remove
  117776. * @returns the index where the camera was in the camera list
  117777. */
  117778. removeCamera(toRemove: Camera): number;
  117779. /**
  117780. * Remove a particle system for the list of scene's particle systems
  117781. * @param toRemove defines the particle system to remove
  117782. * @returns the index where the particle system was in the particle system list
  117783. */
  117784. removeParticleSystem(toRemove: IParticleSystem): number;
  117785. /**
  117786. * Remove a animation for the list of scene's animations
  117787. * @param toRemove defines the animation to remove
  117788. * @returns the index where the animation was in the animation list
  117789. */
  117790. removeAnimation(toRemove: Animation): number;
  117791. /**
  117792. * Will stop the animation of the given target
  117793. * @param target - the target
  117794. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  117795. * @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)
  117796. */
  117797. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  117798. /**
  117799. * Removes the given animation group from this scene.
  117800. * @param toRemove The animation group to remove
  117801. * @returns The index of the removed animation group
  117802. */
  117803. removeAnimationGroup(toRemove: AnimationGroup): number;
  117804. /**
  117805. * Removes the given multi-material from this scene.
  117806. * @param toRemove The multi-material to remove
  117807. * @returns The index of the removed multi-material
  117808. */
  117809. removeMultiMaterial(toRemove: MultiMaterial): number;
  117810. /**
  117811. * Removes the given material from this scene.
  117812. * @param toRemove The material to remove
  117813. * @returns The index of the removed material
  117814. */
  117815. removeMaterial(toRemove: Material): number;
  117816. /**
  117817. * Removes the given action manager from this scene.
  117818. * @param toRemove The action manager to remove
  117819. * @returns The index of the removed action manager
  117820. */
  117821. removeActionManager(toRemove: AbstractActionManager): number;
  117822. /**
  117823. * Removes the given texture from this scene.
  117824. * @param toRemove The texture to remove
  117825. * @returns The index of the removed texture
  117826. */
  117827. removeTexture(toRemove: BaseTexture): number;
  117828. /**
  117829. * Adds the given light to this scene
  117830. * @param newLight The light to add
  117831. */
  117832. addLight(newLight: Light): void;
  117833. /**
  117834. * Sorts the list list based on light priorities
  117835. */
  117836. sortLightsByPriority(): void;
  117837. /**
  117838. * Adds the given camera to this scene
  117839. * @param newCamera The camera to add
  117840. */
  117841. addCamera(newCamera: Camera): void;
  117842. /**
  117843. * Adds the given skeleton to this scene
  117844. * @param newSkeleton The skeleton to add
  117845. */
  117846. addSkeleton(newSkeleton: Skeleton): void;
  117847. /**
  117848. * Adds the given particle system to this scene
  117849. * @param newParticleSystem The particle system to add
  117850. */
  117851. addParticleSystem(newParticleSystem: IParticleSystem): void;
  117852. /**
  117853. * Adds the given animation to this scene
  117854. * @param newAnimation The animation to add
  117855. */
  117856. addAnimation(newAnimation: Animation): void;
  117857. /**
  117858. * Adds the given animation group to this scene.
  117859. * @param newAnimationGroup The animation group to add
  117860. */
  117861. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  117862. /**
  117863. * Adds the given multi-material to this scene
  117864. * @param newMultiMaterial The multi-material to add
  117865. */
  117866. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  117867. /**
  117868. * Adds the given material to this scene
  117869. * @param newMaterial The material to add
  117870. */
  117871. addMaterial(newMaterial: Material): void;
  117872. /**
  117873. * Adds the given morph target to this scene
  117874. * @param newMorphTargetManager The morph target to add
  117875. */
  117876. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  117877. /**
  117878. * Adds the given geometry to this scene
  117879. * @param newGeometry The geometry to add
  117880. */
  117881. addGeometry(newGeometry: Geometry): void;
  117882. /**
  117883. * Adds the given action manager to this scene
  117884. * @param newActionManager The action manager to add
  117885. */
  117886. addActionManager(newActionManager: AbstractActionManager): void;
  117887. /**
  117888. * Adds the given texture to this scene.
  117889. * @param newTexture The texture to add
  117890. */
  117891. addTexture(newTexture: BaseTexture): void;
  117892. /**
  117893. * Switch active camera
  117894. * @param newCamera defines the new active camera
  117895. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  117896. */
  117897. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  117898. /**
  117899. * sets the active camera of the scene using its ID
  117900. * @param id defines the camera's ID
  117901. * @return the new active camera or null if none found.
  117902. */
  117903. setActiveCameraByID(id: string): Nullable<Camera>;
  117904. /**
  117905. * sets the active camera of the scene using its name
  117906. * @param name defines the camera's name
  117907. * @returns the new active camera or null if none found.
  117908. */
  117909. setActiveCameraByName(name: string): Nullable<Camera>;
  117910. /**
  117911. * get an animation group using its name
  117912. * @param name defines the material's name
  117913. * @return the animation group or null if none found.
  117914. */
  117915. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  117916. /**
  117917. * Get a material using its unique id
  117918. * @param uniqueId defines the material's unique id
  117919. * @return the material or null if none found.
  117920. */
  117921. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  117922. /**
  117923. * get a material using its id
  117924. * @param id defines the material's ID
  117925. * @return the material or null if none found.
  117926. */
  117927. getMaterialByID(id: string): Nullable<Material>;
  117928. /**
  117929. * Gets a the last added material using a given id
  117930. * @param id defines the material's ID
  117931. * @return the last material with the given id or null if none found.
  117932. */
  117933. getLastMaterialByID(id: string): Nullable<Material>;
  117934. /**
  117935. * Gets a material using its name
  117936. * @param name defines the material's name
  117937. * @return the material or null if none found.
  117938. */
  117939. getMaterialByName(name: string): Nullable<Material>;
  117940. /**
  117941. * Get a texture using its unique id
  117942. * @param uniqueId defines the texture's unique id
  117943. * @return the texture or null if none found.
  117944. */
  117945. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  117946. /**
  117947. * Gets a camera using its id
  117948. * @param id defines the id to look for
  117949. * @returns the camera or null if not found
  117950. */
  117951. getCameraByID(id: string): Nullable<Camera>;
  117952. /**
  117953. * Gets a camera using its unique id
  117954. * @param uniqueId defines the unique id to look for
  117955. * @returns the camera or null if not found
  117956. */
  117957. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  117958. /**
  117959. * Gets a camera using its name
  117960. * @param name defines the camera's name
  117961. * @return the camera or null if none found.
  117962. */
  117963. getCameraByName(name: string): Nullable<Camera>;
  117964. /**
  117965. * Gets a bone using its id
  117966. * @param id defines the bone's id
  117967. * @return the bone or null if not found
  117968. */
  117969. getBoneByID(id: string): Nullable<Bone>;
  117970. /**
  117971. * Gets a bone using its id
  117972. * @param name defines the bone's name
  117973. * @return the bone or null if not found
  117974. */
  117975. getBoneByName(name: string): Nullable<Bone>;
  117976. /**
  117977. * Gets a light node using its name
  117978. * @param name defines the the light's name
  117979. * @return the light or null if none found.
  117980. */
  117981. getLightByName(name: string): Nullable<Light>;
  117982. /**
  117983. * Gets a light node using its id
  117984. * @param id defines the light's id
  117985. * @return the light or null if none found.
  117986. */
  117987. getLightByID(id: string): Nullable<Light>;
  117988. /**
  117989. * Gets a light node using its scene-generated unique ID
  117990. * @param uniqueId defines the light's unique id
  117991. * @return the light or null if none found.
  117992. */
  117993. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  117994. /**
  117995. * Gets a particle system by id
  117996. * @param id defines the particle system id
  117997. * @return the corresponding system or null if none found
  117998. */
  117999. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  118000. /**
  118001. * Gets a geometry using its ID
  118002. * @param id defines the geometry's id
  118003. * @return the geometry or null if none found.
  118004. */
  118005. getGeometryByID(id: string): Nullable<Geometry>;
  118006. private _getGeometryByUniqueID;
  118007. /**
  118008. * Add a new geometry to this scene
  118009. * @param geometry defines the geometry to be added to the scene.
  118010. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  118011. * @return a boolean defining if the geometry was added or not
  118012. */
  118013. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  118014. /**
  118015. * Removes an existing geometry
  118016. * @param geometry defines the geometry to be removed from the scene
  118017. * @return a boolean defining if the geometry was removed or not
  118018. */
  118019. removeGeometry(geometry: Geometry): boolean;
  118020. /**
  118021. * Gets the list of geometries attached to the scene
  118022. * @returns an array of Geometry
  118023. */
  118024. getGeometries(): Geometry[];
  118025. /**
  118026. * Gets the first added mesh found of a given ID
  118027. * @param id defines the id to search for
  118028. * @return the mesh found or null if not found at all
  118029. */
  118030. getMeshByID(id: string): Nullable<AbstractMesh>;
  118031. /**
  118032. * Gets a list of meshes using their id
  118033. * @param id defines the id to search for
  118034. * @returns a list of meshes
  118035. */
  118036. getMeshesByID(id: string): Array<AbstractMesh>;
  118037. /**
  118038. * Gets the first added transform node found of a given ID
  118039. * @param id defines the id to search for
  118040. * @return the found transform node or null if not found at all.
  118041. */
  118042. getTransformNodeByID(id: string): Nullable<TransformNode>;
  118043. /**
  118044. * Gets a transform node with its auto-generated unique id
  118045. * @param uniqueId efines the unique id to search for
  118046. * @return the found transform node or null if not found at all.
  118047. */
  118048. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  118049. /**
  118050. * Gets a list of transform nodes using their id
  118051. * @param id defines the id to search for
  118052. * @returns a list of transform nodes
  118053. */
  118054. getTransformNodesByID(id: string): Array<TransformNode>;
  118055. /**
  118056. * Gets a mesh with its auto-generated unique id
  118057. * @param uniqueId defines the unique id to search for
  118058. * @return the found mesh or null if not found at all.
  118059. */
  118060. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  118061. /**
  118062. * Gets a the last added mesh using a given id
  118063. * @param id defines the id to search for
  118064. * @return the found mesh or null if not found at all.
  118065. */
  118066. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  118067. /**
  118068. * Gets a the last added node (Mesh, Camera, Light) using a given id
  118069. * @param id defines the id to search for
  118070. * @return the found node or null if not found at all
  118071. */
  118072. getLastEntryByID(id: string): Nullable<Node>;
  118073. /**
  118074. * Gets a node (Mesh, Camera, Light) using a given id
  118075. * @param id defines the id to search for
  118076. * @return the found node or null if not found at all
  118077. */
  118078. getNodeByID(id: string): Nullable<Node>;
  118079. /**
  118080. * Gets a node (Mesh, Camera, Light) using a given name
  118081. * @param name defines the name to search for
  118082. * @return the found node or null if not found at all.
  118083. */
  118084. getNodeByName(name: string): Nullable<Node>;
  118085. /**
  118086. * Gets a mesh using a given name
  118087. * @param name defines the name to search for
  118088. * @return the found mesh or null if not found at all.
  118089. */
  118090. getMeshByName(name: string): Nullable<AbstractMesh>;
  118091. /**
  118092. * Gets a transform node using a given name
  118093. * @param name defines the name to search for
  118094. * @return the found transform node or null if not found at all.
  118095. */
  118096. getTransformNodeByName(name: string): Nullable<TransformNode>;
  118097. /**
  118098. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  118099. * @param id defines the id to search for
  118100. * @return the found skeleton or null if not found at all.
  118101. */
  118102. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  118103. /**
  118104. * Gets a skeleton using a given auto generated unique id
  118105. * @param uniqueId defines the unique id to search for
  118106. * @return the found skeleton or null if not found at all.
  118107. */
  118108. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  118109. /**
  118110. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  118111. * @param id defines the id to search for
  118112. * @return the found skeleton or null if not found at all.
  118113. */
  118114. getSkeletonById(id: string): Nullable<Skeleton>;
  118115. /**
  118116. * Gets a skeleton using a given name
  118117. * @param name defines the name to search for
  118118. * @return the found skeleton or null if not found at all.
  118119. */
  118120. getSkeletonByName(name: string): Nullable<Skeleton>;
  118121. /**
  118122. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  118123. * @param id defines the id to search for
  118124. * @return the found morph target manager or null if not found at all.
  118125. */
  118126. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  118127. /**
  118128. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  118129. * @param id defines the id to search for
  118130. * @return the found morph target or null if not found at all.
  118131. */
  118132. getMorphTargetById(id: string): Nullable<MorphTarget>;
  118133. /**
  118134. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  118135. * @param name defines the name to search for
  118136. * @return the found morph target or null if not found at all.
  118137. */
  118138. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  118139. /**
  118140. * Gets a boolean indicating if the given mesh is active
  118141. * @param mesh defines the mesh to look for
  118142. * @returns true if the mesh is in the active list
  118143. */
  118144. isActiveMesh(mesh: AbstractMesh): boolean;
  118145. /**
  118146. * Return a unique id as a string which can serve as an identifier for the scene
  118147. */
  118148. get uid(): string;
  118149. /**
  118150. * Add an externaly attached data from its key.
  118151. * This method call will fail and return false, if such key already exists.
  118152. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  118153. * @param key the unique key that identifies the data
  118154. * @param data the data object to associate to the key for this Engine instance
  118155. * @return true if no such key were already present and the data was added successfully, false otherwise
  118156. */
  118157. addExternalData<T>(key: string, data: T): boolean;
  118158. /**
  118159. * Get an externaly attached data from its key
  118160. * @param key the unique key that identifies the data
  118161. * @return the associated data, if present (can be null), or undefined if not present
  118162. */
  118163. getExternalData<T>(key: string): Nullable<T>;
  118164. /**
  118165. * Get an externaly attached data from its key, create it using a factory if it's not already present
  118166. * @param key the unique key that identifies the data
  118167. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  118168. * @return the associated data, can be null if the factory returned null.
  118169. */
  118170. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  118171. /**
  118172. * Remove an externaly attached data from the Engine instance
  118173. * @param key the unique key that identifies the data
  118174. * @return true if the data was successfully removed, false if it doesn't exist
  118175. */
  118176. removeExternalData(key: string): boolean;
  118177. private _evaluateSubMesh;
  118178. /**
  118179. * Clear the processed materials smart array preventing retention point in material dispose.
  118180. */
  118181. freeProcessedMaterials(): void;
  118182. private _preventFreeActiveMeshesAndRenderingGroups;
  118183. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  118184. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  118185. * when disposing several meshes in a row or a hierarchy of meshes.
  118186. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  118187. */
  118188. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  118189. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  118190. /**
  118191. * Clear the active meshes smart array preventing retention point in mesh dispose.
  118192. */
  118193. freeActiveMeshes(): void;
  118194. /**
  118195. * Clear the info related to rendering groups preventing retention points during dispose.
  118196. */
  118197. freeRenderingGroups(): void;
  118198. /** @hidden */
  118199. _isInIntermediateRendering(): boolean;
  118200. /**
  118201. * Lambda returning the list of potentially active meshes.
  118202. */
  118203. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  118204. /**
  118205. * Lambda returning the list of potentially active sub meshes.
  118206. */
  118207. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  118208. /**
  118209. * Lambda returning the list of potentially intersecting sub meshes.
  118210. */
  118211. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  118212. /**
  118213. * Lambda returning the list of potentially colliding sub meshes.
  118214. */
  118215. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  118216. private _activeMeshesFrozen;
  118217. private _skipEvaluateActiveMeshesCompletely;
  118218. /**
  118219. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  118220. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  118221. * @returns the current scene
  118222. */
  118223. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  118224. /**
  118225. * Use this function to restart evaluating active meshes on every frame
  118226. * @returns the current scene
  118227. */
  118228. unfreezeActiveMeshes(): Scene;
  118229. private _evaluateActiveMeshes;
  118230. private _activeMesh;
  118231. /**
  118232. * Update the transform matrix to update from the current active camera
  118233. * @param force defines a boolean used to force the update even if cache is up to date
  118234. */
  118235. updateTransformMatrix(force?: boolean): void;
  118236. private _bindFrameBuffer;
  118237. /** @hidden */
  118238. _allowPostProcessClearColor: boolean;
  118239. /** @hidden */
  118240. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  118241. private _processSubCameras;
  118242. private _checkIntersections;
  118243. /** @hidden */
  118244. _advancePhysicsEngineStep(step: number): void;
  118245. /**
  118246. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  118247. */
  118248. getDeterministicFrameTime: () => number;
  118249. /** @hidden */
  118250. _animate(): void;
  118251. /** Execute all animations (for a frame) */
  118252. animate(): void;
  118253. /**
  118254. * Render the scene
  118255. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  118256. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  118257. */
  118258. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  118259. /**
  118260. * Freeze all materials
  118261. * A frozen material will not be updatable but should be faster to render
  118262. */
  118263. freezeMaterials(): void;
  118264. /**
  118265. * Unfreeze all materials
  118266. * A frozen material will not be updatable but should be faster to render
  118267. */
  118268. unfreezeMaterials(): void;
  118269. /**
  118270. * Releases all held ressources
  118271. */
  118272. dispose(): void;
  118273. /**
  118274. * Gets if the scene is already disposed
  118275. */
  118276. get isDisposed(): boolean;
  118277. /**
  118278. * Call this function to reduce memory footprint of the scene.
  118279. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  118280. */
  118281. clearCachedVertexData(): void;
  118282. /**
  118283. * This function will remove the local cached buffer data from texture.
  118284. * It will save memory but will prevent the texture from being rebuilt
  118285. */
  118286. cleanCachedTextureBuffer(): void;
  118287. /**
  118288. * Get the world extend vectors with an optional filter
  118289. *
  118290. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  118291. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  118292. */
  118293. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  118294. min: Vector3;
  118295. max: Vector3;
  118296. };
  118297. /**
  118298. * Creates a ray that can be used to pick in the scene
  118299. * @param x defines the x coordinate of the origin (on-screen)
  118300. * @param y defines the y coordinate of the origin (on-screen)
  118301. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  118302. * @param camera defines the camera to use for the picking
  118303. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  118304. * @returns a Ray
  118305. */
  118306. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  118307. /**
  118308. * Creates a ray that can be used to pick in the scene
  118309. * @param x defines the x coordinate of the origin (on-screen)
  118310. * @param y defines the y coordinate of the origin (on-screen)
  118311. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  118312. * @param result defines the ray where to store the picking ray
  118313. * @param camera defines the camera to use for the picking
  118314. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  118315. * @returns the current scene
  118316. */
  118317. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  118318. /**
  118319. * Creates a ray that can be used to pick in the scene
  118320. * @param x defines the x coordinate of the origin (on-screen)
  118321. * @param y defines the y coordinate of the origin (on-screen)
  118322. * @param camera defines the camera to use for the picking
  118323. * @returns a Ray
  118324. */
  118325. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  118326. /**
  118327. * Creates a ray that can be used to pick in the scene
  118328. * @param x defines the x coordinate of the origin (on-screen)
  118329. * @param y defines the y coordinate of the origin (on-screen)
  118330. * @param result defines the ray where to store the picking ray
  118331. * @param camera defines the camera to use for the picking
  118332. * @returns the current scene
  118333. */
  118334. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  118335. /** Launch a ray to try to pick a mesh in the scene
  118336. * @param x position on screen
  118337. * @param y position on screen
  118338. * @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
  118339. * @param fastCheck defines if the first intersection will be used (and not the closest)
  118340. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  118341. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  118342. * @returns a PickingInfo
  118343. */
  118344. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  118345. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  118346. * @param x position on screen
  118347. * @param y position on screen
  118348. * @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
  118349. * @param fastCheck defines if the first intersection will be used (and not the closest)
  118350. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  118351. * @returns a PickingInfo (Please note that some info will not be set like distance, bv, bu and everything that cannot be capture by only using bounding infos)
  118352. */
  118353. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  118354. /** Use the given ray to pick a mesh in the scene
  118355. * @param ray The ray to use to pick meshes
  118356. * @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
  118357. * @param fastCheck defines if the first intersection will be used (and not the closest)
  118358. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  118359. * @returns a PickingInfo
  118360. */
  118361. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  118362. /**
  118363. * Launch a ray to try to pick a mesh in the scene
  118364. * @param x X position on screen
  118365. * @param y Y position on screen
  118366. * @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
  118367. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  118368. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  118369. * @returns an array of PickingInfo
  118370. */
  118371. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  118372. /**
  118373. * Launch a ray to try to pick a mesh in the scene
  118374. * @param ray Ray to use
  118375. * @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
  118376. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  118377. * @returns an array of PickingInfo
  118378. */
  118379. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  118380. /**
  118381. * Force the value of meshUnderPointer
  118382. * @param mesh defines the mesh to use
  118383. */
  118384. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  118385. /**
  118386. * Gets the mesh under the pointer
  118387. * @returns a Mesh or null if no mesh is under the pointer
  118388. */
  118389. getPointerOverMesh(): Nullable<AbstractMesh>;
  118390. /** @hidden */
  118391. _rebuildGeometries(): void;
  118392. /** @hidden */
  118393. _rebuildTextures(): void;
  118394. private _getByTags;
  118395. /**
  118396. * Get a list of meshes by tags
  118397. * @param tagsQuery defines the tags query to use
  118398. * @param forEach defines a predicate used to filter results
  118399. * @returns an array of Mesh
  118400. */
  118401. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  118402. /**
  118403. * Get a list of cameras by tags
  118404. * @param tagsQuery defines the tags query to use
  118405. * @param forEach defines a predicate used to filter results
  118406. * @returns an array of Camera
  118407. */
  118408. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  118409. /**
  118410. * Get a list of lights by tags
  118411. * @param tagsQuery defines the tags query to use
  118412. * @param forEach defines a predicate used to filter results
  118413. * @returns an array of Light
  118414. */
  118415. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  118416. /**
  118417. * Get a list of materials by tags
  118418. * @param tagsQuery defines the tags query to use
  118419. * @param forEach defines a predicate used to filter results
  118420. * @returns an array of Material
  118421. */
  118422. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  118423. /**
  118424. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  118425. * This allowed control for front to back rendering or reversly depending of the special needs.
  118426. *
  118427. * @param renderingGroupId The rendering group id corresponding to its index
  118428. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  118429. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  118430. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  118431. */
  118432. 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;
  118433. /**
  118434. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  118435. *
  118436. * @param renderingGroupId The rendering group id corresponding to its index
  118437. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  118438. * @param depth Automatically clears depth between groups if true and autoClear is true.
  118439. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  118440. */
  118441. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  118442. /**
  118443. * Gets the current auto clear configuration for one rendering group of the rendering
  118444. * manager.
  118445. * @param index the rendering group index to get the information for
  118446. * @returns The auto clear setup for the requested rendering group
  118447. */
  118448. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  118449. private _blockMaterialDirtyMechanism;
  118450. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  118451. get blockMaterialDirtyMechanism(): boolean;
  118452. set blockMaterialDirtyMechanism(value: boolean);
  118453. /**
  118454. * Will flag all materials as dirty to trigger new shader compilation
  118455. * @param flag defines the flag used to specify which material part must be marked as dirty
  118456. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  118457. */
  118458. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  118459. /** @hidden */
  118460. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  118461. /** @hidden */
  118462. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  118463. /** @hidden */
  118464. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  118465. /** @hidden */
  118466. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  118467. /** @hidden */
  118468. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  118469. /** @hidden */
  118470. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  118471. }
  118472. }
  118473. declare module BABYLON {
  118474. /**
  118475. * Set of assets to keep when moving a scene into an asset container.
  118476. */
  118477. export class KeepAssets extends AbstractScene {
  118478. }
  118479. /**
  118480. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  118481. */
  118482. export class InstantiatedEntries {
  118483. /**
  118484. * List of new root nodes (eg. nodes with no parent)
  118485. */
  118486. rootNodes: TransformNode[];
  118487. /**
  118488. * List of new skeletons
  118489. */
  118490. skeletons: Skeleton[];
  118491. /**
  118492. * List of new animation groups
  118493. */
  118494. animationGroups: AnimationGroup[];
  118495. }
  118496. /**
  118497. * Container with a set of assets that can be added or removed from a scene.
  118498. */
  118499. export class AssetContainer extends AbstractScene {
  118500. private _wasAddedToScene;
  118501. /**
  118502. * The scene the AssetContainer belongs to.
  118503. */
  118504. scene: Scene;
  118505. /**
  118506. * Instantiates an AssetContainer.
  118507. * @param scene The scene the AssetContainer belongs to.
  118508. */
  118509. constructor(scene: Scene);
  118510. /**
  118511. * Instantiate or clone all meshes and add the new ones to the scene.
  118512. * Skeletons and animation groups will all be cloned
  118513. * @param nameFunction defines an optional function used to get new names for clones
  118514. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  118515. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  118516. */
  118517. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  118518. /**
  118519. * Adds all the assets from the container to the scene.
  118520. */
  118521. addAllToScene(): void;
  118522. /**
  118523. * Removes all the assets in the container from the scene
  118524. */
  118525. removeAllFromScene(): void;
  118526. /**
  118527. * Disposes all the assets in the container
  118528. */
  118529. dispose(): void;
  118530. private _moveAssets;
  118531. /**
  118532. * Removes all the assets contained in the scene and adds them to the container.
  118533. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  118534. */
  118535. moveAllFromScene(keepAssets?: KeepAssets): void;
  118536. /**
  118537. * 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.
  118538. * @returns the root mesh
  118539. */
  118540. createRootMesh(): Mesh;
  118541. /**
  118542. * Merge animations (direct and animation groups) from this asset container into a scene
  118543. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118544. * @param animatables set of animatables to retarget to a node from the scene
  118545. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  118546. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  118547. */
  118548. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  118549. }
  118550. }
  118551. declare module BABYLON {
  118552. /**
  118553. * Defines how the parser contract is defined.
  118554. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  118555. */
  118556. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  118557. /**
  118558. * Defines how the individual parser contract is defined.
  118559. * These parser can parse an individual asset
  118560. */
  118561. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  118562. /**
  118563. * Base class of the scene acting as a container for the different elements composing a scene.
  118564. * This class is dynamically extended by the different components of the scene increasing
  118565. * flexibility and reducing coupling
  118566. */
  118567. export abstract class AbstractScene {
  118568. /**
  118569. * Stores the list of available parsers in the application.
  118570. */
  118571. private static _BabylonFileParsers;
  118572. /**
  118573. * Stores the list of available individual parsers in the application.
  118574. */
  118575. private static _IndividualBabylonFileParsers;
  118576. /**
  118577. * Adds a parser in the list of available ones
  118578. * @param name Defines the name of the parser
  118579. * @param parser Defines the parser to add
  118580. */
  118581. static AddParser(name: string, parser: BabylonFileParser): void;
  118582. /**
  118583. * Gets a general parser from the list of avaialble ones
  118584. * @param name Defines the name of the parser
  118585. * @returns the requested parser or null
  118586. */
  118587. static GetParser(name: string): Nullable<BabylonFileParser>;
  118588. /**
  118589. * Adds n individual parser in the list of available ones
  118590. * @param name Defines the name of the parser
  118591. * @param parser Defines the parser to add
  118592. */
  118593. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  118594. /**
  118595. * Gets an individual parser from the list of avaialble ones
  118596. * @param name Defines the name of the parser
  118597. * @returns the requested parser or null
  118598. */
  118599. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  118600. /**
  118601. * Parser json data and populate both a scene and its associated container object
  118602. * @param jsonData Defines the data to parse
  118603. * @param scene Defines the scene to parse the data for
  118604. * @param container Defines the container attached to the parsing sequence
  118605. * @param rootUrl Defines the root url of the data
  118606. */
  118607. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  118608. /**
  118609. * Gets the list of root nodes (ie. nodes with no parent)
  118610. */
  118611. rootNodes: Node[];
  118612. /** All of the cameras added to this scene
  118613. * @see https://doc.babylonjs.com/babylon101/cameras
  118614. */
  118615. cameras: Camera[];
  118616. /**
  118617. * All of the lights added to this scene
  118618. * @see https://doc.babylonjs.com/babylon101/lights
  118619. */
  118620. lights: Light[];
  118621. /**
  118622. * All of the (abstract) meshes added to this scene
  118623. */
  118624. meshes: AbstractMesh[];
  118625. /**
  118626. * The list of skeletons added to the scene
  118627. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  118628. */
  118629. skeletons: Skeleton[];
  118630. /**
  118631. * All of the particle systems added to this scene
  118632. * @see https://doc.babylonjs.com/babylon101/particles
  118633. */
  118634. particleSystems: IParticleSystem[];
  118635. /**
  118636. * Gets a list of Animations associated with the scene
  118637. */
  118638. animations: Animation[];
  118639. /**
  118640. * All of the animation groups added to this scene
  118641. * @see https://doc.babylonjs.com/how_to/group
  118642. */
  118643. animationGroups: AnimationGroup[];
  118644. /**
  118645. * All of the multi-materials added to this scene
  118646. * @see https://doc.babylonjs.com/how_to/multi_materials
  118647. */
  118648. multiMaterials: MultiMaterial[];
  118649. /**
  118650. * All of the materials added to this scene
  118651. * In the context of a Scene, it is not supposed to be modified manually.
  118652. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  118653. * Note also that the order of the Material within the array is not significant and might change.
  118654. * @see https://doc.babylonjs.com/babylon101/materials
  118655. */
  118656. materials: Material[];
  118657. /**
  118658. * The list of morph target managers added to the scene
  118659. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  118660. */
  118661. morphTargetManagers: MorphTargetManager[];
  118662. /**
  118663. * The list of geometries used in the scene.
  118664. */
  118665. geometries: Geometry[];
  118666. /**
  118667. * All of the tranform nodes added to this scene
  118668. * In the context of a Scene, it is not supposed to be modified manually.
  118669. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  118670. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  118671. * @see https://doc.babylonjs.com/how_to/transformnode
  118672. */
  118673. transformNodes: TransformNode[];
  118674. /**
  118675. * ActionManagers available on the scene.
  118676. */
  118677. actionManagers: AbstractActionManager[];
  118678. /**
  118679. * Textures to keep.
  118680. */
  118681. textures: BaseTexture[];
  118682. /**
  118683. * Environment texture for the scene
  118684. */
  118685. environmentTexture: Nullable<BaseTexture>;
  118686. /**
  118687. * @returns all meshes, lights, cameras, transformNodes and bones
  118688. */
  118689. getNodes(): Array<Node>;
  118690. }
  118691. }
  118692. declare module BABYLON {
  118693. /**
  118694. * Interface used to define options for Sound class
  118695. */
  118696. export interface ISoundOptions {
  118697. /**
  118698. * Does the sound autoplay once loaded.
  118699. */
  118700. autoplay?: boolean;
  118701. /**
  118702. * Does the sound loop after it finishes playing once.
  118703. */
  118704. loop?: boolean;
  118705. /**
  118706. * Sound's volume
  118707. */
  118708. volume?: number;
  118709. /**
  118710. * Is it a spatial sound?
  118711. */
  118712. spatialSound?: boolean;
  118713. /**
  118714. * Maximum distance to hear that sound
  118715. */
  118716. maxDistance?: number;
  118717. /**
  118718. * Uses user defined attenuation function
  118719. */
  118720. useCustomAttenuation?: boolean;
  118721. /**
  118722. * Define the roll off factor of spatial sounds.
  118723. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118724. */
  118725. rolloffFactor?: number;
  118726. /**
  118727. * Define the reference distance the sound should be heard perfectly.
  118728. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118729. */
  118730. refDistance?: number;
  118731. /**
  118732. * Define the distance attenuation model the sound will follow.
  118733. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118734. */
  118735. distanceModel?: string;
  118736. /**
  118737. * Defines the playback speed (1 by default)
  118738. */
  118739. playbackRate?: number;
  118740. /**
  118741. * Defines if the sound is from a streaming source
  118742. */
  118743. streaming?: boolean;
  118744. /**
  118745. * Defines an optional length (in seconds) inside the sound file
  118746. */
  118747. length?: number;
  118748. /**
  118749. * Defines an optional offset (in seconds) inside the sound file
  118750. */
  118751. offset?: number;
  118752. /**
  118753. * If true, URLs will not be required to state the audio file codec to use.
  118754. */
  118755. skipCodecCheck?: boolean;
  118756. }
  118757. /**
  118758. * Defines a sound that can be played in the application.
  118759. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  118760. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  118761. */
  118762. export class Sound {
  118763. /**
  118764. * The name of the sound in the scene.
  118765. */
  118766. name: string;
  118767. /**
  118768. * Does the sound autoplay once loaded.
  118769. */
  118770. autoplay: boolean;
  118771. /**
  118772. * Does the sound loop after it finishes playing once.
  118773. */
  118774. loop: boolean;
  118775. /**
  118776. * Does the sound use a custom attenuation curve to simulate the falloff
  118777. * happening when the source gets further away from the camera.
  118778. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  118779. */
  118780. useCustomAttenuation: boolean;
  118781. /**
  118782. * The sound track id this sound belongs to.
  118783. */
  118784. soundTrackId: number;
  118785. /**
  118786. * Is this sound currently played.
  118787. */
  118788. isPlaying: boolean;
  118789. /**
  118790. * Is this sound currently paused.
  118791. */
  118792. isPaused: boolean;
  118793. /**
  118794. * Does this sound enables spatial sound.
  118795. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118796. */
  118797. spatialSound: boolean;
  118798. /**
  118799. * Define the reference distance the sound should be heard perfectly.
  118800. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118801. */
  118802. refDistance: number;
  118803. /**
  118804. * Define the roll off factor of spatial sounds.
  118805. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118806. */
  118807. rolloffFactor: number;
  118808. /**
  118809. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  118810. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118811. */
  118812. maxDistance: number;
  118813. /**
  118814. * Define the distance attenuation model the sound will follow.
  118815. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118816. */
  118817. distanceModel: string;
  118818. /**
  118819. * @hidden
  118820. * Back Compat
  118821. **/
  118822. onended: () => any;
  118823. /**
  118824. * Gets or sets an object used to store user defined information for the sound.
  118825. */
  118826. metadata: any;
  118827. /**
  118828. * Observable event when the current playing sound finishes.
  118829. */
  118830. onEndedObservable: Observable<Sound>;
  118831. private _panningModel;
  118832. private _playbackRate;
  118833. private _streaming;
  118834. private _startTime;
  118835. private _startOffset;
  118836. private _position;
  118837. /** @hidden */
  118838. _positionInEmitterSpace: boolean;
  118839. private _localDirection;
  118840. private _volume;
  118841. private _isReadyToPlay;
  118842. private _isDirectional;
  118843. private _readyToPlayCallback;
  118844. private _audioBuffer;
  118845. private _soundSource;
  118846. private _streamingSource;
  118847. private _soundPanner;
  118848. private _soundGain;
  118849. private _inputAudioNode;
  118850. private _outputAudioNode;
  118851. private _coneInnerAngle;
  118852. private _coneOuterAngle;
  118853. private _coneOuterGain;
  118854. private _scene;
  118855. private _connectedTransformNode;
  118856. private _customAttenuationFunction;
  118857. private _registerFunc;
  118858. private _isOutputConnected;
  118859. private _htmlAudioElement;
  118860. private _urlType;
  118861. private _length?;
  118862. private _offset?;
  118863. /** @hidden */
  118864. static _SceneComponentInitialization: (scene: Scene) => void;
  118865. /**
  118866. * Create a sound and attach it to a scene
  118867. * @param name Name of your sound
  118868. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  118869. * @param scene defines the scene the sound belongs to
  118870. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  118871. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  118872. */
  118873. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  118874. /**
  118875. * Release the sound and its associated resources
  118876. */
  118877. dispose(): void;
  118878. /**
  118879. * Gets if the sounds is ready to be played or not.
  118880. * @returns true if ready, otherwise false
  118881. */
  118882. isReady(): boolean;
  118883. private _soundLoaded;
  118884. /**
  118885. * Sets the data of the sound from an audiobuffer
  118886. * @param audioBuffer The audioBuffer containing the data
  118887. */
  118888. setAudioBuffer(audioBuffer: AudioBuffer): void;
  118889. /**
  118890. * Updates the current sounds options such as maxdistance, loop...
  118891. * @param options A JSON object containing values named as the object properties
  118892. */
  118893. updateOptions(options: ISoundOptions): void;
  118894. private _createSpatialParameters;
  118895. private _updateSpatialParameters;
  118896. /**
  118897. * Switch the panning model to HRTF:
  118898. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  118899. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118900. */
  118901. switchPanningModelToHRTF(): void;
  118902. /**
  118903. * Switch the panning model to Equal Power:
  118904. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  118905. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118906. */
  118907. switchPanningModelToEqualPower(): void;
  118908. private _switchPanningModel;
  118909. /**
  118910. * Connect this sound to a sound track audio node like gain...
  118911. * @param soundTrackAudioNode the sound track audio node to connect to
  118912. */
  118913. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  118914. /**
  118915. * Transform this sound into a directional source
  118916. * @param coneInnerAngle Size of the inner cone in degree
  118917. * @param coneOuterAngle Size of the outer cone in degree
  118918. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  118919. */
  118920. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  118921. /**
  118922. * Gets or sets the inner angle for the directional cone.
  118923. */
  118924. get directionalConeInnerAngle(): number;
  118925. /**
  118926. * Gets or sets the inner angle for the directional cone.
  118927. */
  118928. set directionalConeInnerAngle(value: number);
  118929. /**
  118930. * Gets or sets the outer angle for the directional cone.
  118931. */
  118932. get directionalConeOuterAngle(): number;
  118933. /**
  118934. * Gets or sets the outer angle for the directional cone.
  118935. */
  118936. set directionalConeOuterAngle(value: number);
  118937. /**
  118938. * Sets the position of the emitter if spatial sound is enabled
  118939. * @param newPosition Defines the new posisiton
  118940. */
  118941. setPosition(newPosition: Vector3): void;
  118942. /**
  118943. * Sets the local direction of the emitter if spatial sound is enabled
  118944. * @param newLocalDirection Defines the new local direction
  118945. */
  118946. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  118947. private _updateDirection;
  118948. /** @hidden */
  118949. updateDistanceFromListener(): void;
  118950. /**
  118951. * Sets a new custom attenuation function for the sound.
  118952. * @param callback Defines the function used for the attenuation
  118953. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  118954. */
  118955. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  118956. /**
  118957. * Play the sound
  118958. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  118959. * @param offset (optional) Start the sound at a specific time in seconds
  118960. * @param length (optional) Sound duration (in seconds)
  118961. */
  118962. play(time?: number, offset?: number, length?: number): void;
  118963. private _onended;
  118964. /**
  118965. * Stop the sound
  118966. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  118967. */
  118968. stop(time?: number): void;
  118969. /**
  118970. * Put the sound in pause
  118971. */
  118972. pause(): void;
  118973. /**
  118974. * Sets a dedicated volume for this sounds
  118975. * @param newVolume Define the new volume of the sound
  118976. * @param time Define time for gradual change to new volume
  118977. */
  118978. setVolume(newVolume: number, time?: number): void;
  118979. /**
  118980. * Set the sound play back rate
  118981. * @param newPlaybackRate Define the playback rate the sound should be played at
  118982. */
  118983. setPlaybackRate(newPlaybackRate: number): void;
  118984. /**
  118985. * Gets the volume of the sound.
  118986. * @returns the volume of the sound
  118987. */
  118988. getVolume(): number;
  118989. /**
  118990. * Attach the sound to a dedicated mesh
  118991. * @param transformNode The transform node to connect the sound with
  118992. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  118993. */
  118994. attachToMesh(transformNode: TransformNode): void;
  118995. /**
  118996. * Detach the sound from the previously attached mesh
  118997. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  118998. */
  118999. detachFromMesh(): void;
  119000. private _onRegisterAfterWorldMatrixUpdate;
  119001. /**
  119002. * Clone the current sound in the scene.
  119003. * @returns the new sound clone
  119004. */
  119005. clone(): Nullable<Sound>;
  119006. /**
  119007. * Gets the current underlying audio buffer containing the data
  119008. * @returns the audio buffer
  119009. */
  119010. getAudioBuffer(): Nullable<AudioBuffer>;
  119011. /**
  119012. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  119013. * @returns the source node
  119014. */
  119015. getSoundSource(): Nullable<AudioBufferSourceNode>;
  119016. /**
  119017. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  119018. * @returns the gain node
  119019. */
  119020. getSoundGain(): Nullable<GainNode>;
  119021. /**
  119022. * Serializes the Sound in a JSON representation
  119023. * @returns the JSON representation of the sound
  119024. */
  119025. serialize(): any;
  119026. /**
  119027. * Parse a JSON representation of a sound to innstantiate in a given scene
  119028. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  119029. * @param scene Define the scene the new parsed sound should be created in
  119030. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  119031. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  119032. * @returns the newly parsed sound
  119033. */
  119034. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  119035. }
  119036. }
  119037. declare module BABYLON {
  119038. /**
  119039. * This defines an action helpful to play a defined sound on a triggered action.
  119040. */
  119041. export class PlaySoundAction extends Action {
  119042. private _sound;
  119043. /**
  119044. * Instantiate the action
  119045. * @param triggerOptions defines the trigger options
  119046. * @param sound defines the sound to play
  119047. * @param condition defines the trigger related conditions
  119048. */
  119049. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  119050. /** @hidden */
  119051. _prepare(): void;
  119052. /**
  119053. * Execute the action and play the sound.
  119054. */
  119055. execute(): void;
  119056. /**
  119057. * Serializes the actions and its related information.
  119058. * @param parent defines the object to serialize in
  119059. * @returns the serialized object
  119060. */
  119061. serialize(parent: any): any;
  119062. }
  119063. /**
  119064. * This defines an action helpful to stop a defined sound on a triggered action.
  119065. */
  119066. export class StopSoundAction extends Action {
  119067. private _sound;
  119068. /**
  119069. * Instantiate the action
  119070. * @param triggerOptions defines the trigger options
  119071. * @param sound defines the sound to stop
  119072. * @param condition defines the trigger related conditions
  119073. */
  119074. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  119075. /** @hidden */
  119076. _prepare(): void;
  119077. /**
  119078. * Execute the action and stop the sound.
  119079. */
  119080. execute(): void;
  119081. /**
  119082. * Serializes the actions and its related information.
  119083. * @param parent defines the object to serialize in
  119084. * @returns the serialized object
  119085. */
  119086. serialize(parent: any): any;
  119087. }
  119088. }
  119089. declare module BABYLON {
  119090. /**
  119091. * This defines an action responsible to change the value of a property
  119092. * by interpolating between its current value and the newly set one once triggered.
  119093. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  119094. */
  119095. export class InterpolateValueAction extends Action {
  119096. /**
  119097. * Defines the path of the property where the value should be interpolated
  119098. */
  119099. propertyPath: string;
  119100. /**
  119101. * Defines the target value at the end of the interpolation.
  119102. */
  119103. value: any;
  119104. /**
  119105. * Defines the time it will take for the property to interpolate to the value.
  119106. */
  119107. duration: number;
  119108. /**
  119109. * Defines if the other scene animations should be stopped when the action has been triggered
  119110. */
  119111. stopOtherAnimations?: boolean;
  119112. /**
  119113. * Defines a callback raised once the interpolation animation has been done.
  119114. */
  119115. onInterpolationDone?: () => void;
  119116. /**
  119117. * Observable triggered once the interpolation animation has been done.
  119118. */
  119119. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  119120. private _target;
  119121. private _effectiveTarget;
  119122. private _property;
  119123. /**
  119124. * Instantiate the action
  119125. * @param triggerOptions defines the trigger options
  119126. * @param target defines the object containing the value to interpolate
  119127. * @param propertyPath defines the path to the property in the target object
  119128. * @param value defines the target value at the end of the interpolation
  119129. * @param duration deines the time it will take for the property to interpolate to the value.
  119130. * @param condition defines the trigger related conditions
  119131. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  119132. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  119133. */
  119134. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  119135. /** @hidden */
  119136. _prepare(): void;
  119137. /**
  119138. * Execute the action starts the value interpolation.
  119139. */
  119140. execute(): void;
  119141. /**
  119142. * Serializes the actions and its related information.
  119143. * @param parent defines the object to serialize in
  119144. * @returns the serialized object
  119145. */
  119146. serialize(parent: any): any;
  119147. }
  119148. }
  119149. declare module BABYLON {
  119150. /**
  119151. * Options allowed during the creation of a sound track.
  119152. */
  119153. export interface ISoundTrackOptions {
  119154. /**
  119155. * The volume the sound track should take during creation
  119156. */
  119157. volume?: number;
  119158. /**
  119159. * Define if the sound track is the main sound track of the scene
  119160. */
  119161. mainTrack?: boolean;
  119162. }
  119163. /**
  119164. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  119165. * It will be also used in a future release to apply effects on a specific track.
  119166. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  119167. */
  119168. export class SoundTrack {
  119169. /**
  119170. * The unique identifier of the sound track in the scene.
  119171. */
  119172. id: number;
  119173. /**
  119174. * The list of sounds included in the sound track.
  119175. */
  119176. soundCollection: Array<Sound>;
  119177. private _outputAudioNode;
  119178. private _scene;
  119179. private _connectedAnalyser;
  119180. private _options;
  119181. private _isInitialized;
  119182. /**
  119183. * Creates a new sound track.
  119184. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  119185. * @param scene Define the scene the sound track belongs to
  119186. * @param options
  119187. */
  119188. constructor(scene: Scene, options?: ISoundTrackOptions);
  119189. private _initializeSoundTrackAudioGraph;
  119190. /**
  119191. * Release the sound track and its associated resources
  119192. */
  119193. dispose(): void;
  119194. /**
  119195. * Adds a sound to this sound track
  119196. * @param sound define the cound to add
  119197. * @ignoreNaming
  119198. */
  119199. AddSound(sound: Sound): void;
  119200. /**
  119201. * Removes a sound to this sound track
  119202. * @param sound define the cound to remove
  119203. * @ignoreNaming
  119204. */
  119205. RemoveSound(sound: Sound): void;
  119206. /**
  119207. * Set a global volume for the full sound track.
  119208. * @param newVolume Define the new volume of the sound track
  119209. */
  119210. setVolume(newVolume: number): void;
  119211. /**
  119212. * Switch the panning model to HRTF:
  119213. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  119214. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119215. */
  119216. switchPanningModelToHRTF(): void;
  119217. /**
  119218. * Switch the panning model to Equal Power:
  119219. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  119220. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119221. */
  119222. switchPanningModelToEqualPower(): void;
  119223. /**
  119224. * Connect the sound track to an audio analyser allowing some amazing
  119225. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  119226. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  119227. * @param analyser The analyser to connect to the engine
  119228. */
  119229. connectToAnalyser(analyser: Analyser): void;
  119230. }
  119231. }
  119232. declare module BABYLON {
  119233. interface AbstractScene {
  119234. /**
  119235. * The list of sounds used in the scene.
  119236. */
  119237. sounds: Nullable<Array<Sound>>;
  119238. }
  119239. interface Scene {
  119240. /**
  119241. * @hidden
  119242. * Backing field
  119243. */
  119244. _mainSoundTrack: SoundTrack;
  119245. /**
  119246. * The main sound track played by the scene.
  119247. * It cotains your primary collection of sounds.
  119248. */
  119249. mainSoundTrack: SoundTrack;
  119250. /**
  119251. * The list of sound tracks added to the scene
  119252. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119253. */
  119254. soundTracks: Nullable<Array<SoundTrack>>;
  119255. /**
  119256. * Gets a sound using a given name
  119257. * @param name defines the name to search for
  119258. * @return the found sound or null if not found at all.
  119259. */
  119260. getSoundByName(name: string): Nullable<Sound>;
  119261. /**
  119262. * Gets or sets if audio support is enabled
  119263. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119264. */
  119265. audioEnabled: boolean;
  119266. /**
  119267. * Gets or sets if audio will be output to headphones
  119268. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119269. */
  119270. headphone: boolean;
  119271. /**
  119272. * Gets or sets custom audio listener position provider
  119273. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119274. */
  119275. audioListenerPositionProvider: Nullable<() => Vector3>;
  119276. /**
  119277. * Gets or sets a refresh rate when using 3D audio positioning
  119278. */
  119279. audioPositioningRefreshRate: number;
  119280. }
  119281. /**
  119282. * Defines the sound scene component responsible to manage any sounds
  119283. * in a given scene.
  119284. */
  119285. export class AudioSceneComponent implements ISceneSerializableComponent {
  119286. /**
  119287. * The component name helpfull to identify the component in the list of scene components.
  119288. */
  119289. readonly name: string;
  119290. /**
  119291. * The scene the component belongs to.
  119292. */
  119293. scene: Scene;
  119294. private _audioEnabled;
  119295. /**
  119296. * Gets whether audio is enabled or not.
  119297. * Please use related enable/disable method to switch state.
  119298. */
  119299. get audioEnabled(): boolean;
  119300. private _headphone;
  119301. /**
  119302. * Gets whether audio is outputing to headphone or not.
  119303. * Please use the according Switch methods to change output.
  119304. */
  119305. get headphone(): boolean;
  119306. /**
  119307. * Gets or sets a refresh rate when using 3D audio positioning
  119308. */
  119309. audioPositioningRefreshRate: number;
  119310. private _audioListenerPositionProvider;
  119311. /**
  119312. * Gets the current audio listener position provider
  119313. */
  119314. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  119315. /**
  119316. * Sets a custom listener position for all sounds in the scene
  119317. * By default, this is the position of the first active camera
  119318. */
  119319. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  119320. /**
  119321. * Creates a new instance of the component for the given scene
  119322. * @param scene Defines the scene to register the component in
  119323. */
  119324. constructor(scene: Scene);
  119325. /**
  119326. * Registers the component in a given scene
  119327. */
  119328. register(): void;
  119329. /**
  119330. * Rebuilds the elements related to this component in case of
  119331. * context lost for instance.
  119332. */
  119333. rebuild(): void;
  119334. /**
  119335. * Serializes the component data to the specified json object
  119336. * @param serializationObject The object to serialize to
  119337. */
  119338. serialize(serializationObject: any): void;
  119339. /**
  119340. * Adds all the elements from the container to the scene
  119341. * @param container the container holding the elements
  119342. */
  119343. addFromContainer(container: AbstractScene): void;
  119344. /**
  119345. * Removes all the elements in the container from the scene
  119346. * @param container contains the elements to remove
  119347. * @param dispose if the removed element should be disposed (default: false)
  119348. */
  119349. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119350. /**
  119351. * Disposes the component and the associated ressources.
  119352. */
  119353. dispose(): void;
  119354. /**
  119355. * Disables audio in the associated scene.
  119356. */
  119357. disableAudio(): void;
  119358. /**
  119359. * Enables audio in the associated scene.
  119360. */
  119361. enableAudio(): void;
  119362. /**
  119363. * Switch audio to headphone output.
  119364. */
  119365. switchAudioModeForHeadphones(): void;
  119366. /**
  119367. * Switch audio to normal speakers.
  119368. */
  119369. switchAudioModeForNormalSpeakers(): void;
  119370. private _cachedCameraDirection;
  119371. private _cachedCameraPosition;
  119372. private _lastCheck;
  119373. private _afterRender;
  119374. }
  119375. }
  119376. declare module BABYLON {
  119377. /**
  119378. * Wraps one or more Sound objects and selects one with random weight for playback.
  119379. */
  119380. export class WeightedSound {
  119381. /** When true a Sound will be selected and played when the current playing Sound completes. */
  119382. loop: boolean;
  119383. private _coneInnerAngle;
  119384. private _coneOuterAngle;
  119385. private _volume;
  119386. /** A Sound is currently playing. */
  119387. isPlaying: boolean;
  119388. /** A Sound is currently paused. */
  119389. isPaused: boolean;
  119390. private _sounds;
  119391. private _weights;
  119392. private _currentIndex?;
  119393. /**
  119394. * Creates a new WeightedSound from the list of sounds given.
  119395. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  119396. * @param sounds Array of Sounds that will be selected from.
  119397. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  119398. */
  119399. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  119400. /**
  119401. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  119402. */
  119403. get directionalConeInnerAngle(): number;
  119404. /**
  119405. * The size of cone in degress for a directional sound in which there will be no attenuation.
  119406. */
  119407. set directionalConeInnerAngle(value: number);
  119408. /**
  119409. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  119410. * Listener angles between innerAngle and outerAngle will falloff linearly.
  119411. */
  119412. get directionalConeOuterAngle(): number;
  119413. /**
  119414. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  119415. * Listener angles between innerAngle and outerAngle will falloff linearly.
  119416. */
  119417. set directionalConeOuterAngle(value: number);
  119418. /**
  119419. * Playback volume.
  119420. */
  119421. get volume(): number;
  119422. /**
  119423. * Playback volume.
  119424. */
  119425. set volume(value: number);
  119426. private _onended;
  119427. /**
  119428. * Suspend playback
  119429. */
  119430. pause(): void;
  119431. /**
  119432. * Stop playback
  119433. */
  119434. stop(): void;
  119435. /**
  119436. * Start playback.
  119437. * @param startOffset Position the clip head at a specific time in seconds.
  119438. */
  119439. play(startOffset?: number): void;
  119440. }
  119441. }
  119442. declare module BABYLON {
  119443. /**
  119444. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  119445. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  119446. */
  119447. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  119448. /**
  119449. * Gets the name of the behavior.
  119450. */
  119451. get name(): string;
  119452. /**
  119453. * The easing function used by animations
  119454. */
  119455. static EasingFunction: BackEase;
  119456. /**
  119457. * The easing mode used by animations
  119458. */
  119459. static EasingMode: number;
  119460. /**
  119461. * The duration of the animation, in milliseconds
  119462. */
  119463. transitionDuration: number;
  119464. /**
  119465. * Length of the distance animated by the transition when lower radius is reached
  119466. */
  119467. lowerRadiusTransitionRange: number;
  119468. /**
  119469. * Length of the distance animated by the transition when upper radius is reached
  119470. */
  119471. upperRadiusTransitionRange: number;
  119472. private _autoTransitionRange;
  119473. /**
  119474. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  119475. */
  119476. get autoTransitionRange(): boolean;
  119477. /**
  119478. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  119479. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  119480. */
  119481. set autoTransitionRange(value: boolean);
  119482. private _attachedCamera;
  119483. private _onAfterCheckInputsObserver;
  119484. private _onMeshTargetChangedObserver;
  119485. /**
  119486. * Initializes the behavior.
  119487. */
  119488. init(): void;
  119489. /**
  119490. * Attaches the behavior to its arc rotate camera.
  119491. * @param camera Defines the camera to attach the behavior to
  119492. */
  119493. attach(camera: ArcRotateCamera): void;
  119494. /**
  119495. * Detaches the behavior from its current arc rotate camera.
  119496. */
  119497. detach(): void;
  119498. private _radiusIsAnimating;
  119499. private _radiusBounceTransition;
  119500. private _animatables;
  119501. private _cachedWheelPrecision;
  119502. /**
  119503. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  119504. * @param radiusLimit The limit to check against.
  119505. * @return Bool to indicate if at limit.
  119506. */
  119507. private _isRadiusAtLimit;
  119508. /**
  119509. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  119510. * @param radiusDelta The delta by which to animate to. Can be negative.
  119511. */
  119512. private _applyBoundRadiusAnimation;
  119513. /**
  119514. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  119515. */
  119516. protected _clearAnimationLocks(): void;
  119517. /**
  119518. * Stops and removes all animations that have been applied to the camera
  119519. */
  119520. stopAllAnimations(): void;
  119521. }
  119522. }
  119523. declare module BABYLON {
  119524. /**
  119525. * 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.
  119526. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  119527. */
  119528. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  119529. /**
  119530. * Gets the name of the behavior.
  119531. */
  119532. get name(): string;
  119533. private _mode;
  119534. private _radiusScale;
  119535. private _positionScale;
  119536. private _defaultElevation;
  119537. private _elevationReturnTime;
  119538. private _elevationReturnWaitTime;
  119539. private _zoomStopsAnimation;
  119540. private _framingTime;
  119541. /**
  119542. * The easing function used by animations
  119543. */
  119544. static EasingFunction: ExponentialEase;
  119545. /**
  119546. * The easing mode used by animations
  119547. */
  119548. static EasingMode: number;
  119549. /**
  119550. * Sets the current mode used by the behavior
  119551. */
  119552. set mode(mode: number);
  119553. /**
  119554. * Gets current mode used by the behavior.
  119555. */
  119556. get mode(): number;
  119557. /**
  119558. * Sets the scale applied to the radius (1 by default)
  119559. */
  119560. set radiusScale(radius: number);
  119561. /**
  119562. * Gets the scale applied to the radius
  119563. */
  119564. get radiusScale(): number;
  119565. /**
  119566. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  119567. */
  119568. set positionScale(scale: number);
  119569. /**
  119570. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  119571. */
  119572. get positionScale(): number;
  119573. /**
  119574. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  119575. * behaviour is triggered, in radians.
  119576. */
  119577. set defaultElevation(elevation: number);
  119578. /**
  119579. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  119580. * behaviour is triggered, in radians.
  119581. */
  119582. get defaultElevation(): number;
  119583. /**
  119584. * Sets the time (in milliseconds) taken to return to the default beta position.
  119585. * Negative value indicates camera should not return to default.
  119586. */
  119587. set elevationReturnTime(speed: number);
  119588. /**
  119589. * Gets the time (in milliseconds) taken to return to the default beta position.
  119590. * Negative value indicates camera should not return to default.
  119591. */
  119592. get elevationReturnTime(): number;
  119593. /**
  119594. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  119595. */
  119596. set elevationReturnWaitTime(time: number);
  119597. /**
  119598. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  119599. */
  119600. get elevationReturnWaitTime(): number;
  119601. /**
  119602. * Sets the flag that indicates if user zooming should stop animation.
  119603. */
  119604. set zoomStopsAnimation(flag: boolean);
  119605. /**
  119606. * Gets the flag that indicates if user zooming should stop animation.
  119607. */
  119608. get zoomStopsAnimation(): boolean;
  119609. /**
  119610. * Sets the transition time when framing the mesh, in milliseconds
  119611. */
  119612. set framingTime(time: number);
  119613. /**
  119614. * Gets the transition time when framing the mesh, in milliseconds
  119615. */
  119616. get framingTime(): number;
  119617. /**
  119618. * Define if the behavior should automatically change the configured
  119619. * camera limits and sensibilities.
  119620. */
  119621. autoCorrectCameraLimitsAndSensibility: boolean;
  119622. private _onPrePointerObservableObserver;
  119623. private _onAfterCheckInputsObserver;
  119624. private _onMeshTargetChangedObserver;
  119625. private _attachedCamera;
  119626. private _isPointerDown;
  119627. private _lastInteractionTime;
  119628. /**
  119629. * Initializes the behavior.
  119630. */
  119631. init(): void;
  119632. /**
  119633. * Attaches the behavior to its arc rotate camera.
  119634. * @param camera Defines the camera to attach the behavior to
  119635. */
  119636. attach(camera: ArcRotateCamera): void;
  119637. /**
  119638. * Detaches the behavior from its current arc rotate camera.
  119639. */
  119640. detach(): void;
  119641. private _animatables;
  119642. private _betaIsAnimating;
  119643. private _betaTransition;
  119644. private _radiusTransition;
  119645. private _vectorTransition;
  119646. /**
  119647. * Targets the given mesh and updates zoom level accordingly.
  119648. * @param mesh The mesh to target.
  119649. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119650. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119651. */
  119652. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119653. /**
  119654. * Targets the given mesh with its children and updates zoom level accordingly.
  119655. * @param mesh The mesh to target.
  119656. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119657. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119658. */
  119659. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119660. /**
  119661. * Targets the given meshes with their children and updates zoom level accordingly.
  119662. * @param meshes The mesh to target.
  119663. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119664. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119665. */
  119666. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119667. /**
  119668. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  119669. * @param minimumWorld Determines the smaller position of the bounding box extend
  119670. * @param maximumWorld Determines the bigger position of the bounding box extend
  119671. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119672. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119673. */
  119674. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119675. /**
  119676. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  119677. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  119678. * frustum width.
  119679. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  119680. * to fully enclose the mesh in the viewing frustum.
  119681. */
  119682. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  119683. /**
  119684. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  119685. * is automatically returned to its default position (expected to be above ground plane).
  119686. */
  119687. private _maintainCameraAboveGround;
  119688. /**
  119689. * Returns the frustum slope based on the canvas ratio and camera FOV
  119690. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  119691. */
  119692. private _getFrustumSlope;
  119693. /**
  119694. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  119695. */
  119696. private _clearAnimationLocks;
  119697. /**
  119698. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  119699. */
  119700. private _applyUserInteraction;
  119701. /**
  119702. * Stops and removes all animations that have been applied to the camera
  119703. */
  119704. stopAllAnimations(): void;
  119705. /**
  119706. * Gets a value indicating if the user is moving the camera
  119707. */
  119708. get isUserIsMoving(): boolean;
  119709. /**
  119710. * The camera can move all the way towards the mesh.
  119711. */
  119712. static IgnoreBoundsSizeMode: number;
  119713. /**
  119714. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  119715. */
  119716. static FitFrustumSidesMode: number;
  119717. }
  119718. }
  119719. declare module BABYLON {
  119720. /**
  119721. * Base class for Camera Pointer Inputs.
  119722. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  119723. * for example usage.
  119724. */
  119725. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  119726. /**
  119727. * Defines the camera the input is attached to.
  119728. */
  119729. abstract camera: Camera;
  119730. /**
  119731. * Whether keyboard modifier keys are pressed at time of last mouse event.
  119732. */
  119733. protected _altKey: boolean;
  119734. protected _ctrlKey: boolean;
  119735. protected _metaKey: boolean;
  119736. protected _shiftKey: boolean;
  119737. /**
  119738. * Which mouse buttons were pressed at time of last mouse event.
  119739. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  119740. */
  119741. protected _buttonsPressed: number;
  119742. /**
  119743. * Defines the buttons associated with the input to handle camera move.
  119744. */
  119745. buttons: number[];
  119746. /**
  119747. * Attach the input controls to a specific dom element to get the input from.
  119748. * @param element Defines the element the controls should be listened from
  119749. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119750. */
  119751. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119752. /**
  119753. * Detach the current controls from the specified dom element.
  119754. * @param element Defines the element to stop listening the inputs from
  119755. */
  119756. detachControl(element: Nullable<HTMLElement>): void;
  119757. /**
  119758. * Gets the class name of the current input.
  119759. * @returns the class name
  119760. */
  119761. getClassName(): string;
  119762. /**
  119763. * Get the friendly name associated with the input class.
  119764. * @returns the input friendly name
  119765. */
  119766. getSimpleName(): string;
  119767. /**
  119768. * Called on pointer POINTERDOUBLETAP event.
  119769. * Override this method to provide functionality on POINTERDOUBLETAP event.
  119770. */
  119771. protected onDoubleTap(type: string): void;
  119772. /**
  119773. * Called on pointer POINTERMOVE event if only a single touch is active.
  119774. * Override this method to provide functionality.
  119775. */
  119776. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  119777. /**
  119778. * Called on pointer POINTERMOVE event if multiple touches are active.
  119779. * Override this method to provide functionality.
  119780. */
  119781. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  119782. /**
  119783. * Called on JS contextmenu event.
  119784. * Override this method to provide functionality.
  119785. */
  119786. protected onContextMenu(evt: PointerEvent): void;
  119787. /**
  119788. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  119789. * press.
  119790. * Override this method to provide functionality.
  119791. */
  119792. protected onButtonDown(evt: PointerEvent): void;
  119793. /**
  119794. * Called each time a new POINTERUP event occurs. Ie, for each button
  119795. * release.
  119796. * Override this method to provide functionality.
  119797. */
  119798. protected onButtonUp(evt: PointerEvent): void;
  119799. /**
  119800. * Called when window becomes inactive.
  119801. * Override this method to provide functionality.
  119802. */
  119803. protected onLostFocus(): void;
  119804. private _pointerInput;
  119805. private _observer;
  119806. private _onLostFocus;
  119807. private pointA;
  119808. private pointB;
  119809. }
  119810. }
  119811. declare module BABYLON {
  119812. /**
  119813. * Manage the pointers inputs to control an arc rotate camera.
  119814. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  119815. */
  119816. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  119817. /**
  119818. * Defines the camera the input is attached to.
  119819. */
  119820. camera: ArcRotateCamera;
  119821. /**
  119822. * Gets the class name of the current input.
  119823. * @returns the class name
  119824. */
  119825. getClassName(): string;
  119826. /**
  119827. * Defines the buttons associated with the input to handle camera move.
  119828. */
  119829. buttons: number[];
  119830. /**
  119831. * Defines the pointer angular sensibility along the X axis or how fast is
  119832. * the camera rotating.
  119833. */
  119834. angularSensibilityX: number;
  119835. /**
  119836. * Defines the pointer angular sensibility along the Y axis or how fast is
  119837. * the camera rotating.
  119838. */
  119839. angularSensibilityY: number;
  119840. /**
  119841. * Defines the pointer pinch precision or how fast is the camera zooming.
  119842. */
  119843. pinchPrecision: number;
  119844. /**
  119845. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  119846. * from 0.
  119847. * It defines the percentage of current camera.radius to use as delta when
  119848. * pinch zoom is used.
  119849. */
  119850. pinchDeltaPercentage: number;
  119851. /**
  119852. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  119853. * that any object in the plane at the camera's target point will scale
  119854. * perfectly with finger motion.
  119855. * Overrides pinchDeltaPercentage and pinchPrecision.
  119856. */
  119857. useNaturalPinchZoom: boolean;
  119858. /**
  119859. * Defines the pointer panning sensibility or how fast is the camera moving.
  119860. */
  119861. panningSensibility: number;
  119862. /**
  119863. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  119864. */
  119865. multiTouchPanning: boolean;
  119866. /**
  119867. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  119868. * zoom (pinch) through multitouch.
  119869. */
  119870. multiTouchPanAndZoom: boolean;
  119871. /**
  119872. * Revers pinch action direction.
  119873. */
  119874. pinchInwards: boolean;
  119875. private _isPanClick;
  119876. private _twoFingerActivityCount;
  119877. private _isPinching;
  119878. /**
  119879. * Called on pointer POINTERMOVE event if only a single touch is active.
  119880. */
  119881. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  119882. /**
  119883. * Called on pointer POINTERDOUBLETAP event.
  119884. */
  119885. protected onDoubleTap(type: string): void;
  119886. /**
  119887. * Called on pointer POINTERMOVE event if multiple touches are active.
  119888. */
  119889. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  119890. /**
  119891. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  119892. * press.
  119893. */
  119894. protected onButtonDown(evt: PointerEvent): void;
  119895. /**
  119896. * Called each time a new POINTERUP event occurs. Ie, for each button
  119897. * release.
  119898. */
  119899. protected onButtonUp(evt: PointerEvent): void;
  119900. /**
  119901. * Called when window becomes inactive.
  119902. */
  119903. protected onLostFocus(): void;
  119904. }
  119905. }
  119906. declare module BABYLON {
  119907. /**
  119908. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  119909. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  119910. */
  119911. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  119912. /**
  119913. * Defines the camera the input is attached to.
  119914. */
  119915. camera: ArcRotateCamera;
  119916. /**
  119917. * Defines the list of key codes associated with the up action (increase alpha)
  119918. */
  119919. keysUp: number[];
  119920. /**
  119921. * Defines the list of key codes associated with the down action (decrease alpha)
  119922. */
  119923. keysDown: number[];
  119924. /**
  119925. * Defines the list of key codes associated with the left action (increase beta)
  119926. */
  119927. keysLeft: number[];
  119928. /**
  119929. * Defines the list of key codes associated with the right action (decrease beta)
  119930. */
  119931. keysRight: number[];
  119932. /**
  119933. * Defines the list of key codes associated with the reset action.
  119934. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  119935. */
  119936. keysReset: number[];
  119937. /**
  119938. * Defines the panning sensibility of the inputs.
  119939. * (How fast is the camera panning)
  119940. */
  119941. panningSensibility: number;
  119942. /**
  119943. * Defines the zooming sensibility of the inputs.
  119944. * (How fast is the camera zooming)
  119945. */
  119946. zoomingSensibility: number;
  119947. /**
  119948. * Defines whether maintaining the alt key down switch the movement mode from
  119949. * orientation to zoom.
  119950. */
  119951. useAltToZoom: boolean;
  119952. /**
  119953. * Rotation speed of the camera
  119954. */
  119955. angularSpeed: number;
  119956. private _keys;
  119957. private _ctrlPressed;
  119958. private _altPressed;
  119959. private _onCanvasBlurObserver;
  119960. private _onKeyboardObserver;
  119961. private _engine;
  119962. private _scene;
  119963. /**
  119964. * Attach the input controls to a specific dom element to get the input from.
  119965. * @param element Defines the element the controls should be listened from
  119966. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119967. */
  119968. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119969. /**
  119970. * Detach the current controls from the specified dom element.
  119971. * @param element Defines the element to stop listening the inputs from
  119972. */
  119973. detachControl(element: Nullable<HTMLElement>): void;
  119974. /**
  119975. * Update the current camera state depending on the inputs that have been used this frame.
  119976. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  119977. */
  119978. checkInputs(): void;
  119979. /**
  119980. * Gets the class name of the current intput.
  119981. * @returns the class name
  119982. */
  119983. getClassName(): string;
  119984. /**
  119985. * Get the friendly name associated with the input class.
  119986. * @returns the input friendly name
  119987. */
  119988. getSimpleName(): string;
  119989. }
  119990. }
  119991. declare module BABYLON {
  119992. /**
  119993. * Manage the mouse wheel inputs to control an arc rotate camera.
  119994. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  119995. */
  119996. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  119997. /**
  119998. * Defines the camera the input is attached to.
  119999. */
  120000. camera: ArcRotateCamera;
  120001. /**
  120002. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  120003. */
  120004. wheelPrecision: number;
  120005. /**
  120006. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  120007. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  120008. */
  120009. wheelDeltaPercentage: number;
  120010. private _wheel;
  120011. private _observer;
  120012. private computeDeltaFromMouseWheelLegacyEvent;
  120013. /**
  120014. * Attach the input controls to a specific dom element to get the input from.
  120015. * @param element Defines the element the controls should be listened from
  120016. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120017. */
  120018. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120019. /**
  120020. * Detach the current controls from the specified dom element.
  120021. * @param element Defines the element to stop listening the inputs from
  120022. */
  120023. detachControl(element: Nullable<HTMLElement>): void;
  120024. /**
  120025. * Gets the class name of the current intput.
  120026. * @returns the class name
  120027. */
  120028. getClassName(): string;
  120029. /**
  120030. * Get the friendly name associated with the input class.
  120031. * @returns the input friendly name
  120032. */
  120033. getSimpleName(): string;
  120034. }
  120035. }
  120036. declare module BABYLON {
  120037. /**
  120038. * Default Inputs manager for the ArcRotateCamera.
  120039. * It groups all the default supported inputs for ease of use.
  120040. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  120041. */
  120042. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  120043. /**
  120044. * Instantiates a new ArcRotateCameraInputsManager.
  120045. * @param camera Defines the camera the inputs belong to
  120046. */
  120047. constructor(camera: ArcRotateCamera);
  120048. /**
  120049. * Add mouse wheel input support to the input manager.
  120050. * @returns the current input manager
  120051. */
  120052. addMouseWheel(): ArcRotateCameraInputsManager;
  120053. /**
  120054. * Add pointers input support to the input manager.
  120055. * @returns the current input manager
  120056. */
  120057. addPointers(): ArcRotateCameraInputsManager;
  120058. /**
  120059. * Add keyboard input support to the input manager.
  120060. * @returns the current input manager
  120061. */
  120062. addKeyboard(): ArcRotateCameraInputsManager;
  120063. }
  120064. }
  120065. declare module BABYLON {
  120066. /**
  120067. * This represents an orbital type of camera.
  120068. *
  120069. * 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.
  120070. * 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.
  120071. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  120072. */
  120073. export class ArcRotateCamera extends TargetCamera {
  120074. /**
  120075. * Defines the rotation angle of the camera along the longitudinal axis.
  120076. */
  120077. alpha: number;
  120078. /**
  120079. * Defines the rotation angle of the camera along the latitudinal axis.
  120080. */
  120081. beta: number;
  120082. /**
  120083. * Defines the radius of the camera from it s target point.
  120084. */
  120085. radius: number;
  120086. protected _target: Vector3;
  120087. protected _targetHost: Nullable<AbstractMesh>;
  120088. /**
  120089. * Defines the target point of the camera.
  120090. * The camera looks towards it form the radius distance.
  120091. */
  120092. get target(): Vector3;
  120093. set target(value: Vector3);
  120094. /**
  120095. * Define the current local position of the camera in the scene
  120096. */
  120097. get position(): Vector3;
  120098. set position(newPosition: Vector3);
  120099. protected _upVector: Vector3;
  120100. protected _upToYMatrix: Matrix;
  120101. protected _YToUpMatrix: Matrix;
  120102. /**
  120103. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  120104. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  120105. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  120106. */
  120107. set upVector(vec: Vector3);
  120108. get upVector(): Vector3;
  120109. /**
  120110. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  120111. */
  120112. setMatUp(): void;
  120113. /**
  120114. * Current inertia value on the longitudinal axis.
  120115. * The bigger this number the longer it will take for the camera to stop.
  120116. */
  120117. inertialAlphaOffset: number;
  120118. /**
  120119. * Current inertia value on the latitudinal axis.
  120120. * The bigger this number the longer it will take for the camera to stop.
  120121. */
  120122. inertialBetaOffset: number;
  120123. /**
  120124. * Current inertia value on the radius axis.
  120125. * The bigger this number the longer it will take for the camera to stop.
  120126. */
  120127. inertialRadiusOffset: number;
  120128. /**
  120129. * Minimum allowed angle on the longitudinal axis.
  120130. * This can help limiting how the Camera is able to move in the scene.
  120131. */
  120132. lowerAlphaLimit: Nullable<number>;
  120133. /**
  120134. * Maximum allowed angle on the longitudinal axis.
  120135. * This can help limiting how the Camera is able to move in the scene.
  120136. */
  120137. upperAlphaLimit: Nullable<number>;
  120138. /**
  120139. * Minimum allowed angle on the latitudinal axis.
  120140. * This can help limiting how the Camera is able to move in the scene.
  120141. */
  120142. lowerBetaLimit: number;
  120143. /**
  120144. * Maximum allowed angle on the latitudinal axis.
  120145. * This can help limiting how the Camera is able to move in the scene.
  120146. */
  120147. upperBetaLimit: number;
  120148. /**
  120149. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  120150. * This can help limiting how the Camera is able to move in the scene.
  120151. */
  120152. lowerRadiusLimit: Nullable<number>;
  120153. /**
  120154. * Maximum allowed distance of the camera to the target (The camera can not get further).
  120155. * This can help limiting how the Camera is able to move in the scene.
  120156. */
  120157. upperRadiusLimit: Nullable<number>;
  120158. /**
  120159. * Defines the current inertia value used during panning of the camera along the X axis.
  120160. */
  120161. inertialPanningX: number;
  120162. /**
  120163. * Defines the current inertia value used during panning of the camera along the Y axis.
  120164. */
  120165. inertialPanningY: number;
  120166. /**
  120167. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  120168. * Basically if your fingers moves away from more than this distance you will be considered
  120169. * in pinch mode.
  120170. */
  120171. pinchToPanMaxDistance: number;
  120172. /**
  120173. * Defines the maximum distance the camera can pan.
  120174. * This could help keeping the cammera always in your scene.
  120175. */
  120176. panningDistanceLimit: Nullable<number>;
  120177. /**
  120178. * Defines the target of the camera before paning.
  120179. */
  120180. panningOriginTarget: Vector3;
  120181. /**
  120182. * Defines the value of the inertia used during panning.
  120183. * 0 would mean stop inertia and one would mean no decelleration at all.
  120184. */
  120185. panningInertia: number;
  120186. /**
  120187. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  120188. */
  120189. get angularSensibilityX(): number;
  120190. set angularSensibilityX(value: number);
  120191. /**
  120192. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  120193. */
  120194. get angularSensibilityY(): number;
  120195. set angularSensibilityY(value: number);
  120196. /**
  120197. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  120198. */
  120199. get pinchPrecision(): number;
  120200. set pinchPrecision(value: number);
  120201. /**
  120202. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  120203. * It will be used instead of pinchDeltaPrecision if different from 0.
  120204. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  120205. */
  120206. get pinchDeltaPercentage(): number;
  120207. set pinchDeltaPercentage(value: number);
  120208. /**
  120209. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  120210. * and pinch delta percentage.
  120211. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  120212. * that any object in the plane at the camera's target point will scale
  120213. * perfectly with finger motion.
  120214. */
  120215. get useNaturalPinchZoom(): boolean;
  120216. set useNaturalPinchZoom(value: boolean);
  120217. /**
  120218. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  120219. */
  120220. get panningSensibility(): number;
  120221. set panningSensibility(value: number);
  120222. /**
  120223. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  120224. */
  120225. get keysUp(): number[];
  120226. set keysUp(value: number[]);
  120227. /**
  120228. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  120229. */
  120230. get keysDown(): number[];
  120231. set keysDown(value: number[]);
  120232. /**
  120233. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  120234. */
  120235. get keysLeft(): number[];
  120236. set keysLeft(value: number[]);
  120237. /**
  120238. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  120239. */
  120240. get keysRight(): number[];
  120241. set keysRight(value: number[]);
  120242. /**
  120243. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  120244. */
  120245. get wheelPrecision(): number;
  120246. set wheelPrecision(value: number);
  120247. /**
  120248. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  120249. * It will be used instead of pinchDeltaPrecision if different from 0.
  120250. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  120251. */
  120252. get wheelDeltaPercentage(): number;
  120253. set wheelDeltaPercentage(value: number);
  120254. /**
  120255. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  120256. */
  120257. zoomOnFactor: number;
  120258. /**
  120259. * Defines a screen offset for the camera position.
  120260. */
  120261. targetScreenOffset: Vector2;
  120262. /**
  120263. * Allows the camera to be completely reversed.
  120264. * If false the camera can not arrive upside down.
  120265. */
  120266. allowUpsideDown: boolean;
  120267. /**
  120268. * Define if double tap/click is used to restore the previously saved state of the camera.
  120269. */
  120270. useInputToRestoreState: boolean;
  120271. /** @hidden */
  120272. _viewMatrix: Matrix;
  120273. /** @hidden */
  120274. _useCtrlForPanning: boolean;
  120275. /** @hidden */
  120276. _panningMouseButton: number;
  120277. /**
  120278. * Defines the input associated to the camera.
  120279. */
  120280. inputs: ArcRotateCameraInputsManager;
  120281. /** @hidden */
  120282. _reset: () => void;
  120283. /**
  120284. * Defines the allowed panning axis.
  120285. */
  120286. panningAxis: Vector3;
  120287. protected _localDirection: Vector3;
  120288. protected _transformedDirection: Vector3;
  120289. private _bouncingBehavior;
  120290. /**
  120291. * Gets the bouncing behavior of the camera if it has been enabled.
  120292. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  120293. */
  120294. get bouncingBehavior(): Nullable<BouncingBehavior>;
  120295. /**
  120296. * Defines if the bouncing behavior of the camera is enabled on the camera.
  120297. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  120298. */
  120299. get useBouncingBehavior(): boolean;
  120300. set useBouncingBehavior(value: boolean);
  120301. private _framingBehavior;
  120302. /**
  120303. * Gets the framing behavior of the camera if it has been enabled.
  120304. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  120305. */
  120306. get framingBehavior(): Nullable<FramingBehavior>;
  120307. /**
  120308. * Defines if the framing behavior of the camera is enabled on the camera.
  120309. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  120310. */
  120311. get useFramingBehavior(): boolean;
  120312. set useFramingBehavior(value: boolean);
  120313. private _autoRotationBehavior;
  120314. /**
  120315. * Gets the auto rotation behavior of the camera if it has been enabled.
  120316. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  120317. */
  120318. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  120319. /**
  120320. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  120321. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  120322. */
  120323. get useAutoRotationBehavior(): boolean;
  120324. set useAutoRotationBehavior(value: boolean);
  120325. /**
  120326. * Observable triggered when the mesh target has been changed on the camera.
  120327. */
  120328. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  120329. /**
  120330. * Event raised when the camera is colliding with a mesh.
  120331. */
  120332. onCollide: (collidedMesh: AbstractMesh) => void;
  120333. /**
  120334. * Defines whether the camera should check collision with the objects oh the scene.
  120335. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  120336. */
  120337. checkCollisions: boolean;
  120338. /**
  120339. * Defines the collision radius of the camera.
  120340. * This simulates a sphere around the camera.
  120341. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  120342. */
  120343. collisionRadius: Vector3;
  120344. protected _collider: Collider;
  120345. protected _previousPosition: Vector3;
  120346. protected _collisionVelocity: Vector3;
  120347. protected _newPosition: Vector3;
  120348. protected _previousAlpha: number;
  120349. protected _previousBeta: number;
  120350. protected _previousRadius: number;
  120351. protected _collisionTriggered: boolean;
  120352. protected _targetBoundingCenter: Nullable<Vector3>;
  120353. private _computationVector;
  120354. /**
  120355. * Instantiates a new ArcRotateCamera in a given scene
  120356. * @param name Defines the name of the camera
  120357. * @param alpha Defines the camera rotation along the logitudinal axis
  120358. * @param beta Defines the camera rotation along the latitudinal axis
  120359. * @param radius Defines the camera distance from its target
  120360. * @param target Defines the camera target
  120361. * @param scene Defines the scene the camera belongs to
  120362. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  120363. */
  120364. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  120365. /** @hidden */
  120366. _initCache(): void;
  120367. /** @hidden */
  120368. _updateCache(ignoreParentClass?: boolean): void;
  120369. protected _getTargetPosition(): Vector3;
  120370. private _storedAlpha;
  120371. private _storedBeta;
  120372. private _storedRadius;
  120373. private _storedTarget;
  120374. private _storedTargetScreenOffset;
  120375. /**
  120376. * Stores the current state of the camera (alpha, beta, radius and target)
  120377. * @returns the camera itself
  120378. */
  120379. storeState(): Camera;
  120380. /**
  120381. * @hidden
  120382. * Restored camera state. You must call storeState() first
  120383. */
  120384. _restoreStateValues(): boolean;
  120385. /** @hidden */
  120386. _isSynchronizedViewMatrix(): boolean;
  120387. /**
  120388. * Attached controls to the current camera.
  120389. * @param element Defines the element the controls should be listened from
  120390. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120391. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  120392. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  120393. */
  120394. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  120395. /**
  120396. * Detach the current controls from the camera.
  120397. * The camera will stop reacting to inputs.
  120398. * @param element Defines the element to stop listening the inputs from
  120399. */
  120400. detachControl(element: HTMLElement): void;
  120401. /** @hidden */
  120402. _checkInputs(): void;
  120403. protected _checkLimits(): void;
  120404. /**
  120405. * Rebuilds angles (alpha, beta) and radius from the give position and target
  120406. */
  120407. rebuildAnglesAndRadius(): void;
  120408. /**
  120409. * Use a position to define the current camera related information like alpha, beta and radius
  120410. * @param position Defines the position to set the camera at
  120411. */
  120412. setPosition(position: Vector3): void;
  120413. /**
  120414. * Defines the target the camera should look at.
  120415. * This will automatically adapt alpha beta and radius to fit within the new target.
  120416. * @param target Defines the new target as a Vector or a mesh
  120417. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  120418. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  120419. */
  120420. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  120421. /** @hidden */
  120422. _getViewMatrix(): Matrix;
  120423. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  120424. /**
  120425. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  120426. * @param meshes Defines the mesh to zoom on
  120427. * @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)
  120428. */
  120429. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  120430. /**
  120431. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  120432. * The target will be changed but the radius
  120433. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  120434. * @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)
  120435. */
  120436. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  120437. min: Vector3;
  120438. max: Vector3;
  120439. distance: number;
  120440. }, doNotUpdateMaxZ?: boolean): void;
  120441. /**
  120442. * @override
  120443. * Override Camera.createRigCamera
  120444. */
  120445. createRigCamera(name: string, cameraIndex: number): Camera;
  120446. /**
  120447. * @hidden
  120448. * @override
  120449. * Override Camera._updateRigCameras
  120450. */
  120451. _updateRigCameras(): void;
  120452. /**
  120453. * Destroy the camera and release the current resources hold by it.
  120454. */
  120455. dispose(): void;
  120456. /**
  120457. * Gets the current object class name.
  120458. * @return the class name
  120459. */
  120460. getClassName(): string;
  120461. }
  120462. }
  120463. declare module BABYLON {
  120464. /**
  120465. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  120466. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  120467. */
  120468. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  120469. /**
  120470. * Gets the name of the behavior.
  120471. */
  120472. get name(): string;
  120473. private _zoomStopsAnimation;
  120474. private _idleRotationSpeed;
  120475. private _idleRotationWaitTime;
  120476. private _idleRotationSpinupTime;
  120477. /**
  120478. * Sets the flag that indicates if user zooming should stop animation.
  120479. */
  120480. set zoomStopsAnimation(flag: boolean);
  120481. /**
  120482. * Gets the flag that indicates if user zooming should stop animation.
  120483. */
  120484. get zoomStopsAnimation(): boolean;
  120485. /**
  120486. * Sets the default speed at which the camera rotates around the model.
  120487. */
  120488. set idleRotationSpeed(speed: number);
  120489. /**
  120490. * Gets the default speed at which the camera rotates around the model.
  120491. */
  120492. get idleRotationSpeed(): number;
  120493. /**
  120494. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  120495. */
  120496. set idleRotationWaitTime(time: number);
  120497. /**
  120498. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  120499. */
  120500. get idleRotationWaitTime(): number;
  120501. /**
  120502. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  120503. */
  120504. set idleRotationSpinupTime(time: number);
  120505. /**
  120506. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  120507. */
  120508. get idleRotationSpinupTime(): number;
  120509. /**
  120510. * Gets a value indicating if the camera is currently rotating because of this behavior
  120511. */
  120512. get rotationInProgress(): boolean;
  120513. private _onPrePointerObservableObserver;
  120514. private _onAfterCheckInputsObserver;
  120515. private _attachedCamera;
  120516. private _isPointerDown;
  120517. private _lastFrameTime;
  120518. private _lastInteractionTime;
  120519. private _cameraRotationSpeed;
  120520. /**
  120521. * Initializes the behavior.
  120522. */
  120523. init(): void;
  120524. /**
  120525. * Attaches the behavior to its arc rotate camera.
  120526. * @param camera Defines the camera to attach the behavior to
  120527. */
  120528. attach(camera: ArcRotateCamera): void;
  120529. /**
  120530. * Detaches the behavior from its current arc rotate camera.
  120531. */
  120532. detach(): void;
  120533. /**
  120534. * Returns true if user is scrolling.
  120535. * @return true if user is scrolling.
  120536. */
  120537. private _userIsZooming;
  120538. private _lastFrameRadius;
  120539. private _shouldAnimationStopForInteraction;
  120540. /**
  120541. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  120542. */
  120543. private _applyUserInteraction;
  120544. private _userIsMoving;
  120545. }
  120546. }
  120547. declare module BABYLON {
  120548. /**
  120549. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  120550. */
  120551. export class AttachToBoxBehavior implements Behavior<Mesh> {
  120552. private ui;
  120553. /**
  120554. * The name of the behavior
  120555. */
  120556. name: string;
  120557. /**
  120558. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  120559. */
  120560. distanceAwayFromFace: number;
  120561. /**
  120562. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  120563. */
  120564. distanceAwayFromBottomOfFace: number;
  120565. private _faceVectors;
  120566. private _target;
  120567. private _scene;
  120568. private _onRenderObserver;
  120569. private _tmpMatrix;
  120570. private _tmpVector;
  120571. /**
  120572. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  120573. * @param ui The transform node that should be attched to the mesh
  120574. */
  120575. constructor(ui: TransformNode);
  120576. /**
  120577. * Initializes the behavior
  120578. */
  120579. init(): void;
  120580. private _closestFace;
  120581. private _zeroVector;
  120582. private _lookAtTmpMatrix;
  120583. private _lookAtToRef;
  120584. /**
  120585. * Attaches the AttachToBoxBehavior to the passed in mesh
  120586. * @param target The mesh that the specified node will be attached to
  120587. */
  120588. attach(target: Mesh): void;
  120589. /**
  120590. * Detaches the behavior from the mesh
  120591. */
  120592. detach(): void;
  120593. }
  120594. }
  120595. declare module BABYLON {
  120596. /**
  120597. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  120598. */
  120599. export class FadeInOutBehavior implements Behavior<Mesh> {
  120600. /**
  120601. * Time in milliseconds to delay before fading in (Default: 0)
  120602. */
  120603. delay: number;
  120604. /**
  120605. * Time in milliseconds for the mesh to fade in (Default: 300)
  120606. */
  120607. fadeInTime: number;
  120608. private _millisecondsPerFrame;
  120609. private _hovered;
  120610. private _hoverValue;
  120611. private _ownerNode;
  120612. /**
  120613. * Instatiates the FadeInOutBehavior
  120614. */
  120615. constructor();
  120616. /**
  120617. * The name of the behavior
  120618. */
  120619. get name(): string;
  120620. /**
  120621. * Initializes the behavior
  120622. */
  120623. init(): void;
  120624. /**
  120625. * Attaches the fade behavior on the passed in mesh
  120626. * @param ownerNode The mesh that will be faded in/out once attached
  120627. */
  120628. attach(ownerNode: Mesh): void;
  120629. /**
  120630. * Detaches the behavior from the mesh
  120631. */
  120632. detach(): void;
  120633. /**
  120634. * Triggers the mesh to begin fading in or out
  120635. * @param value if the object should fade in or out (true to fade in)
  120636. */
  120637. fadeIn(value: boolean): void;
  120638. private _update;
  120639. private _setAllVisibility;
  120640. }
  120641. }
  120642. declare module BABYLON {
  120643. /**
  120644. * Class containing a set of static utilities functions for managing Pivots
  120645. * @hidden
  120646. */
  120647. export class PivotTools {
  120648. private static _PivotCached;
  120649. private static _OldPivotPoint;
  120650. private static _PivotTranslation;
  120651. private static _PivotTmpVector;
  120652. /** @hidden */
  120653. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  120654. /** @hidden */
  120655. static _RestorePivotPoint(mesh: AbstractMesh): void;
  120656. }
  120657. }
  120658. declare module BABYLON {
  120659. /**
  120660. * Class containing static functions to help procedurally build meshes
  120661. */
  120662. export class PlaneBuilder {
  120663. /**
  120664. * Creates a plane mesh
  120665. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  120666. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  120667. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  120668. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120669. * * 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
  120670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120671. * @param name defines the name of the mesh
  120672. * @param options defines the options used to create the mesh
  120673. * @param scene defines the hosting scene
  120674. * @returns the plane mesh
  120675. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  120676. */
  120677. static CreatePlane(name: string, options: {
  120678. size?: number;
  120679. width?: number;
  120680. height?: number;
  120681. sideOrientation?: number;
  120682. frontUVs?: Vector4;
  120683. backUVs?: Vector4;
  120684. updatable?: boolean;
  120685. sourcePlane?: Plane;
  120686. }, scene?: Nullable<Scene>): Mesh;
  120687. }
  120688. }
  120689. declare module BABYLON {
  120690. /**
  120691. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  120692. */
  120693. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  120694. private static _AnyMouseID;
  120695. /**
  120696. * Abstract mesh the behavior is set on
  120697. */
  120698. attachedNode: AbstractMesh;
  120699. private _dragPlane;
  120700. private _scene;
  120701. private _pointerObserver;
  120702. private _beforeRenderObserver;
  120703. private static _planeScene;
  120704. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  120705. /**
  120706. * 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)
  120707. */
  120708. maxDragAngle: number;
  120709. /**
  120710. * @hidden
  120711. */
  120712. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  120713. /**
  120714. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  120715. */
  120716. currentDraggingPointerID: number;
  120717. /**
  120718. * The last position where the pointer hit the drag plane in world space
  120719. */
  120720. lastDragPosition: Vector3;
  120721. /**
  120722. * If the behavior is currently in a dragging state
  120723. */
  120724. dragging: boolean;
  120725. /**
  120726. * 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)
  120727. */
  120728. dragDeltaRatio: number;
  120729. /**
  120730. * If the drag plane orientation should be updated during the dragging (Default: true)
  120731. */
  120732. updateDragPlane: boolean;
  120733. private _debugMode;
  120734. private _moving;
  120735. /**
  120736. * Fires each time the attached mesh is dragged with the pointer
  120737. * * delta between last drag position and current drag position in world space
  120738. * * dragDistance along the drag axis
  120739. * * dragPlaneNormal normal of the current drag plane used during the drag
  120740. * * dragPlanePoint in world space where the drag intersects the drag plane
  120741. */
  120742. onDragObservable: Observable<{
  120743. delta: Vector3;
  120744. dragPlanePoint: Vector3;
  120745. dragPlaneNormal: Vector3;
  120746. dragDistance: number;
  120747. pointerId: number;
  120748. }>;
  120749. /**
  120750. * Fires each time a drag begins (eg. mouse down on mesh)
  120751. */
  120752. onDragStartObservable: Observable<{
  120753. dragPlanePoint: Vector3;
  120754. pointerId: number;
  120755. }>;
  120756. /**
  120757. * Fires each time a drag ends (eg. mouse release after drag)
  120758. */
  120759. onDragEndObservable: Observable<{
  120760. dragPlanePoint: Vector3;
  120761. pointerId: number;
  120762. }>;
  120763. /**
  120764. * If the attached mesh should be moved when dragged
  120765. */
  120766. moveAttached: boolean;
  120767. /**
  120768. * If the drag behavior will react to drag events (Default: true)
  120769. */
  120770. enabled: boolean;
  120771. /**
  120772. * If pointer events should start and release the drag (Default: true)
  120773. */
  120774. startAndReleaseDragOnPointerEvents: boolean;
  120775. /**
  120776. * If camera controls should be detached during the drag
  120777. */
  120778. detachCameraControls: boolean;
  120779. /**
  120780. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  120781. */
  120782. useObjectOrientationForDragging: boolean;
  120783. private _options;
  120784. /**
  120785. * Gets the options used by the behavior
  120786. */
  120787. get options(): {
  120788. dragAxis?: Vector3;
  120789. dragPlaneNormal?: Vector3;
  120790. };
  120791. /**
  120792. * Sets the options used by the behavior
  120793. */
  120794. set options(options: {
  120795. dragAxis?: Vector3;
  120796. dragPlaneNormal?: Vector3;
  120797. });
  120798. /**
  120799. * Creates a pointer drag behavior that can be attached to a mesh
  120800. * @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)
  120801. */
  120802. constructor(options?: {
  120803. dragAxis?: Vector3;
  120804. dragPlaneNormal?: Vector3;
  120805. });
  120806. /**
  120807. * Predicate to determine if it is valid to move the object to a new position when it is moved
  120808. */
  120809. validateDrag: (targetPosition: Vector3) => boolean;
  120810. /**
  120811. * The name of the behavior
  120812. */
  120813. get name(): string;
  120814. /**
  120815. * Initializes the behavior
  120816. */
  120817. init(): void;
  120818. private _tmpVector;
  120819. private _alternatePickedPoint;
  120820. private _worldDragAxis;
  120821. private _targetPosition;
  120822. private _attachedElement;
  120823. /**
  120824. * Attaches the drag behavior the passed in mesh
  120825. * @param ownerNode The mesh that will be dragged around once attached
  120826. * @param predicate Predicate to use for pick filtering
  120827. */
  120828. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  120829. /**
  120830. * Force relase the drag action by code.
  120831. */
  120832. releaseDrag(): void;
  120833. private _startDragRay;
  120834. private _lastPointerRay;
  120835. /**
  120836. * Simulates the start of a pointer drag event on the behavior
  120837. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  120838. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  120839. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  120840. */
  120841. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  120842. private _startDrag;
  120843. private _dragDelta;
  120844. private _moveDrag;
  120845. private _pickWithRayOnDragPlane;
  120846. private _pointA;
  120847. private _pointB;
  120848. private _pointC;
  120849. private _lineA;
  120850. private _lineB;
  120851. private _localAxis;
  120852. private _lookAt;
  120853. private _updateDragPlanePosition;
  120854. /**
  120855. * Detaches the behavior from the mesh
  120856. */
  120857. detach(): void;
  120858. }
  120859. }
  120860. declare module BABYLON {
  120861. /**
  120862. * A behavior that when attached to a mesh will allow the mesh to be scaled
  120863. */
  120864. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  120865. private _dragBehaviorA;
  120866. private _dragBehaviorB;
  120867. private _startDistance;
  120868. private _initialScale;
  120869. private _targetScale;
  120870. private _ownerNode;
  120871. private _sceneRenderObserver;
  120872. /**
  120873. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  120874. */
  120875. constructor();
  120876. /**
  120877. * The name of the behavior
  120878. */
  120879. get name(): string;
  120880. /**
  120881. * Initializes the behavior
  120882. */
  120883. init(): void;
  120884. private _getCurrentDistance;
  120885. /**
  120886. * Attaches the scale behavior the passed in mesh
  120887. * @param ownerNode The mesh that will be scaled around once attached
  120888. */
  120889. attach(ownerNode: Mesh): void;
  120890. /**
  120891. * Detaches the behavior from the mesh
  120892. */
  120893. detach(): void;
  120894. }
  120895. }
  120896. declare module BABYLON {
  120897. /**
  120898. * 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
  120899. */
  120900. export class SixDofDragBehavior implements Behavior<Mesh> {
  120901. private static _virtualScene;
  120902. private _ownerNode;
  120903. private _sceneRenderObserver;
  120904. private _scene;
  120905. private _targetPosition;
  120906. private _virtualOriginMesh;
  120907. private _virtualDragMesh;
  120908. private _pointerObserver;
  120909. private _moving;
  120910. private _startingOrientation;
  120911. private _attachedElement;
  120912. /**
  120913. * 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)
  120914. */
  120915. private zDragFactor;
  120916. /**
  120917. * If the object should rotate to face the drag origin
  120918. */
  120919. rotateDraggedObject: boolean;
  120920. /**
  120921. * If the behavior is currently in a dragging state
  120922. */
  120923. dragging: boolean;
  120924. /**
  120925. * 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)
  120926. */
  120927. dragDeltaRatio: number;
  120928. /**
  120929. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  120930. */
  120931. currentDraggingPointerID: number;
  120932. /**
  120933. * If camera controls should be detached during the drag
  120934. */
  120935. detachCameraControls: boolean;
  120936. /**
  120937. * Fires each time a drag starts
  120938. */
  120939. onDragStartObservable: Observable<{}>;
  120940. /**
  120941. * Fires each time a drag ends (eg. mouse release after drag)
  120942. */
  120943. onDragEndObservable: Observable<{}>;
  120944. /**
  120945. * 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
  120946. */
  120947. constructor();
  120948. /**
  120949. * The name of the behavior
  120950. */
  120951. get name(): string;
  120952. /**
  120953. * Initializes the behavior
  120954. */
  120955. init(): void;
  120956. /**
  120957. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  120958. */
  120959. private get _pointerCamera();
  120960. /**
  120961. * Attaches the scale behavior the passed in mesh
  120962. * @param ownerNode The mesh that will be scaled around once attached
  120963. */
  120964. attach(ownerNode: Mesh): void;
  120965. /**
  120966. * Detaches the behavior from the mesh
  120967. */
  120968. detach(): void;
  120969. }
  120970. }
  120971. declare module BABYLON {
  120972. /**
  120973. * Class used to apply inverse kinematics to bones
  120974. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  120975. */
  120976. export class BoneIKController {
  120977. private static _tmpVecs;
  120978. private static _tmpQuat;
  120979. private static _tmpMats;
  120980. /**
  120981. * Gets or sets the target mesh
  120982. */
  120983. targetMesh: AbstractMesh;
  120984. /** Gets or sets the mesh used as pole */
  120985. poleTargetMesh: AbstractMesh;
  120986. /**
  120987. * Gets or sets the bone used as pole
  120988. */
  120989. poleTargetBone: Nullable<Bone>;
  120990. /**
  120991. * Gets or sets the target position
  120992. */
  120993. targetPosition: Vector3;
  120994. /**
  120995. * Gets or sets the pole target position
  120996. */
  120997. poleTargetPosition: Vector3;
  120998. /**
  120999. * Gets or sets the pole target local offset
  121000. */
  121001. poleTargetLocalOffset: Vector3;
  121002. /**
  121003. * Gets or sets the pole angle
  121004. */
  121005. poleAngle: number;
  121006. /**
  121007. * Gets or sets the mesh associated with the controller
  121008. */
  121009. mesh: AbstractMesh;
  121010. /**
  121011. * 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)
  121012. */
  121013. slerpAmount: number;
  121014. private _bone1Quat;
  121015. private _bone1Mat;
  121016. private _bone2Ang;
  121017. private _bone1;
  121018. private _bone2;
  121019. private _bone1Length;
  121020. private _bone2Length;
  121021. private _maxAngle;
  121022. private _maxReach;
  121023. private _rightHandedSystem;
  121024. private _bendAxis;
  121025. private _slerping;
  121026. private _adjustRoll;
  121027. /**
  121028. * Gets or sets maximum allowed angle
  121029. */
  121030. get maxAngle(): number;
  121031. set maxAngle(value: number);
  121032. /**
  121033. * Creates a new BoneIKController
  121034. * @param mesh defines the mesh to control
  121035. * @param bone defines the bone to control
  121036. * @param options defines options to set up the controller
  121037. */
  121038. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  121039. targetMesh?: AbstractMesh;
  121040. poleTargetMesh?: AbstractMesh;
  121041. poleTargetBone?: Bone;
  121042. poleTargetLocalOffset?: Vector3;
  121043. poleAngle?: number;
  121044. bendAxis?: Vector3;
  121045. maxAngle?: number;
  121046. slerpAmount?: number;
  121047. });
  121048. private _setMaxAngle;
  121049. /**
  121050. * Force the controller to update the bones
  121051. */
  121052. update(): void;
  121053. }
  121054. }
  121055. declare module BABYLON {
  121056. /**
  121057. * Class used to make a bone look toward a point in space
  121058. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  121059. */
  121060. export class BoneLookController {
  121061. private static _tmpVecs;
  121062. private static _tmpQuat;
  121063. private static _tmpMats;
  121064. /**
  121065. * The target Vector3 that the bone will look at
  121066. */
  121067. target: Vector3;
  121068. /**
  121069. * The mesh that the bone is attached to
  121070. */
  121071. mesh: AbstractMesh;
  121072. /**
  121073. * The bone that will be looking to the target
  121074. */
  121075. bone: Bone;
  121076. /**
  121077. * The up axis of the coordinate system that is used when the bone is rotated
  121078. */
  121079. upAxis: Vector3;
  121080. /**
  121081. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  121082. */
  121083. upAxisSpace: Space;
  121084. /**
  121085. * Used to make an adjustment to the yaw of the bone
  121086. */
  121087. adjustYaw: number;
  121088. /**
  121089. * Used to make an adjustment to the pitch of the bone
  121090. */
  121091. adjustPitch: number;
  121092. /**
  121093. * Used to make an adjustment to the roll of the bone
  121094. */
  121095. adjustRoll: number;
  121096. /**
  121097. * 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)
  121098. */
  121099. slerpAmount: number;
  121100. private _minYaw;
  121101. private _maxYaw;
  121102. private _minPitch;
  121103. private _maxPitch;
  121104. private _minYawSin;
  121105. private _minYawCos;
  121106. private _maxYawSin;
  121107. private _maxYawCos;
  121108. private _midYawConstraint;
  121109. private _minPitchTan;
  121110. private _maxPitchTan;
  121111. private _boneQuat;
  121112. private _slerping;
  121113. private _transformYawPitch;
  121114. private _transformYawPitchInv;
  121115. private _firstFrameSkipped;
  121116. private _yawRange;
  121117. private _fowardAxis;
  121118. /**
  121119. * Gets or sets the minimum yaw angle that the bone can look to
  121120. */
  121121. get minYaw(): number;
  121122. set minYaw(value: number);
  121123. /**
  121124. * Gets or sets the maximum yaw angle that the bone can look to
  121125. */
  121126. get maxYaw(): number;
  121127. set maxYaw(value: number);
  121128. /**
  121129. * Gets or sets the minimum pitch angle that the bone can look to
  121130. */
  121131. get minPitch(): number;
  121132. set minPitch(value: number);
  121133. /**
  121134. * Gets or sets the maximum pitch angle that the bone can look to
  121135. */
  121136. get maxPitch(): number;
  121137. set maxPitch(value: number);
  121138. /**
  121139. * Create a BoneLookController
  121140. * @param mesh the mesh that the bone belongs to
  121141. * @param bone the bone that will be looking to the target
  121142. * @param target the target Vector3 to look at
  121143. * @param options optional settings:
  121144. * * maxYaw: the maximum angle the bone will yaw to
  121145. * * minYaw: the minimum angle the bone will yaw to
  121146. * * maxPitch: the maximum angle the bone will pitch to
  121147. * * minPitch: the minimum angle the bone will yaw to
  121148. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  121149. * * upAxis: the up axis of the coordinate system
  121150. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  121151. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  121152. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  121153. * * adjustYaw: used to make an adjustment to the yaw of the bone
  121154. * * adjustPitch: used to make an adjustment to the pitch of the bone
  121155. * * adjustRoll: used to make an adjustment to the roll of the bone
  121156. **/
  121157. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  121158. maxYaw?: number;
  121159. minYaw?: number;
  121160. maxPitch?: number;
  121161. minPitch?: number;
  121162. slerpAmount?: number;
  121163. upAxis?: Vector3;
  121164. upAxisSpace?: Space;
  121165. yawAxis?: Vector3;
  121166. pitchAxis?: Vector3;
  121167. adjustYaw?: number;
  121168. adjustPitch?: number;
  121169. adjustRoll?: number;
  121170. });
  121171. /**
  121172. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  121173. */
  121174. update(): void;
  121175. private _getAngleDiff;
  121176. private _getAngleBetween;
  121177. private _isAngleBetween;
  121178. }
  121179. }
  121180. declare module BABYLON {
  121181. /**
  121182. * Manage the gamepad inputs to control an arc rotate camera.
  121183. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121184. */
  121185. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  121186. /**
  121187. * Defines the camera the input is attached to.
  121188. */
  121189. camera: ArcRotateCamera;
  121190. /**
  121191. * Defines the gamepad the input is gathering event from.
  121192. */
  121193. gamepad: Nullable<Gamepad>;
  121194. /**
  121195. * Defines the gamepad rotation sensiblity.
  121196. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  121197. */
  121198. gamepadRotationSensibility: number;
  121199. /**
  121200. * Defines the gamepad move sensiblity.
  121201. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  121202. */
  121203. gamepadMoveSensibility: number;
  121204. private _yAxisScale;
  121205. /**
  121206. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  121207. */
  121208. get invertYAxis(): boolean;
  121209. set invertYAxis(value: boolean);
  121210. private _onGamepadConnectedObserver;
  121211. private _onGamepadDisconnectedObserver;
  121212. /**
  121213. * Attach the input controls to a specific dom element to get the input from.
  121214. * @param element Defines the element the controls should be listened from
  121215. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121216. */
  121217. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121218. /**
  121219. * Detach the current controls from the specified dom element.
  121220. * @param element Defines the element to stop listening the inputs from
  121221. */
  121222. detachControl(element: Nullable<HTMLElement>): void;
  121223. /**
  121224. * Update the current camera state depending on the inputs that have been used this frame.
  121225. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121226. */
  121227. checkInputs(): void;
  121228. /**
  121229. * Gets the class name of the current intput.
  121230. * @returns the class name
  121231. */
  121232. getClassName(): string;
  121233. /**
  121234. * Get the friendly name associated with the input class.
  121235. * @returns the input friendly name
  121236. */
  121237. getSimpleName(): string;
  121238. }
  121239. }
  121240. declare module BABYLON {
  121241. interface ArcRotateCameraInputsManager {
  121242. /**
  121243. * Add orientation input support to the input manager.
  121244. * @returns the current input manager
  121245. */
  121246. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  121247. }
  121248. /**
  121249. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  121250. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121251. */
  121252. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  121253. /**
  121254. * Defines the camera the input is attached to.
  121255. */
  121256. camera: ArcRotateCamera;
  121257. /**
  121258. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  121259. */
  121260. alphaCorrection: number;
  121261. /**
  121262. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  121263. */
  121264. gammaCorrection: number;
  121265. private _alpha;
  121266. private _gamma;
  121267. private _dirty;
  121268. private _deviceOrientationHandler;
  121269. /**
  121270. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  121271. */
  121272. constructor();
  121273. /**
  121274. * Attach the input controls to a specific dom element to get the input from.
  121275. * @param element Defines the element the controls should be listened from
  121276. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121277. */
  121278. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121279. /** @hidden */
  121280. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  121281. /**
  121282. * Update the current camera state depending on the inputs that have been used this frame.
  121283. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121284. */
  121285. checkInputs(): void;
  121286. /**
  121287. * Detach the current controls from the specified dom element.
  121288. * @param element Defines the element to stop listening the inputs from
  121289. */
  121290. detachControl(element: Nullable<HTMLElement>): void;
  121291. /**
  121292. * Gets the class name of the current intput.
  121293. * @returns the class name
  121294. */
  121295. getClassName(): string;
  121296. /**
  121297. * Get the friendly name associated with the input class.
  121298. * @returns the input friendly name
  121299. */
  121300. getSimpleName(): string;
  121301. }
  121302. }
  121303. declare module BABYLON {
  121304. /**
  121305. * Listen to mouse events to control the camera.
  121306. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121307. */
  121308. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  121309. /**
  121310. * Defines the camera the input is attached to.
  121311. */
  121312. camera: FlyCamera;
  121313. /**
  121314. * Defines if touch is enabled. (Default is true.)
  121315. */
  121316. touchEnabled: boolean;
  121317. /**
  121318. * Defines the buttons associated with the input to handle camera rotation.
  121319. */
  121320. buttons: number[];
  121321. /**
  121322. * Assign buttons for Yaw control.
  121323. */
  121324. buttonsYaw: number[];
  121325. /**
  121326. * Assign buttons for Pitch control.
  121327. */
  121328. buttonsPitch: number[];
  121329. /**
  121330. * Assign buttons for Roll control.
  121331. */
  121332. buttonsRoll: number[];
  121333. /**
  121334. * Detect if any button is being pressed while mouse is moved.
  121335. * -1 = Mouse locked.
  121336. * 0 = Left button.
  121337. * 1 = Middle Button.
  121338. * 2 = Right Button.
  121339. */
  121340. activeButton: number;
  121341. /**
  121342. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  121343. * Higher values reduce its sensitivity.
  121344. */
  121345. angularSensibility: number;
  121346. private _mousemoveCallback;
  121347. private _observer;
  121348. private _rollObserver;
  121349. private previousPosition;
  121350. private noPreventDefault;
  121351. private element;
  121352. /**
  121353. * Listen to mouse events to control the camera.
  121354. * @param touchEnabled Define if touch is enabled. (Default is true.)
  121355. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121356. */
  121357. constructor(touchEnabled?: boolean);
  121358. /**
  121359. * Attach the mouse control to the HTML DOM element.
  121360. * @param element Defines the element that listens to the input events.
  121361. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  121362. */
  121363. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121364. /**
  121365. * Detach the current controls from the specified dom element.
  121366. * @param element Defines the element to stop listening the inputs from
  121367. */
  121368. detachControl(element: Nullable<HTMLElement>): void;
  121369. /**
  121370. * Gets the class name of the current input.
  121371. * @returns the class name.
  121372. */
  121373. getClassName(): string;
  121374. /**
  121375. * Get the friendly name associated with the input class.
  121376. * @returns the input's friendly name.
  121377. */
  121378. getSimpleName(): string;
  121379. private _pointerInput;
  121380. private _onMouseMove;
  121381. /**
  121382. * Rotate camera by mouse offset.
  121383. */
  121384. private rotateCamera;
  121385. }
  121386. }
  121387. declare module BABYLON {
  121388. /**
  121389. * Default Inputs manager for the FlyCamera.
  121390. * It groups all the default supported inputs for ease of use.
  121391. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121392. */
  121393. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  121394. /**
  121395. * Instantiates a new FlyCameraInputsManager.
  121396. * @param camera Defines the camera the inputs belong to.
  121397. */
  121398. constructor(camera: FlyCamera);
  121399. /**
  121400. * Add keyboard input support to the input manager.
  121401. * @returns the new FlyCameraKeyboardMoveInput().
  121402. */
  121403. addKeyboard(): FlyCameraInputsManager;
  121404. /**
  121405. * Add mouse input support to the input manager.
  121406. * @param touchEnabled Enable touch screen support.
  121407. * @returns the new FlyCameraMouseInput().
  121408. */
  121409. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  121410. }
  121411. }
  121412. declare module BABYLON {
  121413. /**
  121414. * This is a flying camera, designed for 3D movement and rotation in all directions,
  121415. * such as in a 3D Space Shooter or a Flight Simulator.
  121416. */
  121417. export class FlyCamera extends TargetCamera {
  121418. /**
  121419. * Define the collision ellipsoid of the camera.
  121420. * This is helpful for simulating a camera body, like a player's body.
  121421. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  121422. */
  121423. ellipsoid: Vector3;
  121424. /**
  121425. * Define an offset for the position of the ellipsoid around the camera.
  121426. * This can be helpful if the camera is attached away from the player's body center,
  121427. * such as at its head.
  121428. */
  121429. ellipsoidOffset: Vector3;
  121430. /**
  121431. * Enable or disable collisions of the camera with the rest of the scene objects.
  121432. */
  121433. checkCollisions: boolean;
  121434. /**
  121435. * Enable or disable gravity on the camera.
  121436. */
  121437. applyGravity: boolean;
  121438. /**
  121439. * Define the current direction the camera is moving to.
  121440. */
  121441. cameraDirection: Vector3;
  121442. /**
  121443. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  121444. * This overrides and empties cameraRotation.
  121445. */
  121446. rotationQuaternion: Quaternion;
  121447. /**
  121448. * Track Roll to maintain the wanted Rolling when looking around.
  121449. */
  121450. _trackRoll: number;
  121451. /**
  121452. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  121453. */
  121454. rollCorrect: number;
  121455. /**
  121456. * Mimic a banked turn, Rolling the camera when Yawing.
  121457. * It's recommended to use rollCorrect = 10 for faster banking correction.
  121458. */
  121459. bankedTurn: boolean;
  121460. /**
  121461. * Limit in radians for how much Roll banking will add. (Default: 90°)
  121462. */
  121463. bankedTurnLimit: number;
  121464. /**
  121465. * Value of 0 disables the banked Roll.
  121466. * Value of 1 is equal to the Yaw angle in radians.
  121467. */
  121468. bankedTurnMultiplier: number;
  121469. /**
  121470. * The inputs manager loads all the input sources, such as keyboard and mouse.
  121471. */
  121472. inputs: FlyCameraInputsManager;
  121473. /**
  121474. * Gets the input sensibility for mouse input.
  121475. * Higher values reduce sensitivity.
  121476. */
  121477. get angularSensibility(): number;
  121478. /**
  121479. * Sets the input sensibility for a mouse input.
  121480. * Higher values reduce sensitivity.
  121481. */
  121482. set angularSensibility(value: number);
  121483. /**
  121484. * Get the keys for camera movement forward.
  121485. */
  121486. get keysForward(): number[];
  121487. /**
  121488. * Set the keys for camera movement forward.
  121489. */
  121490. set keysForward(value: number[]);
  121491. /**
  121492. * Get the keys for camera movement backward.
  121493. */
  121494. get keysBackward(): number[];
  121495. set keysBackward(value: number[]);
  121496. /**
  121497. * Get the keys for camera movement up.
  121498. */
  121499. get keysUp(): number[];
  121500. /**
  121501. * Set the keys for camera movement up.
  121502. */
  121503. set keysUp(value: number[]);
  121504. /**
  121505. * Get the keys for camera movement down.
  121506. */
  121507. get keysDown(): number[];
  121508. /**
  121509. * Set the keys for camera movement down.
  121510. */
  121511. set keysDown(value: number[]);
  121512. /**
  121513. * Get the keys for camera movement left.
  121514. */
  121515. get keysLeft(): number[];
  121516. /**
  121517. * Set the keys for camera movement left.
  121518. */
  121519. set keysLeft(value: number[]);
  121520. /**
  121521. * Set the keys for camera movement right.
  121522. */
  121523. get keysRight(): number[];
  121524. /**
  121525. * Set the keys for camera movement right.
  121526. */
  121527. set keysRight(value: number[]);
  121528. /**
  121529. * Event raised when the camera collides with a mesh in the scene.
  121530. */
  121531. onCollide: (collidedMesh: AbstractMesh) => void;
  121532. private _collider;
  121533. private _needMoveForGravity;
  121534. private _oldPosition;
  121535. private _diffPosition;
  121536. private _newPosition;
  121537. /** @hidden */
  121538. _localDirection: Vector3;
  121539. /** @hidden */
  121540. _transformedDirection: Vector3;
  121541. /**
  121542. * Instantiates a FlyCamera.
  121543. * This is a flying camera, designed for 3D movement and rotation in all directions,
  121544. * such as in a 3D Space Shooter or a Flight Simulator.
  121545. * @param name Define the name of the camera in the scene.
  121546. * @param position Define the starting position of the camera in the scene.
  121547. * @param scene Define the scene the camera belongs to.
  121548. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  121549. */
  121550. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  121551. /**
  121552. * Attach a control to the HTML DOM element.
  121553. * @param element Defines the element that listens to the input events.
  121554. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  121555. */
  121556. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121557. /**
  121558. * Detach a control from the HTML DOM element.
  121559. * The camera will stop reacting to that input.
  121560. * @param element Defines the element that listens to the input events.
  121561. */
  121562. detachControl(element: HTMLElement): void;
  121563. private _collisionMask;
  121564. /**
  121565. * Get the mask that the camera ignores in collision events.
  121566. */
  121567. get collisionMask(): number;
  121568. /**
  121569. * Set the mask that the camera ignores in collision events.
  121570. */
  121571. set collisionMask(mask: number);
  121572. /** @hidden */
  121573. _collideWithWorld(displacement: Vector3): void;
  121574. /** @hidden */
  121575. private _onCollisionPositionChange;
  121576. /** @hidden */
  121577. _checkInputs(): void;
  121578. /** @hidden */
  121579. _decideIfNeedsToMove(): boolean;
  121580. /** @hidden */
  121581. _updatePosition(): void;
  121582. /**
  121583. * Restore the Roll to its target value at the rate specified.
  121584. * @param rate - Higher means slower restoring.
  121585. * @hidden
  121586. */
  121587. restoreRoll(rate: number): void;
  121588. /**
  121589. * Destroy the camera and release the current resources held by it.
  121590. */
  121591. dispose(): void;
  121592. /**
  121593. * Get the current object class name.
  121594. * @returns the class name.
  121595. */
  121596. getClassName(): string;
  121597. }
  121598. }
  121599. declare module BABYLON {
  121600. /**
  121601. * Listen to keyboard events to control the camera.
  121602. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121603. */
  121604. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  121605. /**
  121606. * Defines the camera the input is attached to.
  121607. */
  121608. camera: FlyCamera;
  121609. /**
  121610. * The list of keyboard keys used to control the forward move of the camera.
  121611. */
  121612. keysForward: number[];
  121613. /**
  121614. * The list of keyboard keys used to control the backward move of the camera.
  121615. */
  121616. keysBackward: number[];
  121617. /**
  121618. * The list of keyboard keys used to control the forward move of the camera.
  121619. */
  121620. keysUp: number[];
  121621. /**
  121622. * The list of keyboard keys used to control the backward move of the camera.
  121623. */
  121624. keysDown: number[];
  121625. /**
  121626. * The list of keyboard keys used to control the right strafe move of the camera.
  121627. */
  121628. keysRight: number[];
  121629. /**
  121630. * The list of keyboard keys used to control the left strafe move of the camera.
  121631. */
  121632. keysLeft: number[];
  121633. private _keys;
  121634. private _onCanvasBlurObserver;
  121635. private _onKeyboardObserver;
  121636. private _engine;
  121637. private _scene;
  121638. /**
  121639. * Attach the input controls to a specific dom element to get the input from.
  121640. * @param element Defines the element the controls should be listened from
  121641. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121642. */
  121643. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121644. /**
  121645. * Detach the current controls from the specified dom element.
  121646. * @param element Defines the element to stop listening the inputs from
  121647. */
  121648. detachControl(element: Nullable<HTMLElement>): void;
  121649. /**
  121650. * Gets the class name of the current intput.
  121651. * @returns the class name
  121652. */
  121653. getClassName(): string;
  121654. /** @hidden */
  121655. _onLostFocus(e: FocusEvent): void;
  121656. /**
  121657. * Get the friendly name associated with the input class.
  121658. * @returns the input friendly name
  121659. */
  121660. getSimpleName(): string;
  121661. /**
  121662. * Update the current camera state depending on the inputs that have been used this frame.
  121663. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121664. */
  121665. checkInputs(): void;
  121666. }
  121667. }
  121668. declare module BABYLON {
  121669. /**
  121670. * Manage the mouse wheel inputs to control a follow camera.
  121671. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121672. */
  121673. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  121674. /**
  121675. * Defines the camera the input is attached to.
  121676. */
  121677. camera: FollowCamera;
  121678. /**
  121679. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  121680. */
  121681. axisControlRadius: boolean;
  121682. /**
  121683. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  121684. */
  121685. axisControlHeight: boolean;
  121686. /**
  121687. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  121688. */
  121689. axisControlRotation: boolean;
  121690. /**
  121691. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  121692. * relation to mouseWheel events.
  121693. */
  121694. wheelPrecision: number;
  121695. /**
  121696. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  121697. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  121698. */
  121699. wheelDeltaPercentage: number;
  121700. private _wheel;
  121701. private _observer;
  121702. /**
  121703. * Attach the input controls to a specific dom element to get the input from.
  121704. * @param element Defines the element the controls should be listened from
  121705. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121706. */
  121707. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121708. /**
  121709. * Detach the current controls from the specified dom element.
  121710. * @param element Defines the element to stop listening the inputs from
  121711. */
  121712. detachControl(element: Nullable<HTMLElement>): void;
  121713. /**
  121714. * Gets the class name of the current intput.
  121715. * @returns the class name
  121716. */
  121717. getClassName(): string;
  121718. /**
  121719. * Get the friendly name associated with the input class.
  121720. * @returns the input friendly name
  121721. */
  121722. getSimpleName(): string;
  121723. }
  121724. }
  121725. declare module BABYLON {
  121726. /**
  121727. * Manage the pointers inputs to control an follow camera.
  121728. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121729. */
  121730. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  121731. /**
  121732. * Defines the camera the input is attached to.
  121733. */
  121734. camera: FollowCamera;
  121735. /**
  121736. * Gets the class name of the current input.
  121737. * @returns the class name
  121738. */
  121739. getClassName(): string;
  121740. /**
  121741. * Defines the pointer angular sensibility along the X axis or how fast is
  121742. * the camera rotating.
  121743. * A negative number will reverse the axis direction.
  121744. */
  121745. angularSensibilityX: number;
  121746. /**
  121747. * Defines the pointer angular sensibility along the Y axis or how fast is
  121748. * the camera rotating.
  121749. * A negative number will reverse the axis direction.
  121750. */
  121751. angularSensibilityY: number;
  121752. /**
  121753. * Defines the pointer pinch precision or how fast is the camera zooming.
  121754. * A negative number will reverse the axis direction.
  121755. */
  121756. pinchPrecision: number;
  121757. /**
  121758. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  121759. * from 0.
  121760. * It defines the percentage of current camera.radius to use as delta when
  121761. * pinch zoom is used.
  121762. */
  121763. pinchDeltaPercentage: number;
  121764. /**
  121765. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  121766. */
  121767. axisXControlRadius: boolean;
  121768. /**
  121769. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  121770. */
  121771. axisXControlHeight: boolean;
  121772. /**
  121773. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  121774. */
  121775. axisXControlRotation: boolean;
  121776. /**
  121777. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  121778. */
  121779. axisYControlRadius: boolean;
  121780. /**
  121781. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  121782. */
  121783. axisYControlHeight: boolean;
  121784. /**
  121785. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  121786. */
  121787. axisYControlRotation: boolean;
  121788. /**
  121789. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  121790. */
  121791. axisPinchControlRadius: boolean;
  121792. /**
  121793. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  121794. */
  121795. axisPinchControlHeight: boolean;
  121796. /**
  121797. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  121798. */
  121799. axisPinchControlRotation: boolean;
  121800. /**
  121801. * Log error messages if basic misconfiguration has occurred.
  121802. */
  121803. warningEnable: boolean;
  121804. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  121805. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  121806. private _warningCounter;
  121807. private _warning;
  121808. }
  121809. }
  121810. declare module BABYLON {
  121811. /**
  121812. * Default Inputs manager for the FollowCamera.
  121813. * It groups all the default supported inputs for ease of use.
  121814. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121815. */
  121816. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  121817. /**
  121818. * Instantiates a new FollowCameraInputsManager.
  121819. * @param camera Defines the camera the inputs belong to
  121820. */
  121821. constructor(camera: FollowCamera);
  121822. /**
  121823. * Add keyboard input support to the input manager.
  121824. * @returns the current input manager
  121825. */
  121826. addKeyboard(): FollowCameraInputsManager;
  121827. /**
  121828. * Add mouse wheel input support to the input manager.
  121829. * @returns the current input manager
  121830. */
  121831. addMouseWheel(): FollowCameraInputsManager;
  121832. /**
  121833. * Add pointers input support to the input manager.
  121834. * @returns the current input manager
  121835. */
  121836. addPointers(): FollowCameraInputsManager;
  121837. /**
  121838. * Add orientation input support to the input manager.
  121839. * @returns the current input manager
  121840. */
  121841. addVRDeviceOrientation(): FollowCameraInputsManager;
  121842. }
  121843. }
  121844. declare module BABYLON {
  121845. /**
  121846. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  121847. * an arc rotate version arcFollowCamera are available.
  121848. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  121849. */
  121850. export class FollowCamera extends TargetCamera {
  121851. /**
  121852. * Distance the follow camera should follow an object at
  121853. */
  121854. radius: number;
  121855. /**
  121856. * Minimum allowed distance of the camera to the axis of rotation
  121857. * (The camera can not get closer).
  121858. * This can help limiting how the Camera is able to move in the scene.
  121859. */
  121860. lowerRadiusLimit: Nullable<number>;
  121861. /**
  121862. * Maximum allowed distance of the camera to the axis of rotation
  121863. * (The camera can not get further).
  121864. * This can help limiting how the Camera is able to move in the scene.
  121865. */
  121866. upperRadiusLimit: Nullable<number>;
  121867. /**
  121868. * Define a rotation offset between the camera and the object it follows
  121869. */
  121870. rotationOffset: number;
  121871. /**
  121872. * Minimum allowed angle to camera position relative to target object.
  121873. * This can help limiting how the Camera is able to move in the scene.
  121874. */
  121875. lowerRotationOffsetLimit: Nullable<number>;
  121876. /**
  121877. * Maximum allowed angle to camera position relative to target object.
  121878. * This can help limiting how the Camera is able to move in the scene.
  121879. */
  121880. upperRotationOffsetLimit: Nullable<number>;
  121881. /**
  121882. * Define a height offset between the camera and the object it follows.
  121883. * It can help following an object from the top (like a car chaing a plane)
  121884. */
  121885. heightOffset: number;
  121886. /**
  121887. * Minimum allowed height of camera position relative to target object.
  121888. * This can help limiting how the Camera is able to move in the scene.
  121889. */
  121890. lowerHeightOffsetLimit: Nullable<number>;
  121891. /**
  121892. * Maximum allowed height of camera position relative to target object.
  121893. * This can help limiting how the Camera is able to move in the scene.
  121894. */
  121895. upperHeightOffsetLimit: Nullable<number>;
  121896. /**
  121897. * Define how fast the camera can accelerate to follow it s target.
  121898. */
  121899. cameraAcceleration: number;
  121900. /**
  121901. * Define the speed limit of the camera following an object.
  121902. */
  121903. maxCameraSpeed: number;
  121904. /**
  121905. * Define the target of the camera.
  121906. */
  121907. lockedTarget: Nullable<AbstractMesh>;
  121908. /**
  121909. * Defines the input associated with the camera.
  121910. */
  121911. inputs: FollowCameraInputsManager;
  121912. /**
  121913. * Instantiates the follow camera.
  121914. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  121915. * @param name Define the name of the camera in the scene
  121916. * @param position Define the position of the camera
  121917. * @param scene Define the scene the camera belong to
  121918. * @param lockedTarget Define the target of the camera
  121919. */
  121920. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  121921. private _follow;
  121922. /**
  121923. * Attached controls to the current camera.
  121924. * @param element Defines the element the controls should be listened from
  121925. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121926. */
  121927. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121928. /**
  121929. * Detach the current controls from the camera.
  121930. * The camera will stop reacting to inputs.
  121931. * @param element Defines the element to stop listening the inputs from
  121932. */
  121933. detachControl(element: HTMLElement): void;
  121934. /** @hidden */
  121935. _checkInputs(): void;
  121936. private _checkLimits;
  121937. /**
  121938. * Gets the camera class name.
  121939. * @returns the class name
  121940. */
  121941. getClassName(): string;
  121942. }
  121943. /**
  121944. * Arc Rotate version of the follow camera.
  121945. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  121946. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  121947. */
  121948. export class ArcFollowCamera extends TargetCamera {
  121949. /** The longitudinal angle of the camera */
  121950. alpha: number;
  121951. /** The latitudinal angle of the camera */
  121952. beta: number;
  121953. /** The radius of the camera from its target */
  121954. radius: number;
  121955. /** Define the camera target (the mesh it should follow) */
  121956. target: Nullable<AbstractMesh>;
  121957. private _cartesianCoordinates;
  121958. /**
  121959. * Instantiates a new ArcFollowCamera
  121960. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  121961. * @param name Define the name of the camera
  121962. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  121963. * @param beta Define the rotation angle of the camera around the elevation axis
  121964. * @param radius Define the radius of the camera from its target point
  121965. * @param target Define the target of the camera
  121966. * @param scene Define the scene the camera belongs to
  121967. */
  121968. constructor(name: string,
  121969. /** The longitudinal angle of the camera */
  121970. alpha: number,
  121971. /** The latitudinal angle of the camera */
  121972. beta: number,
  121973. /** The radius of the camera from its target */
  121974. radius: number,
  121975. /** Define the camera target (the mesh it should follow) */
  121976. target: Nullable<AbstractMesh>, scene: Scene);
  121977. private _follow;
  121978. /** @hidden */
  121979. _checkInputs(): void;
  121980. /**
  121981. * Returns the class name of the object.
  121982. * It is mostly used internally for serialization purposes.
  121983. */
  121984. getClassName(): string;
  121985. }
  121986. }
  121987. declare module BABYLON {
  121988. /**
  121989. * Manage the keyboard inputs to control the movement of a follow camera.
  121990. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121991. */
  121992. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  121993. /**
  121994. * Defines the camera the input is attached to.
  121995. */
  121996. camera: FollowCamera;
  121997. /**
  121998. * Defines the list of key codes associated with the up action (increase heightOffset)
  121999. */
  122000. keysHeightOffsetIncr: number[];
  122001. /**
  122002. * Defines the list of key codes associated with the down action (decrease heightOffset)
  122003. */
  122004. keysHeightOffsetDecr: number[];
  122005. /**
  122006. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  122007. */
  122008. keysHeightOffsetModifierAlt: boolean;
  122009. /**
  122010. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  122011. */
  122012. keysHeightOffsetModifierCtrl: boolean;
  122013. /**
  122014. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  122015. */
  122016. keysHeightOffsetModifierShift: boolean;
  122017. /**
  122018. * Defines the list of key codes associated with the left action (increase rotationOffset)
  122019. */
  122020. keysRotationOffsetIncr: number[];
  122021. /**
  122022. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  122023. */
  122024. keysRotationOffsetDecr: number[];
  122025. /**
  122026. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  122027. */
  122028. keysRotationOffsetModifierAlt: boolean;
  122029. /**
  122030. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  122031. */
  122032. keysRotationOffsetModifierCtrl: boolean;
  122033. /**
  122034. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  122035. */
  122036. keysRotationOffsetModifierShift: boolean;
  122037. /**
  122038. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  122039. */
  122040. keysRadiusIncr: number[];
  122041. /**
  122042. * Defines the list of key codes associated with the zoom-out action (increase radius)
  122043. */
  122044. keysRadiusDecr: number[];
  122045. /**
  122046. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  122047. */
  122048. keysRadiusModifierAlt: boolean;
  122049. /**
  122050. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  122051. */
  122052. keysRadiusModifierCtrl: boolean;
  122053. /**
  122054. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  122055. */
  122056. keysRadiusModifierShift: boolean;
  122057. /**
  122058. * Defines the rate of change of heightOffset.
  122059. */
  122060. heightSensibility: number;
  122061. /**
  122062. * Defines the rate of change of rotationOffset.
  122063. */
  122064. rotationSensibility: number;
  122065. /**
  122066. * Defines the rate of change of radius.
  122067. */
  122068. radiusSensibility: number;
  122069. private _keys;
  122070. private _ctrlPressed;
  122071. private _altPressed;
  122072. private _shiftPressed;
  122073. private _onCanvasBlurObserver;
  122074. private _onKeyboardObserver;
  122075. private _engine;
  122076. private _scene;
  122077. /**
  122078. * Attach the input controls to a specific dom element to get the input from.
  122079. * @param element Defines the element the controls should be listened from
  122080. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122081. */
  122082. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122083. /**
  122084. * Detach the current controls from the specified dom element.
  122085. * @param element Defines the element to stop listening the inputs from
  122086. */
  122087. detachControl(element: Nullable<HTMLElement>): void;
  122088. /**
  122089. * Update the current camera state depending on the inputs that have been used this frame.
  122090. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122091. */
  122092. checkInputs(): void;
  122093. /**
  122094. * Gets the class name of the current input.
  122095. * @returns the class name
  122096. */
  122097. getClassName(): string;
  122098. /**
  122099. * Get the friendly name associated with the input class.
  122100. * @returns the input friendly name
  122101. */
  122102. getSimpleName(): string;
  122103. /**
  122104. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  122105. * allow modification of the heightOffset value.
  122106. */
  122107. private _modifierHeightOffset;
  122108. /**
  122109. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  122110. * allow modification of the rotationOffset value.
  122111. */
  122112. private _modifierRotationOffset;
  122113. /**
  122114. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  122115. * allow modification of the radius value.
  122116. */
  122117. private _modifierRadius;
  122118. }
  122119. }
  122120. declare module BABYLON {
  122121. interface FreeCameraInputsManager {
  122122. /**
  122123. * @hidden
  122124. */
  122125. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  122126. /**
  122127. * Add orientation input support to the input manager.
  122128. * @returns the current input manager
  122129. */
  122130. addDeviceOrientation(): FreeCameraInputsManager;
  122131. }
  122132. /**
  122133. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  122134. * Screen rotation is taken into account.
  122135. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122136. */
  122137. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  122138. private _camera;
  122139. private _screenOrientationAngle;
  122140. private _constantTranform;
  122141. private _screenQuaternion;
  122142. private _alpha;
  122143. private _beta;
  122144. private _gamma;
  122145. /**
  122146. * Can be used to detect if a device orientation sensor is available on a device
  122147. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  122148. * @returns a promise that will resolve on orientation change
  122149. */
  122150. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  122151. /**
  122152. * @hidden
  122153. */
  122154. _onDeviceOrientationChangedObservable: Observable<void>;
  122155. /**
  122156. * Instantiates a new input
  122157. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122158. */
  122159. constructor();
  122160. /**
  122161. * Define the camera controlled by the input.
  122162. */
  122163. get camera(): FreeCamera;
  122164. set camera(camera: FreeCamera);
  122165. /**
  122166. * Attach the input controls to a specific dom element to get the input from.
  122167. * @param element Defines the element the controls should be listened from
  122168. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122169. */
  122170. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122171. private _orientationChanged;
  122172. private _deviceOrientation;
  122173. /**
  122174. * Detach the current controls from the specified dom element.
  122175. * @param element Defines the element to stop listening the inputs from
  122176. */
  122177. detachControl(element: Nullable<HTMLElement>): void;
  122178. /**
  122179. * Update the current camera state depending on the inputs that have been used this frame.
  122180. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122181. */
  122182. checkInputs(): void;
  122183. /**
  122184. * Gets the class name of the current intput.
  122185. * @returns the class name
  122186. */
  122187. getClassName(): string;
  122188. /**
  122189. * Get the friendly name associated with the input class.
  122190. * @returns the input friendly name
  122191. */
  122192. getSimpleName(): string;
  122193. }
  122194. }
  122195. declare module BABYLON {
  122196. /**
  122197. * Manage the gamepad inputs to control a free camera.
  122198. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122199. */
  122200. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  122201. /**
  122202. * Define the camera the input is attached to.
  122203. */
  122204. camera: FreeCamera;
  122205. /**
  122206. * Define the Gamepad controlling the input
  122207. */
  122208. gamepad: Nullable<Gamepad>;
  122209. /**
  122210. * Defines the gamepad rotation sensiblity.
  122211. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  122212. */
  122213. gamepadAngularSensibility: number;
  122214. /**
  122215. * Defines the gamepad move sensiblity.
  122216. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  122217. */
  122218. gamepadMoveSensibility: number;
  122219. private _yAxisScale;
  122220. /**
  122221. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  122222. */
  122223. get invertYAxis(): boolean;
  122224. set invertYAxis(value: boolean);
  122225. private _onGamepadConnectedObserver;
  122226. private _onGamepadDisconnectedObserver;
  122227. private _cameraTransform;
  122228. private _deltaTransform;
  122229. private _vector3;
  122230. private _vector2;
  122231. /**
  122232. * Attach the input controls to a specific dom element to get the input from.
  122233. * @param element Defines the element the controls should be listened from
  122234. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122235. */
  122236. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122237. /**
  122238. * Detach the current controls from the specified dom element.
  122239. * @param element Defines the element to stop listening the inputs from
  122240. */
  122241. detachControl(element: Nullable<HTMLElement>): void;
  122242. /**
  122243. * Update the current camera state depending on the inputs that have been used this frame.
  122244. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122245. */
  122246. checkInputs(): void;
  122247. /**
  122248. * Gets the class name of the current intput.
  122249. * @returns the class name
  122250. */
  122251. getClassName(): string;
  122252. /**
  122253. * Get the friendly name associated with the input class.
  122254. * @returns the input friendly name
  122255. */
  122256. getSimpleName(): string;
  122257. }
  122258. }
  122259. declare module BABYLON {
  122260. /**
  122261. * Defines the potential axis of a Joystick
  122262. */
  122263. export enum JoystickAxis {
  122264. /** X axis */
  122265. X = 0,
  122266. /** Y axis */
  122267. Y = 1,
  122268. /** Z axis */
  122269. Z = 2
  122270. }
  122271. /**
  122272. * Represents the different customization options available
  122273. * for VirtualJoystick
  122274. */
  122275. interface VirtualJoystickCustomizations {
  122276. /**
  122277. * Size of the joystick's puck
  122278. */
  122279. puckSize: number;
  122280. /**
  122281. * Size of the joystick's container
  122282. */
  122283. containerSize: number;
  122284. /**
  122285. * Color of the joystick && puck
  122286. */
  122287. color: string;
  122288. /**
  122289. * Image URL for the joystick's puck
  122290. */
  122291. puckImage?: string;
  122292. /**
  122293. * Image URL for the joystick's container
  122294. */
  122295. containerImage?: string;
  122296. /**
  122297. * Defines the unmoving position of the joystick container
  122298. */
  122299. position?: {
  122300. x: number;
  122301. y: number;
  122302. };
  122303. /**
  122304. * Defines whether or not the joystick container is always visible
  122305. */
  122306. alwaysVisible: boolean;
  122307. /**
  122308. * Defines whether or not to limit the movement of the puck to the joystick's container
  122309. */
  122310. limitToContainer: boolean;
  122311. }
  122312. /**
  122313. * Class used to define virtual joystick (used in touch mode)
  122314. */
  122315. export class VirtualJoystick {
  122316. /**
  122317. * Gets or sets a boolean indicating that left and right values must be inverted
  122318. */
  122319. reverseLeftRight: boolean;
  122320. /**
  122321. * Gets or sets a boolean indicating that up and down values must be inverted
  122322. */
  122323. reverseUpDown: boolean;
  122324. /**
  122325. * Gets the offset value for the position (ie. the change of the position value)
  122326. */
  122327. deltaPosition: Vector3;
  122328. /**
  122329. * Gets a boolean indicating if the virtual joystick was pressed
  122330. */
  122331. pressed: boolean;
  122332. /**
  122333. * Canvas the virtual joystick will render onto, default z-index of this is 5
  122334. */
  122335. static Canvas: Nullable<HTMLCanvasElement>;
  122336. /**
  122337. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  122338. */
  122339. limitToContainer: boolean;
  122340. private static _globalJoystickIndex;
  122341. private static _alwaysVisibleSticks;
  122342. private static vjCanvasContext;
  122343. private static vjCanvasWidth;
  122344. private static vjCanvasHeight;
  122345. private static halfWidth;
  122346. private static _GetDefaultOptions;
  122347. private _action;
  122348. private _axisTargetedByLeftAndRight;
  122349. private _axisTargetedByUpAndDown;
  122350. private _joystickSensibility;
  122351. private _inversedSensibility;
  122352. private _joystickPointerID;
  122353. private _joystickColor;
  122354. private _joystickPointerPos;
  122355. private _joystickPreviousPointerPos;
  122356. private _joystickPointerStartPos;
  122357. private _deltaJoystickVector;
  122358. private _leftJoystick;
  122359. private _touches;
  122360. private _joystickPosition;
  122361. private _alwaysVisible;
  122362. private _puckImage;
  122363. private _containerImage;
  122364. private _joystickPuckSize;
  122365. private _joystickContainerSize;
  122366. private _clearPuckSize;
  122367. private _clearContainerSize;
  122368. private _clearPuckSizeOffset;
  122369. private _clearContainerSizeOffset;
  122370. private _onPointerDownHandlerRef;
  122371. private _onPointerMoveHandlerRef;
  122372. private _onPointerUpHandlerRef;
  122373. private _onResize;
  122374. /**
  122375. * Creates a new virtual joystick
  122376. * @param leftJoystick defines that the joystick is for left hand (false by default)
  122377. * @param customizations Defines the options we want to customize the VirtualJoystick
  122378. */
  122379. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  122380. /**
  122381. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  122382. * @param newJoystickSensibility defines the new sensibility
  122383. */
  122384. setJoystickSensibility(newJoystickSensibility: number): void;
  122385. private _onPointerDown;
  122386. private _onPointerMove;
  122387. private _onPointerUp;
  122388. /**
  122389. * Change the color of the virtual joystick
  122390. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  122391. */
  122392. setJoystickColor(newColor: string): void;
  122393. /**
  122394. * Size of the joystick's container
  122395. */
  122396. set containerSize(newSize: number);
  122397. get containerSize(): number;
  122398. /**
  122399. * Size of the joystick's puck
  122400. */
  122401. set puckSize(newSize: number);
  122402. get puckSize(): number;
  122403. /**
  122404. * Clears the set position of the joystick
  122405. */
  122406. clearPosition(): void;
  122407. /**
  122408. * Defines whether or not the joystick container is always visible
  122409. */
  122410. set alwaysVisible(value: boolean);
  122411. get alwaysVisible(): boolean;
  122412. /**
  122413. * Sets the constant position of the Joystick container
  122414. * @param x X axis coordinate
  122415. * @param y Y axis coordinate
  122416. */
  122417. setPosition(x: number, y: number): void;
  122418. /**
  122419. * Defines a callback to call when the joystick is touched
  122420. * @param action defines the callback
  122421. */
  122422. setActionOnTouch(action: () => any): void;
  122423. /**
  122424. * Defines which axis you'd like to control for left & right
  122425. * @param axis defines the axis to use
  122426. */
  122427. setAxisForLeftRight(axis: JoystickAxis): void;
  122428. /**
  122429. * Defines which axis you'd like to control for up & down
  122430. * @param axis defines the axis to use
  122431. */
  122432. setAxisForUpDown(axis: JoystickAxis): void;
  122433. /**
  122434. * Clears the canvas from the previous puck / container draw
  122435. */
  122436. private _clearPreviousDraw;
  122437. /**
  122438. * Loads `urlPath` to be used for the container's image
  122439. * @param urlPath defines the urlPath of an image to use
  122440. */
  122441. setContainerImage(urlPath: string): void;
  122442. /**
  122443. * Loads `urlPath` to be used for the puck's image
  122444. * @param urlPath defines the urlPath of an image to use
  122445. */
  122446. setPuckImage(urlPath: string): void;
  122447. /**
  122448. * Draws the Virtual Joystick's container
  122449. */
  122450. private _drawContainer;
  122451. /**
  122452. * Draws the Virtual Joystick's puck
  122453. */
  122454. private _drawPuck;
  122455. private _drawVirtualJoystick;
  122456. /**
  122457. * Release internal HTML canvas
  122458. */
  122459. releaseCanvas(): void;
  122460. }
  122461. }
  122462. declare module BABYLON {
  122463. interface FreeCameraInputsManager {
  122464. /**
  122465. * Add virtual joystick input support to the input manager.
  122466. * @returns the current input manager
  122467. */
  122468. addVirtualJoystick(): FreeCameraInputsManager;
  122469. }
  122470. /**
  122471. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  122472. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122473. */
  122474. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  122475. /**
  122476. * Defines the camera the input is attached to.
  122477. */
  122478. camera: FreeCamera;
  122479. private _leftjoystick;
  122480. private _rightjoystick;
  122481. /**
  122482. * Gets the left stick of the virtual joystick.
  122483. * @returns The virtual Joystick
  122484. */
  122485. getLeftJoystick(): VirtualJoystick;
  122486. /**
  122487. * Gets the right stick of the virtual joystick.
  122488. * @returns The virtual Joystick
  122489. */
  122490. getRightJoystick(): VirtualJoystick;
  122491. /**
  122492. * Update the current camera state depending on the inputs that have been used this frame.
  122493. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122494. */
  122495. checkInputs(): void;
  122496. /**
  122497. * Attach the input controls to a specific dom element to get the input from.
  122498. * @param element Defines the element the controls should be listened from
  122499. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122500. */
  122501. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122502. /**
  122503. * Detach the current controls from the specified dom element.
  122504. * @param element Defines the element to stop listening the inputs from
  122505. */
  122506. detachControl(element: Nullable<HTMLElement>): void;
  122507. /**
  122508. * Gets the class name of the current intput.
  122509. * @returns the class name
  122510. */
  122511. getClassName(): string;
  122512. /**
  122513. * Get the friendly name associated with the input class.
  122514. * @returns the input friendly name
  122515. */
  122516. getSimpleName(): string;
  122517. }
  122518. }
  122519. declare module BABYLON {
  122520. /**
  122521. * This represents a FPS type of camera controlled by touch.
  122522. * This is like a universal camera minus the Gamepad controls.
  122523. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  122524. */
  122525. export class TouchCamera extends FreeCamera {
  122526. /**
  122527. * Defines the touch sensibility for rotation.
  122528. * The higher the faster.
  122529. */
  122530. get touchAngularSensibility(): number;
  122531. set touchAngularSensibility(value: number);
  122532. /**
  122533. * Defines the touch sensibility for move.
  122534. * The higher the faster.
  122535. */
  122536. get touchMoveSensibility(): number;
  122537. set touchMoveSensibility(value: number);
  122538. /**
  122539. * Instantiates a new touch camera.
  122540. * This represents a FPS type of camera controlled by touch.
  122541. * This is like a universal camera minus the Gamepad controls.
  122542. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  122543. * @param name Define the name of the camera in the scene
  122544. * @param position Define the start position of the camera in the scene
  122545. * @param scene Define the scene the camera belongs to
  122546. */
  122547. constructor(name: string, position: Vector3, scene: Scene);
  122548. /**
  122549. * Gets the current object class name.
  122550. * @return the class name
  122551. */
  122552. getClassName(): string;
  122553. /** @hidden */
  122554. _setupInputs(): void;
  122555. }
  122556. }
  122557. declare module BABYLON {
  122558. /**
  122559. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  122560. * being tilted forward or back and left or right.
  122561. */
  122562. export class DeviceOrientationCamera extends FreeCamera {
  122563. private _initialQuaternion;
  122564. private _quaternionCache;
  122565. private _tmpDragQuaternion;
  122566. private _disablePointerInputWhenUsingDeviceOrientation;
  122567. /**
  122568. * Creates a new device orientation camera
  122569. * @param name The name of the camera
  122570. * @param position The start position camera
  122571. * @param scene The scene the camera belongs to
  122572. */
  122573. constructor(name: string, position: Vector3, scene: Scene);
  122574. /**
  122575. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  122576. */
  122577. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  122578. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  122579. private _dragFactor;
  122580. /**
  122581. * Enabled turning on the y axis when the orientation sensor is active
  122582. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  122583. */
  122584. enableHorizontalDragging(dragFactor?: number): void;
  122585. /**
  122586. * Gets the current instance class name ("DeviceOrientationCamera").
  122587. * This helps avoiding instanceof at run time.
  122588. * @returns the class name
  122589. */
  122590. getClassName(): string;
  122591. /**
  122592. * @hidden
  122593. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  122594. */
  122595. _checkInputs(): void;
  122596. /**
  122597. * Reset the camera to its default orientation on the specified axis only.
  122598. * @param axis The axis to reset
  122599. */
  122600. resetToCurrentRotation(axis?: Axis): void;
  122601. }
  122602. }
  122603. declare module BABYLON {
  122604. /**
  122605. * Defines supported buttons for XBox360 compatible gamepads
  122606. */
  122607. export enum Xbox360Button {
  122608. /** A */
  122609. A = 0,
  122610. /** B */
  122611. B = 1,
  122612. /** X */
  122613. X = 2,
  122614. /** Y */
  122615. Y = 3,
  122616. /** Left button */
  122617. LB = 4,
  122618. /** Right button */
  122619. RB = 5,
  122620. /** Back */
  122621. Back = 8,
  122622. /** Start */
  122623. Start = 9,
  122624. /** Left stick */
  122625. LeftStick = 10,
  122626. /** Right stick */
  122627. RightStick = 11
  122628. }
  122629. /** Defines values for XBox360 DPad */
  122630. export enum Xbox360Dpad {
  122631. /** Up */
  122632. Up = 12,
  122633. /** Down */
  122634. Down = 13,
  122635. /** Left */
  122636. Left = 14,
  122637. /** Right */
  122638. Right = 15
  122639. }
  122640. /**
  122641. * Defines a XBox360 gamepad
  122642. */
  122643. export class Xbox360Pad extends Gamepad {
  122644. private _leftTrigger;
  122645. private _rightTrigger;
  122646. private _onlefttriggerchanged;
  122647. private _onrighttriggerchanged;
  122648. private _onbuttondown;
  122649. private _onbuttonup;
  122650. private _ondpaddown;
  122651. private _ondpadup;
  122652. /** Observable raised when a button is pressed */
  122653. onButtonDownObservable: Observable<Xbox360Button>;
  122654. /** Observable raised when a button is released */
  122655. onButtonUpObservable: Observable<Xbox360Button>;
  122656. /** Observable raised when a pad is pressed */
  122657. onPadDownObservable: Observable<Xbox360Dpad>;
  122658. /** Observable raised when a pad is released */
  122659. onPadUpObservable: Observable<Xbox360Dpad>;
  122660. private _buttonA;
  122661. private _buttonB;
  122662. private _buttonX;
  122663. private _buttonY;
  122664. private _buttonBack;
  122665. private _buttonStart;
  122666. private _buttonLB;
  122667. private _buttonRB;
  122668. private _buttonLeftStick;
  122669. private _buttonRightStick;
  122670. private _dPadUp;
  122671. private _dPadDown;
  122672. private _dPadLeft;
  122673. private _dPadRight;
  122674. private _isXboxOnePad;
  122675. /**
  122676. * Creates a new XBox360 gamepad object
  122677. * @param id defines the id of this gamepad
  122678. * @param index defines its index
  122679. * @param gamepad defines the internal HTML gamepad object
  122680. * @param xboxOne defines if it is a XBox One gamepad
  122681. */
  122682. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  122683. /**
  122684. * Defines the callback to call when left trigger is pressed
  122685. * @param callback defines the callback to use
  122686. */
  122687. onlefttriggerchanged(callback: (value: number) => void): void;
  122688. /**
  122689. * Defines the callback to call when right trigger is pressed
  122690. * @param callback defines the callback to use
  122691. */
  122692. onrighttriggerchanged(callback: (value: number) => void): void;
  122693. /**
  122694. * Gets the left trigger value
  122695. */
  122696. get leftTrigger(): number;
  122697. /**
  122698. * Sets the left trigger value
  122699. */
  122700. set leftTrigger(newValue: number);
  122701. /**
  122702. * Gets the right trigger value
  122703. */
  122704. get rightTrigger(): number;
  122705. /**
  122706. * Sets the right trigger value
  122707. */
  122708. set rightTrigger(newValue: number);
  122709. /**
  122710. * Defines the callback to call when a button is pressed
  122711. * @param callback defines the callback to use
  122712. */
  122713. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  122714. /**
  122715. * Defines the callback to call when a button is released
  122716. * @param callback defines the callback to use
  122717. */
  122718. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  122719. /**
  122720. * Defines the callback to call when a pad is pressed
  122721. * @param callback defines the callback to use
  122722. */
  122723. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  122724. /**
  122725. * Defines the callback to call when a pad is released
  122726. * @param callback defines the callback to use
  122727. */
  122728. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  122729. private _setButtonValue;
  122730. private _setDPadValue;
  122731. /**
  122732. * Gets the value of the `A` button
  122733. */
  122734. get buttonA(): number;
  122735. /**
  122736. * Sets the value of the `A` button
  122737. */
  122738. set buttonA(value: number);
  122739. /**
  122740. * Gets the value of the `B` button
  122741. */
  122742. get buttonB(): number;
  122743. /**
  122744. * Sets the value of the `B` button
  122745. */
  122746. set buttonB(value: number);
  122747. /**
  122748. * Gets the value of the `X` button
  122749. */
  122750. get buttonX(): number;
  122751. /**
  122752. * Sets the value of the `X` button
  122753. */
  122754. set buttonX(value: number);
  122755. /**
  122756. * Gets the value of the `Y` button
  122757. */
  122758. get buttonY(): number;
  122759. /**
  122760. * Sets the value of the `Y` button
  122761. */
  122762. set buttonY(value: number);
  122763. /**
  122764. * Gets the value of the `Start` button
  122765. */
  122766. get buttonStart(): number;
  122767. /**
  122768. * Sets the value of the `Start` button
  122769. */
  122770. set buttonStart(value: number);
  122771. /**
  122772. * Gets the value of the `Back` button
  122773. */
  122774. get buttonBack(): number;
  122775. /**
  122776. * Sets the value of the `Back` button
  122777. */
  122778. set buttonBack(value: number);
  122779. /**
  122780. * Gets the value of the `Left` button
  122781. */
  122782. get buttonLB(): number;
  122783. /**
  122784. * Sets the value of the `Left` button
  122785. */
  122786. set buttonLB(value: number);
  122787. /**
  122788. * Gets the value of the `Right` button
  122789. */
  122790. get buttonRB(): number;
  122791. /**
  122792. * Sets the value of the `Right` button
  122793. */
  122794. set buttonRB(value: number);
  122795. /**
  122796. * Gets the value of the Left joystick
  122797. */
  122798. get buttonLeftStick(): number;
  122799. /**
  122800. * Sets the value of the Left joystick
  122801. */
  122802. set buttonLeftStick(value: number);
  122803. /**
  122804. * Gets the value of the Right joystick
  122805. */
  122806. get buttonRightStick(): number;
  122807. /**
  122808. * Sets the value of the Right joystick
  122809. */
  122810. set buttonRightStick(value: number);
  122811. /**
  122812. * Gets the value of D-pad up
  122813. */
  122814. get dPadUp(): number;
  122815. /**
  122816. * Sets the value of D-pad up
  122817. */
  122818. set dPadUp(value: number);
  122819. /**
  122820. * Gets the value of D-pad down
  122821. */
  122822. get dPadDown(): number;
  122823. /**
  122824. * Sets the value of D-pad down
  122825. */
  122826. set dPadDown(value: number);
  122827. /**
  122828. * Gets the value of D-pad left
  122829. */
  122830. get dPadLeft(): number;
  122831. /**
  122832. * Sets the value of D-pad left
  122833. */
  122834. set dPadLeft(value: number);
  122835. /**
  122836. * Gets the value of D-pad right
  122837. */
  122838. get dPadRight(): number;
  122839. /**
  122840. * Sets the value of D-pad right
  122841. */
  122842. set dPadRight(value: number);
  122843. /**
  122844. * Force the gamepad to synchronize with device values
  122845. */
  122846. update(): void;
  122847. /**
  122848. * Disposes the gamepad
  122849. */
  122850. dispose(): void;
  122851. }
  122852. }
  122853. declare module BABYLON {
  122854. /**
  122855. * Defines supported buttons for DualShock compatible gamepads
  122856. */
  122857. export enum DualShockButton {
  122858. /** Cross */
  122859. Cross = 0,
  122860. /** Circle */
  122861. Circle = 1,
  122862. /** Square */
  122863. Square = 2,
  122864. /** Triangle */
  122865. Triangle = 3,
  122866. /** L1 */
  122867. L1 = 4,
  122868. /** R1 */
  122869. R1 = 5,
  122870. /** Share */
  122871. Share = 8,
  122872. /** Options */
  122873. Options = 9,
  122874. /** Left stick */
  122875. LeftStick = 10,
  122876. /** Right stick */
  122877. RightStick = 11
  122878. }
  122879. /** Defines values for DualShock DPad */
  122880. export enum DualShockDpad {
  122881. /** Up */
  122882. Up = 12,
  122883. /** Down */
  122884. Down = 13,
  122885. /** Left */
  122886. Left = 14,
  122887. /** Right */
  122888. Right = 15
  122889. }
  122890. /**
  122891. * Defines a DualShock gamepad
  122892. */
  122893. export class DualShockPad extends Gamepad {
  122894. private _leftTrigger;
  122895. private _rightTrigger;
  122896. private _onlefttriggerchanged;
  122897. private _onrighttriggerchanged;
  122898. private _onbuttondown;
  122899. private _onbuttonup;
  122900. private _ondpaddown;
  122901. private _ondpadup;
  122902. /** Observable raised when a button is pressed */
  122903. onButtonDownObservable: Observable<DualShockButton>;
  122904. /** Observable raised when a button is released */
  122905. onButtonUpObservable: Observable<DualShockButton>;
  122906. /** Observable raised when a pad is pressed */
  122907. onPadDownObservable: Observable<DualShockDpad>;
  122908. /** Observable raised when a pad is released */
  122909. onPadUpObservable: Observable<DualShockDpad>;
  122910. private _buttonCross;
  122911. private _buttonCircle;
  122912. private _buttonSquare;
  122913. private _buttonTriangle;
  122914. private _buttonShare;
  122915. private _buttonOptions;
  122916. private _buttonL1;
  122917. private _buttonR1;
  122918. private _buttonLeftStick;
  122919. private _buttonRightStick;
  122920. private _dPadUp;
  122921. private _dPadDown;
  122922. private _dPadLeft;
  122923. private _dPadRight;
  122924. /**
  122925. * Creates a new DualShock gamepad object
  122926. * @param id defines the id of this gamepad
  122927. * @param index defines its index
  122928. * @param gamepad defines the internal HTML gamepad object
  122929. */
  122930. constructor(id: string, index: number, gamepad: any);
  122931. /**
  122932. * Defines the callback to call when left trigger is pressed
  122933. * @param callback defines the callback to use
  122934. */
  122935. onlefttriggerchanged(callback: (value: number) => void): void;
  122936. /**
  122937. * Defines the callback to call when right trigger is pressed
  122938. * @param callback defines the callback to use
  122939. */
  122940. onrighttriggerchanged(callback: (value: number) => void): void;
  122941. /**
  122942. * Gets the left trigger value
  122943. */
  122944. get leftTrigger(): number;
  122945. /**
  122946. * Sets the left trigger value
  122947. */
  122948. set leftTrigger(newValue: number);
  122949. /**
  122950. * Gets the right trigger value
  122951. */
  122952. get rightTrigger(): number;
  122953. /**
  122954. * Sets the right trigger value
  122955. */
  122956. set rightTrigger(newValue: number);
  122957. /**
  122958. * Defines the callback to call when a button is pressed
  122959. * @param callback defines the callback to use
  122960. */
  122961. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  122962. /**
  122963. * Defines the callback to call when a button is released
  122964. * @param callback defines the callback to use
  122965. */
  122966. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  122967. /**
  122968. * Defines the callback to call when a pad is pressed
  122969. * @param callback defines the callback to use
  122970. */
  122971. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  122972. /**
  122973. * Defines the callback to call when a pad is released
  122974. * @param callback defines the callback to use
  122975. */
  122976. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  122977. private _setButtonValue;
  122978. private _setDPadValue;
  122979. /**
  122980. * Gets the value of the `Cross` button
  122981. */
  122982. get buttonCross(): number;
  122983. /**
  122984. * Sets the value of the `Cross` button
  122985. */
  122986. set buttonCross(value: number);
  122987. /**
  122988. * Gets the value of the `Circle` button
  122989. */
  122990. get buttonCircle(): number;
  122991. /**
  122992. * Sets the value of the `Circle` button
  122993. */
  122994. set buttonCircle(value: number);
  122995. /**
  122996. * Gets the value of the `Square` button
  122997. */
  122998. get buttonSquare(): number;
  122999. /**
  123000. * Sets the value of the `Square` button
  123001. */
  123002. set buttonSquare(value: number);
  123003. /**
  123004. * Gets the value of the `Triangle` button
  123005. */
  123006. get buttonTriangle(): number;
  123007. /**
  123008. * Sets the value of the `Triangle` button
  123009. */
  123010. set buttonTriangle(value: number);
  123011. /**
  123012. * Gets the value of the `Options` button
  123013. */
  123014. get buttonOptions(): number;
  123015. /**
  123016. * Sets the value of the `Options` button
  123017. */
  123018. set buttonOptions(value: number);
  123019. /**
  123020. * Gets the value of the `Share` button
  123021. */
  123022. get buttonShare(): number;
  123023. /**
  123024. * Sets the value of the `Share` button
  123025. */
  123026. set buttonShare(value: number);
  123027. /**
  123028. * Gets the value of the `L1` button
  123029. */
  123030. get buttonL1(): number;
  123031. /**
  123032. * Sets the value of the `L1` button
  123033. */
  123034. set buttonL1(value: number);
  123035. /**
  123036. * Gets the value of the `R1` button
  123037. */
  123038. get buttonR1(): number;
  123039. /**
  123040. * Sets the value of the `R1` button
  123041. */
  123042. set buttonR1(value: number);
  123043. /**
  123044. * Gets the value of the Left joystick
  123045. */
  123046. get buttonLeftStick(): number;
  123047. /**
  123048. * Sets the value of the Left joystick
  123049. */
  123050. set buttonLeftStick(value: number);
  123051. /**
  123052. * Gets the value of the Right joystick
  123053. */
  123054. get buttonRightStick(): number;
  123055. /**
  123056. * Sets the value of the Right joystick
  123057. */
  123058. set buttonRightStick(value: number);
  123059. /**
  123060. * Gets the value of D-pad up
  123061. */
  123062. get dPadUp(): number;
  123063. /**
  123064. * Sets the value of D-pad up
  123065. */
  123066. set dPadUp(value: number);
  123067. /**
  123068. * Gets the value of D-pad down
  123069. */
  123070. get dPadDown(): number;
  123071. /**
  123072. * Sets the value of D-pad down
  123073. */
  123074. set dPadDown(value: number);
  123075. /**
  123076. * Gets the value of D-pad left
  123077. */
  123078. get dPadLeft(): number;
  123079. /**
  123080. * Sets the value of D-pad left
  123081. */
  123082. set dPadLeft(value: number);
  123083. /**
  123084. * Gets the value of D-pad right
  123085. */
  123086. get dPadRight(): number;
  123087. /**
  123088. * Sets the value of D-pad right
  123089. */
  123090. set dPadRight(value: number);
  123091. /**
  123092. * Force the gamepad to synchronize with device values
  123093. */
  123094. update(): void;
  123095. /**
  123096. * Disposes the gamepad
  123097. */
  123098. dispose(): void;
  123099. }
  123100. }
  123101. declare module BABYLON {
  123102. /**
  123103. * Manager for handling gamepads
  123104. */
  123105. export class GamepadManager {
  123106. private _scene?;
  123107. private _babylonGamepads;
  123108. private _oneGamepadConnected;
  123109. /** @hidden */
  123110. _isMonitoring: boolean;
  123111. private _gamepadEventSupported;
  123112. private _gamepadSupport?;
  123113. /**
  123114. * observable to be triggered when the gamepad controller has been connected
  123115. */
  123116. onGamepadConnectedObservable: Observable<Gamepad>;
  123117. /**
  123118. * observable to be triggered when the gamepad controller has been disconnected
  123119. */
  123120. onGamepadDisconnectedObservable: Observable<Gamepad>;
  123121. private _onGamepadConnectedEvent;
  123122. private _onGamepadDisconnectedEvent;
  123123. /**
  123124. * Initializes the gamepad manager
  123125. * @param _scene BabylonJS scene
  123126. */
  123127. constructor(_scene?: Scene | undefined);
  123128. /**
  123129. * The gamepads in the game pad manager
  123130. */
  123131. get gamepads(): Gamepad[];
  123132. /**
  123133. * Get the gamepad controllers based on type
  123134. * @param type The type of gamepad controller
  123135. * @returns Nullable gamepad
  123136. */
  123137. getGamepadByType(type?: number): Nullable<Gamepad>;
  123138. /**
  123139. * Disposes the gamepad manager
  123140. */
  123141. dispose(): void;
  123142. private _addNewGamepad;
  123143. private _startMonitoringGamepads;
  123144. private _stopMonitoringGamepads;
  123145. /** @hidden */
  123146. _checkGamepadsStatus(): void;
  123147. private _updateGamepadObjects;
  123148. }
  123149. }
  123150. declare module BABYLON {
  123151. interface Scene {
  123152. /** @hidden */
  123153. _gamepadManager: Nullable<GamepadManager>;
  123154. /**
  123155. * Gets the gamepad manager associated with the scene
  123156. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  123157. */
  123158. gamepadManager: GamepadManager;
  123159. }
  123160. /**
  123161. * Interface representing a free camera inputs manager
  123162. */
  123163. interface FreeCameraInputsManager {
  123164. /**
  123165. * Adds gamepad input support to the FreeCameraInputsManager.
  123166. * @returns the FreeCameraInputsManager
  123167. */
  123168. addGamepad(): FreeCameraInputsManager;
  123169. }
  123170. /**
  123171. * Interface representing an arc rotate camera inputs manager
  123172. */
  123173. interface ArcRotateCameraInputsManager {
  123174. /**
  123175. * Adds gamepad input support to the ArcRotateCamera InputManager.
  123176. * @returns the camera inputs manager
  123177. */
  123178. addGamepad(): ArcRotateCameraInputsManager;
  123179. }
  123180. /**
  123181. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  123182. */
  123183. export class GamepadSystemSceneComponent implements ISceneComponent {
  123184. /**
  123185. * The component name helpfull to identify the component in the list of scene components.
  123186. */
  123187. readonly name: string;
  123188. /**
  123189. * The scene the component belongs to.
  123190. */
  123191. scene: Scene;
  123192. /**
  123193. * Creates a new instance of the component for the given scene
  123194. * @param scene Defines the scene to register the component in
  123195. */
  123196. constructor(scene: Scene);
  123197. /**
  123198. * Registers the component in a given scene
  123199. */
  123200. register(): void;
  123201. /**
  123202. * Rebuilds the elements related to this component in case of
  123203. * context lost for instance.
  123204. */
  123205. rebuild(): void;
  123206. /**
  123207. * Disposes the component and the associated ressources
  123208. */
  123209. dispose(): void;
  123210. private _beforeCameraUpdate;
  123211. }
  123212. }
  123213. declare module BABYLON {
  123214. /**
  123215. * 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,
  123216. * which still works and will still be found in many Playgrounds.
  123217. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123218. */
  123219. export class UniversalCamera extends TouchCamera {
  123220. /**
  123221. * Defines the gamepad rotation sensiblity.
  123222. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  123223. */
  123224. get gamepadAngularSensibility(): number;
  123225. set gamepadAngularSensibility(value: number);
  123226. /**
  123227. * Defines the gamepad move sensiblity.
  123228. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  123229. */
  123230. get gamepadMoveSensibility(): number;
  123231. set gamepadMoveSensibility(value: number);
  123232. /**
  123233. * 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,
  123234. * which still works and will still be found in many Playgrounds.
  123235. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123236. * @param name Define the name of the camera in the scene
  123237. * @param position Define the start position of the camera in the scene
  123238. * @param scene Define the scene the camera belongs to
  123239. */
  123240. constructor(name: string, position: Vector3, scene: Scene);
  123241. /**
  123242. * Gets the current object class name.
  123243. * @return the class name
  123244. */
  123245. getClassName(): string;
  123246. }
  123247. }
  123248. declare module BABYLON {
  123249. /**
  123250. * This represents a FPS type of camera. This is only here for back compat purpose.
  123251. * Please use the UniversalCamera instead as both are identical.
  123252. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123253. */
  123254. export class GamepadCamera extends UniversalCamera {
  123255. /**
  123256. * Instantiates a new Gamepad Camera
  123257. * This represents a FPS type of camera. This is only here for back compat purpose.
  123258. * Please use the UniversalCamera instead as both are identical.
  123259. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123260. * @param name Define the name of the camera in the scene
  123261. * @param position Define the start position of the camera in the scene
  123262. * @param scene Define the scene the camera belongs to
  123263. */
  123264. constructor(name: string, position: Vector3, scene: Scene);
  123265. /**
  123266. * Gets the current object class name.
  123267. * @return the class name
  123268. */
  123269. getClassName(): string;
  123270. }
  123271. }
  123272. declare module BABYLON {
  123273. /** @hidden */
  123274. export var passPixelShader: {
  123275. name: string;
  123276. shader: string;
  123277. };
  123278. }
  123279. declare module BABYLON {
  123280. /** @hidden */
  123281. export var passCubePixelShader: {
  123282. name: string;
  123283. shader: string;
  123284. };
  123285. }
  123286. declare module BABYLON {
  123287. /**
  123288. * PassPostProcess which produces an output the same as it's input
  123289. */
  123290. export class PassPostProcess extends PostProcess {
  123291. /**
  123292. * Creates the PassPostProcess
  123293. * @param name The name of the effect.
  123294. * @param options The required width/height ratio to downsize to before computing the render pass.
  123295. * @param camera The camera to apply the render pass to.
  123296. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123297. * @param engine The engine which the post process will be applied. (default: current engine)
  123298. * @param reusable If the post process can be reused on the same frame. (default: false)
  123299. * @param textureType The type of texture to be used when performing the post processing.
  123300. * @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)
  123301. */
  123302. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123303. }
  123304. /**
  123305. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  123306. */
  123307. export class PassCubePostProcess extends PostProcess {
  123308. private _face;
  123309. /**
  123310. * Gets or sets the cube face to display.
  123311. * * 0 is +X
  123312. * * 1 is -X
  123313. * * 2 is +Y
  123314. * * 3 is -Y
  123315. * * 4 is +Z
  123316. * * 5 is -Z
  123317. */
  123318. get face(): number;
  123319. set face(value: number);
  123320. /**
  123321. * Creates the PassCubePostProcess
  123322. * @param name The name of the effect.
  123323. * @param options The required width/height ratio to downsize to before computing the render pass.
  123324. * @param camera The camera to apply the render pass to.
  123325. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123326. * @param engine The engine which the post process will be applied. (default: current engine)
  123327. * @param reusable If the post process can be reused on the same frame. (default: false)
  123328. * @param textureType The type of texture to be used when performing the post processing.
  123329. * @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)
  123330. */
  123331. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123332. }
  123333. }
  123334. declare module BABYLON {
  123335. /** @hidden */
  123336. export var anaglyphPixelShader: {
  123337. name: string;
  123338. shader: string;
  123339. };
  123340. }
  123341. declare module BABYLON {
  123342. /**
  123343. * Postprocess used to generate anaglyphic rendering
  123344. */
  123345. export class AnaglyphPostProcess extends PostProcess {
  123346. private _passedProcess;
  123347. /**
  123348. * Creates a new AnaglyphPostProcess
  123349. * @param name defines postprocess name
  123350. * @param options defines creation options or target ratio scale
  123351. * @param rigCameras defines cameras using this postprocess
  123352. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  123353. * @param engine defines hosting engine
  123354. * @param reusable defines if the postprocess will be reused multiple times per frame
  123355. */
  123356. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  123357. }
  123358. }
  123359. declare module BABYLON {
  123360. /**
  123361. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  123362. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  123363. */
  123364. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  123365. /**
  123366. * Creates a new AnaglyphArcRotateCamera
  123367. * @param name defines camera name
  123368. * @param alpha defines alpha angle (in radians)
  123369. * @param beta defines beta angle (in radians)
  123370. * @param radius defines radius
  123371. * @param target defines camera target
  123372. * @param interaxialDistance defines distance between each color axis
  123373. * @param scene defines the hosting scene
  123374. */
  123375. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  123376. /**
  123377. * Gets camera class name
  123378. * @returns AnaglyphArcRotateCamera
  123379. */
  123380. getClassName(): string;
  123381. }
  123382. }
  123383. declare module BABYLON {
  123384. /**
  123385. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  123386. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  123387. */
  123388. export class AnaglyphFreeCamera extends FreeCamera {
  123389. /**
  123390. * Creates a new AnaglyphFreeCamera
  123391. * @param name defines camera name
  123392. * @param position defines initial position
  123393. * @param interaxialDistance defines distance between each color axis
  123394. * @param scene defines the hosting scene
  123395. */
  123396. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  123397. /**
  123398. * Gets camera class name
  123399. * @returns AnaglyphFreeCamera
  123400. */
  123401. getClassName(): string;
  123402. }
  123403. }
  123404. declare module BABYLON {
  123405. /**
  123406. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  123407. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  123408. */
  123409. export class AnaglyphGamepadCamera extends GamepadCamera {
  123410. /**
  123411. * Creates a new AnaglyphGamepadCamera
  123412. * @param name defines camera name
  123413. * @param position defines initial position
  123414. * @param interaxialDistance defines distance between each color axis
  123415. * @param scene defines the hosting scene
  123416. */
  123417. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  123418. /**
  123419. * Gets camera class name
  123420. * @returns AnaglyphGamepadCamera
  123421. */
  123422. getClassName(): string;
  123423. }
  123424. }
  123425. declare module BABYLON {
  123426. /**
  123427. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  123428. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  123429. */
  123430. export class AnaglyphUniversalCamera extends UniversalCamera {
  123431. /**
  123432. * Creates a new AnaglyphUniversalCamera
  123433. * @param name defines camera name
  123434. * @param position defines initial position
  123435. * @param interaxialDistance defines distance between each color axis
  123436. * @param scene defines the hosting scene
  123437. */
  123438. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  123439. /**
  123440. * Gets camera class name
  123441. * @returns AnaglyphUniversalCamera
  123442. */
  123443. getClassName(): string;
  123444. }
  123445. }
  123446. declare module BABYLON {
  123447. /**
  123448. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  123449. * @see https://doc.babylonjs.com/features/cameras
  123450. */
  123451. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  123452. /**
  123453. * Creates a new StereoscopicArcRotateCamera
  123454. * @param name defines camera name
  123455. * @param alpha defines alpha angle (in radians)
  123456. * @param beta defines beta angle (in radians)
  123457. * @param radius defines radius
  123458. * @param target defines camera target
  123459. * @param interaxialDistance defines distance between each color axis
  123460. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  123461. * @param scene defines the hosting scene
  123462. */
  123463. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  123464. /**
  123465. * Gets camera class name
  123466. * @returns StereoscopicArcRotateCamera
  123467. */
  123468. getClassName(): string;
  123469. }
  123470. }
  123471. declare module BABYLON {
  123472. /**
  123473. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  123474. * @see https://doc.babylonjs.com/features/cameras
  123475. */
  123476. export class StereoscopicFreeCamera extends FreeCamera {
  123477. /**
  123478. * Creates a new StereoscopicFreeCamera
  123479. * @param name defines camera name
  123480. * @param position defines initial position
  123481. * @param interaxialDistance defines distance between each color axis
  123482. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  123483. * @param scene defines the hosting scene
  123484. */
  123485. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  123486. /**
  123487. * Gets camera class name
  123488. * @returns StereoscopicFreeCamera
  123489. */
  123490. getClassName(): string;
  123491. }
  123492. }
  123493. declare module BABYLON {
  123494. /**
  123495. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  123496. * @see https://doc.babylonjs.com/features/cameras
  123497. */
  123498. export class StereoscopicGamepadCamera extends GamepadCamera {
  123499. /**
  123500. * Creates a new StereoscopicGamepadCamera
  123501. * @param name defines camera name
  123502. * @param position defines initial position
  123503. * @param interaxialDistance defines distance between each color axis
  123504. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  123505. * @param scene defines the hosting scene
  123506. */
  123507. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  123508. /**
  123509. * Gets camera class name
  123510. * @returns StereoscopicGamepadCamera
  123511. */
  123512. getClassName(): string;
  123513. }
  123514. }
  123515. declare module BABYLON {
  123516. /**
  123517. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  123518. * @see https://doc.babylonjs.com/features/cameras
  123519. */
  123520. export class StereoscopicUniversalCamera extends UniversalCamera {
  123521. /**
  123522. * Creates a new StereoscopicUniversalCamera
  123523. * @param name defines camera name
  123524. * @param position defines initial position
  123525. * @param interaxialDistance defines distance between each color axis
  123526. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  123527. * @param scene defines the hosting scene
  123528. */
  123529. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  123530. /**
  123531. * Gets camera class name
  123532. * @returns StereoscopicUniversalCamera
  123533. */
  123534. getClassName(): string;
  123535. }
  123536. }
  123537. declare module BABYLON {
  123538. /**
  123539. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  123540. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  123541. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  123542. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  123543. */
  123544. export class VirtualJoysticksCamera extends FreeCamera {
  123545. /**
  123546. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  123547. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  123548. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  123549. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  123550. * @param name Define the name of the camera in the scene
  123551. * @param position Define the start position of the camera in the scene
  123552. * @param scene Define the scene the camera belongs to
  123553. */
  123554. constructor(name: string, position: Vector3, scene: Scene);
  123555. /**
  123556. * Gets the current object class name.
  123557. * @return the class name
  123558. */
  123559. getClassName(): string;
  123560. }
  123561. }
  123562. declare module BABYLON {
  123563. /**
  123564. * This represents all the required metrics to create a VR camera.
  123565. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  123566. */
  123567. export class VRCameraMetrics {
  123568. /**
  123569. * Define the horizontal resolution off the screen.
  123570. */
  123571. hResolution: number;
  123572. /**
  123573. * Define the vertical resolution off the screen.
  123574. */
  123575. vResolution: number;
  123576. /**
  123577. * Define the horizontal screen size.
  123578. */
  123579. hScreenSize: number;
  123580. /**
  123581. * Define the vertical screen size.
  123582. */
  123583. vScreenSize: number;
  123584. /**
  123585. * Define the vertical screen center position.
  123586. */
  123587. vScreenCenter: number;
  123588. /**
  123589. * Define the distance of the eyes to the screen.
  123590. */
  123591. eyeToScreenDistance: number;
  123592. /**
  123593. * Define the distance between both lenses
  123594. */
  123595. lensSeparationDistance: number;
  123596. /**
  123597. * Define the distance between both viewer's eyes.
  123598. */
  123599. interpupillaryDistance: number;
  123600. /**
  123601. * Define the distortion factor of the VR postprocess.
  123602. * Please, touch with care.
  123603. */
  123604. distortionK: number[];
  123605. /**
  123606. * Define the chromatic aberration correction factors for the VR post process.
  123607. */
  123608. chromaAbCorrection: number[];
  123609. /**
  123610. * Define the scale factor of the post process.
  123611. * The smaller the better but the slower.
  123612. */
  123613. postProcessScaleFactor: number;
  123614. /**
  123615. * Define an offset for the lens center.
  123616. */
  123617. lensCenterOffset: number;
  123618. /**
  123619. * Define if the current vr camera should compensate the distortion of the lense or not.
  123620. */
  123621. compensateDistortion: boolean;
  123622. /**
  123623. * Defines if multiview should be enabled when rendering (Default: false)
  123624. */
  123625. multiviewEnabled: boolean;
  123626. /**
  123627. * Gets the rendering aspect ratio based on the provided resolutions.
  123628. */
  123629. get aspectRatio(): number;
  123630. /**
  123631. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  123632. */
  123633. get aspectRatioFov(): number;
  123634. /**
  123635. * @hidden
  123636. */
  123637. get leftHMatrix(): Matrix;
  123638. /**
  123639. * @hidden
  123640. */
  123641. get rightHMatrix(): Matrix;
  123642. /**
  123643. * @hidden
  123644. */
  123645. get leftPreViewMatrix(): Matrix;
  123646. /**
  123647. * @hidden
  123648. */
  123649. get rightPreViewMatrix(): Matrix;
  123650. /**
  123651. * Get the default VRMetrics based on the most generic setup.
  123652. * @returns the default vr metrics
  123653. */
  123654. static GetDefault(): VRCameraMetrics;
  123655. }
  123656. }
  123657. declare module BABYLON {
  123658. /** @hidden */
  123659. export var vrDistortionCorrectionPixelShader: {
  123660. name: string;
  123661. shader: string;
  123662. };
  123663. }
  123664. declare module BABYLON {
  123665. /**
  123666. * VRDistortionCorrectionPostProcess used for mobile VR
  123667. */
  123668. export class VRDistortionCorrectionPostProcess extends PostProcess {
  123669. private _isRightEye;
  123670. private _distortionFactors;
  123671. private _postProcessScaleFactor;
  123672. private _lensCenterOffset;
  123673. private _scaleIn;
  123674. private _scaleFactor;
  123675. private _lensCenter;
  123676. /**
  123677. * Initializes the VRDistortionCorrectionPostProcess
  123678. * @param name The name of the effect.
  123679. * @param camera The camera to apply the render pass to.
  123680. * @param isRightEye If this is for the right eye distortion
  123681. * @param vrMetrics All the required metrics for the VR camera
  123682. */
  123683. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  123684. }
  123685. }
  123686. declare module BABYLON {
  123687. /**
  123688. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  123689. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123690. */
  123691. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  123692. /**
  123693. * Creates a new VRDeviceOrientationArcRotateCamera
  123694. * @param name defines camera name
  123695. * @param alpha defines the camera rotation along the logitudinal axis
  123696. * @param beta defines the camera rotation along the latitudinal axis
  123697. * @param radius defines the camera distance from its target
  123698. * @param target defines the camera target
  123699. * @param scene defines the scene the camera belongs to
  123700. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123701. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123702. */
  123703. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123704. /**
  123705. * Gets camera class name
  123706. * @returns VRDeviceOrientationArcRotateCamera
  123707. */
  123708. getClassName(): string;
  123709. }
  123710. }
  123711. declare module BABYLON {
  123712. /**
  123713. * Camera used to simulate VR rendering (based on FreeCamera)
  123714. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123715. */
  123716. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  123717. /**
  123718. * Creates a new VRDeviceOrientationFreeCamera
  123719. * @param name defines camera name
  123720. * @param position defines the start position of the camera
  123721. * @param scene defines the scene the camera belongs to
  123722. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123723. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123724. */
  123725. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123726. /**
  123727. * Gets camera class name
  123728. * @returns VRDeviceOrientationFreeCamera
  123729. */
  123730. getClassName(): string;
  123731. }
  123732. }
  123733. declare module BABYLON {
  123734. /**
  123735. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  123736. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123737. */
  123738. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  123739. /**
  123740. * Creates a new VRDeviceOrientationGamepadCamera
  123741. * @param name defines camera name
  123742. * @param position defines the start position of the camera
  123743. * @param scene defines the scene the camera belongs to
  123744. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123745. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123746. */
  123747. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123748. /**
  123749. * Gets camera class name
  123750. * @returns VRDeviceOrientationGamepadCamera
  123751. */
  123752. getClassName(): string;
  123753. }
  123754. }
  123755. declare module BABYLON {
  123756. /**
  123757. * A class extending Texture allowing drawing on a texture
  123758. * @see https://doc.babylonjs.com/how_to/dynamictexture
  123759. */
  123760. export class DynamicTexture extends Texture {
  123761. private _generateMipMaps;
  123762. private _canvas;
  123763. private _context;
  123764. /**
  123765. * Creates a DynamicTexture
  123766. * @param name defines the name of the texture
  123767. * @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
  123768. * @param scene defines the scene where you want the texture
  123769. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  123770. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  123771. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  123772. */
  123773. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  123774. /**
  123775. * Get the current class name of the texture useful for serialization or dynamic coding.
  123776. * @returns "DynamicTexture"
  123777. */
  123778. getClassName(): string;
  123779. /**
  123780. * Gets the current state of canRescale
  123781. */
  123782. get canRescale(): boolean;
  123783. private _recreate;
  123784. /**
  123785. * Scales the texture
  123786. * @param ratio the scale factor to apply to both width and height
  123787. */
  123788. scale(ratio: number): void;
  123789. /**
  123790. * Resizes the texture
  123791. * @param width the new width
  123792. * @param height the new height
  123793. */
  123794. scaleTo(width: number, height: number): void;
  123795. /**
  123796. * Gets the context of the canvas used by the texture
  123797. * @returns the canvas context of the dynamic texture
  123798. */
  123799. getContext(): CanvasRenderingContext2D;
  123800. /**
  123801. * Clears the texture
  123802. */
  123803. clear(): void;
  123804. /**
  123805. * Updates the texture
  123806. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  123807. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  123808. */
  123809. update(invertY?: boolean, premulAlpha?: boolean): void;
  123810. /**
  123811. * Draws text onto the texture
  123812. * @param text defines the text to be drawn
  123813. * @param x defines the placement of the text from the left
  123814. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  123815. * @param font defines the font to be used with font-style, font-size, font-name
  123816. * @param color defines the color used for the text
  123817. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  123818. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  123819. * @param update defines whether texture is immediately update (default is true)
  123820. */
  123821. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  123822. /**
  123823. * Clones the texture
  123824. * @returns the clone of the texture.
  123825. */
  123826. clone(): DynamicTexture;
  123827. /**
  123828. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  123829. * @returns a serialized dynamic texture object
  123830. */
  123831. serialize(): any;
  123832. private _IsCanvasElement;
  123833. /** @hidden */
  123834. _rebuild(): void;
  123835. }
  123836. }
  123837. declare module BABYLON {
  123838. /** @hidden */
  123839. export var imageProcessingPixelShader: {
  123840. name: string;
  123841. shader: string;
  123842. };
  123843. }
  123844. declare module BABYLON {
  123845. /**
  123846. * ImageProcessingPostProcess
  123847. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  123848. */
  123849. export class ImageProcessingPostProcess extends PostProcess {
  123850. /**
  123851. * Default configuration related to image processing available in the PBR Material.
  123852. */
  123853. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123854. /**
  123855. * Gets the image processing configuration used either in this material.
  123856. */
  123857. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  123858. /**
  123859. * Sets the Default image processing configuration used either in the this material.
  123860. *
  123861. * If sets to null, the scene one is in use.
  123862. */
  123863. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  123864. /**
  123865. * Keep track of the image processing observer to allow dispose and replace.
  123866. */
  123867. private _imageProcessingObserver;
  123868. /**
  123869. * Attaches a new image processing configuration to the PBR Material.
  123870. * @param configuration
  123871. */
  123872. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  123873. /**
  123874. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  123875. */
  123876. get colorCurves(): Nullable<ColorCurves>;
  123877. /**
  123878. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  123879. */
  123880. set colorCurves(value: Nullable<ColorCurves>);
  123881. /**
  123882. * Gets wether the color curves effect is enabled.
  123883. */
  123884. get colorCurvesEnabled(): boolean;
  123885. /**
  123886. * Sets wether the color curves effect is enabled.
  123887. */
  123888. set colorCurvesEnabled(value: boolean);
  123889. /**
  123890. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  123891. */
  123892. get colorGradingTexture(): Nullable<BaseTexture>;
  123893. /**
  123894. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  123895. */
  123896. set colorGradingTexture(value: Nullable<BaseTexture>);
  123897. /**
  123898. * Gets wether the color grading effect is enabled.
  123899. */
  123900. get colorGradingEnabled(): boolean;
  123901. /**
  123902. * Gets wether the color grading effect is enabled.
  123903. */
  123904. set colorGradingEnabled(value: boolean);
  123905. /**
  123906. * Gets exposure used in the effect.
  123907. */
  123908. get exposure(): number;
  123909. /**
  123910. * Sets exposure used in the effect.
  123911. */
  123912. set exposure(value: number);
  123913. /**
  123914. * Gets wether tonemapping is enabled or not.
  123915. */
  123916. get toneMappingEnabled(): boolean;
  123917. /**
  123918. * Sets wether tonemapping is enabled or not
  123919. */
  123920. set toneMappingEnabled(value: boolean);
  123921. /**
  123922. * Gets the type of tone mapping effect.
  123923. */
  123924. get toneMappingType(): number;
  123925. /**
  123926. * Sets the type of tone mapping effect.
  123927. */
  123928. set toneMappingType(value: number);
  123929. /**
  123930. * Gets contrast used in the effect.
  123931. */
  123932. get contrast(): number;
  123933. /**
  123934. * Sets contrast used in the effect.
  123935. */
  123936. set contrast(value: number);
  123937. /**
  123938. * Gets Vignette stretch size.
  123939. */
  123940. get vignetteStretch(): number;
  123941. /**
  123942. * Sets Vignette stretch size.
  123943. */
  123944. set vignetteStretch(value: number);
  123945. /**
  123946. * Gets Vignette centre X Offset.
  123947. */
  123948. get vignetteCentreX(): number;
  123949. /**
  123950. * Sets Vignette centre X Offset.
  123951. */
  123952. set vignetteCentreX(value: number);
  123953. /**
  123954. * Gets Vignette centre Y Offset.
  123955. */
  123956. get vignetteCentreY(): number;
  123957. /**
  123958. * Sets Vignette centre Y Offset.
  123959. */
  123960. set vignetteCentreY(value: number);
  123961. /**
  123962. * Gets Vignette weight or intensity of the vignette effect.
  123963. */
  123964. get vignetteWeight(): number;
  123965. /**
  123966. * Sets Vignette weight or intensity of the vignette effect.
  123967. */
  123968. set vignetteWeight(value: number);
  123969. /**
  123970. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  123971. * if vignetteEnabled is set to true.
  123972. */
  123973. get vignetteColor(): Color4;
  123974. /**
  123975. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  123976. * if vignetteEnabled is set to true.
  123977. */
  123978. set vignetteColor(value: Color4);
  123979. /**
  123980. * Gets Camera field of view used by the Vignette effect.
  123981. */
  123982. get vignetteCameraFov(): number;
  123983. /**
  123984. * Sets Camera field of view used by the Vignette effect.
  123985. */
  123986. set vignetteCameraFov(value: number);
  123987. /**
  123988. * Gets the vignette blend mode allowing different kind of effect.
  123989. */
  123990. get vignetteBlendMode(): number;
  123991. /**
  123992. * Sets the vignette blend mode allowing different kind of effect.
  123993. */
  123994. set vignetteBlendMode(value: number);
  123995. /**
  123996. * Gets wether the vignette effect is enabled.
  123997. */
  123998. get vignetteEnabled(): boolean;
  123999. /**
  124000. * Sets wether the vignette effect is enabled.
  124001. */
  124002. set vignetteEnabled(value: boolean);
  124003. private _fromLinearSpace;
  124004. /**
  124005. * Gets wether the input of the processing is in Gamma or Linear Space.
  124006. */
  124007. get fromLinearSpace(): boolean;
  124008. /**
  124009. * Sets wether the input of the processing is in Gamma or Linear Space.
  124010. */
  124011. set fromLinearSpace(value: boolean);
  124012. /**
  124013. * Defines cache preventing GC.
  124014. */
  124015. private _defines;
  124016. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  124017. /**
  124018. * "ImageProcessingPostProcess"
  124019. * @returns "ImageProcessingPostProcess"
  124020. */
  124021. getClassName(): string;
  124022. protected _updateParameters(): void;
  124023. dispose(camera?: Camera): void;
  124024. }
  124025. }
  124026. declare module BABYLON {
  124027. /**
  124028. * Class containing static functions to help procedurally build meshes
  124029. */
  124030. export class GroundBuilder {
  124031. /**
  124032. * Creates a ground mesh
  124033. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  124034. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  124035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124036. * @param name defines the name of the mesh
  124037. * @param options defines the options used to create the mesh
  124038. * @param scene defines the hosting scene
  124039. * @returns the ground mesh
  124040. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  124041. */
  124042. static CreateGround(name: string, options: {
  124043. width?: number;
  124044. height?: number;
  124045. subdivisions?: number;
  124046. subdivisionsX?: number;
  124047. subdivisionsY?: number;
  124048. updatable?: boolean;
  124049. }, scene: any): Mesh;
  124050. /**
  124051. * Creates a tiled ground mesh
  124052. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  124053. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  124054. * * 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
  124055. * * 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
  124056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124057. * @param name defines the name of the mesh
  124058. * @param options defines the options used to create the mesh
  124059. * @param scene defines the hosting scene
  124060. * @returns the tiled ground mesh
  124061. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  124062. */
  124063. static CreateTiledGround(name: string, options: {
  124064. xmin: number;
  124065. zmin: number;
  124066. xmax: number;
  124067. zmax: number;
  124068. subdivisions?: {
  124069. w: number;
  124070. h: number;
  124071. };
  124072. precision?: {
  124073. w: number;
  124074. h: number;
  124075. };
  124076. updatable?: boolean;
  124077. }, scene?: Nullable<Scene>): Mesh;
  124078. /**
  124079. * Creates a ground mesh from a height map
  124080. * * The parameter `url` sets the URL of the height map image resource.
  124081. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  124082. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  124083. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  124084. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  124085. * * 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.
  124086. * * 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).
  124087. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  124088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124089. * @param name defines the name of the mesh
  124090. * @param url defines the url to the height map
  124091. * @param options defines the options used to create the mesh
  124092. * @param scene defines the hosting scene
  124093. * @returns the ground mesh
  124094. * @see https://doc.babylonjs.com/babylon101/height_map
  124095. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  124096. */
  124097. static CreateGroundFromHeightMap(name: string, url: string, options: {
  124098. width?: number;
  124099. height?: number;
  124100. subdivisions?: number;
  124101. minHeight?: number;
  124102. maxHeight?: number;
  124103. colorFilter?: Color3;
  124104. alphaFilter?: number;
  124105. updatable?: boolean;
  124106. onReady?: (mesh: GroundMesh) => void;
  124107. }, scene?: Nullable<Scene>): GroundMesh;
  124108. }
  124109. }
  124110. declare module BABYLON {
  124111. /**
  124112. * Class containing static functions to help procedurally build meshes
  124113. */
  124114. export class TorusBuilder {
  124115. /**
  124116. * Creates a torus mesh
  124117. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  124118. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  124119. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  124120. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124121. * * 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
  124122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124123. * @param name defines the name of the mesh
  124124. * @param options defines the options used to create the mesh
  124125. * @param scene defines the hosting scene
  124126. * @returns the torus mesh
  124127. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  124128. */
  124129. static CreateTorus(name: string, options: {
  124130. diameter?: number;
  124131. thickness?: number;
  124132. tessellation?: number;
  124133. updatable?: boolean;
  124134. sideOrientation?: number;
  124135. frontUVs?: Vector4;
  124136. backUVs?: Vector4;
  124137. }, scene: any): Mesh;
  124138. }
  124139. }
  124140. declare module BABYLON {
  124141. /**
  124142. * Class containing static functions to help procedurally build meshes
  124143. */
  124144. export class CylinderBuilder {
  124145. /**
  124146. * Creates a cylinder or a cone mesh
  124147. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  124148. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  124149. * * 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.
  124150. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  124151. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  124152. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  124153. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  124154. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  124155. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  124156. * * 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).
  124157. * * 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
  124158. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  124159. * * 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
  124160. * * 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.
  124161. * * If `enclose` is false, a ring surface is one element.
  124162. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  124163. * * 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
  124164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124165. * * 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
  124166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124167. * @param name defines the name of the mesh
  124168. * @param options defines the options used to create the mesh
  124169. * @param scene defines the hosting scene
  124170. * @returns the cylinder mesh
  124171. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  124172. */
  124173. static CreateCylinder(name: string, options: {
  124174. height?: number;
  124175. diameterTop?: number;
  124176. diameterBottom?: number;
  124177. diameter?: number;
  124178. tessellation?: number;
  124179. subdivisions?: number;
  124180. arc?: number;
  124181. faceColors?: Color4[];
  124182. faceUV?: Vector4[];
  124183. updatable?: boolean;
  124184. hasRings?: boolean;
  124185. enclose?: boolean;
  124186. cap?: number;
  124187. sideOrientation?: number;
  124188. frontUVs?: Vector4;
  124189. backUVs?: Vector4;
  124190. }, scene: any): Mesh;
  124191. }
  124192. }
  124193. declare module BABYLON {
  124194. /**
  124195. * States of the webXR experience
  124196. */
  124197. export enum WebXRState {
  124198. /**
  124199. * Transitioning to being in XR mode
  124200. */
  124201. ENTERING_XR = 0,
  124202. /**
  124203. * Transitioning to non XR mode
  124204. */
  124205. EXITING_XR = 1,
  124206. /**
  124207. * In XR mode and presenting
  124208. */
  124209. IN_XR = 2,
  124210. /**
  124211. * Not entered XR mode
  124212. */
  124213. NOT_IN_XR = 3
  124214. }
  124215. /**
  124216. * Abstraction of the XR render target
  124217. */
  124218. export interface WebXRRenderTarget extends IDisposable {
  124219. /**
  124220. * xrpresent context of the canvas which can be used to display/mirror xr content
  124221. */
  124222. canvasContext: WebGLRenderingContext;
  124223. /**
  124224. * xr layer for the canvas
  124225. */
  124226. xrLayer: Nullable<XRWebGLLayer>;
  124227. /**
  124228. * Initializes the xr layer for the session
  124229. * @param xrSession xr session
  124230. * @returns a promise that will resolve once the XR Layer has been created
  124231. */
  124232. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  124233. }
  124234. }
  124235. declare module BABYLON {
  124236. /**
  124237. * COnfiguration object for WebXR output canvas
  124238. */
  124239. export class WebXRManagedOutputCanvasOptions {
  124240. /**
  124241. * An optional canvas in case you wish to create it yourself and provide it here.
  124242. * If not provided, a new canvas will be created
  124243. */
  124244. canvasElement?: HTMLCanvasElement;
  124245. /**
  124246. * Options for this XR Layer output
  124247. */
  124248. canvasOptions?: XRWebGLLayerOptions;
  124249. /**
  124250. * CSS styling for a newly created canvas (if not provided)
  124251. */
  124252. newCanvasCssStyle?: string;
  124253. /**
  124254. * Get the default values of the configuration object
  124255. * @returns default values of this configuration object
  124256. */
  124257. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  124258. }
  124259. /**
  124260. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  124261. */
  124262. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  124263. private _options;
  124264. private _canvas;
  124265. private _engine;
  124266. /**
  124267. * Rendering context of the canvas which can be used to display/mirror xr content
  124268. */
  124269. canvasContext: WebGLRenderingContext;
  124270. /**
  124271. * xr layer for the canvas
  124272. */
  124273. xrLayer: Nullable<XRWebGLLayer>;
  124274. /**
  124275. * Initializes the canvas to be added/removed upon entering/exiting xr
  124276. * @param _xrSessionManager The XR Session manager
  124277. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  124278. */
  124279. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  124280. /**
  124281. * Disposes of the object
  124282. */
  124283. dispose(): void;
  124284. /**
  124285. * Initializes the xr layer for the session
  124286. * @param xrSession xr session
  124287. * @returns a promise that will resolve once the XR Layer has been created
  124288. */
  124289. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  124290. private _addCanvas;
  124291. private _removeCanvas;
  124292. private _setManagedOutputCanvas;
  124293. }
  124294. }
  124295. declare module BABYLON {
  124296. /**
  124297. * Manages an XRSession to work with Babylon's engine
  124298. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  124299. */
  124300. export class WebXRSessionManager implements IDisposable {
  124301. /** The scene which the session should be created for */
  124302. scene: Scene;
  124303. private _referenceSpace;
  124304. private _rttProvider;
  124305. private _sessionEnded;
  124306. private _xrNavigator;
  124307. private baseLayer;
  124308. /**
  124309. * The base reference space from which the session started. good if you want to reset your
  124310. * reference space
  124311. */
  124312. baseReferenceSpace: XRReferenceSpace;
  124313. /**
  124314. * Current XR frame
  124315. */
  124316. currentFrame: Nullable<XRFrame>;
  124317. /** WebXR timestamp updated every frame */
  124318. currentTimestamp: number;
  124319. /**
  124320. * Used just in case of a failure to initialize an immersive session.
  124321. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  124322. */
  124323. defaultHeightCompensation: number;
  124324. /**
  124325. * Fires every time a new xrFrame arrives which can be used to update the camera
  124326. */
  124327. onXRFrameObservable: Observable<XRFrame>;
  124328. /**
  124329. * Fires when the reference space changed
  124330. */
  124331. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  124332. /**
  124333. * Fires when the xr session is ended either by the device or manually done
  124334. */
  124335. onXRSessionEnded: Observable<any>;
  124336. /**
  124337. * Fires when the xr session is ended either by the device or manually done
  124338. */
  124339. onXRSessionInit: Observable<XRSession>;
  124340. /**
  124341. * Underlying xr session
  124342. */
  124343. session: XRSession;
  124344. /**
  124345. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  124346. * or get the offset the player is currently at.
  124347. */
  124348. viewerReferenceSpace: XRReferenceSpace;
  124349. /**
  124350. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  124351. * @param scene The scene which the session should be created for
  124352. */
  124353. constructor(
  124354. /** The scene which the session should be created for */
  124355. scene: Scene);
  124356. /**
  124357. * The current reference space used in this session. This reference space can constantly change!
  124358. * It is mainly used to offset the camera's position.
  124359. */
  124360. get referenceSpace(): XRReferenceSpace;
  124361. /**
  124362. * Set a new reference space and triggers the observable
  124363. */
  124364. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  124365. /**
  124366. * Disposes of the session manager
  124367. */
  124368. dispose(): void;
  124369. /**
  124370. * Stops the xrSession and restores the render loop
  124371. * @returns Promise which resolves after it exits XR
  124372. */
  124373. exitXRAsync(): Promise<void>;
  124374. /**
  124375. * Gets the correct render target texture to be rendered this frame for this eye
  124376. * @param eye the eye for which to get the render target
  124377. * @returns the render target for the specified eye
  124378. */
  124379. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  124380. /**
  124381. * Creates a WebXRRenderTarget object for the XR session
  124382. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  124383. * @param options optional options to provide when creating a new render target
  124384. * @returns a WebXR render target to which the session can render
  124385. */
  124386. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  124387. /**
  124388. * Initializes the manager
  124389. * After initialization enterXR can be called to start an XR session
  124390. * @returns Promise which resolves after it is initialized
  124391. */
  124392. initializeAsync(): Promise<void>;
  124393. /**
  124394. * Initializes an xr session
  124395. * @param xrSessionMode mode to initialize
  124396. * @param xrSessionInit defines optional and required values to pass to the session builder
  124397. * @returns a promise which will resolve once the session has been initialized
  124398. */
  124399. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  124400. /**
  124401. * Checks if a session would be supported for the creation options specified
  124402. * @param sessionMode session mode to check if supported eg. immersive-vr
  124403. * @returns A Promise that resolves to true if supported and false if not
  124404. */
  124405. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  124406. /**
  124407. * Resets the reference space to the one started the session
  124408. */
  124409. resetReferenceSpace(): void;
  124410. /**
  124411. * Starts rendering to the xr layer
  124412. */
  124413. runXRRenderLoop(): void;
  124414. /**
  124415. * Sets the reference space on the xr session
  124416. * @param referenceSpaceType space to set
  124417. * @returns a promise that will resolve once the reference space has been set
  124418. */
  124419. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  124420. /**
  124421. * Updates the render state of the session
  124422. * @param state state to set
  124423. * @returns a promise that resolves once the render state has been updated
  124424. */
  124425. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  124426. /**
  124427. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  124428. * @param sessionMode defines the session to test
  124429. * @returns a promise with boolean as final value
  124430. */
  124431. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  124432. private _createRenderTargetTexture;
  124433. }
  124434. }
  124435. declare module BABYLON {
  124436. /**
  124437. * WebXR Camera which holds the views for the xrSession
  124438. * @see https://doc.babylonjs.com/how_to/webxr_camera
  124439. */
  124440. export class WebXRCamera extends FreeCamera {
  124441. private _xrSessionManager;
  124442. private _firstFrame;
  124443. private _referenceQuaternion;
  124444. private _referencedPosition;
  124445. private _xrInvPositionCache;
  124446. private _xrInvQuaternionCache;
  124447. /**
  124448. * Should position compensation execute on first frame.
  124449. * This is used when copying the position from a native (non XR) camera
  124450. */
  124451. compensateOnFirstFrame: boolean;
  124452. /**
  124453. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  124454. * @param name the name of the camera
  124455. * @param scene the scene to add the camera to
  124456. * @param _xrSessionManager a constructed xr session manager
  124457. */
  124458. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  124459. /**
  124460. * Return the user's height, unrelated to the current ground.
  124461. * This will be the y position of this camera, when ground level is 0.
  124462. */
  124463. get realWorldHeight(): number;
  124464. /** @hidden */
  124465. _updateForDualEyeDebugging(): void;
  124466. /**
  124467. * Sets this camera's transformation based on a non-vr camera
  124468. * @param otherCamera the non-vr camera to copy the transformation from
  124469. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  124470. */
  124471. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  124472. /**
  124473. * Gets the current instance class name ("WebXRCamera").
  124474. * @returns the class name
  124475. */
  124476. getClassName(): string;
  124477. /**
  124478. * Overriding the _getViewMatrix function, as it is computed by WebXR
  124479. */
  124480. _getViewMatrix(): Matrix;
  124481. private _updateFromXRSession;
  124482. private _updateNumberOfRigCameras;
  124483. private _updateReferenceSpace;
  124484. private _updateReferenceSpaceOffset;
  124485. }
  124486. }
  124487. declare module BABYLON {
  124488. /**
  124489. * Defining the interface required for a (webxr) feature
  124490. */
  124491. export interface IWebXRFeature extends IDisposable {
  124492. /**
  124493. * Is this feature attached
  124494. */
  124495. attached: boolean;
  124496. /**
  124497. * Should auto-attach be disabled?
  124498. */
  124499. disableAutoAttach: boolean;
  124500. /**
  124501. * Attach the feature to the session
  124502. * Will usually be called by the features manager
  124503. *
  124504. * @param force should attachment be forced (even when already attached)
  124505. * @returns true if successful.
  124506. */
  124507. attach(force?: boolean): boolean;
  124508. /**
  124509. * Detach the feature from the session
  124510. * Will usually be called by the features manager
  124511. *
  124512. * @returns true if successful.
  124513. */
  124514. detach(): boolean;
  124515. }
  124516. /**
  124517. * A list of the currently available features without referencing them
  124518. */
  124519. export class WebXRFeatureName {
  124520. /**
  124521. * The name of the anchor system feature
  124522. */
  124523. static ANCHOR_SYSTEM: string;
  124524. /**
  124525. * The name of the background remover feature
  124526. */
  124527. static BACKGROUND_REMOVER: string;
  124528. /**
  124529. * The name of the hit test feature
  124530. */
  124531. static HIT_TEST: string;
  124532. /**
  124533. * physics impostors for xr controllers feature
  124534. */
  124535. static PHYSICS_CONTROLLERS: string;
  124536. /**
  124537. * The name of the plane detection feature
  124538. */
  124539. static PLANE_DETECTION: string;
  124540. /**
  124541. * The name of the pointer selection feature
  124542. */
  124543. static POINTER_SELECTION: string;
  124544. /**
  124545. * The name of the teleportation feature
  124546. */
  124547. static TELEPORTATION: string;
  124548. }
  124549. /**
  124550. * Defining the constructor of a feature. Used to register the modules.
  124551. */
  124552. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  124553. /**
  124554. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  124555. * It is mainly used in AR sessions.
  124556. *
  124557. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  124558. */
  124559. export class WebXRFeaturesManager implements IDisposable {
  124560. private _xrSessionManager;
  124561. private static readonly _AvailableFeatures;
  124562. private _features;
  124563. /**
  124564. * constructs a new features manages.
  124565. *
  124566. * @param _xrSessionManager an instance of WebXRSessionManager
  124567. */
  124568. constructor(_xrSessionManager: WebXRSessionManager);
  124569. /**
  124570. * Used to register a module. After calling this function a developer can use this feature in the scene.
  124571. * Mainly used internally.
  124572. *
  124573. * @param featureName the name of the feature to register
  124574. * @param constructorFunction the function used to construct the module
  124575. * @param version the (babylon) version of the module
  124576. * @param stable is that a stable version of this module
  124577. */
  124578. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  124579. /**
  124580. * Returns a constructor of a specific feature.
  124581. *
  124582. * @param featureName the name of the feature to construct
  124583. * @param version the version of the feature to load
  124584. * @param xrSessionManager the xrSessionManager. Used to construct the module
  124585. * @param options optional options provided to the module.
  124586. * @returns a function that, when called, will return a new instance of this feature
  124587. */
  124588. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  124589. /**
  124590. * Can be used to return the list of features currently registered
  124591. *
  124592. * @returns an Array of available features
  124593. */
  124594. static GetAvailableFeatures(): string[];
  124595. /**
  124596. * Gets the versions available for a specific feature
  124597. * @param featureName the name of the feature
  124598. * @returns an array with the available versions
  124599. */
  124600. static GetAvailableVersions(featureName: string): string[];
  124601. /**
  124602. * Return the latest unstable version of this feature
  124603. * @param featureName the name of the feature to search
  124604. * @returns the version number. if not found will return -1
  124605. */
  124606. static GetLatestVersionOfFeature(featureName: string): number;
  124607. /**
  124608. * Return the latest stable version of this feature
  124609. * @param featureName the name of the feature to search
  124610. * @returns the version number. if not found will return -1
  124611. */
  124612. static GetStableVersionOfFeature(featureName: string): number;
  124613. /**
  124614. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  124615. * Can be used during a session to start a feature
  124616. * @param featureName the name of feature to attach
  124617. */
  124618. attachFeature(featureName: string): void;
  124619. /**
  124620. * Can be used inside a session or when the session ends to detach a specific feature
  124621. * @param featureName the name of the feature to detach
  124622. */
  124623. detachFeature(featureName: string): void;
  124624. /**
  124625. * Used to disable an already-enabled feature
  124626. * The feature will be disposed and will be recreated once enabled.
  124627. * @param featureName the feature to disable
  124628. * @returns true if disable was successful
  124629. */
  124630. disableFeature(featureName: string | {
  124631. Name: string;
  124632. }): boolean;
  124633. /**
  124634. * dispose this features manager
  124635. */
  124636. dispose(): void;
  124637. /**
  124638. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  124639. * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.
  124640. *
  124641. * @param featureName the name of the feature to load or the class of the feature
  124642. * @param version optional version to load. if not provided the latest version will be enabled
  124643. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  124644. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  124645. * @returns a new constructed feature or throws an error if feature not found.
  124646. */
  124647. enableFeature(featureName: string | {
  124648. Name: string;
  124649. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  124650. /**
  124651. * get the implementation of an enabled feature.
  124652. * @param featureName the name of the feature to load
  124653. * @returns the feature class, if found
  124654. */
  124655. getEnabledFeature(featureName: string): IWebXRFeature;
  124656. /**
  124657. * Get the list of enabled features
  124658. * @returns an array of enabled features
  124659. */
  124660. getEnabledFeatures(): string[];
  124661. }
  124662. }
  124663. declare module BABYLON {
  124664. /**
  124665. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  124666. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  124667. */
  124668. export class WebXRExperienceHelper implements IDisposable {
  124669. private scene;
  124670. private _nonVRCamera;
  124671. private _originalSceneAutoClear;
  124672. private _supported;
  124673. /**
  124674. * Camera used to render xr content
  124675. */
  124676. camera: WebXRCamera;
  124677. /** A features manager for this xr session */
  124678. featuresManager: WebXRFeaturesManager;
  124679. /**
  124680. * Observers registered here will be triggered after the camera's initial transformation is set
  124681. * This can be used to set a different ground level or an extra rotation.
  124682. *
  124683. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  124684. * to the position set after this observable is done executing.
  124685. */
  124686. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  124687. /**
  124688. * Fires when the state of the experience helper has changed
  124689. */
  124690. onStateChangedObservable: Observable<WebXRState>;
  124691. /** Session manager used to keep track of xr session */
  124692. sessionManager: WebXRSessionManager;
  124693. /**
  124694. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  124695. */
  124696. state: WebXRState;
  124697. /**
  124698. * Creates a WebXRExperienceHelper
  124699. * @param scene The scene the helper should be created in
  124700. */
  124701. private constructor();
  124702. /**
  124703. * Creates the experience helper
  124704. * @param scene the scene to attach the experience helper to
  124705. * @returns a promise for the experience helper
  124706. */
  124707. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  124708. /**
  124709. * Disposes of the experience helper
  124710. */
  124711. dispose(): void;
  124712. /**
  124713. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  124714. * @param sessionMode options for the XR session
  124715. * @param referenceSpaceType frame of reference of the XR session
  124716. * @param renderTarget the output canvas that will be used to enter XR mode
  124717. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  124718. * @returns promise that resolves after xr mode has entered
  124719. */
  124720. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  124721. /**
  124722. * Exits XR mode and returns the scene to its original state
  124723. * @returns promise that resolves after xr mode has exited
  124724. */
  124725. exitXRAsync(): Promise<void>;
  124726. private _nonXRToXRCamera;
  124727. private _setState;
  124728. }
  124729. }
  124730. declare module BABYLON {
  124731. /**
  124732. * X-Y values for axes in WebXR
  124733. */
  124734. export interface IWebXRMotionControllerAxesValue {
  124735. /**
  124736. * The value of the x axis
  124737. */
  124738. x: number;
  124739. /**
  124740. * The value of the y-axis
  124741. */
  124742. y: number;
  124743. }
  124744. /**
  124745. * changed / previous values for the values of this component
  124746. */
  124747. export interface IWebXRMotionControllerComponentChangesValues<T> {
  124748. /**
  124749. * current (this frame) value
  124750. */
  124751. current: T;
  124752. /**
  124753. * previous (last change) value
  124754. */
  124755. previous: T;
  124756. }
  124757. /**
  124758. * Represents changes in the component between current frame and last values recorded
  124759. */
  124760. export interface IWebXRMotionControllerComponentChanges {
  124761. /**
  124762. * will be populated with previous and current values if axes changed
  124763. */
  124764. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  124765. /**
  124766. * will be populated with previous and current values if pressed changed
  124767. */
  124768. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  124769. /**
  124770. * will be populated with previous and current values if touched changed
  124771. */
  124772. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  124773. /**
  124774. * will be populated with previous and current values if value changed
  124775. */
  124776. value?: IWebXRMotionControllerComponentChangesValues<number>;
  124777. }
  124778. /**
  124779. * This class represents a single component (for example button or thumbstick) of a motion controller
  124780. */
  124781. export class WebXRControllerComponent implements IDisposable {
  124782. /**
  124783. * the id of this component
  124784. */
  124785. id: string;
  124786. /**
  124787. * the type of the component
  124788. */
  124789. type: MotionControllerComponentType;
  124790. private _buttonIndex;
  124791. private _axesIndices;
  124792. private _axes;
  124793. private _changes;
  124794. private _currentValue;
  124795. private _hasChanges;
  124796. private _pressed;
  124797. private _touched;
  124798. /**
  124799. * button component type
  124800. */
  124801. static BUTTON_TYPE: MotionControllerComponentType;
  124802. /**
  124803. * squeeze component type
  124804. */
  124805. static SQUEEZE_TYPE: MotionControllerComponentType;
  124806. /**
  124807. * Thumbstick component type
  124808. */
  124809. static THUMBSTICK_TYPE: MotionControllerComponentType;
  124810. /**
  124811. * Touchpad component type
  124812. */
  124813. static TOUCHPAD_TYPE: MotionControllerComponentType;
  124814. /**
  124815. * trigger component type
  124816. */
  124817. static TRIGGER_TYPE: MotionControllerComponentType;
  124818. /**
  124819. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  124820. * the axes data changes
  124821. */
  124822. onAxisValueChangedObservable: Observable<{
  124823. x: number;
  124824. y: number;
  124825. }>;
  124826. /**
  124827. * Observers registered here will be triggered when the state of a button changes
  124828. * State change is either pressed / touched / value
  124829. */
  124830. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  124831. /**
  124832. * Creates a new component for a motion controller.
  124833. * It is created by the motion controller itself
  124834. *
  124835. * @param id the id of this component
  124836. * @param type the type of the component
  124837. * @param _buttonIndex index in the buttons array of the gamepad
  124838. * @param _axesIndices indices of the values in the axes array of the gamepad
  124839. */
  124840. constructor(
  124841. /**
  124842. * the id of this component
  124843. */
  124844. id: string,
  124845. /**
  124846. * the type of the component
  124847. */
  124848. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  124849. /**
  124850. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  124851. */
  124852. get axes(): IWebXRMotionControllerAxesValue;
  124853. /**
  124854. * Get the changes. Elements will be populated only if they changed with their previous and current value
  124855. */
  124856. get changes(): IWebXRMotionControllerComponentChanges;
  124857. /**
  124858. * Return whether or not the component changed the last frame
  124859. */
  124860. get hasChanges(): boolean;
  124861. /**
  124862. * is the button currently pressed
  124863. */
  124864. get pressed(): boolean;
  124865. /**
  124866. * is the button currently touched
  124867. */
  124868. get touched(): boolean;
  124869. /**
  124870. * Get the current value of this component
  124871. */
  124872. get value(): number;
  124873. /**
  124874. * Dispose this component
  124875. */
  124876. dispose(): void;
  124877. /**
  124878. * Are there axes correlating to this component
  124879. * @return true is axes data is available
  124880. */
  124881. isAxes(): boolean;
  124882. /**
  124883. * Is this component a button (hence - pressable)
  124884. * @returns true if can be pressed
  124885. */
  124886. isButton(): boolean;
  124887. /**
  124888. * update this component using the gamepad object it is in. Called on every frame
  124889. * @param nativeController the native gamepad controller object
  124890. */
  124891. update(nativeController: IMinimalMotionControllerObject): void;
  124892. }
  124893. }
  124894. declare module BABYLON {
  124895. /**
  124896. * Interface used to represent data loading progression
  124897. */
  124898. export interface ISceneLoaderProgressEvent {
  124899. /**
  124900. * Defines if data length to load can be evaluated
  124901. */
  124902. readonly lengthComputable: boolean;
  124903. /**
  124904. * Defines the loaded data length
  124905. */
  124906. readonly loaded: number;
  124907. /**
  124908. * Defines the data length to load
  124909. */
  124910. readonly total: number;
  124911. }
  124912. /**
  124913. * Interface used by SceneLoader plugins to define supported file extensions
  124914. */
  124915. export interface ISceneLoaderPluginExtensions {
  124916. /**
  124917. * Defines the list of supported extensions
  124918. */
  124919. [extension: string]: {
  124920. isBinary: boolean;
  124921. };
  124922. }
  124923. /**
  124924. * Interface used by SceneLoader plugin factory
  124925. */
  124926. export interface ISceneLoaderPluginFactory {
  124927. /**
  124928. * Defines the name of the factory
  124929. */
  124930. name: string;
  124931. /**
  124932. * Function called to create a new plugin
  124933. * @return the new plugin
  124934. */
  124935. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  124936. /**
  124937. * The callback that returns true if the data can be directly loaded.
  124938. * @param data string containing the file data
  124939. * @returns if the data can be loaded directly
  124940. */
  124941. canDirectLoad?(data: string): boolean;
  124942. }
  124943. /**
  124944. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  124945. */
  124946. export interface ISceneLoaderPluginBase {
  124947. /**
  124948. * The friendly name of this plugin.
  124949. */
  124950. name: string;
  124951. /**
  124952. * The file extensions supported by this plugin.
  124953. */
  124954. extensions: string | ISceneLoaderPluginExtensions;
  124955. /**
  124956. * The callback called when loading from a url.
  124957. * @param scene scene loading this url
  124958. * @param url url to load
  124959. * @param onSuccess callback called when the file successfully loads
  124960. * @param onProgress callback called while file is loading (if the server supports this mode)
  124961. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  124962. * @param onError callback called when the file fails to load
  124963. * @returns a file request object
  124964. */
  124965. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  124966. /**
  124967. * The callback called when loading from a file object.
  124968. * @param scene scene loading this file
  124969. * @param file defines the file to load
  124970. * @param onSuccess defines the callback to call when data is loaded
  124971. * @param onProgress defines the callback to call during loading process
  124972. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  124973. * @param onError defines the callback to call when an error occurs
  124974. * @returns a file request object
  124975. */
  124976. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  124977. /**
  124978. * The callback that returns true if the data can be directly loaded.
  124979. * @param data string containing the file data
  124980. * @returns if the data can be loaded directly
  124981. */
  124982. canDirectLoad?(data: string): boolean;
  124983. /**
  124984. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  124985. * @param scene scene loading this data
  124986. * @param data string containing the data
  124987. * @returns data to pass to the plugin
  124988. */
  124989. directLoad?(scene: Scene, data: string): any;
  124990. /**
  124991. * The callback that allows custom handling of the root url based on the response url.
  124992. * @param rootUrl the original root url
  124993. * @param responseURL the response url if available
  124994. * @returns the new root url
  124995. */
  124996. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  124997. }
  124998. /**
  124999. * Interface used to define a SceneLoader plugin
  125000. */
  125001. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  125002. /**
  125003. * Import meshes into a scene.
  125004. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  125005. * @param scene The scene to import into
  125006. * @param data The data to import
  125007. * @param rootUrl The root url for scene and resources
  125008. * @param meshes The meshes array to import into
  125009. * @param particleSystems The particle systems array to import into
  125010. * @param skeletons The skeletons array to import into
  125011. * @param onError The callback when import fails
  125012. * @returns True if successful or false otherwise
  125013. */
  125014. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  125015. /**
  125016. * Load into a scene.
  125017. * @param scene The scene to load into
  125018. * @param data The data to import
  125019. * @param rootUrl The root url for scene and resources
  125020. * @param onError The callback when import fails
  125021. * @returns True if successful or false otherwise
  125022. */
  125023. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  125024. /**
  125025. * Load into an asset container.
  125026. * @param scene The scene to load into
  125027. * @param data The data to import
  125028. * @param rootUrl The root url for scene and resources
  125029. * @param onError The callback when import fails
  125030. * @returns The loaded asset container
  125031. */
  125032. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  125033. }
  125034. /**
  125035. * Interface used to define an async SceneLoader plugin
  125036. */
  125037. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  125038. /**
  125039. * Import meshes into a scene.
  125040. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  125041. * @param scene The scene to import into
  125042. * @param data The data to import
  125043. * @param rootUrl The root url for scene and resources
  125044. * @param onProgress The callback when the load progresses
  125045. * @param fileName Defines the name of the file to load
  125046. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  125047. */
  125048. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  125049. meshes: AbstractMesh[];
  125050. particleSystems: IParticleSystem[];
  125051. skeletons: Skeleton[];
  125052. animationGroups: AnimationGroup[];
  125053. }>;
  125054. /**
  125055. * Load into a scene.
  125056. * @param scene The scene to load into
  125057. * @param data The data to import
  125058. * @param rootUrl The root url for scene and resources
  125059. * @param onProgress The callback when the load progresses
  125060. * @param fileName Defines the name of the file to load
  125061. * @returns Nothing
  125062. */
  125063. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  125064. /**
  125065. * Load into an asset container.
  125066. * @param scene The scene to load into
  125067. * @param data The data to import
  125068. * @param rootUrl The root url for scene and resources
  125069. * @param onProgress The callback when the load progresses
  125070. * @param fileName Defines the name of the file to load
  125071. * @returns The loaded asset container
  125072. */
  125073. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  125074. }
  125075. /**
  125076. * Mode that determines how to handle old animation groups before loading new ones.
  125077. */
  125078. export enum SceneLoaderAnimationGroupLoadingMode {
  125079. /**
  125080. * Reset all old animations to initial state then dispose them.
  125081. */
  125082. Clean = 0,
  125083. /**
  125084. * Stop all old animations.
  125085. */
  125086. Stop = 1,
  125087. /**
  125088. * Restart old animations from first frame.
  125089. */
  125090. Sync = 2,
  125091. /**
  125092. * Old animations remains untouched.
  125093. */
  125094. NoSync = 3
  125095. }
  125096. /**
  125097. * Class used to load scene from various file formats using registered plugins
  125098. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  125099. */
  125100. export class SceneLoader {
  125101. /**
  125102. * No logging while loading
  125103. */
  125104. static readonly NO_LOGGING: number;
  125105. /**
  125106. * Minimal logging while loading
  125107. */
  125108. static readonly MINIMAL_LOGGING: number;
  125109. /**
  125110. * Summary logging while loading
  125111. */
  125112. static readonly SUMMARY_LOGGING: number;
  125113. /**
  125114. * Detailled logging while loading
  125115. */
  125116. static readonly DETAILED_LOGGING: number;
  125117. /**
  125118. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  125119. */
  125120. static get ForceFullSceneLoadingForIncremental(): boolean;
  125121. static set ForceFullSceneLoadingForIncremental(value: boolean);
  125122. /**
  125123. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  125124. */
  125125. static get ShowLoadingScreen(): boolean;
  125126. static set ShowLoadingScreen(value: boolean);
  125127. /**
  125128. * Defines the current logging level (while loading the scene)
  125129. * @ignorenaming
  125130. */
  125131. static get loggingLevel(): number;
  125132. static set loggingLevel(value: number);
  125133. /**
  125134. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  125135. */
  125136. static get CleanBoneMatrixWeights(): boolean;
  125137. static set CleanBoneMatrixWeights(value: boolean);
  125138. /**
  125139. * Event raised when a plugin is used to load a scene
  125140. */
  125141. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  125142. private static _registeredPlugins;
  125143. private static _getDefaultPlugin;
  125144. private static _getPluginForExtension;
  125145. private static _getPluginForDirectLoad;
  125146. private static _getPluginForFilename;
  125147. private static _getDirectLoad;
  125148. private static _loadData;
  125149. private static _getFileInfo;
  125150. /**
  125151. * Gets a plugin that can load the given extension
  125152. * @param extension defines the extension to load
  125153. * @returns a plugin or null if none works
  125154. */
  125155. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  125156. /**
  125157. * Gets a boolean indicating that the given extension can be loaded
  125158. * @param extension defines the extension to load
  125159. * @returns true if the extension is supported
  125160. */
  125161. static IsPluginForExtensionAvailable(extension: string): boolean;
  125162. /**
  125163. * Adds a new plugin to the list of registered plugins
  125164. * @param plugin defines the plugin to add
  125165. */
  125166. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  125167. /**
  125168. * Import meshes into a scene
  125169. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  125170. * @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)
  125171. * @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)
  125172. * @param scene the instance of BABYLON.Scene to append to
  125173. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  125174. * @param onProgress a callback with a progress event for each file being loaded
  125175. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125176. * @param pluginExtension the extension used to determine the plugin
  125177. * @returns The loaded plugin
  125178. */
  125179. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  125180. /**
  125181. * Import meshes into a scene
  125182. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  125183. * @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)
  125184. * @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)
  125185. * @param scene the instance of BABYLON.Scene to append to
  125186. * @param onProgress a callback with a progress event for each file being loaded
  125187. * @param pluginExtension the extension used to determine the plugin
  125188. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  125189. */
  125190. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  125191. meshes: AbstractMesh[];
  125192. particleSystems: IParticleSystem[];
  125193. skeletons: Skeleton[];
  125194. animationGroups: AnimationGroup[];
  125195. }>;
  125196. /**
  125197. * Load a scene
  125198. * @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)
  125199. * @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)
  125200. * @param engine is the instance of BABYLON.Engine to use to create the scene
  125201. * @param onSuccess a callback with the scene when import succeeds
  125202. * @param onProgress a callback with a progress event for each file being loaded
  125203. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125204. * @param pluginExtension the extension used to determine the plugin
  125205. * @returns The loaded plugin
  125206. */
  125207. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  125208. /**
  125209. * Load a scene
  125210. * @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)
  125211. * @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)
  125212. * @param engine is the instance of BABYLON.Engine to use to create the scene
  125213. * @param onProgress a callback with a progress event for each file being loaded
  125214. * @param pluginExtension the extension used to determine the plugin
  125215. * @returns The loaded scene
  125216. */
  125217. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  125218. /**
  125219. * Append a scene
  125220. * @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)
  125221. * @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)
  125222. * @param scene is the instance of BABYLON.Scene to append to
  125223. * @param onSuccess a callback with the scene when import succeeds
  125224. * @param onProgress a callback with a progress event for each file being loaded
  125225. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125226. * @param pluginExtension the extension used to determine the plugin
  125227. * @returns The loaded plugin
  125228. */
  125229. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  125230. /**
  125231. * Append a scene
  125232. * @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)
  125233. * @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)
  125234. * @param scene is the instance of BABYLON.Scene to append to
  125235. * @param onProgress a callback with a progress event for each file being loaded
  125236. * @param pluginExtension the extension used to determine the plugin
  125237. * @returns The given scene
  125238. */
  125239. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  125240. /**
  125241. * Load a scene into an asset container
  125242. * @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)
  125243. * @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)
  125244. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  125245. * @param onSuccess a callback with the scene when import succeeds
  125246. * @param onProgress a callback with a progress event for each file being loaded
  125247. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125248. * @param pluginExtension the extension used to determine the plugin
  125249. * @returns The loaded plugin
  125250. */
  125251. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  125252. /**
  125253. * Load a scene into an asset container
  125254. * @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)
  125255. * @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)
  125256. * @param scene is the instance of Scene to append to
  125257. * @param onProgress a callback with a progress event for each file being loaded
  125258. * @param pluginExtension the extension used to determine the plugin
  125259. * @returns The loaded asset container
  125260. */
  125261. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  125262. /**
  125263. * Import animations from a file into a scene
  125264. * @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)
  125265. * @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)
  125266. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  125267. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  125268. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  125269. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  125270. * @param onSuccess a callback with the scene when import succeeds
  125271. * @param onProgress a callback with a progress event for each file being loaded
  125272. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125273. * @param pluginExtension the extension used to determine the plugin
  125274. */
  125275. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): void;
  125276. /**
  125277. * Import animations from a file into a scene
  125278. * @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)
  125279. * @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)
  125280. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  125281. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  125282. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  125283. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  125284. * @param onSuccess a callback with the scene when import succeeds
  125285. * @param onProgress a callback with a progress event for each file being loaded
  125286. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125287. * @param pluginExtension the extension used to determine the plugin
  125288. * @returns the updated scene with imported animations
  125289. */
  125290. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  125291. }
  125292. }
  125293. declare module BABYLON {
  125294. /**
  125295. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  125296. */
  125297. export type MotionControllerHandedness = "none" | "left" | "right";
  125298. /**
  125299. * The type of components available in motion controllers.
  125300. * This is not the name of the component.
  125301. */
  125302. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  125303. /**
  125304. * The state of a controller component
  125305. */
  125306. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  125307. /**
  125308. * The schema of motion controller layout.
  125309. * No object will be initialized using this interface
  125310. * This is used just to define the profile.
  125311. */
  125312. export interface IMotionControllerLayout {
  125313. /**
  125314. * Path to load the assets. Usually relative to the base path
  125315. */
  125316. assetPath: string;
  125317. /**
  125318. * Available components (unsorted)
  125319. */
  125320. components: {
  125321. /**
  125322. * A map of component Ids
  125323. */
  125324. [componentId: string]: {
  125325. /**
  125326. * The type of input the component outputs
  125327. */
  125328. type: MotionControllerComponentType;
  125329. /**
  125330. * The indices of this component in the gamepad object
  125331. */
  125332. gamepadIndices: {
  125333. /**
  125334. * Index of button
  125335. */
  125336. button?: number;
  125337. /**
  125338. * If available, index of x-axis
  125339. */
  125340. xAxis?: number;
  125341. /**
  125342. * If available, index of y-axis
  125343. */
  125344. yAxis?: number;
  125345. };
  125346. /**
  125347. * The mesh's root node name
  125348. */
  125349. rootNodeName: string;
  125350. /**
  125351. * Animation definitions for this model
  125352. */
  125353. visualResponses: {
  125354. [stateKey: string]: {
  125355. /**
  125356. * What property will be animated
  125357. */
  125358. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  125359. /**
  125360. * What states influence this visual response
  125361. */
  125362. states: MotionControllerComponentStateType[];
  125363. /**
  125364. * Type of animation - movement or visibility
  125365. */
  125366. valueNodeProperty: "transform" | "visibility";
  125367. /**
  125368. * Base node name to move. Its position will be calculated according to the min and max nodes
  125369. */
  125370. valueNodeName?: string;
  125371. /**
  125372. * Minimum movement node
  125373. */
  125374. minNodeName?: string;
  125375. /**
  125376. * Max movement node
  125377. */
  125378. maxNodeName?: string;
  125379. };
  125380. };
  125381. /**
  125382. * If touch enabled, what is the name of node to display user feedback
  125383. */
  125384. touchPointNodeName?: string;
  125385. };
  125386. };
  125387. /**
  125388. * Is it xr standard mapping or not
  125389. */
  125390. gamepadMapping: "" | "xr-standard";
  125391. /**
  125392. * Base root node of this entire model
  125393. */
  125394. rootNodeName: string;
  125395. /**
  125396. * Defines the main button component id
  125397. */
  125398. selectComponentId: string;
  125399. }
  125400. /**
  125401. * A definition for the layout map in the input profile
  125402. */
  125403. export interface IMotionControllerLayoutMap {
  125404. /**
  125405. * Layouts with handedness type as a key
  125406. */
  125407. [handedness: string]: IMotionControllerLayout;
  125408. }
  125409. /**
  125410. * The XR Input profile schema
  125411. * Profiles can be found here:
  125412. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  125413. */
  125414. export interface IMotionControllerProfile {
  125415. /**
  125416. * fallback profiles for this profileId
  125417. */
  125418. fallbackProfileIds: string[];
  125419. /**
  125420. * The layout map, with handedness as key
  125421. */
  125422. layouts: IMotionControllerLayoutMap;
  125423. /**
  125424. * The id of this profile
  125425. * correlates to the profile(s) in the xrInput.profiles array
  125426. */
  125427. profileId: string;
  125428. }
  125429. /**
  125430. * A helper-interface for the 3 meshes needed for controller button animation
  125431. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  125432. */
  125433. export interface IMotionControllerButtonMeshMap {
  125434. /**
  125435. * the mesh that defines the pressed value mesh position.
  125436. * This is used to find the max-position of this button
  125437. */
  125438. pressedMesh: AbstractMesh;
  125439. /**
  125440. * the mesh that defines the unpressed value mesh position.
  125441. * This is used to find the min (or initial) position of this button
  125442. */
  125443. unpressedMesh: AbstractMesh;
  125444. /**
  125445. * The mesh that will be changed when value changes
  125446. */
  125447. valueMesh: AbstractMesh;
  125448. }
  125449. /**
  125450. * A helper-interface for the 3 meshes needed for controller axis animation.
  125451. * This will be expanded when touchpad animations are fully supported
  125452. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  125453. */
  125454. export interface IMotionControllerMeshMap {
  125455. /**
  125456. * the mesh that defines the maximum value mesh position.
  125457. */
  125458. maxMesh?: AbstractMesh;
  125459. /**
  125460. * the mesh that defines the minimum value mesh position.
  125461. */
  125462. minMesh?: AbstractMesh;
  125463. /**
  125464. * The mesh that will be changed when axis value changes
  125465. */
  125466. valueMesh: AbstractMesh;
  125467. }
  125468. /**
  125469. * The elements needed for change-detection of the gamepad objects in motion controllers
  125470. */
  125471. export interface IMinimalMotionControllerObject {
  125472. /**
  125473. * Available axes of this controller
  125474. */
  125475. axes: number[];
  125476. /**
  125477. * An array of available buttons
  125478. */
  125479. buttons: Array<{
  125480. /**
  125481. * Value of the button/trigger
  125482. */
  125483. value: number;
  125484. /**
  125485. * If the button/trigger is currently touched
  125486. */
  125487. touched: boolean;
  125488. /**
  125489. * If the button/trigger is currently pressed
  125490. */
  125491. pressed: boolean;
  125492. }>;
  125493. /**
  125494. * EXPERIMENTAL haptic support.
  125495. */
  125496. hapticActuators?: Array<{
  125497. pulse: (value: number, duration: number) => Promise<boolean>;
  125498. }>;
  125499. }
  125500. /**
  125501. * An Abstract Motion controller
  125502. * This class receives an xrInput and a profile layout and uses those to initialize the components
  125503. * Each component has an observable to check for changes in value and state
  125504. */
  125505. export abstract class WebXRAbstractMotionController implements IDisposable {
  125506. protected scene: Scene;
  125507. protected layout: IMotionControllerLayout;
  125508. /**
  125509. * The gamepad object correlating to this controller
  125510. */
  125511. gamepadObject: IMinimalMotionControllerObject;
  125512. /**
  125513. * handedness (left/right/none) of this controller
  125514. */
  125515. handedness: MotionControllerHandedness;
  125516. private _initComponent;
  125517. private _modelReady;
  125518. /**
  125519. * A map of components (WebXRControllerComponent) in this motion controller
  125520. * Components have a ComponentType and can also have both button and axis definitions
  125521. */
  125522. readonly components: {
  125523. [id: string]: WebXRControllerComponent;
  125524. };
  125525. /**
  125526. * Disable the model's animation. Can be set at any time.
  125527. */
  125528. disableAnimation: boolean;
  125529. /**
  125530. * Observers registered here will be triggered when the model of this controller is done loading
  125531. */
  125532. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  125533. /**
  125534. * The profile id of this motion controller
  125535. */
  125536. abstract profileId: string;
  125537. /**
  125538. * The root mesh of the model. It is null if the model was not yet initialized
  125539. */
  125540. rootMesh: Nullable<AbstractMesh>;
  125541. /**
  125542. * constructs a new abstract motion controller
  125543. * @param scene the scene to which the model of the controller will be added
  125544. * @param layout The profile layout to load
  125545. * @param gamepadObject The gamepad object correlating to this controller
  125546. * @param handedness handedness (left/right/none) of this controller
  125547. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  125548. */
  125549. constructor(scene: Scene, layout: IMotionControllerLayout,
  125550. /**
  125551. * The gamepad object correlating to this controller
  125552. */
  125553. gamepadObject: IMinimalMotionControllerObject,
  125554. /**
  125555. * handedness (left/right/none) of this controller
  125556. */
  125557. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  125558. /**
  125559. * Dispose this controller, the model mesh and all its components
  125560. */
  125561. dispose(): void;
  125562. /**
  125563. * Returns all components of specific type
  125564. * @param type the type to search for
  125565. * @return an array of components with this type
  125566. */
  125567. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  125568. /**
  125569. * get a component based an its component id as defined in layout.components
  125570. * @param id the id of the component
  125571. * @returns the component correlates to the id or undefined if not found
  125572. */
  125573. getComponent(id: string): WebXRControllerComponent;
  125574. /**
  125575. * Get the list of components available in this motion controller
  125576. * @returns an array of strings correlating to available components
  125577. */
  125578. getComponentIds(): string[];
  125579. /**
  125580. * Get the first component of specific type
  125581. * @param type type of component to find
  125582. * @return a controller component or null if not found
  125583. */
  125584. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  125585. /**
  125586. * Get the main (Select) component of this controller as defined in the layout
  125587. * @returns the main component of this controller
  125588. */
  125589. getMainComponent(): WebXRControllerComponent;
  125590. /**
  125591. * Loads the model correlating to this controller
  125592. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  125593. * @returns A promise fulfilled with the result of the model loading
  125594. */
  125595. loadModel(): Promise<boolean>;
  125596. /**
  125597. * Update this model using the current XRFrame
  125598. * @param xrFrame the current xr frame to use and update the model
  125599. */
  125600. updateFromXRFrame(xrFrame: XRFrame): void;
  125601. /**
  125602. * Backwards compatibility due to a deeply-integrated typo
  125603. */
  125604. get handness(): XREye;
  125605. /**
  125606. * Pulse (vibrate) this controller
  125607. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  125608. * Consecutive calls to this function will cancel the last pulse call
  125609. *
  125610. * @param value the strength of the pulse in 0.0...1.0 range
  125611. * @param duration Duration of the pulse in milliseconds
  125612. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  125613. * @returns a promise that will send true when the pulse has ended and false if the device doesn't support pulse or an error accrued
  125614. */
  125615. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  125616. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  125617. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  125618. /**
  125619. * Moves the axis on the controller mesh based on its current state
  125620. * @param axis the index of the axis
  125621. * @param axisValue the value of the axis which determines the meshes new position
  125622. * @hidden
  125623. */
  125624. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  125625. /**
  125626. * Update the model itself with the current frame data
  125627. * @param xrFrame the frame to use for updating the model mesh
  125628. */
  125629. protected updateModel(xrFrame: XRFrame): void;
  125630. /**
  125631. * Get the filename and path for this controller's model
  125632. * @returns a map of filename and path
  125633. */
  125634. protected abstract _getFilenameAndPath(): {
  125635. filename: string;
  125636. path: string;
  125637. };
  125638. /**
  125639. * This function is called before the mesh is loaded. It checks for loading constraints.
  125640. * For example, this function can check if the GLB loader is available
  125641. * If this function returns false, the generic controller will be loaded instead
  125642. * @returns Is the client ready to load the mesh
  125643. */
  125644. protected abstract _getModelLoadingConstraints(): boolean;
  125645. /**
  125646. * This function will be called after the model was successfully loaded and can be used
  125647. * for mesh transformations before it is available for the user
  125648. * @param meshes the loaded meshes
  125649. */
  125650. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  125651. /**
  125652. * Set the root mesh for this controller. Important for the WebXR controller class
  125653. * @param meshes the loaded meshes
  125654. */
  125655. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  125656. /**
  125657. * A function executed each frame that updates the mesh (if needed)
  125658. * @param xrFrame the current xrFrame
  125659. */
  125660. protected abstract _updateModel(xrFrame: XRFrame): void;
  125661. private _getGenericFilenameAndPath;
  125662. private _getGenericParentMesh;
  125663. }
  125664. }
  125665. declare module BABYLON {
  125666. /**
  125667. * A generic trigger-only motion controller for WebXR
  125668. */
  125669. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  125670. /**
  125671. * Static version of the profile id of this controller
  125672. */
  125673. static ProfileId: string;
  125674. profileId: string;
  125675. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  125676. protected _getFilenameAndPath(): {
  125677. filename: string;
  125678. path: string;
  125679. };
  125680. protected _getModelLoadingConstraints(): boolean;
  125681. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  125682. protected _setRootMesh(meshes: AbstractMesh[]): void;
  125683. protected _updateModel(): void;
  125684. }
  125685. }
  125686. declare module BABYLON {
  125687. /**
  125688. * Class containing static functions to help procedurally build meshes
  125689. */
  125690. export class SphereBuilder {
  125691. /**
  125692. * Creates a sphere mesh
  125693. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  125694. * * 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`)
  125695. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  125696. * * 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
  125697. * * 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)
  125698. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125699. * * 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
  125700. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125701. * @param name defines the name of the mesh
  125702. * @param options defines the options used to create the mesh
  125703. * @param scene defines the hosting scene
  125704. * @returns the sphere mesh
  125705. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  125706. */
  125707. static CreateSphere(name: string, options: {
  125708. segments?: number;
  125709. diameter?: number;
  125710. diameterX?: number;
  125711. diameterY?: number;
  125712. diameterZ?: number;
  125713. arc?: number;
  125714. slice?: number;
  125715. sideOrientation?: number;
  125716. frontUVs?: Vector4;
  125717. backUVs?: Vector4;
  125718. updatable?: boolean;
  125719. }, scene?: Nullable<Scene>): Mesh;
  125720. }
  125721. }
  125722. declare module BABYLON {
  125723. /**
  125724. * A profiled motion controller has its profile loaded from an online repository.
  125725. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  125726. */
  125727. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  125728. private _repositoryUrl;
  125729. private _buttonMeshMapping;
  125730. private _touchDots;
  125731. /**
  125732. * The profile ID of this controller. Will be populated when the controller initializes.
  125733. */
  125734. profileId: string;
  125735. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  125736. dispose(): void;
  125737. protected _getFilenameAndPath(): {
  125738. filename: string;
  125739. path: string;
  125740. };
  125741. protected _getModelLoadingConstraints(): boolean;
  125742. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  125743. protected _setRootMesh(meshes: AbstractMesh[]): void;
  125744. protected _updateModel(_xrFrame: XRFrame): void;
  125745. }
  125746. }
  125747. declare module BABYLON {
  125748. /**
  125749. * A construction function type to create a new controller based on an xrInput object
  125750. */
  125751. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  125752. /**
  125753. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  125754. *
  125755. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  125756. * it should be replaced with auto-loaded controllers.
  125757. *
  125758. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  125759. */
  125760. export class WebXRMotionControllerManager {
  125761. private static _AvailableControllers;
  125762. private static _Fallbacks;
  125763. private static _ProfileLoadingPromises;
  125764. private static _ProfilesList;
  125765. /**
  125766. * The base URL of the online controller repository. Can be changed at any time.
  125767. */
  125768. static BaseRepositoryUrl: string;
  125769. /**
  125770. * Which repository gets priority - local or online
  125771. */
  125772. static PrioritizeOnlineRepository: boolean;
  125773. /**
  125774. * Use the online repository, or use only locally-defined controllers
  125775. */
  125776. static UseOnlineRepository: boolean;
  125777. /**
  125778. * Clear the cache used for profile loading and reload when requested again
  125779. */
  125780. static ClearProfilesCache(): void;
  125781. /**
  125782. * Register the default fallbacks.
  125783. * This function is called automatically when this file is imported.
  125784. */
  125785. static DefaultFallbacks(): void;
  125786. /**
  125787. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  125788. * @param profileId the profile to which a fallback needs to be found
  125789. * @return an array with corresponding fallback profiles
  125790. */
  125791. static FindFallbackWithProfileId(profileId: string): string[];
  125792. /**
  125793. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  125794. * The order of search:
  125795. *
  125796. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  125797. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  125798. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  125799. * 4) return the generic trigger controller if none were found
  125800. *
  125801. * @param xrInput the xrInput to which a new controller is initialized
  125802. * @param scene the scene to which the model will be added
  125803. * @param forceProfile force a certain profile for this controller
  125804. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  125805. */
  125806. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  125807. /**
  125808. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  125809. *
  125810. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  125811. *
  125812. * @param type the profile type to register
  125813. * @param constructFunction the function to be called when loading this profile
  125814. */
  125815. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  125816. /**
  125817. * Register a fallback to a specific profile.
  125818. * @param profileId the profileId that will receive the fallbacks
  125819. * @param fallbacks A list of fallback profiles
  125820. */
  125821. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  125822. /**
  125823. * Will update the list of profiles available in the repository
  125824. * @return a promise that resolves to a map of profiles available online
  125825. */
  125826. static UpdateProfilesList(): Promise<{
  125827. [profile: string]: string;
  125828. }>;
  125829. private static _LoadProfileFromRepository;
  125830. private static _LoadProfilesFromAvailableControllers;
  125831. }
  125832. }
  125833. declare module BABYLON {
  125834. /**
  125835. * Configuration options for the WebXR controller creation
  125836. */
  125837. export interface IWebXRControllerOptions {
  125838. /**
  125839. * Should the controller mesh be animated when a user interacts with it
  125840. * The pressed buttons / thumbstick and touchpad animations will be disabled
  125841. */
  125842. disableMotionControllerAnimation?: boolean;
  125843. /**
  125844. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  125845. */
  125846. doNotLoadControllerMesh?: boolean;
  125847. /**
  125848. * Force a specific controller type for this controller.
  125849. * This can be used when creating your own profile or when testing different controllers
  125850. */
  125851. forceControllerProfile?: string;
  125852. /**
  125853. * Defines a rendering group ID for meshes that will be loaded.
  125854. * This is for the default controllers only.
  125855. */
  125856. renderingGroupId?: number;
  125857. }
  125858. /**
  125859. * Represents an XR controller
  125860. */
  125861. export class WebXRInputSource {
  125862. private _scene;
  125863. /** The underlying input source for the controller */
  125864. inputSource: XRInputSource;
  125865. private _options;
  125866. private _tmpVector;
  125867. private _uniqueId;
  125868. /**
  125869. * 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
  125870. */
  125871. grip?: AbstractMesh;
  125872. /**
  125873. * If available, this is the gamepad object related to this controller.
  125874. * Using this object it is possible to get click events and trackpad changes of the
  125875. * webxr controller that is currently being used.
  125876. */
  125877. motionController?: WebXRAbstractMotionController;
  125878. /**
  125879. * Event that fires when the controller is removed/disposed.
  125880. * The object provided as event data is this controller, after associated assets were disposed.
  125881. * uniqueId is still available.
  125882. */
  125883. onDisposeObservable: Observable<WebXRInputSource>;
  125884. /**
  125885. * Will be triggered when the mesh associated with the motion controller is done loading.
  125886. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  125887. * A shortened version of controller -> motion controller -> on mesh loaded.
  125888. */
  125889. onMeshLoadedObservable: Observable<AbstractMesh>;
  125890. /**
  125891. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  125892. */
  125893. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  125894. /**
  125895. * Pointer which can be used to select objects or attach a visible laser to
  125896. */
  125897. pointer: AbstractMesh;
  125898. /**
  125899. * Creates the input source object
  125900. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  125901. * @param _scene the scene which the controller should be associated to
  125902. * @param inputSource the underlying input source for the controller
  125903. * @param _options options for this controller creation
  125904. */
  125905. constructor(_scene: Scene,
  125906. /** The underlying input source for the controller */
  125907. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  125908. /**
  125909. * Get this controllers unique id
  125910. */
  125911. get uniqueId(): string;
  125912. /**
  125913. * Disposes of the object
  125914. */
  125915. dispose(): void;
  125916. /**
  125917. * Gets a world space ray coming from the pointer or grip
  125918. * @param result the resulting ray
  125919. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  125920. */
  125921. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  125922. /**
  125923. * Updates the controller pose based on the given XRFrame
  125924. * @param xrFrame xr frame to update the pose with
  125925. * @param referenceSpace reference space to use
  125926. */
  125927. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  125928. }
  125929. }
  125930. declare module BABYLON {
  125931. /**
  125932. * The schema for initialization options of the XR Input class
  125933. */
  125934. export interface IWebXRInputOptions {
  125935. /**
  125936. * If set to true no model will be automatically loaded
  125937. */
  125938. doNotLoadControllerMeshes?: boolean;
  125939. /**
  125940. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  125941. * If not found, the xr input profile data will be used.
  125942. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  125943. */
  125944. forceInputProfile?: string;
  125945. /**
  125946. * Do not send a request to the controller repository to load the profile.
  125947. *
  125948. * Instead, use the controllers available in babylon itself.
  125949. */
  125950. disableOnlineControllerRepository?: boolean;
  125951. /**
  125952. * A custom URL for the controllers repository
  125953. */
  125954. customControllersRepositoryURL?: string;
  125955. /**
  125956. * Should the controller model's components not move according to the user input
  125957. */
  125958. disableControllerAnimation?: boolean;
  125959. /**
  125960. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  125961. */
  125962. controllerOptions?: IWebXRControllerOptions;
  125963. }
  125964. /**
  125965. * XR input used to track XR inputs such as controllers/rays
  125966. */
  125967. export class WebXRInput implements IDisposable {
  125968. /**
  125969. * the xr session manager for this session
  125970. */
  125971. xrSessionManager: WebXRSessionManager;
  125972. /**
  125973. * the WebXR camera for this session. Mainly used for teleportation
  125974. */
  125975. xrCamera: WebXRCamera;
  125976. private readonly options;
  125977. /**
  125978. * XR controllers being tracked
  125979. */
  125980. controllers: Array<WebXRInputSource>;
  125981. private _frameObserver;
  125982. private _sessionEndedObserver;
  125983. private _sessionInitObserver;
  125984. /**
  125985. * Event when a controller has been connected/added
  125986. */
  125987. onControllerAddedObservable: Observable<WebXRInputSource>;
  125988. /**
  125989. * Event when a controller has been removed/disconnected
  125990. */
  125991. onControllerRemovedObservable: Observable<WebXRInputSource>;
  125992. /**
  125993. * Initializes the WebXRInput
  125994. * @param xrSessionManager the xr session manager for this session
  125995. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  125996. * @param options = initialization options for this xr input
  125997. */
  125998. constructor(
  125999. /**
  126000. * the xr session manager for this session
  126001. */
  126002. xrSessionManager: WebXRSessionManager,
  126003. /**
  126004. * the WebXR camera for this session. Mainly used for teleportation
  126005. */
  126006. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  126007. private _onInputSourcesChange;
  126008. private _addAndRemoveControllers;
  126009. /**
  126010. * Disposes of the object
  126011. */
  126012. dispose(): void;
  126013. }
  126014. }
  126015. declare module BABYLON {
  126016. /**
  126017. * This is the base class for all WebXR features.
  126018. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  126019. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  126020. */
  126021. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  126022. protected _xrSessionManager: WebXRSessionManager;
  126023. private _attached;
  126024. private _removeOnDetach;
  126025. /**
  126026. * Should auto-attach be disabled?
  126027. */
  126028. disableAutoAttach: boolean;
  126029. /**
  126030. * Construct a new (abstract) WebXR feature
  126031. * @param _xrSessionManager the xr session manager for this feature
  126032. */
  126033. constructor(_xrSessionManager: WebXRSessionManager);
  126034. /**
  126035. * Is this feature attached
  126036. */
  126037. get attached(): boolean;
  126038. /**
  126039. * attach this feature
  126040. *
  126041. * @param force should attachment be forced (even when already attached)
  126042. * @returns true if successful, false is failed or already attached
  126043. */
  126044. attach(force?: boolean): boolean;
  126045. /**
  126046. * detach this feature.
  126047. *
  126048. * @returns true if successful, false if failed or already detached
  126049. */
  126050. detach(): boolean;
  126051. /**
  126052. * Dispose this feature and all of the resources attached
  126053. */
  126054. dispose(): void;
  126055. /**
  126056. * This is used to register callbacks that will automatically be removed when detach is called.
  126057. * @param observable the observable to which the observer will be attached
  126058. * @param callback the callback to register
  126059. */
  126060. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  126061. /**
  126062. * Code in this function will be executed on each xrFrame received from the browser.
  126063. * This function will not execute after the feature is detached.
  126064. * @param _xrFrame the current frame
  126065. */
  126066. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  126067. }
  126068. }
  126069. declare module BABYLON {
  126070. /**
  126071. * Renders a layer on top of an existing scene
  126072. */
  126073. export class UtilityLayerRenderer implements IDisposable {
  126074. /** the original scene that will be rendered on top of */
  126075. originalScene: Scene;
  126076. private _pointerCaptures;
  126077. private _lastPointerEvents;
  126078. private static _DefaultUtilityLayer;
  126079. private static _DefaultKeepDepthUtilityLayer;
  126080. private _sharedGizmoLight;
  126081. private _renderCamera;
  126082. /**
  126083. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  126084. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  126085. * @returns the camera that is used when rendering the utility layer
  126086. */
  126087. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  126088. /**
  126089. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  126090. * @param cam the camera that should be used when rendering the utility layer
  126091. */
  126092. setRenderCamera(cam: Nullable<Camera>): void;
  126093. /**
  126094. * @hidden
  126095. * Light which used by gizmos to get light shading
  126096. */
  126097. _getSharedGizmoLight(): HemisphericLight;
  126098. /**
  126099. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  126100. */
  126101. pickUtilitySceneFirst: boolean;
  126102. /**
  126103. * 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)
  126104. */
  126105. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  126106. /**
  126107. * 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)
  126108. */
  126109. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  126110. /**
  126111. * The scene that is rendered on top of the original scene
  126112. */
  126113. utilityLayerScene: Scene;
  126114. /**
  126115. * If the utility layer should automatically be rendered on top of existing scene
  126116. */
  126117. shouldRender: boolean;
  126118. /**
  126119. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  126120. */
  126121. onlyCheckPointerDownEvents: boolean;
  126122. /**
  126123. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  126124. */
  126125. processAllEvents: boolean;
  126126. /**
  126127. * Observable raised when the pointer move from the utility layer scene to the main scene
  126128. */
  126129. onPointerOutObservable: Observable<number>;
  126130. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  126131. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  126132. private _afterRenderObserver;
  126133. private _sceneDisposeObserver;
  126134. private _originalPointerObserver;
  126135. /**
  126136. * Instantiates a UtilityLayerRenderer
  126137. * @param originalScene the original scene that will be rendered on top of
  126138. * @param handleEvents boolean indicating if the utility layer should handle events
  126139. */
  126140. constructor(
  126141. /** the original scene that will be rendered on top of */
  126142. originalScene: Scene, handleEvents?: boolean);
  126143. private _notifyObservers;
  126144. /**
  126145. * Renders the utility layers scene on top of the original scene
  126146. */
  126147. render(): void;
  126148. /**
  126149. * Disposes of the renderer
  126150. */
  126151. dispose(): void;
  126152. private _updateCamera;
  126153. }
  126154. }
  126155. declare module BABYLON {
  126156. /**
  126157. * Options interface for the pointer selection module
  126158. */
  126159. export interface IWebXRControllerPointerSelectionOptions {
  126160. /**
  126161. * if provided, this scene will be used to render meshes.
  126162. */
  126163. customUtilityLayerScene?: Scene;
  126164. /**
  126165. * Disable the pointer up event when the xr controller in screen and gaze mode is disposed (meaning - when the user removed the finger from the screen)
  126166. * If not disabled, the last picked point will be used to execute a pointer up event
  126167. * If disabled, pointer up event will be triggered right after the pointer down event.
  126168. * Used in screen and gaze target ray mode only
  126169. */
  126170. disablePointerUpOnTouchOut: boolean;
  126171. /**
  126172. * For gaze mode (time to select instead of press)
  126173. */
  126174. forceGazeMode: boolean;
  126175. /**
  126176. * Factor to be applied to the pointer-moved function in the gaze mode. How sensitive should the gaze mode be when checking if the pointer moved
  126177. * to start a new countdown to the pointer down event.
  126178. * Defaults to 1.
  126179. */
  126180. gazeModePointerMovedFactor?: number;
  126181. /**
  126182. * Different button type to use instead of the main component
  126183. */
  126184. overrideButtonId?: string;
  126185. /**
  126186. * use this rendering group id for the meshes (optional)
  126187. */
  126188. renderingGroupId?: number;
  126189. /**
  126190. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  126191. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  126192. * 3000 means 3 seconds between pointing at something and selecting it
  126193. */
  126194. timeToSelect?: number;
  126195. /**
  126196. * Should meshes created here be added to a utility layer or the main scene
  126197. */
  126198. useUtilityLayer?: boolean;
  126199. /**
  126200. * the xr input to use with this pointer selection
  126201. */
  126202. xrInput: WebXRInput;
  126203. }
  126204. /**
  126205. * A module that will enable pointer selection for motion controllers of XR Input Sources
  126206. */
  126207. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  126208. private readonly _options;
  126209. private static _idCounter;
  126210. private _attachController;
  126211. private _controllers;
  126212. private _scene;
  126213. private _tmpVectorForPickCompare;
  126214. /**
  126215. * The module's name
  126216. */
  126217. static readonly Name: string;
  126218. /**
  126219. * The (Babylon) version of this module.
  126220. * This is an integer representing the implementation version.
  126221. * This number does not correspond to the WebXR specs version
  126222. */
  126223. static readonly Version: number;
  126224. /**
  126225. * Disable lighting on the laser pointer (so it will always be visible)
  126226. */
  126227. disablePointerLighting: boolean;
  126228. /**
  126229. * Disable lighting on the selection mesh (so it will always be visible)
  126230. */
  126231. disableSelectionMeshLighting: boolean;
  126232. /**
  126233. * Should the laser pointer be displayed
  126234. */
  126235. displayLaserPointer: boolean;
  126236. /**
  126237. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  126238. */
  126239. displaySelectionMesh: boolean;
  126240. /**
  126241. * This color will be set to the laser pointer when selection is triggered
  126242. */
  126243. laserPointerPickedColor: Color3;
  126244. /**
  126245. * Default color of the laser pointer
  126246. */
  126247. laserPointerDefaultColor: Color3;
  126248. /**
  126249. * default color of the selection ring
  126250. */
  126251. selectionMeshDefaultColor: Color3;
  126252. /**
  126253. * This color will be applied to the selection ring when selection is triggered
  126254. */
  126255. selectionMeshPickedColor: Color3;
  126256. /**
  126257. * Optional filter to be used for ray selection. This predicate shares behavior with
  126258. * scene.pointerMovePredicate which takes priority if it is also assigned.
  126259. */
  126260. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  126261. /**
  126262. * constructs a new background remover module
  126263. * @param _xrSessionManager the session manager for this module
  126264. * @param _options read-only options to be used in this module
  126265. */
  126266. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  126267. /**
  126268. * attach this feature
  126269. * Will usually be called by the features manager
  126270. *
  126271. * @returns true if successful.
  126272. */
  126273. attach(): boolean;
  126274. /**
  126275. * detach this feature.
  126276. * Will usually be called by the features manager
  126277. *
  126278. * @returns true if successful.
  126279. */
  126280. detach(): boolean;
  126281. /**
  126282. * Will get the mesh under a specific pointer.
  126283. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  126284. * @param controllerId the controllerId to check
  126285. * @returns The mesh under pointer or null if no mesh is under the pointer
  126286. */
  126287. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  126288. /**
  126289. * Get the xr controller that correlates to the pointer id in the pointer event
  126290. *
  126291. * @param id the pointer id to search for
  126292. * @returns the controller that correlates to this id or null if not found
  126293. */
  126294. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  126295. protected _onXRFrame(_xrFrame: XRFrame): void;
  126296. private _attachGazeMode;
  126297. private _attachScreenRayMode;
  126298. private _attachTrackedPointerRayMode;
  126299. private _convertNormalToDirectionOfRay;
  126300. private _detachController;
  126301. private _generateNewMeshPair;
  126302. private _pickingMoved;
  126303. private _updatePointerDistance;
  126304. /** @hidden */
  126305. get lasterPointerDefaultColor(): Color3;
  126306. }
  126307. }
  126308. declare module BABYLON {
  126309. /**
  126310. * Button which can be used to enter a different mode of XR
  126311. */
  126312. export class WebXREnterExitUIButton {
  126313. /** button element */
  126314. element: HTMLElement;
  126315. /** XR initialization options for the button */
  126316. sessionMode: XRSessionMode;
  126317. /** Reference space type */
  126318. referenceSpaceType: XRReferenceSpaceType;
  126319. /**
  126320. * Creates a WebXREnterExitUIButton
  126321. * @param element button element
  126322. * @param sessionMode XR initialization session mode
  126323. * @param referenceSpaceType the type of reference space to be used
  126324. */
  126325. constructor(
  126326. /** button element */
  126327. element: HTMLElement,
  126328. /** XR initialization options for the button */
  126329. sessionMode: XRSessionMode,
  126330. /** Reference space type */
  126331. referenceSpaceType: XRReferenceSpaceType);
  126332. /**
  126333. * Extendable function which can be used to update the button's visuals when the state changes
  126334. * @param activeButton the current active button in the UI
  126335. */
  126336. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  126337. }
  126338. /**
  126339. * Options to create the webXR UI
  126340. */
  126341. export class WebXREnterExitUIOptions {
  126342. /**
  126343. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  126344. */
  126345. customButtons?: Array<WebXREnterExitUIButton>;
  126346. /**
  126347. * A reference space type to use when creating the default button.
  126348. * Default is local-floor
  126349. */
  126350. referenceSpaceType?: XRReferenceSpaceType;
  126351. /**
  126352. * Context to enter xr with
  126353. */
  126354. renderTarget?: Nullable<WebXRRenderTarget>;
  126355. /**
  126356. * A session mode to use when creating the default button.
  126357. * Default is immersive-vr
  126358. */
  126359. sessionMode?: XRSessionMode;
  126360. /**
  126361. * A list of optional features to init the session with
  126362. */
  126363. optionalFeatures?: string[];
  126364. }
  126365. /**
  126366. * UI to allow the user to enter/exit XR mode
  126367. */
  126368. export class WebXREnterExitUI implements IDisposable {
  126369. private scene;
  126370. /** version of the options passed to this UI */
  126371. options: WebXREnterExitUIOptions;
  126372. private _activeButton;
  126373. private _buttons;
  126374. private _overlay;
  126375. /**
  126376. * Fired every time the active button is changed.
  126377. *
  126378. * When xr is entered via a button that launches xr that button will be the callback parameter
  126379. *
  126380. * When exiting xr the callback parameter will be null)
  126381. */
  126382. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  126383. /**
  126384. *
  126385. * @param scene babylon scene object to use
  126386. * @param options (read-only) version of the options passed to this UI
  126387. */
  126388. private constructor();
  126389. /**
  126390. * Creates UI to allow the user to enter/exit XR mode
  126391. * @param scene the scene to add the ui to
  126392. * @param helper the xr experience helper to enter/exit xr with
  126393. * @param options options to configure the UI
  126394. * @returns the created ui
  126395. */
  126396. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  126397. /**
  126398. * Disposes of the XR UI component
  126399. */
  126400. dispose(): void;
  126401. private _updateButtons;
  126402. }
  126403. }
  126404. declare module BABYLON {
  126405. /**
  126406. * Class containing static functions to help procedurally build meshes
  126407. */
  126408. export class LinesBuilder {
  126409. /**
  126410. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  126411. * * 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
  126412. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  126413. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  126414. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  126415. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  126416. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  126417. * * 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
  126418. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  126419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126420. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  126421. * @param name defines the name of the new line system
  126422. * @param options defines the options used to create the line system
  126423. * @param scene defines the hosting scene
  126424. * @returns a new line system mesh
  126425. */
  126426. static CreateLineSystem(name: string, options: {
  126427. lines: Vector3[][];
  126428. updatable?: boolean;
  126429. instance?: Nullable<LinesMesh>;
  126430. colors?: Nullable<Color4[][]>;
  126431. useVertexAlpha?: boolean;
  126432. }, scene: Nullable<Scene>): LinesMesh;
  126433. /**
  126434. * Creates a line mesh
  126435. * 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
  126436. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  126437. * * The parameter `points` is an array successive Vector3
  126438. * * 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
  126439. * * The optional parameter `colors` is an array of successive Color4, one per line point
  126440. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  126441. * * When updating an instance, remember that only point positions can change, not the number of points
  126442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126443. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  126444. * @param name defines the name of the new line system
  126445. * @param options defines the options used to create the line system
  126446. * @param scene defines the hosting scene
  126447. * @returns a new line mesh
  126448. */
  126449. static CreateLines(name: string, options: {
  126450. points: Vector3[];
  126451. updatable?: boolean;
  126452. instance?: Nullable<LinesMesh>;
  126453. colors?: Color4[];
  126454. useVertexAlpha?: boolean;
  126455. }, scene?: Nullable<Scene>): LinesMesh;
  126456. /**
  126457. * Creates a dashed line mesh
  126458. * * 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
  126459. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  126460. * * The parameter `points` is an array successive Vector3
  126461. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  126462. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  126463. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  126464. * * 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
  126465. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  126466. * * When updating an instance, remember that only point positions can change, not the number of points
  126467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126468. * @param name defines the name of the mesh
  126469. * @param options defines the options used to create the mesh
  126470. * @param scene defines the hosting scene
  126471. * @returns the dashed line mesh
  126472. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  126473. */
  126474. static CreateDashedLines(name: string, options: {
  126475. points: Vector3[];
  126476. dashSize?: number;
  126477. gapSize?: number;
  126478. dashNb?: number;
  126479. updatable?: boolean;
  126480. instance?: LinesMesh;
  126481. useVertexAlpha?: boolean;
  126482. }, scene?: Nullable<Scene>): LinesMesh;
  126483. }
  126484. }
  126485. declare module BABYLON {
  126486. /**
  126487. * Construction options for a timer
  126488. */
  126489. export interface ITimerOptions<T> {
  126490. /**
  126491. * Time-to-end
  126492. */
  126493. timeout: number;
  126494. /**
  126495. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  126496. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  126497. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  126498. */
  126499. contextObservable: Observable<T>;
  126500. /**
  126501. * Optional parameters when adding an observer to the observable
  126502. */
  126503. observableParameters?: {
  126504. mask?: number;
  126505. insertFirst?: boolean;
  126506. scope?: any;
  126507. };
  126508. /**
  126509. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  126510. */
  126511. breakCondition?: (data?: ITimerData<T>) => boolean;
  126512. /**
  126513. * Will be triggered when the time condition has met
  126514. */
  126515. onEnded?: (data: ITimerData<any>) => void;
  126516. /**
  126517. * Will be triggered when the break condition has met (prematurely ended)
  126518. */
  126519. onAborted?: (data: ITimerData<any>) => void;
  126520. /**
  126521. * Optional function to execute on each tick (or count)
  126522. */
  126523. onTick?: (data: ITimerData<any>) => void;
  126524. }
  126525. /**
  126526. * An interface defining the data sent by the timer
  126527. */
  126528. export interface ITimerData<T> {
  126529. /**
  126530. * When did it start
  126531. */
  126532. startTime: number;
  126533. /**
  126534. * Time now
  126535. */
  126536. currentTime: number;
  126537. /**
  126538. * Time passed since started
  126539. */
  126540. deltaTime: number;
  126541. /**
  126542. * How much is completed, in [0.0...1.0].
  126543. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  126544. */
  126545. completeRate: number;
  126546. /**
  126547. * What the registered observable sent in the last count
  126548. */
  126549. payload: T;
  126550. }
  126551. /**
  126552. * The current state of the timer
  126553. */
  126554. export enum TimerState {
  126555. /**
  126556. * Timer initialized, not yet started
  126557. */
  126558. INIT = 0,
  126559. /**
  126560. * Timer started and counting
  126561. */
  126562. STARTED = 1,
  126563. /**
  126564. * Timer ended (whether aborted or time reached)
  126565. */
  126566. ENDED = 2
  126567. }
  126568. /**
  126569. * A simple version of the timer. Will take options and start the timer immediately after calling it
  126570. *
  126571. * @param options options with which to initialize this timer
  126572. */
  126573. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  126574. /**
  126575. * An advanced implementation of a timer class
  126576. */
  126577. export class AdvancedTimer<T = any> implements IDisposable {
  126578. /**
  126579. * Will notify each time the timer calculates the remaining time
  126580. */
  126581. onEachCountObservable: Observable<ITimerData<T>>;
  126582. /**
  126583. * Will trigger when the timer was aborted due to the break condition
  126584. */
  126585. onTimerAbortedObservable: Observable<ITimerData<T>>;
  126586. /**
  126587. * Will trigger when the timer ended successfully
  126588. */
  126589. onTimerEndedObservable: Observable<ITimerData<T>>;
  126590. /**
  126591. * Will trigger when the timer state has changed
  126592. */
  126593. onStateChangedObservable: Observable<TimerState>;
  126594. private _observer;
  126595. private _contextObservable;
  126596. private _observableParameters;
  126597. private _startTime;
  126598. private _timer;
  126599. private _state;
  126600. private _breakCondition;
  126601. private _timeToEnd;
  126602. private _breakOnNextTick;
  126603. /**
  126604. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  126605. * @param options construction options for this advanced timer
  126606. */
  126607. constructor(options: ITimerOptions<T>);
  126608. /**
  126609. * set a breaking condition for this timer. Default is to never break during count
  126610. * @param predicate the new break condition. Returns true to break, false otherwise
  126611. */
  126612. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  126613. /**
  126614. * Reset ALL associated observables in this advanced timer
  126615. */
  126616. clearObservables(): void;
  126617. /**
  126618. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  126619. *
  126620. * @param timeToEnd how much time to measure until timer ended
  126621. */
  126622. start(timeToEnd?: number): void;
  126623. /**
  126624. * Will force a stop on the next tick.
  126625. */
  126626. stop(): void;
  126627. /**
  126628. * Dispose this timer, clearing all resources
  126629. */
  126630. dispose(): void;
  126631. private _setState;
  126632. private _tick;
  126633. private _stop;
  126634. }
  126635. }
  126636. declare module BABYLON {
  126637. /**
  126638. * The options container for the teleportation module
  126639. */
  126640. export interface IWebXRTeleportationOptions {
  126641. /**
  126642. * if provided, this scene will be used to render meshes.
  126643. */
  126644. customUtilityLayerScene?: Scene;
  126645. /**
  126646. * Values to configure the default target mesh
  126647. */
  126648. defaultTargetMeshOptions?: {
  126649. /**
  126650. * Fill color of the teleportation area
  126651. */
  126652. teleportationFillColor?: string;
  126653. /**
  126654. * Border color for the teleportation area
  126655. */
  126656. teleportationBorderColor?: string;
  126657. /**
  126658. * Disable the mesh's animation sequence
  126659. */
  126660. disableAnimation?: boolean;
  126661. /**
  126662. * Disable lighting on the material or the ring and arrow
  126663. */
  126664. disableLighting?: boolean;
  126665. /**
  126666. * Override the default material of the torus and arrow
  126667. */
  126668. torusArrowMaterial?: Material;
  126669. };
  126670. /**
  126671. * A list of meshes to use as floor meshes.
  126672. * Meshes can be added and removed after initializing the feature using the
  126673. * addFloorMesh and removeFloorMesh functions
  126674. * If empty, rotation will still work
  126675. */
  126676. floorMeshes?: AbstractMesh[];
  126677. /**
  126678. * use this rendering group id for the meshes (optional)
  126679. */
  126680. renderingGroupId?: number;
  126681. /**
  126682. * Should teleportation move only to snap points
  126683. */
  126684. snapPointsOnly?: boolean;
  126685. /**
  126686. * An array of points to which the teleportation will snap to.
  126687. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  126688. */
  126689. snapPositions?: Vector3[];
  126690. /**
  126691. * How close should the teleportation ray be in order to snap to position.
  126692. * Default to 0.8 units (meters)
  126693. */
  126694. snapToPositionRadius?: number;
  126695. /**
  126696. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  126697. * If you want to support rotation, make sure your mesh has a direction indicator.
  126698. *
  126699. * When left untouched, the default mesh will be initialized.
  126700. */
  126701. teleportationTargetMesh?: AbstractMesh;
  126702. /**
  126703. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  126704. */
  126705. timeToTeleport?: number;
  126706. /**
  126707. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  126708. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  126709. */
  126710. useMainComponentOnly?: boolean;
  126711. /**
  126712. * Should meshes created here be added to a utility layer or the main scene
  126713. */
  126714. useUtilityLayer?: boolean;
  126715. /**
  126716. * Babylon XR Input class for controller
  126717. */
  126718. xrInput: WebXRInput;
  126719. }
  126720. /**
  126721. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  126722. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  126723. * the input of the attached controllers.
  126724. */
  126725. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  126726. private _options;
  126727. private _controllers;
  126728. private _currentTeleportationControllerId;
  126729. private _floorMeshes;
  126730. private _quadraticBezierCurve;
  126731. private _selectionFeature;
  126732. private _snapToPositions;
  126733. private _snappedToPoint;
  126734. private _teleportationRingMaterial?;
  126735. private _tmpRay;
  126736. private _tmpVector;
  126737. /**
  126738. * The module's name
  126739. */
  126740. static readonly Name: string;
  126741. /**
  126742. * The (Babylon) version of this module.
  126743. * This is an integer representing the implementation version.
  126744. * This number does not correspond to the webxr specs version
  126745. */
  126746. static readonly Version: number;
  126747. /**
  126748. * Is movement backwards enabled
  126749. */
  126750. backwardsMovementEnabled: boolean;
  126751. /**
  126752. * Distance to travel when moving backwards
  126753. */
  126754. backwardsTeleportationDistance: number;
  126755. /**
  126756. * The distance from the user to the inspection point in the direction of the controller
  126757. * A higher number will allow the user to move further
  126758. * defaults to 5 (meters, in xr units)
  126759. */
  126760. parabolicCheckRadius: number;
  126761. /**
  126762. * Should the module support parabolic ray on top of direct ray
  126763. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  126764. * Very helpful when moving between floors / different heights
  126765. */
  126766. parabolicRayEnabled: boolean;
  126767. /**
  126768. * How much rotation should be applied when rotating right and left
  126769. */
  126770. rotationAngle: number;
  126771. /**
  126772. * Is rotation enabled when moving forward?
  126773. * Disabling this feature will prevent the user from deciding the direction when teleporting
  126774. */
  126775. rotationEnabled: boolean;
  126776. /**
  126777. * constructs a new anchor system
  126778. * @param _xrSessionManager an instance of WebXRSessionManager
  126779. * @param _options configuration object for this feature
  126780. */
  126781. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  126782. /**
  126783. * Get the snapPointsOnly flag
  126784. */
  126785. get snapPointsOnly(): boolean;
  126786. /**
  126787. * Sets the snapPointsOnly flag
  126788. * @param snapToPoints should teleportation be exclusively to snap points
  126789. */
  126790. set snapPointsOnly(snapToPoints: boolean);
  126791. /**
  126792. * Add a new mesh to the floor meshes array
  126793. * @param mesh the mesh to use as floor mesh
  126794. */
  126795. addFloorMesh(mesh: AbstractMesh): void;
  126796. /**
  126797. * Add a new snap-to point to fix teleportation to this position
  126798. * @param newSnapPoint The new Snap-To point
  126799. */
  126800. addSnapPoint(newSnapPoint: Vector3): void;
  126801. attach(): boolean;
  126802. detach(): boolean;
  126803. dispose(): void;
  126804. /**
  126805. * Remove a mesh from the floor meshes array
  126806. * @param mesh the mesh to remove
  126807. */
  126808. removeFloorMesh(mesh: AbstractMesh): void;
  126809. /**
  126810. * Remove a mesh from the floor meshes array using its name
  126811. * @param name the mesh name to remove
  126812. */
  126813. removeFloorMeshByName(name: string): void;
  126814. /**
  126815. * This function will iterate through the array, searching for this point or equal to it. It will then remove it from the snap-to array
  126816. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  126817. * @returns was the point found and removed or not
  126818. */
  126819. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  126820. /**
  126821. * This function sets a selection feature that will be disabled when
  126822. * the forward ray is shown and will be reattached when hidden.
  126823. * This is used to remove the selection rays when moving.
  126824. * @param selectionFeature the feature to disable when forward movement is enabled
  126825. */
  126826. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  126827. protected _onXRFrame(_xrFrame: XRFrame): void;
  126828. private _attachController;
  126829. private _createDefaultTargetMesh;
  126830. private _detachController;
  126831. private _findClosestSnapPointWithRadius;
  126832. private _setTargetMeshPosition;
  126833. private _setTargetMeshVisibility;
  126834. private _showParabolicPath;
  126835. private _teleportForward;
  126836. }
  126837. }
  126838. declare module BABYLON {
  126839. /**
  126840. * Options for the default xr helper
  126841. */
  126842. export class WebXRDefaultExperienceOptions {
  126843. /**
  126844. * Enable or disable default UI to enter XR
  126845. */
  126846. disableDefaultUI?: boolean;
  126847. /**
  126848. * Should teleportation not initialize. defaults to false.
  126849. */
  126850. disableTeleportation?: boolean;
  126851. /**
  126852. * Floor meshes that will be used for teleport
  126853. */
  126854. floorMeshes?: Array<AbstractMesh>;
  126855. /**
  126856. * If set to true, the first frame will not be used to reset position
  126857. * The first frame is mainly used when copying transformation from the old camera
  126858. * Mainly used in AR
  126859. */
  126860. ignoreNativeCameraTransformation?: boolean;
  126861. /**
  126862. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  126863. */
  126864. inputOptions?: IWebXRInputOptions;
  126865. /**
  126866. * optional configuration for the output canvas
  126867. */
  126868. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  126869. /**
  126870. * optional UI options. This can be used among other to change session mode and reference space type
  126871. */
  126872. uiOptions?: WebXREnterExitUIOptions;
  126873. /**
  126874. * When loading teleportation and pointer select, use stable versions instead of latest.
  126875. */
  126876. useStablePlugins?: boolean;
  126877. /**
  126878. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  126879. */
  126880. renderingGroupId?: number;
  126881. /**
  126882. * A list of optional features to init the session with
  126883. * If set to true, all features we support will be added
  126884. */
  126885. optionalFeatures?: boolean | string[];
  126886. }
  126887. /**
  126888. * Default experience which provides a similar setup to the previous webVRExperience
  126889. */
  126890. export class WebXRDefaultExperience {
  126891. /**
  126892. * Base experience
  126893. */
  126894. baseExperience: WebXRExperienceHelper;
  126895. /**
  126896. * Enables ui for entering/exiting xr
  126897. */
  126898. enterExitUI: WebXREnterExitUI;
  126899. /**
  126900. * Input experience extension
  126901. */
  126902. input: WebXRInput;
  126903. /**
  126904. * Enables laser pointer and selection
  126905. */
  126906. pointerSelection: WebXRControllerPointerSelection;
  126907. /**
  126908. * Default target xr should render to
  126909. */
  126910. renderTarget: WebXRRenderTarget;
  126911. /**
  126912. * Enables teleportation
  126913. */
  126914. teleportation: WebXRMotionControllerTeleportation;
  126915. private constructor();
  126916. /**
  126917. * Creates the default xr experience
  126918. * @param scene scene
  126919. * @param options options for basic configuration
  126920. * @returns resulting WebXRDefaultExperience
  126921. */
  126922. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  126923. /**
  126924. * DIsposes of the experience helper
  126925. */
  126926. dispose(): void;
  126927. }
  126928. }
  126929. declare module BABYLON {
  126930. /**
  126931. * Options to modify the vr teleportation behavior.
  126932. */
  126933. export interface VRTeleportationOptions {
  126934. /**
  126935. * The name of the mesh which should be used as the teleportation floor. (default: null)
  126936. */
  126937. floorMeshName?: string;
  126938. /**
  126939. * A list of meshes to be used as the teleportation floor. (default: empty)
  126940. */
  126941. floorMeshes?: Mesh[];
  126942. /**
  126943. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  126944. */
  126945. teleportationMode?: number;
  126946. /**
  126947. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  126948. */
  126949. teleportationTime?: number;
  126950. /**
  126951. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  126952. */
  126953. teleportationSpeed?: number;
  126954. /**
  126955. * The easing function used in the animation or null for Linear. (default CircleEase)
  126956. */
  126957. easingFunction?: EasingFunction;
  126958. }
  126959. /**
  126960. * Options to modify the vr experience helper's behavior.
  126961. */
  126962. export interface VRExperienceHelperOptions extends WebVROptions {
  126963. /**
  126964. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  126965. */
  126966. createDeviceOrientationCamera?: boolean;
  126967. /**
  126968. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  126969. */
  126970. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  126971. /**
  126972. * Uses the main button on the controller to toggle the laser casted. (default: true)
  126973. */
  126974. laserToggle?: boolean;
  126975. /**
  126976. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  126977. */
  126978. floorMeshes?: Mesh[];
  126979. /**
  126980. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  126981. */
  126982. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  126983. /**
  126984. * Defines if WebXR should be used instead of WebVR (if available)
  126985. */
  126986. useXR?: boolean;
  126987. }
  126988. /**
  126989. * Event containing information after VR has been entered
  126990. */
  126991. export class OnAfterEnteringVRObservableEvent {
  126992. /**
  126993. * If entering vr was successful
  126994. */
  126995. success: boolean;
  126996. }
  126997. /**
  126998. * Helps to quickly add VR support to an existing scene.
  126999. * See https://doc.babylonjs.com/how_to/webvr_helper
  127000. */
  127001. export class VRExperienceHelper {
  127002. /** Options to modify the vr experience helper's behavior. */
  127003. webVROptions: VRExperienceHelperOptions;
  127004. private _scene;
  127005. private _position;
  127006. private _btnVR;
  127007. private _btnVRDisplayed;
  127008. private _webVRsupported;
  127009. private _webVRready;
  127010. private _webVRrequesting;
  127011. private _webVRpresenting;
  127012. private _hasEnteredVR;
  127013. private _fullscreenVRpresenting;
  127014. private _inputElement;
  127015. private _webVRCamera;
  127016. private _vrDeviceOrientationCamera;
  127017. private _deviceOrientationCamera;
  127018. private _existingCamera;
  127019. private _onKeyDown;
  127020. private _onVrDisplayPresentChange;
  127021. private _onVRDisplayChanged;
  127022. private _onVRRequestPresentStart;
  127023. private _onVRRequestPresentComplete;
  127024. /**
  127025. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  127026. */
  127027. enableGazeEvenWhenNoPointerLock: boolean;
  127028. /**
  127029. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  127030. */
  127031. exitVROnDoubleTap: boolean;
  127032. /**
  127033. * Observable raised right before entering VR.
  127034. */
  127035. onEnteringVRObservable: Observable<VRExperienceHelper>;
  127036. /**
  127037. * Observable raised when entering VR has completed.
  127038. */
  127039. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  127040. /**
  127041. * Observable raised when exiting VR.
  127042. */
  127043. onExitingVRObservable: Observable<VRExperienceHelper>;
  127044. /**
  127045. * Observable raised when controller mesh is loaded.
  127046. */
  127047. onControllerMeshLoadedObservable: Observable<WebVRController>;
  127048. /** Return this.onEnteringVRObservable
  127049. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  127050. */
  127051. get onEnteringVR(): Observable<VRExperienceHelper>;
  127052. /** Return this.onExitingVRObservable
  127053. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  127054. */
  127055. get onExitingVR(): Observable<VRExperienceHelper>;
  127056. /** Return this.onControllerMeshLoadedObservable
  127057. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  127058. */
  127059. get onControllerMeshLoaded(): Observable<WebVRController>;
  127060. private _rayLength;
  127061. private _useCustomVRButton;
  127062. private _teleportationRequested;
  127063. private _teleportActive;
  127064. private _floorMeshName;
  127065. private _floorMeshesCollection;
  127066. private _teleportationMode;
  127067. private _teleportationTime;
  127068. private _teleportationSpeed;
  127069. private _teleportationEasing;
  127070. private _rotationAllowed;
  127071. private _teleportBackwardsVector;
  127072. private _teleportationTarget;
  127073. private _isDefaultTeleportationTarget;
  127074. private _postProcessMove;
  127075. private _teleportationFillColor;
  127076. private _teleportationBorderColor;
  127077. private _rotationAngle;
  127078. private _haloCenter;
  127079. private _cameraGazer;
  127080. private _padSensibilityUp;
  127081. private _padSensibilityDown;
  127082. private _leftController;
  127083. private _rightController;
  127084. private _gazeColor;
  127085. private _laserColor;
  127086. private _pickedLaserColor;
  127087. private _pickedGazeColor;
  127088. /**
  127089. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  127090. */
  127091. onNewMeshSelected: Observable<AbstractMesh>;
  127092. /**
  127093. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  127094. * This observable will provide the mesh and the controller used to select the mesh
  127095. */
  127096. onMeshSelectedWithController: Observable<{
  127097. mesh: AbstractMesh;
  127098. controller: WebVRController;
  127099. }>;
  127100. /**
  127101. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  127102. */
  127103. onNewMeshPicked: Observable<PickingInfo>;
  127104. private _circleEase;
  127105. /**
  127106. * Observable raised before camera teleportation
  127107. */
  127108. onBeforeCameraTeleport: Observable<Vector3>;
  127109. /**
  127110. * Observable raised after camera teleportation
  127111. */
  127112. onAfterCameraTeleport: Observable<Vector3>;
  127113. /**
  127114. * Observable raised when current selected mesh gets unselected
  127115. */
  127116. onSelectedMeshUnselected: Observable<AbstractMesh>;
  127117. private _raySelectionPredicate;
  127118. /**
  127119. * To be optionaly changed by user to define custom ray selection
  127120. */
  127121. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  127122. /**
  127123. * To be optionaly changed by user to define custom selection logic (after ray selection)
  127124. */
  127125. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  127126. /**
  127127. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  127128. */
  127129. teleportationEnabled: boolean;
  127130. private _defaultHeight;
  127131. private _teleportationInitialized;
  127132. private _interactionsEnabled;
  127133. private _interactionsRequested;
  127134. private _displayGaze;
  127135. private _displayLaserPointer;
  127136. /**
  127137. * The mesh used to display where the user is going to teleport.
  127138. */
  127139. get teleportationTarget(): Mesh;
  127140. /**
  127141. * Sets the mesh to be used to display where the user is going to teleport.
  127142. */
  127143. set teleportationTarget(value: Mesh);
  127144. /**
  127145. * 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
  127146. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  127147. * See https://doc.babylonjs.com/resources/baking_transformations
  127148. */
  127149. get gazeTrackerMesh(): Mesh;
  127150. set gazeTrackerMesh(value: Mesh);
  127151. /**
  127152. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  127153. */
  127154. updateGazeTrackerScale: boolean;
  127155. /**
  127156. * If the gaze trackers color should be updated when selecting meshes
  127157. */
  127158. updateGazeTrackerColor: boolean;
  127159. /**
  127160. * If the controller laser color should be updated when selecting meshes
  127161. */
  127162. updateControllerLaserColor: boolean;
  127163. /**
  127164. * The gaze tracking mesh corresponding to the left controller
  127165. */
  127166. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  127167. /**
  127168. * The gaze tracking mesh corresponding to the right controller
  127169. */
  127170. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  127171. /**
  127172. * If the ray of the gaze should be displayed.
  127173. */
  127174. get displayGaze(): boolean;
  127175. /**
  127176. * Sets if the ray of the gaze should be displayed.
  127177. */
  127178. set displayGaze(value: boolean);
  127179. /**
  127180. * If the ray of the LaserPointer should be displayed.
  127181. */
  127182. get displayLaserPointer(): boolean;
  127183. /**
  127184. * Sets if the ray of the LaserPointer should be displayed.
  127185. */
  127186. set displayLaserPointer(value: boolean);
  127187. /**
  127188. * The deviceOrientationCamera used as the camera when not in VR.
  127189. */
  127190. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  127191. /**
  127192. * Based on the current WebVR support, returns the current VR camera used.
  127193. */
  127194. get currentVRCamera(): Nullable<Camera>;
  127195. /**
  127196. * The webVRCamera which is used when in VR.
  127197. */
  127198. get webVRCamera(): WebVRFreeCamera;
  127199. /**
  127200. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  127201. */
  127202. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  127203. /**
  127204. * The html button that is used to trigger entering into VR.
  127205. */
  127206. get vrButton(): Nullable<HTMLButtonElement>;
  127207. private get _teleportationRequestInitiated();
  127208. /**
  127209. * Defines whether or not Pointer lock should be requested when switching to
  127210. * full screen.
  127211. */
  127212. requestPointerLockOnFullScreen: boolean;
  127213. /**
  127214. * If asking to force XR, this will be populated with the default xr experience
  127215. */
  127216. xr: WebXRDefaultExperience;
  127217. /**
  127218. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  127219. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  127220. */
  127221. xrTestDone: boolean;
  127222. /**
  127223. * Instantiates a VRExperienceHelper.
  127224. * Helps to quickly add VR support to an existing scene.
  127225. * @param scene The scene the VRExperienceHelper belongs to.
  127226. * @param webVROptions Options to modify the vr experience helper's behavior.
  127227. */
  127228. constructor(scene: Scene,
  127229. /** Options to modify the vr experience helper's behavior. */
  127230. webVROptions?: VRExperienceHelperOptions);
  127231. private completeVRInit;
  127232. private _onDefaultMeshLoaded;
  127233. private _onResize;
  127234. private _onFullscreenChange;
  127235. /**
  127236. * Gets a value indicating if we are currently in VR mode.
  127237. */
  127238. get isInVRMode(): boolean;
  127239. private onVrDisplayPresentChange;
  127240. private onVRDisplayChanged;
  127241. private moveButtonToBottomRight;
  127242. private displayVRButton;
  127243. private updateButtonVisibility;
  127244. private _cachedAngularSensibility;
  127245. /**
  127246. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  127247. * Otherwise, will use the fullscreen API.
  127248. */
  127249. enterVR(): void;
  127250. /**
  127251. * Attempt to exit VR, or fullscreen.
  127252. */
  127253. exitVR(): void;
  127254. /**
  127255. * The position of the vr experience helper.
  127256. */
  127257. get position(): Vector3;
  127258. /**
  127259. * Sets the position of the vr experience helper.
  127260. */
  127261. set position(value: Vector3);
  127262. /**
  127263. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  127264. */
  127265. enableInteractions(): void;
  127266. private get _noControllerIsActive();
  127267. private beforeRender;
  127268. private _isTeleportationFloor;
  127269. /**
  127270. * Adds a floor mesh to be used for teleportation.
  127271. * @param floorMesh the mesh to be used for teleportation.
  127272. */
  127273. addFloorMesh(floorMesh: Mesh): void;
  127274. /**
  127275. * Removes a floor mesh from being used for teleportation.
  127276. * @param floorMesh the mesh to be removed.
  127277. */
  127278. removeFloorMesh(floorMesh: Mesh): void;
  127279. /**
  127280. * Enables interactions and teleportation using the VR controllers and gaze.
  127281. * @param vrTeleportationOptions options to modify teleportation behavior.
  127282. */
  127283. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  127284. private _onNewGamepadConnected;
  127285. private _tryEnableInteractionOnController;
  127286. private _onNewGamepadDisconnected;
  127287. private _enableInteractionOnController;
  127288. private _checkTeleportWithRay;
  127289. private _checkRotate;
  127290. private _checkTeleportBackwards;
  127291. private _enableTeleportationOnController;
  127292. private _createTeleportationCircles;
  127293. private _displayTeleportationTarget;
  127294. private _hideTeleportationTarget;
  127295. private _rotateCamera;
  127296. private _moveTeleportationSelectorTo;
  127297. private _workingVector;
  127298. private _workingQuaternion;
  127299. private _workingMatrix;
  127300. /**
  127301. * Time Constant Teleportation Mode
  127302. */
  127303. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  127304. /**
  127305. * Speed Constant Teleportation Mode
  127306. */
  127307. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  127308. /**
  127309. * Teleports the users feet to the desired location
  127310. * @param location The location where the user's feet should be placed
  127311. */
  127312. teleportCamera(location: Vector3): void;
  127313. private _convertNormalToDirectionOfRay;
  127314. private _castRayAndSelectObject;
  127315. private _notifySelectedMeshUnselected;
  127316. /**
  127317. * Permanently set new colors for the laser pointer
  127318. * @param color the new laser color
  127319. * @param pickedColor the new laser color when picked mesh detected
  127320. */
  127321. setLaserColor(color: Color3, pickedColor?: Color3): void;
  127322. /**
  127323. * Set lighting enabled / disabled on the laser pointer of both controllers
  127324. * @param enabled should the lighting be enabled on the laser pointer
  127325. */
  127326. setLaserLightingState(enabled?: boolean): void;
  127327. /**
  127328. * Permanently set new colors for the gaze pointer
  127329. * @param color the new gaze color
  127330. * @param pickedColor the new gaze color when picked mesh detected
  127331. */
  127332. setGazeColor(color: Color3, pickedColor?: Color3): void;
  127333. /**
  127334. * Sets the color of the laser ray from the vr controllers.
  127335. * @param color new color for the ray.
  127336. */
  127337. changeLaserColor(color: Color3): void;
  127338. /**
  127339. * Sets the color of the ray from the vr headsets gaze.
  127340. * @param color new color for the ray.
  127341. */
  127342. changeGazeColor(color: Color3): void;
  127343. /**
  127344. * Exits VR and disposes of the vr experience helper
  127345. */
  127346. dispose(): void;
  127347. /**
  127348. * Gets the name of the VRExperienceHelper class
  127349. * @returns "VRExperienceHelper"
  127350. */
  127351. getClassName(): string;
  127352. }
  127353. }
  127354. declare module BABYLON {
  127355. /**
  127356. * Contains an array of blocks representing the octree
  127357. */
  127358. export interface IOctreeContainer<T> {
  127359. /**
  127360. * Blocks within the octree
  127361. */
  127362. blocks: Array<OctreeBlock<T>>;
  127363. }
  127364. /**
  127365. * Class used to store a cell in an octree
  127366. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127367. */
  127368. export class OctreeBlock<T> {
  127369. /**
  127370. * Gets the content of the current block
  127371. */
  127372. entries: T[];
  127373. /**
  127374. * Gets the list of block children
  127375. */
  127376. blocks: Array<OctreeBlock<T>>;
  127377. private _depth;
  127378. private _maxDepth;
  127379. private _capacity;
  127380. private _minPoint;
  127381. private _maxPoint;
  127382. private _boundingVectors;
  127383. private _creationFunc;
  127384. /**
  127385. * Creates a new block
  127386. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  127387. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  127388. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  127389. * @param depth defines the current depth of this block in the octree
  127390. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  127391. * @param creationFunc defines a callback to call when an element is added to the block
  127392. */
  127393. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  127394. /**
  127395. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  127396. */
  127397. get capacity(): number;
  127398. /**
  127399. * Gets the minimum vector (in world space) of the block's bounding box
  127400. */
  127401. get minPoint(): Vector3;
  127402. /**
  127403. * Gets the maximum vector (in world space) of the block's bounding box
  127404. */
  127405. get maxPoint(): Vector3;
  127406. /**
  127407. * Add a new element to this block
  127408. * @param entry defines the element to add
  127409. */
  127410. addEntry(entry: T): void;
  127411. /**
  127412. * Remove an element from this block
  127413. * @param entry defines the element to remove
  127414. */
  127415. removeEntry(entry: T): void;
  127416. /**
  127417. * Add an array of elements to this block
  127418. * @param entries defines the array of elements to add
  127419. */
  127420. addEntries(entries: T[]): void;
  127421. /**
  127422. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  127423. * @param frustumPlanes defines the frustum planes to test
  127424. * @param selection defines the array to store current content if selection is positive
  127425. * @param allowDuplicate defines if the selection array can contains duplicated entries
  127426. */
  127427. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  127428. /**
  127429. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  127430. * @param sphereCenter defines the bounding sphere center
  127431. * @param sphereRadius defines the bounding sphere radius
  127432. * @param selection defines the array to store current content if selection is positive
  127433. * @param allowDuplicate defines if the selection array can contains duplicated entries
  127434. */
  127435. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  127436. /**
  127437. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  127438. * @param ray defines the ray to test with
  127439. * @param selection defines the array to store current content if selection is positive
  127440. */
  127441. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  127442. /**
  127443. * Subdivide the content into child blocks (this block will then be empty)
  127444. */
  127445. createInnerBlocks(): void;
  127446. /**
  127447. * @hidden
  127448. */
  127449. 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;
  127450. }
  127451. }
  127452. declare module BABYLON {
  127453. /**
  127454. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  127455. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127456. */
  127457. export class Octree<T> {
  127458. /** 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.) */
  127459. maxDepth: number;
  127460. /**
  127461. * Blocks within the octree containing objects
  127462. */
  127463. blocks: Array<OctreeBlock<T>>;
  127464. /**
  127465. * Content stored in the octree
  127466. */
  127467. dynamicContent: T[];
  127468. private _maxBlockCapacity;
  127469. private _selectionContent;
  127470. private _creationFunc;
  127471. /**
  127472. * Creates a octree
  127473. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127474. * @param creationFunc function to be used to instatiate the octree
  127475. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  127476. * @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.)
  127477. */
  127478. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  127479. /** 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.) */
  127480. maxDepth?: number);
  127481. /**
  127482. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  127483. * @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);
  127484. * @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);
  127485. * @param entries meshes to be added to the octree blocks
  127486. */
  127487. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  127488. /**
  127489. * Adds a mesh to the octree
  127490. * @param entry Mesh to add to the octree
  127491. */
  127492. addMesh(entry: T): void;
  127493. /**
  127494. * Remove an element from the octree
  127495. * @param entry defines the element to remove
  127496. */
  127497. removeMesh(entry: T): void;
  127498. /**
  127499. * Selects an array of meshes within the frustum
  127500. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  127501. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  127502. * @returns array of meshes within the frustum
  127503. */
  127504. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  127505. /**
  127506. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  127507. * @param sphereCenter defines the bounding sphere center
  127508. * @param sphereRadius defines the bounding sphere radius
  127509. * @param allowDuplicate defines if the selection array can contains duplicated entries
  127510. * @returns an array of objects that intersect the sphere
  127511. */
  127512. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  127513. /**
  127514. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  127515. * @param ray defines the ray to test with
  127516. * @returns array of intersected objects
  127517. */
  127518. intersectsRay(ray: Ray): SmartArray<T>;
  127519. /**
  127520. * Adds a mesh into the octree block if it intersects the block
  127521. */
  127522. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  127523. /**
  127524. * Adds a submesh into the octree block if it intersects the block
  127525. */
  127526. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  127527. }
  127528. }
  127529. declare module BABYLON {
  127530. interface Scene {
  127531. /**
  127532. * @hidden
  127533. * Backing Filed
  127534. */
  127535. _selectionOctree: Octree<AbstractMesh>;
  127536. /**
  127537. * Gets the octree used to boost mesh selection (picking)
  127538. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127539. */
  127540. selectionOctree: Octree<AbstractMesh>;
  127541. /**
  127542. * Creates or updates the octree used to boost selection (picking)
  127543. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127544. * @param maxCapacity defines the maximum capacity per leaf
  127545. * @param maxDepth defines the maximum depth of the octree
  127546. * @returns an octree of AbstractMesh
  127547. */
  127548. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  127549. }
  127550. interface AbstractMesh {
  127551. /**
  127552. * @hidden
  127553. * Backing Field
  127554. */
  127555. _submeshesOctree: Octree<SubMesh>;
  127556. /**
  127557. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  127558. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  127559. * @param maxCapacity defines the maximum size of each block (64 by default)
  127560. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  127561. * @returns the new octree
  127562. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  127563. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127564. */
  127565. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  127566. }
  127567. /**
  127568. * Defines the octree scene component responsible to manage any octrees
  127569. * in a given scene.
  127570. */
  127571. export class OctreeSceneComponent {
  127572. /**
  127573. * The component name help to identify the component in the list of scene components.
  127574. */
  127575. readonly name: string;
  127576. /**
  127577. * The scene the component belongs to.
  127578. */
  127579. scene: Scene;
  127580. /**
  127581. * Indicates if the meshes have been checked to make sure they are isEnabled()
  127582. */
  127583. readonly checksIsEnabled: boolean;
  127584. /**
  127585. * Creates a new instance of the component for the given scene
  127586. * @param scene Defines the scene to register the component in
  127587. */
  127588. constructor(scene: Scene);
  127589. /**
  127590. * Registers the component in a given scene
  127591. */
  127592. register(): void;
  127593. /**
  127594. * Return the list of active meshes
  127595. * @returns the list of active meshes
  127596. */
  127597. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  127598. /**
  127599. * Return the list of active sub meshes
  127600. * @param mesh The mesh to get the candidates sub meshes from
  127601. * @returns the list of active sub meshes
  127602. */
  127603. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  127604. private _tempRay;
  127605. /**
  127606. * Return the list of sub meshes intersecting with a given local ray
  127607. * @param mesh defines the mesh to find the submesh for
  127608. * @param localRay defines the ray in local space
  127609. * @returns the list of intersecting sub meshes
  127610. */
  127611. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  127612. /**
  127613. * Return the list of sub meshes colliding with a collider
  127614. * @param mesh defines the mesh to find the submesh for
  127615. * @param collider defines the collider to evaluate the collision against
  127616. * @returns the list of colliding sub meshes
  127617. */
  127618. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  127619. /**
  127620. * Rebuilds the elements related to this component in case of
  127621. * context lost for instance.
  127622. */
  127623. rebuild(): void;
  127624. /**
  127625. * Disposes the component and the associated ressources.
  127626. */
  127627. dispose(): void;
  127628. }
  127629. }
  127630. declare module BABYLON {
  127631. /**
  127632. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  127633. */
  127634. export class Gizmo implements IDisposable {
  127635. /** The utility layer the gizmo will be added to */
  127636. gizmoLayer: UtilityLayerRenderer;
  127637. /**
  127638. * The root mesh of the gizmo
  127639. */
  127640. _rootMesh: Mesh;
  127641. private _attachedMesh;
  127642. /**
  127643. * Ratio for the scale of the gizmo (Default: 1)
  127644. */
  127645. scaleRatio: number;
  127646. /**
  127647. * If a custom mesh has been set (Default: false)
  127648. */
  127649. protected _customMeshSet: boolean;
  127650. /**
  127651. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  127652. * * When set, interactions will be enabled
  127653. */
  127654. get attachedMesh(): Nullable<AbstractMesh>;
  127655. set attachedMesh(value: Nullable<AbstractMesh>);
  127656. /**
  127657. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  127658. * @param mesh The mesh to replace the default mesh of the gizmo
  127659. */
  127660. setCustomMesh(mesh: Mesh): void;
  127661. /**
  127662. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  127663. */
  127664. updateGizmoRotationToMatchAttachedMesh: boolean;
  127665. /**
  127666. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  127667. */
  127668. updateGizmoPositionToMatchAttachedMesh: boolean;
  127669. /**
  127670. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  127671. */
  127672. updateScale: boolean;
  127673. protected _interactionsEnabled: boolean;
  127674. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  127675. private _beforeRenderObserver;
  127676. private _tempVector;
  127677. /**
  127678. * Creates a gizmo
  127679. * @param gizmoLayer The utility layer the gizmo will be added to
  127680. */
  127681. constructor(
  127682. /** The utility layer the gizmo will be added to */
  127683. gizmoLayer?: UtilityLayerRenderer);
  127684. /**
  127685. * Updates the gizmo to match the attached mesh's position/rotation
  127686. */
  127687. protected _update(): void;
  127688. /**
  127689. * Disposes of the gizmo
  127690. */
  127691. dispose(): void;
  127692. }
  127693. }
  127694. declare module BABYLON {
  127695. /**
  127696. * Single plane drag gizmo
  127697. */
  127698. export class PlaneDragGizmo extends Gizmo {
  127699. /**
  127700. * Drag behavior responsible for the gizmos dragging interactions
  127701. */
  127702. dragBehavior: PointerDragBehavior;
  127703. private _pointerObserver;
  127704. /**
  127705. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  127706. */
  127707. snapDistance: number;
  127708. /**
  127709. * Event that fires each time the gizmo snaps to a new location.
  127710. * * snapDistance is the the change in distance
  127711. */
  127712. onSnapObservable: Observable<{
  127713. snapDistance: number;
  127714. }>;
  127715. private _plane;
  127716. private _coloredMaterial;
  127717. private _hoverMaterial;
  127718. private _isEnabled;
  127719. private _parent;
  127720. /** @hidden */
  127721. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  127722. /** @hidden */
  127723. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  127724. /**
  127725. * Creates a PlaneDragGizmo
  127726. * @param gizmoLayer The utility layer the gizmo will be added to
  127727. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  127728. * @param color The color of the gizmo
  127729. */
  127730. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  127731. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  127732. /**
  127733. * If the gizmo is enabled
  127734. */
  127735. set isEnabled(value: boolean);
  127736. get isEnabled(): boolean;
  127737. /**
  127738. * Disposes of the gizmo
  127739. */
  127740. dispose(): void;
  127741. }
  127742. }
  127743. declare module BABYLON {
  127744. /**
  127745. * Gizmo that enables dragging a mesh along 3 axis
  127746. */
  127747. export class PositionGizmo extends Gizmo {
  127748. /**
  127749. * Internal gizmo used for interactions on the x axis
  127750. */
  127751. xGizmo: AxisDragGizmo;
  127752. /**
  127753. * Internal gizmo used for interactions on the y axis
  127754. */
  127755. yGizmo: AxisDragGizmo;
  127756. /**
  127757. * Internal gizmo used for interactions on the z axis
  127758. */
  127759. zGizmo: AxisDragGizmo;
  127760. /**
  127761. * Internal gizmo used for interactions on the yz plane
  127762. */
  127763. xPlaneGizmo: PlaneDragGizmo;
  127764. /**
  127765. * Internal gizmo used for interactions on the xz plane
  127766. */
  127767. yPlaneGizmo: PlaneDragGizmo;
  127768. /**
  127769. * Internal gizmo used for interactions on the xy plane
  127770. */
  127771. zPlaneGizmo: PlaneDragGizmo;
  127772. /**
  127773. * private variables
  127774. */
  127775. private _meshAttached;
  127776. private _updateGizmoRotationToMatchAttachedMesh;
  127777. private _snapDistance;
  127778. private _scaleRatio;
  127779. /** Fires an event when any of it's sub gizmos are dragged */
  127780. onDragStartObservable: Observable<unknown>;
  127781. /** Fires an event when any of it's sub gizmos are released from dragging */
  127782. onDragEndObservable: Observable<unknown>;
  127783. /**
  127784. * If set to true, planar drag is enabled
  127785. */
  127786. private _planarGizmoEnabled;
  127787. get attachedMesh(): Nullable<AbstractMesh>;
  127788. set attachedMesh(mesh: Nullable<AbstractMesh>);
  127789. /**
  127790. * Creates a PositionGizmo
  127791. * @param gizmoLayer The utility layer the gizmo will be added to
  127792. */
  127793. constructor(gizmoLayer?: UtilityLayerRenderer);
  127794. /**
  127795. * If the planar drag gizmo is enabled
  127796. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  127797. */
  127798. set planarGizmoEnabled(value: boolean);
  127799. get planarGizmoEnabled(): boolean;
  127800. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  127801. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  127802. /**
  127803. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  127804. */
  127805. set snapDistance(value: number);
  127806. get snapDistance(): number;
  127807. /**
  127808. * Ratio for the scale of the gizmo (Default: 1)
  127809. */
  127810. set scaleRatio(value: number);
  127811. get scaleRatio(): number;
  127812. /**
  127813. * Disposes of the gizmo
  127814. */
  127815. dispose(): void;
  127816. /**
  127817. * CustomMeshes are not supported by this gizmo
  127818. * @param mesh The mesh to replace the default mesh of the gizmo
  127819. */
  127820. setCustomMesh(mesh: Mesh): void;
  127821. }
  127822. }
  127823. declare module BABYLON {
  127824. /**
  127825. * Single axis drag gizmo
  127826. */
  127827. export class AxisDragGizmo extends Gizmo {
  127828. /**
  127829. * Drag behavior responsible for the gizmos dragging interactions
  127830. */
  127831. dragBehavior: PointerDragBehavior;
  127832. private _pointerObserver;
  127833. /**
  127834. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  127835. */
  127836. snapDistance: number;
  127837. /**
  127838. * Event that fires each time the gizmo snaps to a new location.
  127839. * * snapDistance is the the change in distance
  127840. */
  127841. onSnapObservable: Observable<{
  127842. snapDistance: number;
  127843. }>;
  127844. private _isEnabled;
  127845. private _parent;
  127846. private _arrow;
  127847. private _coloredMaterial;
  127848. private _hoverMaterial;
  127849. /** @hidden */
  127850. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  127851. /** @hidden */
  127852. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  127853. /**
  127854. * Creates an AxisDragGizmo
  127855. * @param gizmoLayer The utility layer the gizmo will be added to
  127856. * @param dragAxis The axis which the gizmo will be able to drag on
  127857. * @param color The color of the gizmo
  127858. */
  127859. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  127860. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  127861. /**
  127862. * If the gizmo is enabled
  127863. */
  127864. set isEnabled(value: boolean);
  127865. get isEnabled(): boolean;
  127866. /**
  127867. * Disposes of the gizmo
  127868. */
  127869. dispose(): void;
  127870. }
  127871. }
  127872. declare module BABYLON.Debug {
  127873. /**
  127874. * The Axes viewer will show 3 axes in a specific point in space
  127875. */
  127876. export class AxesViewer {
  127877. private _xAxis;
  127878. private _yAxis;
  127879. private _zAxis;
  127880. private _scaleLinesFactor;
  127881. private _instanced;
  127882. /**
  127883. * Gets the hosting scene
  127884. */
  127885. scene: Scene;
  127886. /**
  127887. * Gets or sets a number used to scale line length
  127888. */
  127889. scaleLines: number;
  127890. /** Gets the node hierarchy used to render x-axis */
  127891. get xAxis(): TransformNode;
  127892. /** Gets the node hierarchy used to render y-axis */
  127893. get yAxis(): TransformNode;
  127894. /** Gets the node hierarchy used to render z-axis */
  127895. get zAxis(): TransformNode;
  127896. /**
  127897. * Creates a new AxesViewer
  127898. * @param scene defines the hosting scene
  127899. * @param scaleLines defines a number used to scale line length (1 by default)
  127900. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  127901. * @param xAxis defines the node hierarchy used to render the x-axis
  127902. * @param yAxis defines the node hierarchy used to render the y-axis
  127903. * @param zAxis defines the node hierarchy used to render the z-axis
  127904. */
  127905. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  127906. /**
  127907. * Force the viewer to update
  127908. * @param position defines the position of the viewer
  127909. * @param xaxis defines the x axis of the viewer
  127910. * @param yaxis defines the y axis of the viewer
  127911. * @param zaxis defines the z axis of the viewer
  127912. */
  127913. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  127914. /**
  127915. * Creates an instance of this axes viewer.
  127916. * @returns a new axes viewer with instanced meshes
  127917. */
  127918. createInstance(): AxesViewer;
  127919. /** Releases resources */
  127920. dispose(): void;
  127921. private static _SetRenderingGroupId;
  127922. }
  127923. }
  127924. declare module BABYLON.Debug {
  127925. /**
  127926. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  127927. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  127928. */
  127929. export class BoneAxesViewer extends AxesViewer {
  127930. /**
  127931. * Gets or sets the target mesh where to display the axes viewer
  127932. */
  127933. mesh: Nullable<Mesh>;
  127934. /**
  127935. * Gets or sets the target bone where to display the axes viewer
  127936. */
  127937. bone: Nullable<Bone>;
  127938. /** Gets current position */
  127939. pos: Vector3;
  127940. /** Gets direction of X axis */
  127941. xaxis: Vector3;
  127942. /** Gets direction of Y axis */
  127943. yaxis: Vector3;
  127944. /** Gets direction of Z axis */
  127945. zaxis: Vector3;
  127946. /**
  127947. * Creates a new BoneAxesViewer
  127948. * @param scene defines the hosting scene
  127949. * @param bone defines the target bone
  127950. * @param mesh defines the target mesh
  127951. * @param scaleLines defines a scaling factor for line length (1 by default)
  127952. */
  127953. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  127954. /**
  127955. * Force the viewer to update
  127956. */
  127957. update(): void;
  127958. /** Releases resources */
  127959. dispose(): void;
  127960. }
  127961. }
  127962. declare module BABYLON {
  127963. /**
  127964. * Interface used to define scene explorer extensibility option
  127965. */
  127966. export interface IExplorerExtensibilityOption {
  127967. /**
  127968. * Define the option label
  127969. */
  127970. label: string;
  127971. /**
  127972. * Defines the action to execute on click
  127973. */
  127974. action: (entity: any) => void;
  127975. }
  127976. /**
  127977. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  127978. */
  127979. export interface IExplorerExtensibilityGroup {
  127980. /**
  127981. * Defines a predicate to test if a given type mut be extended
  127982. */
  127983. predicate: (entity: any) => boolean;
  127984. /**
  127985. * Gets the list of options added to a type
  127986. */
  127987. entries: IExplorerExtensibilityOption[];
  127988. }
  127989. /**
  127990. * Interface used to define the options to use to create the Inspector
  127991. */
  127992. export interface IInspectorOptions {
  127993. /**
  127994. * Display in overlay mode (default: false)
  127995. */
  127996. overlay?: boolean;
  127997. /**
  127998. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  127999. */
  128000. globalRoot?: HTMLElement;
  128001. /**
  128002. * Display the Scene explorer
  128003. */
  128004. showExplorer?: boolean;
  128005. /**
  128006. * Display the property inspector
  128007. */
  128008. showInspector?: boolean;
  128009. /**
  128010. * Display in embed mode (both panes on the right)
  128011. */
  128012. embedMode?: boolean;
  128013. /**
  128014. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  128015. */
  128016. handleResize?: boolean;
  128017. /**
  128018. * Allow the panes to popup (default: true)
  128019. */
  128020. enablePopup?: boolean;
  128021. /**
  128022. * Allow the panes to be closed by users (default: true)
  128023. */
  128024. enableClose?: boolean;
  128025. /**
  128026. * Optional list of extensibility entries
  128027. */
  128028. explorerExtensibility?: IExplorerExtensibilityGroup[];
  128029. /**
  128030. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  128031. */
  128032. inspectorURL?: string;
  128033. /**
  128034. * Optional initial tab (default to DebugLayerTab.Properties)
  128035. */
  128036. initialTab?: DebugLayerTab;
  128037. }
  128038. interface Scene {
  128039. /**
  128040. * @hidden
  128041. * Backing field
  128042. */
  128043. _debugLayer: DebugLayer;
  128044. /**
  128045. * Gets the debug layer (aka Inspector) associated with the scene
  128046. * @see https://doc.babylonjs.com/features/playground_debuglayer
  128047. */
  128048. debugLayer: DebugLayer;
  128049. }
  128050. /**
  128051. * Enum of inspector action tab
  128052. */
  128053. export enum DebugLayerTab {
  128054. /**
  128055. * Properties tag (default)
  128056. */
  128057. Properties = 0,
  128058. /**
  128059. * Debug tab
  128060. */
  128061. Debug = 1,
  128062. /**
  128063. * Statistics tab
  128064. */
  128065. Statistics = 2,
  128066. /**
  128067. * Tools tab
  128068. */
  128069. Tools = 3,
  128070. /**
  128071. * Settings tab
  128072. */
  128073. Settings = 4
  128074. }
  128075. /**
  128076. * The debug layer (aka Inspector) is the go to tool in order to better understand
  128077. * what is happening in your scene
  128078. * @see https://doc.babylonjs.com/features/playground_debuglayer
  128079. */
  128080. export class DebugLayer {
  128081. /**
  128082. * Define the url to get the inspector script from.
  128083. * By default it uses the babylonjs CDN.
  128084. * @ignoreNaming
  128085. */
  128086. static InspectorURL: string;
  128087. private _scene;
  128088. private BJSINSPECTOR;
  128089. private _onPropertyChangedObservable?;
  128090. /**
  128091. * Observable triggered when a property is changed through the inspector.
  128092. */
  128093. get onPropertyChangedObservable(): any;
  128094. /**
  128095. * Instantiates a new debug layer.
  128096. * The debug layer (aka Inspector) is the go to tool in order to better understand
  128097. * what is happening in your scene
  128098. * @see https://doc.babylonjs.com/features/playground_debuglayer
  128099. * @param scene Defines the scene to inspect
  128100. */
  128101. constructor(scene: Scene);
  128102. /** Creates the inspector window. */
  128103. private _createInspector;
  128104. /**
  128105. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  128106. * @param entity defines the entity to select
  128107. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  128108. */
  128109. select(entity: any, lineContainerTitles?: string | string[]): void;
  128110. /** Get the inspector from bundle or global */
  128111. private _getGlobalInspector;
  128112. /**
  128113. * Get if the inspector is visible or not.
  128114. * @returns true if visible otherwise, false
  128115. */
  128116. isVisible(): boolean;
  128117. /**
  128118. * Hide the inspector and close its window.
  128119. */
  128120. hide(): void;
  128121. /**
  128122. * Update the scene in the inspector
  128123. */
  128124. setAsActiveScene(): void;
  128125. /**
  128126. * Launch the debugLayer.
  128127. * @param config Define the configuration of the inspector
  128128. * @return a promise fulfilled when the debug layer is visible
  128129. */
  128130. show(config?: IInspectorOptions): Promise<DebugLayer>;
  128131. }
  128132. }
  128133. declare module BABYLON {
  128134. /**
  128135. * Class containing static functions to help procedurally build meshes
  128136. */
  128137. export class BoxBuilder {
  128138. /**
  128139. * Creates a box mesh
  128140. * * The parameter `size` sets the size (float) of each box side (default 1)
  128141. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  128142. * * 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)
  128143. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  128144. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128145. * * 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
  128146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128147. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  128148. * @param name defines the name of the mesh
  128149. * @param options defines the options used to create the mesh
  128150. * @param scene defines the hosting scene
  128151. * @returns the box mesh
  128152. */
  128153. static CreateBox(name: string, options: {
  128154. size?: number;
  128155. width?: number;
  128156. height?: number;
  128157. depth?: number;
  128158. faceUV?: Vector4[];
  128159. faceColors?: Color4[];
  128160. sideOrientation?: number;
  128161. frontUVs?: Vector4;
  128162. backUVs?: Vector4;
  128163. wrap?: boolean;
  128164. topBaseAt?: number;
  128165. bottomBaseAt?: number;
  128166. updatable?: boolean;
  128167. }, scene?: Nullable<Scene>): Mesh;
  128168. }
  128169. }
  128170. declare module BABYLON.Debug {
  128171. /**
  128172. * Used to show the physics impostor around the specific mesh
  128173. */
  128174. export class PhysicsViewer {
  128175. /** @hidden */
  128176. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  128177. /** @hidden */
  128178. protected _meshes: Array<Nullable<AbstractMesh>>;
  128179. /** @hidden */
  128180. protected _scene: Nullable<Scene>;
  128181. /** @hidden */
  128182. protected _numMeshes: number;
  128183. /** @hidden */
  128184. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  128185. private _renderFunction;
  128186. private _utilityLayer;
  128187. private _debugBoxMesh;
  128188. private _debugSphereMesh;
  128189. private _debugCylinderMesh;
  128190. private _debugMaterial;
  128191. private _debugMeshMeshes;
  128192. /**
  128193. * Creates a new PhysicsViewer
  128194. * @param scene defines the hosting scene
  128195. */
  128196. constructor(scene: Scene);
  128197. /** @hidden */
  128198. protected _updateDebugMeshes(): void;
  128199. /**
  128200. * Renders a specified physic impostor
  128201. * @param impostor defines the impostor to render
  128202. * @param targetMesh defines the mesh represented by the impostor
  128203. * @returns the new debug mesh used to render the impostor
  128204. */
  128205. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  128206. /**
  128207. * Hides a specified physic impostor
  128208. * @param impostor defines the impostor to hide
  128209. */
  128210. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  128211. private _getDebugMaterial;
  128212. private _getDebugBoxMesh;
  128213. private _getDebugSphereMesh;
  128214. private _getDebugCylinderMesh;
  128215. private _getDebugMeshMesh;
  128216. private _getDebugMesh;
  128217. /** Releases all resources */
  128218. dispose(): void;
  128219. }
  128220. }
  128221. declare module BABYLON {
  128222. /**
  128223. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  128224. * in order to better appreciate the issue one might have.
  128225. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  128226. */
  128227. export class RayHelper {
  128228. /**
  128229. * Defines the ray we are currently tryin to visualize.
  128230. */
  128231. ray: Nullable<Ray>;
  128232. private _renderPoints;
  128233. private _renderLine;
  128234. private _renderFunction;
  128235. private _scene;
  128236. private _updateToMeshFunction;
  128237. private _attachedToMesh;
  128238. private _meshSpaceDirection;
  128239. private _meshSpaceOrigin;
  128240. /**
  128241. * Helper function to create a colored helper in a scene in one line.
  128242. * @param ray Defines the ray we are currently tryin to visualize
  128243. * @param scene Defines the scene the ray is used in
  128244. * @param color Defines the color we want to see the ray in
  128245. * @returns The newly created ray helper.
  128246. */
  128247. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  128248. /**
  128249. * Instantiate a new ray helper.
  128250. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  128251. * in order to better appreciate the issue one might have.
  128252. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  128253. * @param ray Defines the ray we are currently tryin to visualize
  128254. */
  128255. constructor(ray: Ray);
  128256. /**
  128257. * Shows the ray we are willing to debug.
  128258. * @param scene Defines the scene the ray needs to be rendered in
  128259. * @param color Defines the color the ray needs to be rendered in
  128260. */
  128261. show(scene: Scene, color?: Color3): void;
  128262. /**
  128263. * Hides the ray we are debugging.
  128264. */
  128265. hide(): void;
  128266. private _render;
  128267. /**
  128268. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  128269. * @param mesh Defines the mesh we want the helper attached to
  128270. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  128271. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  128272. * @param length Defines the length of the ray
  128273. */
  128274. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  128275. /**
  128276. * Detach the ray helper from the mesh it has previously been attached to.
  128277. */
  128278. detachFromMesh(): void;
  128279. private _updateToMesh;
  128280. /**
  128281. * Dispose the helper and release its associated resources.
  128282. */
  128283. dispose(): void;
  128284. }
  128285. }
  128286. declare module BABYLON.Debug {
  128287. /**
  128288. * Class used to render a debug view of a given skeleton
  128289. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  128290. */
  128291. export class SkeletonViewer {
  128292. /** defines the skeleton to render */
  128293. skeleton: Skeleton;
  128294. /** defines the mesh attached to the skeleton */
  128295. mesh: AbstractMesh;
  128296. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  128297. autoUpdateBonesMatrices: boolean;
  128298. /** defines the rendering group id to use with the viewer */
  128299. renderingGroupId: number;
  128300. /** Gets or sets the color used to render the skeleton */
  128301. color: Color3;
  128302. private _scene;
  128303. private _debugLines;
  128304. private _debugMesh;
  128305. private _isEnabled;
  128306. private _renderFunction;
  128307. private _utilityLayer;
  128308. /**
  128309. * Returns the mesh used to render the bones
  128310. */
  128311. get debugMesh(): Nullable<LinesMesh>;
  128312. /**
  128313. * Creates a new SkeletonViewer
  128314. * @param skeleton defines the skeleton to render
  128315. * @param mesh defines the mesh attached to the skeleton
  128316. * @param scene defines the hosting scene
  128317. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  128318. * @param renderingGroupId defines the rendering group id to use with the viewer
  128319. */
  128320. constructor(
  128321. /** defines the skeleton to render */
  128322. skeleton: Skeleton,
  128323. /** defines the mesh attached to the skeleton */
  128324. mesh: AbstractMesh, scene: Scene,
  128325. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  128326. autoUpdateBonesMatrices?: boolean,
  128327. /** defines the rendering group id to use with the viewer */
  128328. renderingGroupId?: number);
  128329. /** Gets or sets a boolean indicating if the viewer is enabled */
  128330. set isEnabled(value: boolean);
  128331. get isEnabled(): boolean;
  128332. private _getBonePosition;
  128333. private _getLinesForBonesWithLength;
  128334. private _getLinesForBonesNoLength;
  128335. /** Update the viewer to sync with current skeleton state */
  128336. update(): void;
  128337. /** Release associated resources */
  128338. dispose(): void;
  128339. }
  128340. }
  128341. declare module BABYLON {
  128342. /**
  128343. * Enum for Device Types
  128344. */
  128345. export enum DeviceType {
  128346. /** Generic */
  128347. Generic = 0,
  128348. /** Keyboard */
  128349. Keyboard = 1,
  128350. /** Mouse */
  128351. Mouse = 2,
  128352. /** Touch Pointers */
  128353. Touch = 3,
  128354. /** PS4 Dual Shock */
  128355. DualShock = 4,
  128356. /** Xbox */
  128357. Xbox = 5,
  128358. /** Switch Controller */
  128359. Switch = 6
  128360. }
  128361. /**
  128362. * Enum for All Pointers (Touch/Mouse)
  128363. */
  128364. export enum PointerInput {
  128365. /** Horizontal Axis */
  128366. Horizontal = 0,
  128367. /** Vertical Axis */
  128368. Vertical = 1,
  128369. /** Left Click or Touch */
  128370. LeftClick = 2,
  128371. /** Middle Click */
  128372. MiddleClick = 3,
  128373. /** Right Click */
  128374. RightClick = 4,
  128375. /** Browser Back */
  128376. BrowserBack = 5,
  128377. /** Browser Forward */
  128378. BrowserForward = 6
  128379. }
  128380. /**
  128381. * Enum for Dual Shock Gamepad
  128382. */
  128383. export enum DualShockInput {
  128384. /** Cross */
  128385. Cross = 0,
  128386. /** Circle */
  128387. Circle = 1,
  128388. /** Square */
  128389. Square = 2,
  128390. /** Triangle */
  128391. Triangle = 3,
  128392. /** L1 */
  128393. L1 = 4,
  128394. /** R1 */
  128395. R1 = 5,
  128396. /** L2 */
  128397. L2 = 6,
  128398. /** R2 */
  128399. R2 = 7,
  128400. /** Share */
  128401. Share = 8,
  128402. /** Options */
  128403. Options = 9,
  128404. /** L3 */
  128405. L3 = 10,
  128406. /** R3 */
  128407. R3 = 11,
  128408. /** DPadUp */
  128409. DPadUp = 12,
  128410. /** DPadDown */
  128411. DPadDown = 13,
  128412. /** DPadLeft */
  128413. DPadLeft = 14,
  128414. /** DRight */
  128415. DPadRight = 15,
  128416. /** Home */
  128417. Home = 16,
  128418. /** TouchPad */
  128419. TouchPad = 17,
  128420. /** LStickXAxis */
  128421. LStickXAxis = 18,
  128422. /** LStickYAxis */
  128423. LStickYAxis = 19,
  128424. /** RStickXAxis */
  128425. RStickXAxis = 20,
  128426. /** RStickYAxis */
  128427. RStickYAxis = 21
  128428. }
  128429. /**
  128430. * Enum for Xbox Gamepad
  128431. */
  128432. export enum XboxInput {
  128433. /** A */
  128434. A = 0,
  128435. /** B */
  128436. B = 1,
  128437. /** X */
  128438. X = 2,
  128439. /** Y */
  128440. Y = 3,
  128441. /** LB */
  128442. LB = 4,
  128443. /** RB */
  128444. RB = 5,
  128445. /** LT */
  128446. LT = 6,
  128447. /** RT */
  128448. RT = 7,
  128449. /** Back */
  128450. Back = 8,
  128451. /** Start */
  128452. Start = 9,
  128453. /** LS */
  128454. LS = 10,
  128455. /** RS */
  128456. RS = 11,
  128457. /** DPadUp */
  128458. DPadUp = 12,
  128459. /** DPadDown */
  128460. DPadDown = 13,
  128461. /** DPadLeft */
  128462. DPadLeft = 14,
  128463. /** DRight */
  128464. DPadRight = 15,
  128465. /** Home */
  128466. Home = 16,
  128467. /** LStickXAxis */
  128468. LStickXAxis = 17,
  128469. /** LStickYAxis */
  128470. LStickYAxis = 18,
  128471. /** RStickXAxis */
  128472. RStickXAxis = 19,
  128473. /** RStickYAxis */
  128474. RStickYAxis = 20
  128475. }
  128476. /**
  128477. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  128478. */
  128479. export enum SwitchInput {
  128480. /** B */
  128481. B = 0,
  128482. /** A */
  128483. A = 1,
  128484. /** Y */
  128485. Y = 2,
  128486. /** X */
  128487. X = 3,
  128488. /** L */
  128489. L = 4,
  128490. /** R */
  128491. R = 5,
  128492. /** ZL */
  128493. ZL = 6,
  128494. /** ZR */
  128495. ZR = 7,
  128496. /** Minus */
  128497. Minus = 8,
  128498. /** Plus */
  128499. Plus = 9,
  128500. /** LS */
  128501. LS = 10,
  128502. /** RS */
  128503. RS = 11,
  128504. /** DPadUp */
  128505. DPadUp = 12,
  128506. /** DPadDown */
  128507. DPadDown = 13,
  128508. /** DPadLeft */
  128509. DPadLeft = 14,
  128510. /** DRight */
  128511. DPadRight = 15,
  128512. /** Home */
  128513. Home = 16,
  128514. /** Capture */
  128515. Capture = 17,
  128516. /** LStickXAxis */
  128517. LStickXAxis = 18,
  128518. /** LStickYAxis */
  128519. LStickYAxis = 19,
  128520. /** RStickXAxis */
  128521. RStickXAxis = 20,
  128522. /** RStickYAxis */
  128523. RStickYAxis = 21
  128524. }
  128525. }
  128526. declare module BABYLON {
  128527. /**
  128528. * This class will take all inputs from Keyboard, Pointer, and
  128529. * any Gamepads and provide a polling system that all devices
  128530. * will use. This class assumes that there will only be one
  128531. * pointer device and one keyboard.
  128532. */
  128533. export class DeviceInputSystem implements IDisposable {
  128534. /**
  128535. * Callback to be triggered when a device is connected
  128536. */
  128537. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  128538. /**
  128539. * Callback to be triggered when a device is disconnected
  128540. */
  128541. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  128542. /**
  128543. * Callback to be triggered when event driven input is updated
  128544. */
  128545. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  128546. private _inputs;
  128547. private _gamepads;
  128548. private _keyboardActive;
  128549. private _pointerActive;
  128550. private _elementToAttachTo;
  128551. private _keyboardDownEvent;
  128552. private _keyboardUpEvent;
  128553. private _pointerMoveEvent;
  128554. private _pointerDownEvent;
  128555. private _pointerUpEvent;
  128556. private _gamepadConnectedEvent;
  128557. private _gamepadDisconnectedEvent;
  128558. private static _MAX_KEYCODES;
  128559. private static _MAX_POINTER_INPUTS;
  128560. private constructor();
  128561. /**
  128562. * Creates a new DeviceInputSystem instance
  128563. * @param engine Engine to pull input element from
  128564. * @returns The new instance
  128565. */
  128566. static Create(engine: Engine): DeviceInputSystem;
  128567. /**
  128568. * Checks for current device input value, given an id and input index
  128569. * @param deviceName Id of connected device
  128570. * @param inputIndex Index of device input
  128571. * @returns Current value of input
  128572. */
  128573. /**
  128574. * Checks for current device input value, given an id and input index
  128575. * @param deviceType Enum specifiying device type
  128576. * @param deviceSlot "Slot" or index that device is referenced in
  128577. * @param inputIndex Id of input to be checked
  128578. * @returns Current value of input
  128579. */
  128580. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  128581. /**
  128582. * Dispose of all the eventlisteners
  128583. */
  128584. dispose(): void;
  128585. /**
  128586. * Add device and inputs to device array
  128587. * @param deviceType Enum specifiying device type
  128588. * @param deviceSlot "Slot" or index that device is referenced in
  128589. * @param numberOfInputs Number of input entries to create for given device
  128590. */
  128591. private _registerDevice;
  128592. /**
  128593. * Given a specific device name, remove that device from the device map
  128594. * @param deviceType Enum specifiying device type
  128595. * @param deviceSlot "Slot" or index that device is referenced in
  128596. */
  128597. private _unregisterDevice;
  128598. /**
  128599. * Handle all actions that come from keyboard interaction
  128600. */
  128601. private _handleKeyActions;
  128602. /**
  128603. * Handle all actions that come from pointer interaction
  128604. */
  128605. private _handlePointerActions;
  128606. /**
  128607. * Handle all actions that come from gamepad interaction
  128608. */
  128609. private _handleGamepadActions;
  128610. /**
  128611. * Update all non-event based devices with each frame
  128612. * @param deviceType Enum specifiying device type
  128613. * @param deviceSlot "Slot" or index that device is referenced in
  128614. * @param inputIndex Id of input to be checked
  128615. */
  128616. private _updateDevice;
  128617. /**
  128618. * Gets DeviceType from the device name
  128619. * @param deviceName Name of Device from DeviceInputSystem
  128620. * @returns DeviceType enum value
  128621. */
  128622. private _getGamepadDeviceType;
  128623. }
  128624. }
  128625. declare module BABYLON {
  128626. /**
  128627. * Type to handle enforcement of inputs
  128628. */
  128629. export type DeviceInput<T extends DeviceType> = T extends DeviceType.Keyboard | DeviceType.Generic ? number : T extends DeviceType.Mouse | DeviceType.Touch ? PointerInput : T extends DeviceType.DualShock ? DualShockInput : T extends DeviceType.Xbox ? XboxInput : T extends DeviceType.Switch ? SwitchInput : never;
  128630. }
  128631. declare module BABYLON {
  128632. /**
  128633. * Class that handles all input for a specific device
  128634. */
  128635. export class DeviceSource<T extends DeviceType> {
  128636. /** Type of device */
  128637. readonly deviceType: DeviceType;
  128638. /** "Slot" or index that device is referenced in */
  128639. readonly deviceSlot: number;
  128640. /**
  128641. * Observable to handle device input changes per device
  128642. */
  128643. readonly onInputChangedObservable: Observable<{
  128644. inputIndex: DeviceInput<T>;
  128645. previousState: Nullable<number>;
  128646. currentState: Nullable<number>;
  128647. }>;
  128648. private readonly _deviceInputSystem;
  128649. /**
  128650. * Default Constructor
  128651. * @param deviceInputSystem Reference to DeviceInputSystem
  128652. * @param deviceType Type of device
  128653. * @param deviceSlot "Slot" or index that device is referenced in
  128654. */
  128655. constructor(deviceInputSystem: DeviceInputSystem,
  128656. /** Type of device */
  128657. deviceType: DeviceType,
  128658. /** "Slot" or index that device is referenced in */
  128659. deviceSlot?: number);
  128660. /**
  128661. * Get input for specific input
  128662. * @param inputIndex index of specific input on device
  128663. * @returns Input value from DeviceInputSystem
  128664. */
  128665. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  128666. }
  128667. /**
  128668. * Class to keep track of devices
  128669. */
  128670. export class DeviceSourceManager implements IDisposable {
  128671. /**
  128672. * Observable to be triggered when before a device is connected
  128673. */
  128674. readonly onBeforeDeviceConnectedObservable: Observable<{
  128675. deviceType: DeviceType;
  128676. deviceSlot: number;
  128677. }>;
  128678. /**
  128679. * Observable to be triggered when before a device is disconnected
  128680. */
  128681. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  128682. deviceType: DeviceType;
  128683. deviceSlot: number;
  128684. }>;
  128685. /**
  128686. * Observable to be triggered when after a device is connected
  128687. */
  128688. readonly onAfterDeviceConnectedObservable: Observable<{
  128689. deviceType: DeviceType;
  128690. deviceSlot: number;
  128691. }>;
  128692. /**
  128693. * Observable to be triggered when after a device is disconnected
  128694. */
  128695. readonly onAfterDeviceDisconnectedObservable: Observable<{
  128696. deviceType: DeviceType;
  128697. deviceSlot: number;
  128698. }>;
  128699. private readonly _devices;
  128700. private readonly _firstDevice;
  128701. private readonly _deviceInputSystem;
  128702. /**
  128703. * Default Constructor
  128704. * @param engine engine to pull input element from
  128705. */
  128706. constructor(engine: Engine);
  128707. /**
  128708. * Gets a DeviceSource, given a type and slot
  128709. * @param deviceType Enum specifying device type
  128710. * @param deviceSlot "Slot" or index that device is referenced in
  128711. * @returns DeviceSource object
  128712. */
  128713. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  128714. /**
  128715. * Gets an array of DeviceSource objects for a given device type
  128716. * @param deviceType Enum specifying device type
  128717. * @returns Array of DeviceSource objects
  128718. */
  128719. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  128720. /**
  128721. * Dispose of DeviceInputSystem and other parts
  128722. */
  128723. dispose(): void;
  128724. /**
  128725. * Function to add device name to device list
  128726. * @param deviceType Enum specifying device type
  128727. * @param deviceSlot "Slot" or index that device is referenced in
  128728. */
  128729. private _addDevice;
  128730. /**
  128731. * Function to remove device name to device list
  128732. * @param deviceType Enum specifying device type
  128733. * @param deviceSlot "Slot" or index that device is referenced in
  128734. */
  128735. private _removeDevice;
  128736. /**
  128737. * Updates array storing first connected device of each type
  128738. * @param type Type of Device
  128739. */
  128740. private _updateFirstDevices;
  128741. }
  128742. }
  128743. declare module BABYLON {
  128744. /**
  128745. * Options to create the null engine
  128746. */
  128747. export class NullEngineOptions {
  128748. /**
  128749. * Render width (Default: 512)
  128750. */
  128751. renderWidth: number;
  128752. /**
  128753. * Render height (Default: 256)
  128754. */
  128755. renderHeight: number;
  128756. /**
  128757. * Texture size (Default: 512)
  128758. */
  128759. textureSize: number;
  128760. /**
  128761. * If delta time between frames should be constant
  128762. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128763. */
  128764. deterministicLockstep: boolean;
  128765. /**
  128766. * Maximum about of steps between frames (Default: 4)
  128767. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128768. */
  128769. lockstepMaxSteps: number;
  128770. }
  128771. /**
  128772. * The null engine class provides support for headless version of babylon.js.
  128773. * This can be used in server side scenario or for testing purposes
  128774. */
  128775. export class NullEngine extends Engine {
  128776. private _options;
  128777. /**
  128778. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  128779. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128780. * @returns true if engine is in deterministic lock step mode
  128781. */
  128782. isDeterministicLockStep(): boolean;
  128783. /**
  128784. * Gets the max steps when engine is running in deterministic lock step
  128785. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128786. * @returns the max steps
  128787. */
  128788. getLockstepMaxSteps(): number;
  128789. /**
  128790. * Gets the current hardware scaling level.
  128791. * By default the hardware scaling level is computed from the window device ratio.
  128792. * 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.
  128793. * @returns a number indicating the current hardware scaling level
  128794. */
  128795. getHardwareScalingLevel(): number;
  128796. constructor(options?: NullEngineOptions);
  128797. /**
  128798. * Creates a vertex buffer
  128799. * @param vertices the data for the vertex buffer
  128800. * @returns the new WebGL static buffer
  128801. */
  128802. createVertexBuffer(vertices: FloatArray): DataBuffer;
  128803. /**
  128804. * Creates a new index buffer
  128805. * @param indices defines the content of the index buffer
  128806. * @param updatable defines if the index buffer must be updatable
  128807. * @returns a new webGL buffer
  128808. */
  128809. createIndexBuffer(indices: IndicesArray): DataBuffer;
  128810. /**
  128811. * Clear the current render buffer or the current render target (if any is set up)
  128812. * @param color defines the color to use
  128813. * @param backBuffer defines if the back buffer must be cleared
  128814. * @param depth defines if the depth buffer must be cleared
  128815. * @param stencil defines if the stencil buffer must be cleared
  128816. */
  128817. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  128818. /**
  128819. * Gets the current render width
  128820. * @param useScreen defines if screen size must be used (or the current render target if any)
  128821. * @returns a number defining the current render width
  128822. */
  128823. getRenderWidth(useScreen?: boolean): number;
  128824. /**
  128825. * Gets the current render height
  128826. * @param useScreen defines if screen size must be used (or the current render target if any)
  128827. * @returns a number defining the current render height
  128828. */
  128829. getRenderHeight(useScreen?: boolean): number;
  128830. /**
  128831. * Set the WebGL's viewport
  128832. * @param viewport defines the viewport element to be used
  128833. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  128834. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  128835. */
  128836. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  128837. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  128838. /**
  128839. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  128840. * @param pipelineContext defines the pipeline context to use
  128841. * @param uniformsNames defines the list of uniform names
  128842. * @returns an array of webGL uniform locations
  128843. */
  128844. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  128845. /**
  128846. * Gets the lsit of active attributes for a given webGL program
  128847. * @param pipelineContext defines the pipeline context to use
  128848. * @param attributesNames defines the list of attribute names to get
  128849. * @returns an array of indices indicating the offset of each attribute
  128850. */
  128851. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  128852. /**
  128853. * Binds an effect to the webGL context
  128854. * @param effect defines the effect to bind
  128855. */
  128856. bindSamplers(effect: Effect): void;
  128857. /**
  128858. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  128859. * @param effect defines the effect to activate
  128860. */
  128861. enableEffect(effect: Effect): void;
  128862. /**
  128863. * Set various states to the webGL context
  128864. * @param culling defines backface culling state
  128865. * @param zOffset defines the value to apply to zOffset (0 by default)
  128866. * @param force defines if states must be applied even if cache is up to date
  128867. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  128868. */
  128869. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  128870. /**
  128871. * Set the value of an uniform to an array of int32
  128872. * @param uniform defines the webGL uniform location where to store the value
  128873. * @param array defines the array of int32 to store
  128874. */
  128875. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  128876. /**
  128877. * Set the value of an uniform to an array of int32 (stored as vec2)
  128878. * @param uniform defines the webGL uniform location where to store the value
  128879. * @param array defines the array of int32 to store
  128880. */
  128881. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  128882. /**
  128883. * Set the value of an uniform to an array of int32 (stored as vec3)
  128884. * @param uniform defines the webGL uniform location where to store the value
  128885. * @param array defines the array of int32 to store
  128886. */
  128887. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  128888. /**
  128889. * Set the value of an uniform to an array of int32 (stored as vec4)
  128890. * @param uniform defines the webGL uniform location where to store the value
  128891. * @param array defines the array of int32 to store
  128892. */
  128893. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  128894. /**
  128895. * Set the value of an uniform to an array of float32
  128896. * @param uniform defines the webGL uniform location where to store the value
  128897. * @param array defines the array of float32 to store
  128898. */
  128899. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  128900. /**
  128901. * Set the value of an uniform to an array of float32 (stored as vec2)
  128902. * @param uniform defines the webGL uniform location where to store the value
  128903. * @param array defines the array of float32 to store
  128904. */
  128905. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  128906. /**
  128907. * Set the value of an uniform to an array of float32 (stored as vec3)
  128908. * @param uniform defines the webGL uniform location where to store the value
  128909. * @param array defines the array of float32 to store
  128910. */
  128911. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  128912. /**
  128913. * Set the value of an uniform to an array of float32 (stored as vec4)
  128914. * @param uniform defines the webGL uniform location where to store the value
  128915. * @param array defines the array of float32 to store
  128916. */
  128917. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  128918. /**
  128919. * Set the value of an uniform to an array of number
  128920. * @param uniform defines the webGL uniform location where to store the value
  128921. * @param array defines the array of number to store
  128922. */
  128923. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  128924. /**
  128925. * Set the value of an uniform to an array of number (stored as vec2)
  128926. * @param uniform defines the webGL uniform location where to store the value
  128927. * @param array defines the array of number to store
  128928. */
  128929. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  128930. /**
  128931. * Set the value of an uniform to an array of number (stored as vec3)
  128932. * @param uniform defines the webGL uniform location where to store the value
  128933. * @param array defines the array of number to store
  128934. */
  128935. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  128936. /**
  128937. * Set the value of an uniform to an array of number (stored as vec4)
  128938. * @param uniform defines the webGL uniform location where to store the value
  128939. * @param array defines the array of number to store
  128940. */
  128941. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  128942. /**
  128943. * Set the value of an uniform to an array of float32 (stored as matrices)
  128944. * @param uniform defines the webGL uniform location where to store the value
  128945. * @param matrices defines the array of float32 to store
  128946. */
  128947. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  128948. /**
  128949. * Set the value of an uniform to a matrix (3x3)
  128950. * @param uniform defines the webGL uniform location where to store the value
  128951. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  128952. */
  128953. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  128954. /**
  128955. * Set the value of an uniform to a matrix (2x2)
  128956. * @param uniform defines the webGL uniform location where to store the value
  128957. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  128958. */
  128959. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  128960. /**
  128961. * Set the value of an uniform to a number (float)
  128962. * @param uniform defines the webGL uniform location where to store the value
  128963. * @param value defines the float number to store
  128964. */
  128965. setFloat(uniform: WebGLUniformLocation, value: number): void;
  128966. /**
  128967. * Set the value of an uniform to a vec2
  128968. * @param uniform defines the webGL uniform location where to store the value
  128969. * @param x defines the 1st component of the value
  128970. * @param y defines the 2nd component of the value
  128971. */
  128972. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  128973. /**
  128974. * Set the value of an uniform to a vec3
  128975. * @param uniform defines the webGL uniform location where to store the value
  128976. * @param x defines the 1st component of the value
  128977. * @param y defines the 2nd component of the value
  128978. * @param z defines the 3rd component of the value
  128979. */
  128980. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  128981. /**
  128982. * Set the value of an uniform to a boolean
  128983. * @param uniform defines the webGL uniform location where to store the value
  128984. * @param bool defines the boolean to store
  128985. */
  128986. setBool(uniform: WebGLUniformLocation, bool: number): void;
  128987. /**
  128988. * Set the value of an uniform to a vec4
  128989. * @param uniform defines the webGL uniform location where to store the value
  128990. * @param x defines the 1st component of the value
  128991. * @param y defines the 2nd component of the value
  128992. * @param z defines the 3rd component of the value
  128993. * @param w defines the 4th component of the value
  128994. */
  128995. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  128996. /**
  128997. * Sets the current alpha mode
  128998. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  128999. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  129000. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  129001. */
  129002. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  129003. /**
  129004. * Bind webGl buffers directly to the webGL context
  129005. * @param vertexBuffers defines the vertex buffer to bind
  129006. * @param indexBuffer defines the index buffer to bind
  129007. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  129008. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  129009. * @param effect defines the effect associated with the vertex buffer
  129010. */
  129011. bindBuffers(vertexBuffers: {
  129012. [key: string]: VertexBuffer;
  129013. }, indexBuffer: DataBuffer, effect: Effect): void;
  129014. /**
  129015. * Force the entire cache to be cleared
  129016. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  129017. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  129018. */
  129019. wipeCaches(bruteForce?: boolean): void;
  129020. /**
  129021. * Send a draw order
  129022. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  129023. * @param indexStart defines the starting index
  129024. * @param indexCount defines the number of index to draw
  129025. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129026. */
  129027. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  129028. /**
  129029. * Draw a list of indexed primitives
  129030. * @param fillMode defines the primitive to use
  129031. * @param indexStart defines the starting index
  129032. * @param indexCount defines the number of index to draw
  129033. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129034. */
  129035. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  129036. /**
  129037. * Draw a list of unindexed primitives
  129038. * @param fillMode defines the primitive to use
  129039. * @param verticesStart defines the index of first vertex to draw
  129040. * @param verticesCount defines the count of vertices to draw
  129041. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129042. */
  129043. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  129044. /** @hidden */
  129045. _createTexture(): WebGLTexture;
  129046. /** @hidden */
  129047. _releaseTexture(texture: InternalTexture): void;
  129048. /**
  129049. * Usually called from Texture.ts.
  129050. * Passed information to create a WebGLTexture
  129051. * @param urlArg defines a value which contains one of the following:
  129052. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  129053. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  129054. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  129055. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  129056. * @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)
  129057. * @param scene needed for loading to the correct scene
  129058. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  129059. * @param onLoad optional callback to be called upon successful completion
  129060. * @param onError optional callback to be called upon failure
  129061. * @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
  129062. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  129063. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  129064. * @param forcedExtension defines the extension to use to pick the right loader
  129065. * @param mimeType defines an optional mime type
  129066. * @returns a InternalTexture for assignment back into BABYLON.Texture
  129067. */
  129068. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  129069. /**
  129070. * Creates a new render target texture
  129071. * @param size defines the size of the texture
  129072. * @param options defines the options used to create the texture
  129073. * @returns a new render target texture stored in an InternalTexture
  129074. */
  129075. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  129076. /**
  129077. * Update the sampling mode of a given texture
  129078. * @param samplingMode defines the required sampling mode
  129079. * @param texture defines the texture to update
  129080. */
  129081. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  129082. /**
  129083. * Binds the frame buffer to the specified texture.
  129084. * @param texture The texture to render to or null for the default canvas
  129085. * @param faceIndex The face of the texture to render to in case of cube texture
  129086. * @param requiredWidth The width of the target to render to
  129087. * @param requiredHeight The height of the target to render to
  129088. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  129089. * @param lodLevel defines le lod level to bind to the frame buffer
  129090. */
  129091. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  129092. /**
  129093. * Unbind the current render target texture from the webGL context
  129094. * @param texture defines the render target texture to unbind
  129095. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  129096. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  129097. */
  129098. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  129099. /**
  129100. * Creates a dynamic vertex buffer
  129101. * @param vertices the data for the dynamic vertex buffer
  129102. * @returns the new WebGL dynamic buffer
  129103. */
  129104. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  129105. /**
  129106. * Update the content of a dynamic texture
  129107. * @param texture defines the texture to update
  129108. * @param canvas defines the canvas containing the source
  129109. * @param invertY defines if data must be stored with Y axis inverted
  129110. * @param premulAlpha defines if alpha is stored as premultiplied
  129111. * @param format defines the format of the data
  129112. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  129113. */
  129114. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  129115. /**
  129116. * Gets a boolean indicating if all created effects are ready
  129117. * @returns true if all effects are ready
  129118. */
  129119. areAllEffectsReady(): boolean;
  129120. /**
  129121. * @hidden
  129122. * Get the current error code of the webGL context
  129123. * @returns the error code
  129124. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  129125. */
  129126. getError(): number;
  129127. /** @hidden */
  129128. _getUnpackAlignement(): number;
  129129. /** @hidden */
  129130. _unpackFlipY(value: boolean): void;
  129131. /**
  129132. * Update a dynamic index buffer
  129133. * @param indexBuffer defines the target index buffer
  129134. * @param indices defines the data to update
  129135. * @param offset defines the offset in the target index buffer where update should start
  129136. */
  129137. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  129138. /**
  129139. * Updates a dynamic vertex buffer.
  129140. * @param vertexBuffer the vertex buffer to update
  129141. * @param vertices the data used to update the vertex buffer
  129142. * @param byteOffset the byte offset of the data (optional)
  129143. * @param byteLength the byte length of the data (optional)
  129144. */
  129145. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  129146. /** @hidden */
  129147. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  129148. /** @hidden */
  129149. _bindTexture(channel: number, texture: InternalTexture): void;
  129150. protected _deleteBuffer(buffer: WebGLBuffer): void;
  129151. /**
  129152. * 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
  129153. */
  129154. releaseEffects(): void;
  129155. displayLoadingUI(): void;
  129156. hideLoadingUI(): void;
  129157. /** @hidden */
  129158. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129159. /** @hidden */
  129160. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129161. /** @hidden */
  129162. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129163. /** @hidden */
  129164. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  129165. }
  129166. }
  129167. declare module BABYLON {
  129168. /**
  129169. * @hidden
  129170. **/
  129171. export class _TimeToken {
  129172. _startTimeQuery: Nullable<WebGLQuery>;
  129173. _endTimeQuery: Nullable<WebGLQuery>;
  129174. _timeElapsedQuery: Nullable<WebGLQuery>;
  129175. _timeElapsedQueryEnded: boolean;
  129176. }
  129177. }
  129178. declare module BABYLON {
  129179. /** @hidden */
  129180. export class _OcclusionDataStorage {
  129181. /** @hidden */
  129182. occlusionInternalRetryCounter: number;
  129183. /** @hidden */
  129184. isOcclusionQueryInProgress: boolean;
  129185. /** @hidden */
  129186. isOccluded: boolean;
  129187. /** @hidden */
  129188. occlusionRetryCount: number;
  129189. /** @hidden */
  129190. occlusionType: number;
  129191. /** @hidden */
  129192. occlusionQueryAlgorithmType: number;
  129193. }
  129194. interface Engine {
  129195. /**
  129196. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  129197. * @return the new query
  129198. */
  129199. createQuery(): WebGLQuery;
  129200. /**
  129201. * Delete and release a webGL query
  129202. * @param query defines the query to delete
  129203. * @return the current engine
  129204. */
  129205. deleteQuery(query: WebGLQuery): Engine;
  129206. /**
  129207. * Check if a given query has resolved and got its value
  129208. * @param query defines the query to check
  129209. * @returns true if the query got its value
  129210. */
  129211. isQueryResultAvailable(query: WebGLQuery): boolean;
  129212. /**
  129213. * Gets the value of a given query
  129214. * @param query defines the query to check
  129215. * @returns the value of the query
  129216. */
  129217. getQueryResult(query: WebGLQuery): number;
  129218. /**
  129219. * Initiates an occlusion query
  129220. * @param algorithmType defines the algorithm to use
  129221. * @param query defines the query to use
  129222. * @returns the current engine
  129223. * @see https://doc.babylonjs.com/features/occlusionquery
  129224. */
  129225. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  129226. /**
  129227. * Ends an occlusion query
  129228. * @see https://doc.babylonjs.com/features/occlusionquery
  129229. * @param algorithmType defines the algorithm to use
  129230. * @returns the current engine
  129231. */
  129232. endOcclusionQuery(algorithmType: number): Engine;
  129233. /**
  129234. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  129235. * Please note that only one query can be issued at a time
  129236. * @returns a time token used to track the time span
  129237. */
  129238. startTimeQuery(): Nullable<_TimeToken>;
  129239. /**
  129240. * Ends a time query
  129241. * @param token defines the token used to measure the time span
  129242. * @returns the time spent (in ns)
  129243. */
  129244. endTimeQuery(token: _TimeToken): int;
  129245. /** @hidden */
  129246. _currentNonTimestampToken: Nullable<_TimeToken>;
  129247. /** @hidden */
  129248. _createTimeQuery(): WebGLQuery;
  129249. /** @hidden */
  129250. _deleteTimeQuery(query: WebGLQuery): void;
  129251. /** @hidden */
  129252. _getGlAlgorithmType(algorithmType: number): number;
  129253. /** @hidden */
  129254. _getTimeQueryResult(query: WebGLQuery): any;
  129255. /** @hidden */
  129256. _getTimeQueryAvailability(query: WebGLQuery): any;
  129257. }
  129258. interface AbstractMesh {
  129259. /**
  129260. * Backing filed
  129261. * @hidden
  129262. */
  129263. __occlusionDataStorage: _OcclusionDataStorage;
  129264. /**
  129265. * Access property
  129266. * @hidden
  129267. */
  129268. _occlusionDataStorage: _OcclusionDataStorage;
  129269. /**
  129270. * 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.
  129271. * The default value is -1 which means don't break the query and wait till the result
  129272. * @see https://doc.babylonjs.com/features/occlusionquery
  129273. */
  129274. occlusionRetryCount: number;
  129275. /**
  129276. * 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:
  129277. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  129278. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  129279. * * 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.
  129280. * @see https://doc.babylonjs.com/features/occlusionquery
  129281. */
  129282. occlusionType: number;
  129283. /**
  129284. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  129285. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  129286. * * 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.
  129287. * @see https://doc.babylonjs.com/features/occlusionquery
  129288. */
  129289. occlusionQueryAlgorithmType: number;
  129290. /**
  129291. * 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
  129292. * @see https://doc.babylonjs.com/features/occlusionquery
  129293. */
  129294. isOccluded: boolean;
  129295. /**
  129296. * Flag to check the progress status of the query
  129297. * @see https://doc.babylonjs.com/features/occlusionquery
  129298. */
  129299. isOcclusionQueryInProgress: boolean;
  129300. }
  129301. }
  129302. declare module BABYLON {
  129303. /** @hidden */
  129304. export var _forceTransformFeedbackToBundle: boolean;
  129305. interface Engine {
  129306. /**
  129307. * Creates a webGL transform feedback object
  129308. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  129309. * @returns the webGL transform feedback object
  129310. */
  129311. createTransformFeedback(): WebGLTransformFeedback;
  129312. /**
  129313. * Delete a webGL transform feedback object
  129314. * @param value defines the webGL transform feedback object to delete
  129315. */
  129316. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  129317. /**
  129318. * Bind a webGL transform feedback object to the webgl context
  129319. * @param value defines the webGL transform feedback object to bind
  129320. */
  129321. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  129322. /**
  129323. * Begins a transform feedback operation
  129324. * @param usePoints defines if points or triangles must be used
  129325. */
  129326. beginTransformFeedback(usePoints: boolean): void;
  129327. /**
  129328. * Ends a transform feedback operation
  129329. */
  129330. endTransformFeedback(): void;
  129331. /**
  129332. * Specify the varyings to use with transform feedback
  129333. * @param program defines the associated webGL program
  129334. * @param value defines the list of strings representing the varying names
  129335. */
  129336. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  129337. /**
  129338. * Bind a webGL buffer for a transform feedback operation
  129339. * @param value defines the webGL buffer to bind
  129340. */
  129341. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  129342. }
  129343. }
  129344. declare module BABYLON {
  129345. /**
  129346. * Creation options of the multi render target texture.
  129347. */
  129348. export interface IMultiRenderTargetOptions {
  129349. /**
  129350. * Define if the texture needs to create mip maps after render.
  129351. */
  129352. generateMipMaps?: boolean;
  129353. /**
  129354. * Define the types of all the draw buffers we want to create
  129355. */
  129356. types?: number[];
  129357. /**
  129358. * Define the sampling modes of all the draw buffers we want to create
  129359. */
  129360. samplingModes?: number[];
  129361. /**
  129362. * Define if a depth buffer is required
  129363. */
  129364. generateDepthBuffer?: boolean;
  129365. /**
  129366. * Define if a stencil buffer is required
  129367. */
  129368. generateStencilBuffer?: boolean;
  129369. /**
  129370. * Define if a depth texture is required instead of a depth buffer
  129371. */
  129372. generateDepthTexture?: boolean;
  129373. /**
  129374. * Define the number of desired draw buffers
  129375. */
  129376. textureCount?: number;
  129377. /**
  129378. * Define if aspect ratio should be adapted to the texture or stay the scene one
  129379. */
  129380. doNotChangeAspectRatio?: boolean;
  129381. /**
  129382. * Define the default type of the buffers we are creating
  129383. */
  129384. defaultType?: number;
  129385. }
  129386. /**
  129387. * A multi render target, like a render target provides the ability to render to a texture.
  129388. * Unlike the render target, it can render to several draw buffers in one draw.
  129389. * This is specially interesting in deferred rendering or for any effects requiring more than
  129390. * just one color from a single pass.
  129391. */
  129392. export class MultiRenderTarget extends RenderTargetTexture {
  129393. private _internalTextures;
  129394. private _textures;
  129395. private _multiRenderTargetOptions;
  129396. private _count;
  129397. /**
  129398. * Get if draw buffers are currently supported by the used hardware and browser.
  129399. */
  129400. get isSupported(): boolean;
  129401. /**
  129402. * Get the list of textures generated by the multi render target.
  129403. */
  129404. get textures(): Texture[];
  129405. /**
  129406. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  129407. */
  129408. get count(): number;
  129409. /**
  129410. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  129411. */
  129412. get depthTexture(): Texture;
  129413. /**
  129414. * Set the wrapping mode on U of all the textures we are rendering to.
  129415. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  129416. */
  129417. set wrapU(wrap: number);
  129418. /**
  129419. * Set the wrapping mode on V of all the textures we are rendering to.
  129420. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  129421. */
  129422. set wrapV(wrap: number);
  129423. /**
  129424. * Instantiate a new multi render target texture.
  129425. * A multi render target, like a render target provides the ability to render to a texture.
  129426. * Unlike the render target, it can render to several draw buffers in one draw.
  129427. * This is specially interesting in deferred rendering or for any effects requiring more than
  129428. * just one color from a single pass.
  129429. * @param name Define the name of the texture
  129430. * @param size Define the size of the buffers to render to
  129431. * @param count Define the number of target we are rendering into
  129432. * @param scene Define the scene the texture belongs to
  129433. * @param options Define the options used to create the multi render target
  129434. */
  129435. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  129436. /** @hidden */
  129437. _rebuild(): void;
  129438. private _createInternalTextures;
  129439. private _createTextures;
  129440. /**
  129441. * Define the number of samples used if MSAA is enabled.
  129442. */
  129443. get samples(): number;
  129444. set samples(value: number);
  129445. /**
  129446. * Resize all the textures in the multi render target.
  129447. * Be carrefull as it will recreate all the data in the new texture.
  129448. * @param size Define the new size
  129449. */
  129450. resize(size: any): void;
  129451. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  129452. /**
  129453. * Dispose the render targets and their associated resources
  129454. */
  129455. dispose(): void;
  129456. /**
  129457. * Release all the underlying texture used as draw buffers.
  129458. */
  129459. releaseInternalTextures(): void;
  129460. }
  129461. }
  129462. declare module BABYLON {
  129463. interface ThinEngine {
  129464. /**
  129465. * Unbind a list of render target textures from the webGL context
  129466. * This is used only when drawBuffer extension or webGL2 are active
  129467. * @param textures defines the render target textures to unbind
  129468. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  129469. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  129470. */
  129471. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  129472. /**
  129473. * Create a multi render target texture
  129474. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  129475. * @param size defines the size of the texture
  129476. * @param options defines the creation options
  129477. * @returns the cube texture as an InternalTexture
  129478. */
  129479. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  129480. /**
  129481. * Update the sample count for a given multiple render target texture
  129482. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  129483. * @param textures defines the textures to update
  129484. * @param samples defines the sample count to set
  129485. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  129486. */
  129487. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  129488. /**
  129489. * Select a subsets of attachments to draw to.
  129490. * @param attachments gl attachments
  129491. */
  129492. bindAttachments(attachments: number[]): void;
  129493. }
  129494. }
  129495. declare module BABYLON {
  129496. /**
  129497. * Class used to define an additional view for the engine
  129498. * @see https://doc.babylonjs.com/how_to/multi_canvases
  129499. */
  129500. export class EngineView {
  129501. /** Defines the canvas where to render the view */
  129502. target: HTMLCanvasElement;
  129503. /** Defines an optional camera used to render the view (will use active camera else) */
  129504. camera?: Camera;
  129505. }
  129506. interface Engine {
  129507. /**
  129508. * Gets or sets the HTML element to use for attaching events
  129509. */
  129510. inputElement: Nullable<HTMLElement>;
  129511. /**
  129512. * Gets the current engine view
  129513. * @see https://doc.babylonjs.com/how_to/multi_canvases
  129514. */
  129515. activeView: Nullable<EngineView>;
  129516. /** Gets or sets the list of views */
  129517. views: EngineView[];
  129518. /**
  129519. * Register a new child canvas
  129520. * @param canvas defines the canvas to register
  129521. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  129522. * @returns the associated view
  129523. */
  129524. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  129525. /**
  129526. * Remove a registered child canvas
  129527. * @param canvas defines the canvas to remove
  129528. * @returns the current engine
  129529. */
  129530. unRegisterView(canvas: HTMLCanvasElement): Engine;
  129531. }
  129532. }
  129533. declare module BABYLON {
  129534. interface Engine {
  129535. /** @hidden */
  129536. _excludedCompressedTextures: string[];
  129537. /** @hidden */
  129538. _textureFormatInUse: string;
  129539. /**
  129540. * Gets the list of texture formats supported
  129541. */
  129542. readonly texturesSupported: Array<string>;
  129543. /**
  129544. * Gets the texture format in use
  129545. */
  129546. readonly textureFormatInUse: Nullable<string>;
  129547. /**
  129548. * Set the compressed texture extensions or file names to skip.
  129549. *
  129550. * @param skippedFiles defines the list of those texture files you want to skip
  129551. * Example: [".dds", ".env", "myfile.png"]
  129552. */
  129553. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  129554. /**
  129555. * Set the compressed texture format to use, based on the formats you have, and the formats
  129556. * supported by the hardware / browser.
  129557. *
  129558. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  129559. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  129560. * to API arguments needed to compressed textures. This puts the burden on the container
  129561. * generator to house the arcane code for determining these for current & future formats.
  129562. *
  129563. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  129564. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  129565. *
  129566. * Note: The result of this call is not taken into account when a texture is base64.
  129567. *
  129568. * @param formatsAvailable defines the list of those format families you have created
  129569. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  129570. *
  129571. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  129572. * @returns The extension selected.
  129573. */
  129574. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  129575. }
  129576. }
  129577. declare module BABYLON {
  129578. /**
  129579. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  129580. */
  129581. export interface CubeMapInfo {
  129582. /**
  129583. * The pixel array for the front face.
  129584. * This is stored in format, left to right, up to down format.
  129585. */
  129586. front: Nullable<ArrayBufferView>;
  129587. /**
  129588. * The pixel array for the back face.
  129589. * This is stored in format, left to right, up to down format.
  129590. */
  129591. back: Nullable<ArrayBufferView>;
  129592. /**
  129593. * The pixel array for the left face.
  129594. * This is stored in format, left to right, up to down format.
  129595. */
  129596. left: Nullable<ArrayBufferView>;
  129597. /**
  129598. * The pixel array for the right face.
  129599. * This is stored in format, left to right, up to down format.
  129600. */
  129601. right: Nullable<ArrayBufferView>;
  129602. /**
  129603. * The pixel array for the up face.
  129604. * This is stored in format, left to right, up to down format.
  129605. */
  129606. up: Nullable<ArrayBufferView>;
  129607. /**
  129608. * The pixel array for the down face.
  129609. * This is stored in format, left to right, up to down format.
  129610. */
  129611. down: Nullable<ArrayBufferView>;
  129612. /**
  129613. * The size of the cubemap stored.
  129614. *
  129615. * Each faces will be size * size pixels.
  129616. */
  129617. size: number;
  129618. /**
  129619. * The format of the texture.
  129620. *
  129621. * RGBA, RGB.
  129622. */
  129623. format: number;
  129624. /**
  129625. * The type of the texture data.
  129626. *
  129627. * UNSIGNED_INT, FLOAT.
  129628. */
  129629. type: number;
  129630. /**
  129631. * Specifies whether the texture is in gamma space.
  129632. */
  129633. gammaSpace: boolean;
  129634. }
  129635. /**
  129636. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  129637. */
  129638. export class PanoramaToCubeMapTools {
  129639. private static FACE_LEFT;
  129640. private static FACE_RIGHT;
  129641. private static FACE_FRONT;
  129642. private static FACE_BACK;
  129643. private static FACE_DOWN;
  129644. private static FACE_UP;
  129645. /**
  129646. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  129647. *
  129648. * @param float32Array The source data.
  129649. * @param inputWidth The width of the input panorama.
  129650. * @param inputHeight The height of the input panorama.
  129651. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  129652. * @return The cubemap data
  129653. */
  129654. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  129655. private static CreateCubemapTexture;
  129656. private static CalcProjectionSpherical;
  129657. }
  129658. }
  129659. declare module BABYLON {
  129660. /**
  129661. * Helper class dealing with the extraction of spherical polynomial dataArray
  129662. * from a cube map.
  129663. */
  129664. export class CubeMapToSphericalPolynomialTools {
  129665. private static FileFaces;
  129666. /**
  129667. * Converts a texture to the according Spherical Polynomial data.
  129668. * This extracts the first 3 orders only as they are the only one used in the lighting.
  129669. *
  129670. * @param texture The texture to extract the information from.
  129671. * @return The Spherical Polynomial data.
  129672. */
  129673. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  129674. /**
  129675. * Converts a cubemap to the according Spherical Polynomial data.
  129676. * This extracts the first 3 orders only as they are the only one used in the lighting.
  129677. *
  129678. * @param cubeInfo The Cube map to extract the information from.
  129679. * @return The Spherical Polynomial data.
  129680. */
  129681. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  129682. }
  129683. }
  129684. declare module BABYLON {
  129685. interface BaseTexture {
  129686. /**
  129687. * Get the polynomial representation of the texture data.
  129688. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  129689. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  129690. */
  129691. sphericalPolynomial: Nullable<SphericalPolynomial>;
  129692. }
  129693. }
  129694. declare module BABYLON {
  129695. /** @hidden */
  129696. export var rgbdEncodePixelShader: {
  129697. name: string;
  129698. shader: string;
  129699. };
  129700. }
  129701. declare module BABYLON {
  129702. /** @hidden */
  129703. export var rgbdDecodePixelShader: {
  129704. name: string;
  129705. shader: string;
  129706. };
  129707. }
  129708. declare module BABYLON {
  129709. /**
  129710. * Raw texture data and descriptor sufficient for WebGL texture upload
  129711. */
  129712. export interface EnvironmentTextureInfo {
  129713. /**
  129714. * Version of the environment map
  129715. */
  129716. version: number;
  129717. /**
  129718. * Width of image
  129719. */
  129720. width: number;
  129721. /**
  129722. * Irradiance information stored in the file.
  129723. */
  129724. irradiance: any;
  129725. /**
  129726. * Specular information stored in the file.
  129727. */
  129728. specular: any;
  129729. }
  129730. /**
  129731. * Defines One Image in the file. It requires only the position in the file
  129732. * as well as the length.
  129733. */
  129734. interface BufferImageData {
  129735. /**
  129736. * Length of the image data.
  129737. */
  129738. length: number;
  129739. /**
  129740. * Position of the data from the null terminator delimiting the end of the JSON.
  129741. */
  129742. position: number;
  129743. }
  129744. /**
  129745. * Defines the specular data enclosed in the file.
  129746. * This corresponds to the version 1 of the data.
  129747. */
  129748. export interface EnvironmentTextureSpecularInfoV1 {
  129749. /**
  129750. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  129751. */
  129752. specularDataPosition?: number;
  129753. /**
  129754. * This contains all the images data needed to reconstruct the cubemap.
  129755. */
  129756. mipmaps: Array<BufferImageData>;
  129757. /**
  129758. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  129759. */
  129760. lodGenerationScale: number;
  129761. }
  129762. /**
  129763. * Sets of helpers addressing the serialization and deserialization of environment texture
  129764. * stored in a BabylonJS env file.
  129765. * Those files are usually stored as .env files.
  129766. */
  129767. export class EnvironmentTextureTools {
  129768. /**
  129769. * Magic number identifying the env file.
  129770. */
  129771. private static _MagicBytes;
  129772. /**
  129773. * Gets the environment info from an env file.
  129774. * @param data The array buffer containing the .env bytes.
  129775. * @returns the environment file info (the json header) if successfully parsed.
  129776. */
  129777. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  129778. /**
  129779. * Creates an environment texture from a loaded cube texture.
  129780. * @param texture defines the cube texture to convert in env file
  129781. * @return a promise containing the environment data if succesfull.
  129782. */
  129783. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  129784. /**
  129785. * Creates a JSON representation of the spherical data.
  129786. * @param texture defines the texture containing the polynomials
  129787. * @return the JSON representation of the spherical info
  129788. */
  129789. private static _CreateEnvTextureIrradiance;
  129790. /**
  129791. * Creates the ArrayBufferViews used for initializing environment texture image data.
  129792. * @param data the image data
  129793. * @param info parameters that determine what views will be created for accessing the underlying buffer
  129794. * @return the views described by info providing access to the underlying buffer
  129795. */
  129796. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  129797. /**
  129798. * Uploads the texture info contained in the env file to the GPU.
  129799. * @param texture defines the internal texture to upload to
  129800. * @param data defines the data to load
  129801. * @param info defines the texture info retrieved through the GetEnvInfo method
  129802. * @returns a promise
  129803. */
  129804. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  129805. private static _OnImageReadyAsync;
  129806. /**
  129807. * Uploads the levels of image data to the GPU.
  129808. * @param texture defines the internal texture to upload to
  129809. * @param imageData defines the array buffer views of image data [mipmap][face]
  129810. * @returns a promise
  129811. */
  129812. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  129813. /**
  129814. * Uploads spherical polynomials information to the texture.
  129815. * @param texture defines the texture we are trying to upload the information to
  129816. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  129817. */
  129818. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  129819. /** @hidden */
  129820. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129821. }
  129822. }
  129823. declare module BABYLON {
  129824. /**
  129825. * Class used to inline functions in shader code
  129826. */
  129827. export class ShaderCodeInliner {
  129828. private static readonly _RegexpFindFunctionNameAndType;
  129829. private _sourceCode;
  129830. private _functionDescr;
  129831. private _numMaxIterations;
  129832. /** Gets or sets the token used to mark the functions to inline */
  129833. inlineToken: string;
  129834. /** Gets or sets the debug mode */
  129835. debug: boolean;
  129836. /** Gets the code after the inlining process */
  129837. get code(): string;
  129838. /**
  129839. * Initializes the inliner
  129840. * @param sourceCode shader code source to inline
  129841. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  129842. */
  129843. constructor(sourceCode: string, numMaxIterations?: number);
  129844. /**
  129845. * Start the processing of the shader code
  129846. */
  129847. processCode(): void;
  129848. private _collectFunctions;
  129849. private _processInlining;
  129850. private _extractBetweenMarkers;
  129851. private _skipWhitespaces;
  129852. private _removeComments;
  129853. private _replaceFunctionCallsByCode;
  129854. private _findBackward;
  129855. private _escapeRegExp;
  129856. private _replaceNames;
  129857. }
  129858. }
  129859. declare module BABYLON {
  129860. /**
  129861. * Container for accessors for natively-stored mesh data buffers.
  129862. */
  129863. class NativeDataBuffer extends DataBuffer {
  129864. /**
  129865. * Accessor value used to identify/retrieve a natively-stored index buffer.
  129866. */
  129867. nativeIndexBuffer?: any;
  129868. /**
  129869. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  129870. */
  129871. nativeVertexBuffer?: any;
  129872. }
  129873. /** @hidden */
  129874. class NativeTexture extends InternalTexture {
  129875. getInternalTexture(): InternalTexture;
  129876. getViewCount(): number;
  129877. }
  129878. /** @hidden */
  129879. export class NativeEngine extends Engine {
  129880. private readonly _native;
  129881. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  129882. private readonly INVALID_HANDLE;
  129883. getHardwareScalingLevel(): number;
  129884. constructor();
  129885. dispose(): void;
  129886. /**
  129887. * Can be used to override the current requestAnimationFrame requester.
  129888. * @hidden
  129889. */
  129890. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  129891. /**
  129892. * Override default engine behavior.
  129893. * @param color
  129894. * @param backBuffer
  129895. * @param depth
  129896. * @param stencil
  129897. */
  129898. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  129899. /**
  129900. * Gets host document
  129901. * @returns the host document object
  129902. */
  129903. getHostDocument(): Nullable<Document>;
  129904. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  129905. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  129906. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  129907. recordVertexArrayObject(vertexBuffers: {
  129908. [key: string]: VertexBuffer;
  129909. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  129910. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  129911. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  129912. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  129913. /**
  129914. * Draw a list of indexed primitives
  129915. * @param fillMode defines the primitive to use
  129916. * @param indexStart defines the starting index
  129917. * @param indexCount defines the number of index to draw
  129918. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129919. */
  129920. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  129921. /**
  129922. * Draw a list of unindexed primitives
  129923. * @param fillMode defines the primitive to use
  129924. * @param verticesStart defines the index of first vertex to draw
  129925. * @param verticesCount defines the count of vertices to draw
  129926. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129927. */
  129928. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  129929. createPipelineContext(): IPipelineContext;
  129930. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  129931. /** @hidden */
  129932. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  129933. /** @hidden */
  129934. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  129935. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  129936. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  129937. protected _setProgram(program: WebGLProgram): void;
  129938. _releaseEffect(effect: Effect): void;
  129939. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  129940. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  129941. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  129942. bindSamplers(effect: Effect): void;
  129943. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  129944. getRenderWidth(useScreen?: boolean): number;
  129945. getRenderHeight(useScreen?: boolean): number;
  129946. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  129947. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  129948. /**
  129949. * Set the z offset to apply to current rendering
  129950. * @param value defines the offset to apply
  129951. */
  129952. setZOffset(value: number): void;
  129953. /**
  129954. * Gets the current value of the zOffset
  129955. * @returns the current zOffset state
  129956. */
  129957. getZOffset(): number;
  129958. /**
  129959. * Enable or disable depth buffering
  129960. * @param enable defines the state to set
  129961. */
  129962. setDepthBuffer(enable: boolean): void;
  129963. /**
  129964. * Gets a boolean indicating if depth writing is enabled
  129965. * @returns the current depth writing state
  129966. */
  129967. getDepthWrite(): boolean;
  129968. /**
  129969. * Enable or disable depth writing
  129970. * @param enable defines the state to set
  129971. */
  129972. setDepthWrite(enable: boolean): void;
  129973. /**
  129974. * Enable or disable color writing
  129975. * @param enable defines the state to set
  129976. */
  129977. setColorWrite(enable: boolean): void;
  129978. /**
  129979. * Gets a boolean indicating if color writing is enabled
  129980. * @returns the current color writing state
  129981. */
  129982. getColorWrite(): boolean;
  129983. /**
  129984. * Sets alpha constants used by some alpha blending modes
  129985. * @param r defines the red component
  129986. * @param g defines the green component
  129987. * @param b defines the blue component
  129988. * @param a defines the alpha component
  129989. */
  129990. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  129991. /**
  129992. * Sets the current alpha mode
  129993. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  129994. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  129995. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  129996. */
  129997. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  129998. /**
  129999. * Gets the current alpha mode
  130000. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  130001. * @returns the current alpha mode
  130002. */
  130003. getAlphaMode(): number;
  130004. setInt(uniform: WebGLUniformLocation, int: number): void;
  130005. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  130006. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  130007. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  130008. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  130009. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  130010. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  130011. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  130012. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  130013. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  130014. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  130015. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  130016. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  130017. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  130018. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  130019. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  130020. setFloat(uniform: WebGLUniformLocation, value: number): void;
  130021. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  130022. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  130023. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  130024. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  130025. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  130026. wipeCaches(bruteForce?: boolean): void;
  130027. _createTexture(): WebGLTexture;
  130028. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  130029. /**
  130030. * Usually called from Texture.ts.
  130031. * Passed information to create a WebGLTexture
  130032. * @param url defines a value which contains one of the following:
  130033. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  130034. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  130035. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  130036. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  130037. * @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)
  130038. * @param scene needed for loading to the correct scene
  130039. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  130040. * @param onLoad optional callback to be called upon successful completion
  130041. * @param onError optional callback to be called upon failure
  130042. * @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
  130043. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  130044. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  130045. * @param forcedExtension defines the extension to use to pick the right loader
  130046. * @param mimeType defines an optional mime type
  130047. * @returns a InternalTexture for assignment back into BABYLON.Texture
  130048. */
  130049. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  130050. /**
  130051. * Creates a cube texture
  130052. * @param rootUrl defines the url where the files to load is located
  130053. * @param scene defines the current scene
  130054. * @param files defines the list of files to load (1 per face)
  130055. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  130056. * @param onLoad defines an optional callback raised when the texture is loaded
  130057. * @param onError defines an optional callback raised if there is an issue to load the texture
  130058. * @param format defines the format of the data
  130059. * @param forcedExtension defines the extension to use to pick the right loader
  130060. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  130061. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  130062. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  130063. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  130064. * @returns the cube texture as an InternalTexture
  130065. */
  130066. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  130067. private _getSamplingFilter;
  130068. private static _GetNativeTextureFormat;
  130069. createRenderTargetTexture(size: number | {
  130070. width: number;
  130071. height: number;
  130072. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  130073. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  130074. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  130075. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  130076. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  130077. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  130078. /**
  130079. * Updates a dynamic vertex buffer.
  130080. * @param vertexBuffer the vertex buffer to update
  130081. * @param data the data used to update the vertex buffer
  130082. * @param byteOffset the byte offset of the data (optional)
  130083. * @param byteLength the byte length of the data (optional)
  130084. */
  130085. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  130086. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  130087. private _updateAnisotropicLevel;
  130088. private _getAddressMode;
  130089. /** @hidden */
  130090. _bindTexture(channel: number, texture: InternalTexture): void;
  130091. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  130092. releaseEffects(): void;
  130093. /** @hidden */
  130094. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130095. /** @hidden */
  130096. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130097. /** @hidden */
  130098. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130099. /** @hidden */
  130100. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  130101. }
  130102. }
  130103. declare module BABYLON {
  130104. /**
  130105. * Gather the list of clipboard event types as constants.
  130106. */
  130107. export class ClipboardEventTypes {
  130108. /**
  130109. * The clipboard event is fired when a copy command is active (pressed).
  130110. */
  130111. static readonly COPY: number;
  130112. /**
  130113. * The clipboard event is fired when a cut command is active (pressed).
  130114. */
  130115. static readonly CUT: number;
  130116. /**
  130117. * The clipboard event is fired when a paste command is active (pressed).
  130118. */
  130119. static readonly PASTE: number;
  130120. }
  130121. /**
  130122. * This class is used to store clipboard related info for the onClipboardObservable event.
  130123. */
  130124. export class ClipboardInfo {
  130125. /**
  130126. * Defines the type of event (BABYLON.ClipboardEventTypes)
  130127. */
  130128. type: number;
  130129. /**
  130130. * Defines the related dom event
  130131. */
  130132. event: ClipboardEvent;
  130133. /**
  130134. *Creates an instance of ClipboardInfo.
  130135. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  130136. * @param event Defines the related dom event
  130137. */
  130138. constructor(
  130139. /**
  130140. * Defines the type of event (BABYLON.ClipboardEventTypes)
  130141. */
  130142. type: number,
  130143. /**
  130144. * Defines the related dom event
  130145. */
  130146. event: ClipboardEvent);
  130147. /**
  130148. * Get the clipboard event's type from the keycode.
  130149. * @param keyCode Defines the keyCode for the current keyboard event.
  130150. * @return {number}
  130151. */
  130152. static GetTypeFromCharacter(keyCode: number): number;
  130153. }
  130154. }
  130155. declare module BABYLON {
  130156. /**
  130157. * Google Daydream controller
  130158. */
  130159. export class DaydreamController extends WebVRController {
  130160. /**
  130161. * Base Url for the controller model.
  130162. */
  130163. static MODEL_BASE_URL: string;
  130164. /**
  130165. * File name for the controller model.
  130166. */
  130167. static MODEL_FILENAME: string;
  130168. /**
  130169. * Gamepad Id prefix used to identify Daydream Controller.
  130170. */
  130171. static readonly GAMEPAD_ID_PREFIX: string;
  130172. /**
  130173. * Creates a new DaydreamController from a gamepad
  130174. * @param vrGamepad the gamepad that the controller should be created from
  130175. */
  130176. constructor(vrGamepad: any);
  130177. /**
  130178. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130179. * @param scene scene in which to add meshes
  130180. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130181. */
  130182. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130183. /**
  130184. * Called once for each button that changed state since the last frame
  130185. * @param buttonIdx Which button index changed
  130186. * @param state New state of the button
  130187. * @param changes Which properties on the state changed since last frame
  130188. */
  130189. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130190. }
  130191. }
  130192. declare module BABYLON {
  130193. /**
  130194. * Gear VR Controller
  130195. */
  130196. export class GearVRController extends WebVRController {
  130197. /**
  130198. * Base Url for the controller model.
  130199. */
  130200. static MODEL_BASE_URL: string;
  130201. /**
  130202. * File name for the controller model.
  130203. */
  130204. static MODEL_FILENAME: string;
  130205. /**
  130206. * Gamepad Id prefix used to identify this controller.
  130207. */
  130208. static readonly GAMEPAD_ID_PREFIX: string;
  130209. private readonly _buttonIndexToObservableNameMap;
  130210. /**
  130211. * Creates a new GearVRController from a gamepad
  130212. * @param vrGamepad the gamepad that the controller should be created from
  130213. */
  130214. constructor(vrGamepad: any);
  130215. /**
  130216. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130217. * @param scene scene in which to add meshes
  130218. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130219. */
  130220. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130221. /**
  130222. * Called once for each button that changed state since the last frame
  130223. * @param buttonIdx Which button index changed
  130224. * @param state New state of the button
  130225. * @param changes Which properties on the state changed since last frame
  130226. */
  130227. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130228. }
  130229. }
  130230. declare module BABYLON {
  130231. /**
  130232. * Generic Controller
  130233. */
  130234. export class GenericController extends WebVRController {
  130235. /**
  130236. * Base Url for the controller model.
  130237. */
  130238. static readonly MODEL_BASE_URL: string;
  130239. /**
  130240. * File name for the controller model.
  130241. */
  130242. static readonly MODEL_FILENAME: string;
  130243. /**
  130244. * Creates a new GenericController from a gamepad
  130245. * @param vrGamepad the gamepad that the controller should be created from
  130246. */
  130247. constructor(vrGamepad: any);
  130248. /**
  130249. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130250. * @param scene scene in which to add meshes
  130251. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130252. */
  130253. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130254. /**
  130255. * Called once for each button that changed state since the last frame
  130256. * @param buttonIdx Which button index changed
  130257. * @param state New state of the button
  130258. * @param changes Which properties on the state changed since last frame
  130259. */
  130260. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130261. }
  130262. }
  130263. declare module BABYLON {
  130264. /**
  130265. * Oculus Touch Controller
  130266. */
  130267. export class OculusTouchController extends WebVRController {
  130268. /**
  130269. * Base Url for the controller model.
  130270. */
  130271. static MODEL_BASE_URL: string;
  130272. /**
  130273. * File name for the left controller model.
  130274. */
  130275. static MODEL_LEFT_FILENAME: string;
  130276. /**
  130277. * File name for the right controller model.
  130278. */
  130279. static MODEL_RIGHT_FILENAME: string;
  130280. /**
  130281. * Base Url for the Quest controller model.
  130282. */
  130283. static QUEST_MODEL_BASE_URL: string;
  130284. /**
  130285. * @hidden
  130286. * If the controllers are running on a device that needs the updated Quest controller models
  130287. */
  130288. static _IsQuest: boolean;
  130289. /**
  130290. * Fired when the secondary trigger on this controller is modified
  130291. */
  130292. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  130293. /**
  130294. * Fired when the thumb rest on this controller is modified
  130295. */
  130296. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  130297. /**
  130298. * Creates a new OculusTouchController from a gamepad
  130299. * @param vrGamepad the gamepad that the controller should be created from
  130300. */
  130301. constructor(vrGamepad: any);
  130302. /**
  130303. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130304. * @param scene scene in which to add meshes
  130305. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130306. */
  130307. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130308. /**
  130309. * Fired when the A button on this controller is modified
  130310. */
  130311. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130312. /**
  130313. * Fired when the B button on this controller is modified
  130314. */
  130315. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130316. /**
  130317. * Fired when the X button on this controller is modified
  130318. */
  130319. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130320. /**
  130321. * Fired when the Y button on this controller is modified
  130322. */
  130323. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130324. /**
  130325. * Called once for each button that changed state since the last frame
  130326. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  130327. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  130328. * 2) secondary trigger (same)
  130329. * 3) A (right) X (left), touch, pressed = value
  130330. * 4) B / Y
  130331. * 5) thumb rest
  130332. * @param buttonIdx Which button index changed
  130333. * @param state New state of the button
  130334. * @param changes Which properties on the state changed since last frame
  130335. */
  130336. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130337. }
  130338. }
  130339. declare module BABYLON {
  130340. /**
  130341. * Vive Controller
  130342. */
  130343. export class ViveController extends WebVRController {
  130344. /**
  130345. * Base Url for the controller model.
  130346. */
  130347. static MODEL_BASE_URL: string;
  130348. /**
  130349. * File name for the controller model.
  130350. */
  130351. static MODEL_FILENAME: string;
  130352. /**
  130353. * Creates a new ViveController from a gamepad
  130354. * @param vrGamepad the gamepad that the controller should be created from
  130355. */
  130356. constructor(vrGamepad: any);
  130357. /**
  130358. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130359. * @param scene scene in which to add meshes
  130360. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130361. */
  130362. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130363. /**
  130364. * Fired when the left button on this controller is modified
  130365. */
  130366. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130367. /**
  130368. * Fired when the right button on this controller is modified
  130369. */
  130370. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130371. /**
  130372. * Fired when the menu button on this controller is modified
  130373. */
  130374. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130375. /**
  130376. * Called once for each button that changed state since the last frame
  130377. * Vive mapping:
  130378. * 0: touchpad
  130379. * 1: trigger
  130380. * 2: left AND right buttons
  130381. * 3: menu button
  130382. * @param buttonIdx Which button index changed
  130383. * @param state New state of the button
  130384. * @param changes Which properties on the state changed since last frame
  130385. */
  130386. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130387. }
  130388. }
  130389. declare module BABYLON {
  130390. /**
  130391. * Defines the WindowsMotionController object that the state of the windows motion controller
  130392. */
  130393. export class WindowsMotionController extends WebVRController {
  130394. /**
  130395. * The base url used to load the left and right controller models
  130396. */
  130397. static MODEL_BASE_URL: string;
  130398. /**
  130399. * The name of the left controller model file
  130400. */
  130401. static MODEL_LEFT_FILENAME: string;
  130402. /**
  130403. * The name of the right controller model file
  130404. */
  130405. static MODEL_RIGHT_FILENAME: string;
  130406. /**
  130407. * The controller name prefix for this controller type
  130408. */
  130409. static readonly GAMEPAD_ID_PREFIX: string;
  130410. /**
  130411. * The controller id pattern for this controller type
  130412. */
  130413. private static readonly GAMEPAD_ID_PATTERN;
  130414. private _loadedMeshInfo;
  130415. protected readonly _mapping: {
  130416. buttons: string[];
  130417. buttonMeshNames: {
  130418. trigger: string;
  130419. menu: string;
  130420. grip: string;
  130421. thumbstick: string;
  130422. trackpad: string;
  130423. };
  130424. buttonObservableNames: {
  130425. trigger: string;
  130426. menu: string;
  130427. grip: string;
  130428. thumbstick: string;
  130429. trackpad: string;
  130430. };
  130431. axisMeshNames: string[];
  130432. pointingPoseMeshName: string;
  130433. };
  130434. /**
  130435. * Fired when the trackpad on this controller is clicked
  130436. */
  130437. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  130438. /**
  130439. * Fired when the trackpad on this controller is modified
  130440. */
  130441. onTrackpadValuesChangedObservable: Observable<StickValues>;
  130442. /**
  130443. * The current x and y values of this controller's trackpad
  130444. */
  130445. trackpad: StickValues;
  130446. /**
  130447. * Creates a new WindowsMotionController from a gamepad
  130448. * @param vrGamepad the gamepad that the controller should be created from
  130449. */
  130450. constructor(vrGamepad: any);
  130451. /**
  130452. * Fired when the trigger on this controller is modified
  130453. */
  130454. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130455. /**
  130456. * Fired when the menu button on this controller is modified
  130457. */
  130458. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130459. /**
  130460. * Fired when the grip button on this controller is modified
  130461. */
  130462. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130463. /**
  130464. * Fired when the thumbstick button on this controller is modified
  130465. */
  130466. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130467. /**
  130468. * Fired when the touchpad button on this controller is modified
  130469. */
  130470. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130471. /**
  130472. * Fired when the touchpad values on this controller are modified
  130473. */
  130474. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  130475. protected _updateTrackpad(): void;
  130476. /**
  130477. * Called once per frame by the engine.
  130478. */
  130479. update(): void;
  130480. /**
  130481. * Called once for each button that changed state since the last frame
  130482. * @param buttonIdx Which button index changed
  130483. * @param state New state of the button
  130484. * @param changes Which properties on the state changed since last frame
  130485. */
  130486. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130487. /**
  130488. * Moves the buttons on the controller mesh based on their current state
  130489. * @param buttonName the name of the button to move
  130490. * @param buttonValue the value of the button which determines the buttons new position
  130491. */
  130492. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  130493. /**
  130494. * Moves the axis on the controller mesh based on its current state
  130495. * @param axis the index of the axis
  130496. * @param axisValue the value of the axis which determines the meshes new position
  130497. * @hidden
  130498. */
  130499. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  130500. /**
  130501. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130502. * @param scene scene in which to add meshes
  130503. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130504. */
  130505. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  130506. /**
  130507. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  130508. * can be transformed by button presses and axes values, based on this._mapping.
  130509. *
  130510. * @param scene scene in which the meshes exist
  130511. * @param meshes list of meshes that make up the controller model to process
  130512. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  130513. */
  130514. private processModel;
  130515. private createMeshInfo;
  130516. /**
  130517. * Gets the ray of the controller in the direction the controller is pointing
  130518. * @param length the length the resulting ray should be
  130519. * @returns a ray in the direction the controller is pointing
  130520. */
  130521. getForwardRay(length?: number): Ray;
  130522. /**
  130523. * Disposes of the controller
  130524. */
  130525. dispose(): void;
  130526. }
  130527. /**
  130528. * This class represents a new windows motion controller in XR.
  130529. */
  130530. export class XRWindowsMotionController extends WindowsMotionController {
  130531. /**
  130532. * Changing the original WIndowsMotionController mapping to fir the new mapping
  130533. */
  130534. protected readonly _mapping: {
  130535. buttons: string[];
  130536. buttonMeshNames: {
  130537. trigger: string;
  130538. menu: string;
  130539. grip: string;
  130540. thumbstick: string;
  130541. trackpad: string;
  130542. };
  130543. buttonObservableNames: {
  130544. trigger: string;
  130545. menu: string;
  130546. grip: string;
  130547. thumbstick: string;
  130548. trackpad: string;
  130549. };
  130550. axisMeshNames: string[];
  130551. pointingPoseMeshName: string;
  130552. };
  130553. /**
  130554. * Construct a new XR-Based windows motion controller
  130555. *
  130556. * @param gamepadInfo the gamepad object from the browser
  130557. */
  130558. constructor(gamepadInfo: any);
  130559. /**
  130560. * holds the thumbstick values (X,Y)
  130561. */
  130562. thumbstickValues: StickValues;
  130563. /**
  130564. * Fired when the thumbstick on this controller is clicked
  130565. */
  130566. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  130567. /**
  130568. * Fired when the thumbstick on this controller is modified
  130569. */
  130570. onThumbstickValuesChangedObservable: Observable<StickValues>;
  130571. /**
  130572. * Fired when the touchpad button on this controller is modified
  130573. */
  130574. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  130575. /**
  130576. * Fired when the touchpad values on this controller are modified
  130577. */
  130578. onTrackpadValuesChangedObservable: Observable<StickValues>;
  130579. /**
  130580. * Fired when the thumbstick button on this controller is modified
  130581. * here to prevent breaking changes
  130582. */
  130583. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130584. /**
  130585. * updating the thumbstick(!) and not the trackpad.
  130586. * This is named this way due to the difference between WebVR and XR and to avoid
  130587. * changing the parent class.
  130588. */
  130589. protected _updateTrackpad(): void;
  130590. /**
  130591. * Disposes the class with joy
  130592. */
  130593. dispose(): void;
  130594. }
  130595. }
  130596. declare module BABYLON {
  130597. /**
  130598. * Class containing static functions to help procedurally build meshes
  130599. */
  130600. export class PolyhedronBuilder {
  130601. /**
  130602. * Creates a polyhedron mesh
  130603. * * 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
  130604. * * The parameter `size` (positive float, default 1) sets the polygon size
  130605. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  130606. * * 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`
  130607. * * 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
  130608. * * 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)`)
  130609. * * 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
  130610. * * 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
  130611. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130612. * * 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
  130613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130614. * @param name defines the name of the mesh
  130615. * @param options defines the options used to create the mesh
  130616. * @param scene defines the hosting scene
  130617. * @returns the polyhedron mesh
  130618. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  130619. */
  130620. static CreatePolyhedron(name: string, options: {
  130621. type?: number;
  130622. size?: number;
  130623. sizeX?: number;
  130624. sizeY?: number;
  130625. sizeZ?: number;
  130626. custom?: any;
  130627. faceUV?: Vector4[];
  130628. faceColors?: Color4[];
  130629. flat?: boolean;
  130630. updatable?: boolean;
  130631. sideOrientation?: number;
  130632. frontUVs?: Vector4;
  130633. backUVs?: Vector4;
  130634. }, scene?: Nullable<Scene>): Mesh;
  130635. }
  130636. }
  130637. declare module BABYLON {
  130638. /**
  130639. * Gizmo that enables scaling a mesh along 3 axis
  130640. */
  130641. export class ScaleGizmo extends Gizmo {
  130642. /**
  130643. * Internal gizmo used for interactions on the x axis
  130644. */
  130645. xGizmo: AxisScaleGizmo;
  130646. /**
  130647. * Internal gizmo used for interactions on the y axis
  130648. */
  130649. yGizmo: AxisScaleGizmo;
  130650. /**
  130651. * Internal gizmo used for interactions on the z axis
  130652. */
  130653. zGizmo: AxisScaleGizmo;
  130654. /**
  130655. * Internal gizmo used to scale all axis equally
  130656. */
  130657. uniformScaleGizmo: AxisScaleGizmo;
  130658. private _meshAttached;
  130659. private _updateGizmoRotationToMatchAttachedMesh;
  130660. private _snapDistance;
  130661. private _scaleRatio;
  130662. private _uniformScalingMesh;
  130663. private _octahedron;
  130664. private _sensitivity;
  130665. /** Fires an event when any of it's sub gizmos are dragged */
  130666. onDragStartObservable: Observable<unknown>;
  130667. /** Fires an event when any of it's sub gizmos are released from dragging */
  130668. onDragEndObservable: Observable<unknown>;
  130669. get attachedMesh(): Nullable<AbstractMesh>;
  130670. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130671. /**
  130672. * Creates a ScaleGizmo
  130673. * @param gizmoLayer The utility layer the gizmo will be added to
  130674. */
  130675. constructor(gizmoLayer?: UtilityLayerRenderer);
  130676. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130677. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130678. /**
  130679. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130680. */
  130681. set snapDistance(value: number);
  130682. get snapDistance(): number;
  130683. /**
  130684. * Ratio for the scale of the gizmo (Default: 1)
  130685. */
  130686. set scaleRatio(value: number);
  130687. get scaleRatio(): number;
  130688. /**
  130689. * Sensitivity factor for dragging (Default: 1)
  130690. */
  130691. set sensitivity(value: number);
  130692. get sensitivity(): number;
  130693. /**
  130694. * Disposes of the gizmo
  130695. */
  130696. dispose(): void;
  130697. }
  130698. }
  130699. declare module BABYLON {
  130700. /**
  130701. * Single axis scale gizmo
  130702. */
  130703. export class AxisScaleGizmo extends Gizmo {
  130704. /**
  130705. * Drag behavior responsible for the gizmos dragging interactions
  130706. */
  130707. dragBehavior: PointerDragBehavior;
  130708. private _pointerObserver;
  130709. /**
  130710. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130711. */
  130712. snapDistance: number;
  130713. /**
  130714. * Event that fires each time the gizmo snaps to a new location.
  130715. * * snapDistance is the the change in distance
  130716. */
  130717. onSnapObservable: Observable<{
  130718. snapDistance: number;
  130719. }>;
  130720. /**
  130721. * If the scaling operation should be done on all axis (default: false)
  130722. */
  130723. uniformScaling: boolean;
  130724. /**
  130725. * Custom sensitivity value for the drag strength
  130726. */
  130727. sensitivity: number;
  130728. private _isEnabled;
  130729. private _parent;
  130730. private _arrow;
  130731. private _coloredMaterial;
  130732. private _hoverMaterial;
  130733. /**
  130734. * Creates an AxisScaleGizmo
  130735. * @param gizmoLayer The utility layer the gizmo will be added to
  130736. * @param dragAxis The axis which the gizmo will be able to scale on
  130737. * @param color The color of the gizmo
  130738. */
  130739. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  130740. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  130741. /**
  130742. * If the gizmo is enabled
  130743. */
  130744. set isEnabled(value: boolean);
  130745. get isEnabled(): boolean;
  130746. /**
  130747. * Disposes of the gizmo
  130748. */
  130749. dispose(): void;
  130750. /**
  130751. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  130752. * @param mesh The mesh to replace the default mesh of the gizmo
  130753. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  130754. */
  130755. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  130756. }
  130757. }
  130758. declare module BABYLON {
  130759. /**
  130760. * Bounding box gizmo
  130761. */
  130762. export class BoundingBoxGizmo extends Gizmo {
  130763. private _lineBoundingBox;
  130764. private _rotateSpheresParent;
  130765. private _scaleBoxesParent;
  130766. private _boundingDimensions;
  130767. private _renderObserver;
  130768. private _pointerObserver;
  130769. private _scaleDragSpeed;
  130770. private _tmpQuaternion;
  130771. private _tmpVector;
  130772. private _tmpRotationMatrix;
  130773. /**
  130774. * 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)
  130775. */
  130776. ignoreChildren: boolean;
  130777. /**
  130778. * 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)
  130779. */
  130780. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  130781. /**
  130782. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  130783. */
  130784. rotationSphereSize: number;
  130785. /**
  130786. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  130787. */
  130788. scaleBoxSize: number;
  130789. /**
  130790. * 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)
  130791. */
  130792. fixedDragMeshScreenSize: boolean;
  130793. /**
  130794. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  130795. */
  130796. fixedDragMeshScreenSizeDistanceFactor: number;
  130797. /**
  130798. * Fired when a rotation sphere or scale box is dragged
  130799. */
  130800. onDragStartObservable: Observable<{}>;
  130801. /**
  130802. * Fired when a scale box is dragged
  130803. */
  130804. onScaleBoxDragObservable: Observable<{}>;
  130805. /**
  130806. * Fired when a scale box drag is ended
  130807. */
  130808. onScaleBoxDragEndObservable: Observable<{}>;
  130809. /**
  130810. * Fired when a rotation sphere is dragged
  130811. */
  130812. onRotationSphereDragObservable: Observable<{}>;
  130813. /**
  130814. * Fired when a rotation sphere drag is ended
  130815. */
  130816. onRotationSphereDragEndObservable: Observable<{}>;
  130817. /**
  130818. * 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)
  130819. */
  130820. scalePivot: Nullable<Vector3>;
  130821. /**
  130822. * Mesh used as a pivot to rotate the attached mesh
  130823. */
  130824. private _anchorMesh;
  130825. private _existingMeshScale;
  130826. private _dragMesh;
  130827. private pointerDragBehavior;
  130828. private coloredMaterial;
  130829. private hoverColoredMaterial;
  130830. /**
  130831. * Sets the color of the bounding box gizmo
  130832. * @param color the color to set
  130833. */
  130834. setColor(color: Color3): void;
  130835. /**
  130836. * Creates an BoundingBoxGizmo
  130837. * @param gizmoLayer The utility layer the gizmo will be added to
  130838. * @param color The color of the gizmo
  130839. */
  130840. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  130841. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  130842. private _selectNode;
  130843. /**
  130844. * Updates the bounding box information for the Gizmo
  130845. */
  130846. updateBoundingBox(): void;
  130847. private _updateRotationSpheres;
  130848. private _updateScaleBoxes;
  130849. /**
  130850. * Enables rotation on the specified axis and disables rotation on the others
  130851. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  130852. */
  130853. setEnabledRotationAxis(axis: string): void;
  130854. /**
  130855. * Enables/disables scaling
  130856. * @param enable if scaling should be enabled
  130857. * @param homogeneousScaling defines if scaling should only be homogeneous
  130858. */
  130859. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  130860. private _updateDummy;
  130861. /**
  130862. * Enables a pointer drag behavior on the bounding box of the gizmo
  130863. */
  130864. enableDragBehavior(): void;
  130865. /**
  130866. * Disposes of the gizmo
  130867. */
  130868. dispose(): void;
  130869. /**
  130870. * 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)
  130871. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  130872. * @returns the bounding box mesh with the passed in mesh as a child
  130873. */
  130874. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  130875. /**
  130876. * CustomMeshes are not supported by this gizmo
  130877. * @param mesh The mesh to replace the default mesh of the gizmo
  130878. */
  130879. setCustomMesh(mesh: Mesh): void;
  130880. }
  130881. }
  130882. declare module BABYLON {
  130883. /**
  130884. * Single plane rotation gizmo
  130885. */
  130886. export class PlaneRotationGizmo extends Gizmo {
  130887. /**
  130888. * Drag behavior responsible for the gizmos dragging interactions
  130889. */
  130890. dragBehavior: PointerDragBehavior;
  130891. private _pointerObserver;
  130892. /**
  130893. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  130894. */
  130895. snapDistance: number;
  130896. /**
  130897. * Event that fires each time the gizmo snaps to a new location.
  130898. * * snapDistance is the the change in distance
  130899. */
  130900. onSnapObservable: Observable<{
  130901. snapDistance: number;
  130902. }>;
  130903. private _isEnabled;
  130904. private _parent;
  130905. /**
  130906. * Creates a PlaneRotationGizmo
  130907. * @param gizmoLayer The utility layer the gizmo will be added to
  130908. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  130909. * @param color The color of the gizmo
  130910. * @param tessellation Amount of tessellation to be used when creating rotation circles
  130911. * @param useEulerRotation Use and update Euler angle instead of quaternion
  130912. */
  130913. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  130914. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  130915. /**
  130916. * If the gizmo is enabled
  130917. */
  130918. set isEnabled(value: boolean);
  130919. get isEnabled(): boolean;
  130920. /**
  130921. * Disposes of the gizmo
  130922. */
  130923. dispose(): void;
  130924. }
  130925. }
  130926. declare module BABYLON {
  130927. /**
  130928. * Gizmo that enables rotating a mesh along 3 axis
  130929. */
  130930. export class RotationGizmo extends Gizmo {
  130931. /**
  130932. * Internal gizmo used for interactions on the x axis
  130933. */
  130934. xGizmo: PlaneRotationGizmo;
  130935. /**
  130936. * Internal gizmo used for interactions on the y axis
  130937. */
  130938. yGizmo: PlaneRotationGizmo;
  130939. /**
  130940. * Internal gizmo used for interactions on the z axis
  130941. */
  130942. zGizmo: PlaneRotationGizmo;
  130943. /** Fires an event when any of it's sub gizmos are dragged */
  130944. onDragStartObservable: Observable<unknown>;
  130945. /** Fires an event when any of it's sub gizmos are released from dragging */
  130946. onDragEndObservable: Observable<unknown>;
  130947. private _meshAttached;
  130948. get attachedMesh(): Nullable<AbstractMesh>;
  130949. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130950. /**
  130951. * Creates a RotationGizmo
  130952. * @param gizmoLayer The utility layer the gizmo will be added to
  130953. * @param tessellation Amount of tessellation to be used when creating rotation circles
  130954. * @param useEulerRotation Use and update Euler angle instead of quaternion
  130955. */
  130956. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  130957. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130958. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130959. /**
  130960. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130961. */
  130962. set snapDistance(value: number);
  130963. get snapDistance(): number;
  130964. /**
  130965. * Ratio for the scale of the gizmo (Default: 1)
  130966. */
  130967. set scaleRatio(value: number);
  130968. get scaleRatio(): number;
  130969. /**
  130970. * Disposes of the gizmo
  130971. */
  130972. dispose(): void;
  130973. /**
  130974. * CustomMeshes are not supported by this gizmo
  130975. * @param mesh The mesh to replace the default mesh of the gizmo
  130976. */
  130977. setCustomMesh(mesh: Mesh): void;
  130978. }
  130979. }
  130980. declare module BABYLON {
  130981. /**
  130982. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  130983. */
  130984. export class GizmoManager implements IDisposable {
  130985. private scene;
  130986. /**
  130987. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  130988. */
  130989. gizmos: {
  130990. positionGizmo: Nullable<PositionGizmo>;
  130991. rotationGizmo: Nullable<RotationGizmo>;
  130992. scaleGizmo: Nullable<ScaleGizmo>;
  130993. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  130994. };
  130995. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  130996. clearGizmoOnEmptyPointerEvent: boolean;
  130997. /** Fires an event when the manager is attached to a mesh */
  130998. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  130999. private _gizmosEnabled;
  131000. private _pointerObserver;
  131001. private _attachedMesh;
  131002. private _boundingBoxColor;
  131003. private _defaultUtilityLayer;
  131004. private _defaultKeepDepthUtilityLayer;
  131005. /**
  131006. * When bounding box gizmo is enabled, this can be used to track drag/end events
  131007. */
  131008. boundingBoxDragBehavior: SixDofDragBehavior;
  131009. /**
  131010. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  131011. */
  131012. attachableMeshes: Nullable<Array<AbstractMesh>>;
  131013. /**
  131014. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  131015. */
  131016. usePointerToAttachGizmos: boolean;
  131017. /**
  131018. * Utility layer that the bounding box gizmo belongs to
  131019. */
  131020. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  131021. /**
  131022. * Utility layer that all gizmos besides bounding box belong to
  131023. */
  131024. get utilityLayer(): UtilityLayerRenderer;
  131025. /**
  131026. * Instatiates a gizmo manager
  131027. * @param scene the scene to overlay the gizmos on top of
  131028. */
  131029. constructor(scene: Scene);
  131030. /**
  131031. * Attaches a set of gizmos to the specified mesh
  131032. * @param mesh The mesh the gizmo's should be attached to
  131033. */
  131034. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  131035. /**
  131036. * If the position gizmo is enabled
  131037. */
  131038. set positionGizmoEnabled(value: boolean);
  131039. get positionGizmoEnabled(): boolean;
  131040. /**
  131041. * If the rotation gizmo is enabled
  131042. */
  131043. set rotationGizmoEnabled(value: boolean);
  131044. get rotationGizmoEnabled(): boolean;
  131045. /**
  131046. * If the scale gizmo is enabled
  131047. */
  131048. set scaleGizmoEnabled(value: boolean);
  131049. get scaleGizmoEnabled(): boolean;
  131050. /**
  131051. * If the boundingBox gizmo is enabled
  131052. */
  131053. set boundingBoxGizmoEnabled(value: boolean);
  131054. get boundingBoxGizmoEnabled(): boolean;
  131055. /**
  131056. * Disposes of the gizmo manager
  131057. */
  131058. dispose(): void;
  131059. }
  131060. }
  131061. declare module BABYLON {
  131062. /**
  131063. * A directional light is defined by a direction (what a surprise!).
  131064. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  131065. * 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.
  131066. * Documentation: https://doc.babylonjs.com/babylon101/lights
  131067. */
  131068. export class DirectionalLight extends ShadowLight {
  131069. private _shadowFrustumSize;
  131070. /**
  131071. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  131072. */
  131073. get shadowFrustumSize(): number;
  131074. /**
  131075. * Specifies a fix frustum size for the shadow generation.
  131076. */
  131077. set shadowFrustumSize(value: number);
  131078. private _shadowOrthoScale;
  131079. /**
  131080. * Gets the shadow projection scale against the optimal computed one.
  131081. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  131082. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  131083. */
  131084. get shadowOrthoScale(): number;
  131085. /**
  131086. * Sets the shadow projection scale against the optimal computed one.
  131087. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  131088. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  131089. */
  131090. set shadowOrthoScale(value: number);
  131091. /**
  131092. * Automatically compute the projection matrix to best fit (including all the casters)
  131093. * on each frame.
  131094. */
  131095. autoUpdateExtends: boolean;
  131096. /**
  131097. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  131098. * on each frame. autoUpdateExtends must be set to true for this to work
  131099. */
  131100. autoCalcShadowZBounds: boolean;
  131101. private _orthoLeft;
  131102. private _orthoRight;
  131103. private _orthoTop;
  131104. private _orthoBottom;
  131105. /**
  131106. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  131107. * The directional light is emitted from everywhere in the given direction.
  131108. * It can cast shadows.
  131109. * Documentation : https://doc.babylonjs.com/babylon101/lights
  131110. * @param name The friendly name of the light
  131111. * @param direction The direction of the light
  131112. * @param scene The scene the light belongs to
  131113. */
  131114. constructor(name: string, direction: Vector3, scene: Scene);
  131115. /**
  131116. * Returns the string "DirectionalLight".
  131117. * @return The class name
  131118. */
  131119. getClassName(): string;
  131120. /**
  131121. * Returns the integer 1.
  131122. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  131123. */
  131124. getTypeID(): number;
  131125. /**
  131126. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  131127. * Returns the DirectionalLight Shadow projection matrix.
  131128. */
  131129. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  131130. /**
  131131. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  131132. * Returns the DirectionalLight Shadow projection matrix.
  131133. */
  131134. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  131135. /**
  131136. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  131137. * Returns the DirectionalLight Shadow projection matrix.
  131138. */
  131139. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  131140. protected _buildUniformLayout(): void;
  131141. /**
  131142. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  131143. * @param effect The effect to update
  131144. * @param lightIndex The index of the light in the effect to update
  131145. * @returns The directional light
  131146. */
  131147. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  131148. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  131149. /**
  131150. * Gets the minZ used for shadow according to both the scene and the light.
  131151. *
  131152. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  131153. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  131154. * @param activeCamera The camera we are returning the min for
  131155. * @returns the depth min z
  131156. */
  131157. getDepthMinZ(activeCamera: Camera): number;
  131158. /**
  131159. * Gets the maxZ used for shadow according to both the scene and the light.
  131160. *
  131161. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  131162. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  131163. * @param activeCamera The camera we are returning the max for
  131164. * @returns the depth max z
  131165. */
  131166. getDepthMaxZ(activeCamera: Camera): number;
  131167. /**
  131168. * Prepares the list of defines specific to the light type.
  131169. * @param defines the list of defines
  131170. * @param lightIndex defines the index of the light for the effect
  131171. */
  131172. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  131173. }
  131174. }
  131175. declare module BABYLON {
  131176. /**
  131177. * Class containing static functions to help procedurally build meshes
  131178. */
  131179. export class HemisphereBuilder {
  131180. /**
  131181. * Creates a hemisphere mesh
  131182. * @param name defines the name of the mesh
  131183. * @param options defines the options used to create the mesh
  131184. * @param scene defines the hosting scene
  131185. * @returns the hemisphere mesh
  131186. */
  131187. static CreateHemisphere(name: string, options: {
  131188. segments?: number;
  131189. diameter?: number;
  131190. sideOrientation?: number;
  131191. }, scene: any): Mesh;
  131192. }
  131193. }
  131194. declare module BABYLON {
  131195. /**
  131196. * A spot light is defined by a position, a direction, an angle, and an exponent.
  131197. * These values define a cone of light starting from the position, emitting toward the direction.
  131198. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  131199. * and the exponent defines the speed of the decay of the light with distance (reach).
  131200. * Documentation: https://doc.babylonjs.com/babylon101/lights
  131201. */
  131202. export class SpotLight extends ShadowLight {
  131203. private _angle;
  131204. private _innerAngle;
  131205. private _cosHalfAngle;
  131206. private _lightAngleScale;
  131207. private _lightAngleOffset;
  131208. /**
  131209. * Gets the cone angle of the spot light in Radians.
  131210. */
  131211. get angle(): number;
  131212. /**
  131213. * Sets the cone angle of the spot light in Radians.
  131214. */
  131215. set angle(value: number);
  131216. /**
  131217. * Only used in gltf falloff mode, this defines the angle where
  131218. * the directional falloff will start before cutting at angle which could be seen
  131219. * as outer angle.
  131220. */
  131221. get innerAngle(): number;
  131222. /**
  131223. * Only used in gltf falloff mode, this defines the angle where
  131224. * the directional falloff will start before cutting at angle which could be seen
  131225. * as outer angle.
  131226. */
  131227. set innerAngle(value: number);
  131228. private _shadowAngleScale;
  131229. /**
  131230. * Allows scaling the angle of the light for shadow generation only.
  131231. */
  131232. get shadowAngleScale(): number;
  131233. /**
  131234. * Allows scaling the angle of the light for shadow generation only.
  131235. */
  131236. set shadowAngleScale(value: number);
  131237. /**
  131238. * The light decay speed with the distance from the emission spot.
  131239. */
  131240. exponent: number;
  131241. private _projectionTextureMatrix;
  131242. /**
  131243. * Allows reading the projecton texture
  131244. */
  131245. get projectionTextureMatrix(): Matrix;
  131246. protected _projectionTextureLightNear: number;
  131247. /**
  131248. * Gets the near clip of the Spotlight for texture projection.
  131249. */
  131250. get projectionTextureLightNear(): number;
  131251. /**
  131252. * Sets the near clip of the Spotlight for texture projection.
  131253. */
  131254. set projectionTextureLightNear(value: number);
  131255. protected _projectionTextureLightFar: number;
  131256. /**
  131257. * Gets the far clip of the Spotlight for texture projection.
  131258. */
  131259. get projectionTextureLightFar(): number;
  131260. /**
  131261. * Sets the far clip of the Spotlight for texture projection.
  131262. */
  131263. set projectionTextureLightFar(value: number);
  131264. protected _projectionTextureUpDirection: Vector3;
  131265. /**
  131266. * Gets the Up vector of the Spotlight for texture projection.
  131267. */
  131268. get projectionTextureUpDirection(): Vector3;
  131269. /**
  131270. * Sets the Up vector of the Spotlight for texture projection.
  131271. */
  131272. set projectionTextureUpDirection(value: Vector3);
  131273. private _projectionTexture;
  131274. /**
  131275. * Gets the projection texture of the light.
  131276. */
  131277. get projectionTexture(): Nullable<BaseTexture>;
  131278. /**
  131279. * Sets the projection texture of the light.
  131280. */
  131281. set projectionTexture(value: Nullable<BaseTexture>);
  131282. private _projectionTextureViewLightDirty;
  131283. private _projectionTextureProjectionLightDirty;
  131284. private _projectionTextureDirty;
  131285. private _projectionTextureViewTargetVector;
  131286. private _projectionTextureViewLightMatrix;
  131287. private _projectionTextureProjectionLightMatrix;
  131288. private _projectionTextureScalingMatrix;
  131289. /**
  131290. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  131291. * It can cast shadows.
  131292. * Documentation : https://doc.babylonjs.com/babylon101/lights
  131293. * @param name The light friendly name
  131294. * @param position The position of the spot light in the scene
  131295. * @param direction The direction of the light in the scene
  131296. * @param angle The cone angle of the light in Radians
  131297. * @param exponent The light decay speed with the distance from the emission spot
  131298. * @param scene The scene the lights belongs to
  131299. */
  131300. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  131301. /**
  131302. * Returns the string "SpotLight".
  131303. * @returns the class name
  131304. */
  131305. getClassName(): string;
  131306. /**
  131307. * Returns the integer 2.
  131308. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  131309. */
  131310. getTypeID(): number;
  131311. /**
  131312. * Overrides the direction setter to recompute the projection texture view light Matrix.
  131313. */
  131314. protected _setDirection(value: Vector3): void;
  131315. /**
  131316. * Overrides the position setter to recompute the projection texture view light Matrix.
  131317. */
  131318. protected _setPosition(value: Vector3): void;
  131319. /**
  131320. * 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.
  131321. * Returns the SpotLight.
  131322. */
  131323. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  131324. protected _computeProjectionTextureViewLightMatrix(): void;
  131325. protected _computeProjectionTextureProjectionLightMatrix(): void;
  131326. /**
  131327. * Main function for light texture projection matrix computing.
  131328. */
  131329. protected _computeProjectionTextureMatrix(): void;
  131330. protected _buildUniformLayout(): void;
  131331. private _computeAngleValues;
  131332. /**
  131333. * Sets the passed Effect "effect" with the Light textures.
  131334. * @param effect The effect to update
  131335. * @param lightIndex The index of the light in the effect to update
  131336. * @returns The light
  131337. */
  131338. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  131339. /**
  131340. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  131341. * @param effect The effect to update
  131342. * @param lightIndex The index of the light in the effect to update
  131343. * @returns The spot light
  131344. */
  131345. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  131346. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  131347. /**
  131348. * Disposes the light and the associated resources.
  131349. */
  131350. dispose(): void;
  131351. /**
  131352. * Prepares the list of defines specific to the light type.
  131353. * @param defines the list of defines
  131354. * @param lightIndex defines the index of the light for the effect
  131355. */
  131356. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  131357. }
  131358. }
  131359. declare module BABYLON {
  131360. /**
  131361. * Gizmo that enables viewing a light
  131362. */
  131363. export class LightGizmo extends Gizmo {
  131364. private _lightMesh;
  131365. private _material;
  131366. private _cachedPosition;
  131367. private _cachedForward;
  131368. private _attachedMeshParent;
  131369. /**
  131370. * Creates a LightGizmo
  131371. * @param gizmoLayer The utility layer the gizmo will be added to
  131372. */
  131373. constructor(gizmoLayer?: UtilityLayerRenderer);
  131374. private _light;
  131375. /**
  131376. * The light that the gizmo is attached to
  131377. */
  131378. set light(light: Nullable<Light>);
  131379. get light(): Nullable<Light>;
  131380. /**
  131381. * Gets the material used to render the light gizmo
  131382. */
  131383. get material(): StandardMaterial;
  131384. /**
  131385. * @hidden
  131386. * Updates the gizmo to match the attached mesh's position/rotation
  131387. */
  131388. protected _update(): void;
  131389. private static _Scale;
  131390. /**
  131391. * Creates the lines for a light mesh
  131392. */
  131393. private static _CreateLightLines;
  131394. /**
  131395. * Disposes of the light gizmo
  131396. */
  131397. dispose(): void;
  131398. private static _CreateHemisphericLightMesh;
  131399. private static _CreatePointLightMesh;
  131400. private static _CreateSpotLightMesh;
  131401. private static _CreateDirectionalLightMesh;
  131402. }
  131403. }
  131404. declare module BABYLON {
  131405. /** @hidden */
  131406. export var backgroundFragmentDeclaration: {
  131407. name: string;
  131408. shader: string;
  131409. };
  131410. }
  131411. declare module BABYLON {
  131412. /** @hidden */
  131413. export var backgroundUboDeclaration: {
  131414. name: string;
  131415. shader: string;
  131416. };
  131417. }
  131418. declare module BABYLON {
  131419. /** @hidden */
  131420. export var backgroundPixelShader: {
  131421. name: string;
  131422. shader: string;
  131423. };
  131424. }
  131425. declare module BABYLON {
  131426. /** @hidden */
  131427. export var backgroundVertexDeclaration: {
  131428. name: string;
  131429. shader: string;
  131430. };
  131431. }
  131432. declare module BABYLON {
  131433. /** @hidden */
  131434. export var backgroundVertexShader: {
  131435. name: string;
  131436. shader: string;
  131437. };
  131438. }
  131439. declare module BABYLON {
  131440. /**
  131441. * Background material used to create an efficient environement around your scene.
  131442. */
  131443. export class BackgroundMaterial extends PushMaterial {
  131444. /**
  131445. * Standard reflectance value at parallel view angle.
  131446. */
  131447. static StandardReflectance0: number;
  131448. /**
  131449. * Standard reflectance value at grazing angle.
  131450. */
  131451. static StandardReflectance90: number;
  131452. protected _primaryColor: Color3;
  131453. /**
  131454. * Key light Color (multiply against the environement texture)
  131455. */
  131456. primaryColor: Color3;
  131457. protected __perceptualColor: Nullable<Color3>;
  131458. /**
  131459. * Experimental Internal Use Only.
  131460. *
  131461. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  131462. * This acts as a helper to set the primary color to a more "human friendly" value.
  131463. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  131464. * output color as close as possible from the chosen value.
  131465. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  131466. * part of lighting setup.)
  131467. */
  131468. get _perceptualColor(): Nullable<Color3>;
  131469. set _perceptualColor(value: Nullable<Color3>);
  131470. protected _primaryColorShadowLevel: float;
  131471. /**
  131472. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  131473. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  131474. */
  131475. get primaryColorShadowLevel(): float;
  131476. set primaryColorShadowLevel(value: float);
  131477. protected _primaryColorHighlightLevel: float;
  131478. /**
  131479. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  131480. * The primary color is used at the level chosen to define what the white area would look.
  131481. */
  131482. get primaryColorHighlightLevel(): float;
  131483. set primaryColorHighlightLevel(value: float);
  131484. protected _reflectionTexture: Nullable<BaseTexture>;
  131485. /**
  131486. * Reflection Texture used in the material.
  131487. * Should be author in a specific way for the best result (refer to the documentation).
  131488. */
  131489. reflectionTexture: Nullable<BaseTexture>;
  131490. protected _reflectionBlur: float;
  131491. /**
  131492. * Reflection Texture level of blur.
  131493. *
  131494. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  131495. * texture twice.
  131496. */
  131497. reflectionBlur: float;
  131498. protected _diffuseTexture: Nullable<BaseTexture>;
  131499. /**
  131500. * Diffuse Texture used in the material.
  131501. * Should be author in a specific way for the best result (refer to the documentation).
  131502. */
  131503. diffuseTexture: Nullable<BaseTexture>;
  131504. protected _shadowLights: Nullable<IShadowLight[]>;
  131505. /**
  131506. * Specify the list of lights casting shadow on the material.
  131507. * All scene shadow lights will be included if null.
  131508. */
  131509. shadowLights: Nullable<IShadowLight[]>;
  131510. protected _shadowLevel: float;
  131511. /**
  131512. * Helps adjusting the shadow to a softer level if required.
  131513. * 0 means black shadows and 1 means no shadows.
  131514. */
  131515. shadowLevel: float;
  131516. protected _sceneCenter: Vector3;
  131517. /**
  131518. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  131519. * It is usually zero but might be interesting to modify according to your setup.
  131520. */
  131521. sceneCenter: Vector3;
  131522. protected _opacityFresnel: boolean;
  131523. /**
  131524. * This helps specifying that the material is falling off to the sky box at grazing angle.
  131525. * This helps ensuring a nice transition when the camera goes under the ground.
  131526. */
  131527. opacityFresnel: boolean;
  131528. protected _reflectionFresnel: boolean;
  131529. /**
  131530. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  131531. * This helps adding a mirror texture on the ground.
  131532. */
  131533. reflectionFresnel: boolean;
  131534. protected _reflectionFalloffDistance: number;
  131535. /**
  131536. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  131537. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  131538. */
  131539. reflectionFalloffDistance: number;
  131540. protected _reflectionAmount: number;
  131541. /**
  131542. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  131543. */
  131544. reflectionAmount: number;
  131545. protected _reflectionReflectance0: number;
  131546. /**
  131547. * This specifies the weight of the reflection at grazing angle.
  131548. */
  131549. reflectionReflectance0: number;
  131550. protected _reflectionReflectance90: number;
  131551. /**
  131552. * This specifies the weight of the reflection at a perpendicular point of view.
  131553. */
  131554. reflectionReflectance90: number;
  131555. /**
  131556. * Sets the reflection reflectance fresnel values according to the default standard
  131557. * empirically know to work well :-)
  131558. */
  131559. set reflectionStandardFresnelWeight(value: number);
  131560. protected _useRGBColor: boolean;
  131561. /**
  131562. * Helps to directly use the maps channels instead of their level.
  131563. */
  131564. useRGBColor: boolean;
  131565. protected _enableNoise: boolean;
  131566. /**
  131567. * This helps reducing the banding effect that could occur on the background.
  131568. */
  131569. enableNoise: boolean;
  131570. /**
  131571. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  131572. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  131573. * Recommended to be keep at 1.0 except for special cases.
  131574. */
  131575. get fovMultiplier(): number;
  131576. set fovMultiplier(value: number);
  131577. private _fovMultiplier;
  131578. /**
  131579. * Enable the FOV adjustment feature controlled by fovMultiplier.
  131580. */
  131581. useEquirectangularFOV: boolean;
  131582. private _maxSimultaneousLights;
  131583. /**
  131584. * Number of Simultaneous lights allowed on the material.
  131585. */
  131586. maxSimultaneousLights: int;
  131587. private _shadowOnly;
  131588. /**
  131589. * Make the material only render shadows
  131590. */
  131591. shadowOnly: boolean;
  131592. /**
  131593. * Default configuration related to image processing available in the Background Material.
  131594. */
  131595. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  131596. /**
  131597. * Keep track of the image processing observer to allow dispose and replace.
  131598. */
  131599. private _imageProcessingObserver;
  131600. /**
  131601. * Attaches a new image processing configuration to the PBR Material.
  131602. * @param configuration (if null the scene configuration will be use)
  131603. */
  131604. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  131605. /**
  131606. * Gets the image processing configuration used either in this material.
  131607. */
  131608. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  131609. /**
  131610. * Sets the Default image processing configuration used either in the this material.
  131611. *
  131612. * If sets to null, the scene one is in use.
  131613. */
  131614. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  131615. /**
  131616. * Gets wether the color curves effect is enabled.
  131617. */
  131618. get cameraColorCurvesEnabled(): boolean;
  131619. /**
  131620. * Sets wether the color curves effect is enabled.
  131621. */
  131622. set cameraColorCurvesEnabled(value: boolean);
  131623. /**
  131624. * Gets wether the color grading effect is enabled.
  131625. */
  131626. get cameraColorGradingEnabled(): boolean;
  131627. /**
  131628. * Gets wether the color grading effect is enabled.
  131629. */
  131630. set cameraColorGradingEnabled(value: boolean);
  131631. /**
  131632. * Gets wether tonemapping is enabled or not.
  131633. */
  131634. get cameraToneMappingEnabled(): boolean;
  131635. /**
  131636. * Sets wether tonemapping is enabled or not
  131637. */
  131638. set cameraToneMappingEnabled(value: boolean);
  131639. /**
  131640. * The camera exposure used on this material.
  131641. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  131642. * This corresponds to a photographic exposure.
  131643. */
  131644. get cameraExposure(): float;
  131645. /**
  131646. * The camera exposure used on this material.
  131647. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  131648. * This corresponds to a photographic exposure.
  131649. */
  131650. set cameraExposure(value: float);
  131651. /**
  131652. * Gets The camera contrast used on this material.
  131653. */
  131654. get cameraContrast(): float;
  131655. /**
  131656. * Sets The camera contrast used on this material.
  131657. */
  131658. set cameraContrast(value: float);
  131659. /**
  131660. * Gets the Color Grading 2D Lookup Texture.
  131661. */
  131662. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  131663. /**
  131664. * Sets the Color Grading 2D Lookup Texture.
  131665. */
  131666. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  131667. /**
  131668. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  131669. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  131670. * 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;
  131671. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  131672. */
  131673. get cameraColorCurves(): Nullable<ColorCurves>;
  131674. /**
  131675. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  131676. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  131677. * 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;
  131678. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  131679. */
  131680. set cameraColorCurves(value: Nullable<ColorCurves>);
  131681. /**
  131682. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  131683. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  131684. */
  131685. switchToBGR: boolean;
  131686. private _renderTargets;
  131687. private _reflectionControls;
  131688. private _white;
  131689. private _primaryShadowColor;
  131690. private _primaryHighlightColor;
  131691. /**
  131692. * Instantiates a Background Material in the given scene
  131693. * @param name The friendly name of the material
  131694. * @param scene The scene to add the material to
  131695. */
  131696. constructor(name: string, scene: Scene);
  131697. /**
  131698. * Gets a boolean indicating that current material needs to register RTT
  131699. */
  131700. get hasRenderTargetTextures(): boolean;
  131701. /**
  131702. * The entire material has been created in order to prevent overdraw.
  131703. * @returns false
  131704. */
  131705. needAlphaTesting(): boolean;
  131706. /**
  131707. * The entire material has been created in order to prevent overdraw.
  131708. * @returns true if blending is enable
  131709. */
  131710. needAlphaBlending(): boolean;
  131711. /**
  131712. * Checks wether the material is ready to be rendered for a given mesh.
  131713. * @param mesh The mesh to render
  131714. * @param subMesh The submesh to check against
  131715. * @param useInstances Specify wether or not the material is used with instances
  131716. * @returns true if all the dependencies are ready (Textures, Effects...)
  131717. */
  131718. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  131719. /**
  131720. * Compute the primary color according to the chosen perceptual color.
  131721. */
  131722. private _computePrimaryColorFromPerceptualColor;
  131723. /**
  131724. * Compute the highlights and shadow colors according to their chosen levels.
  131725. */
  131726. private _computePrimaryColors;
  131727. /**
  131728. * Build the uniform buffer used in the material.
  131729. */
  131730. buildUniformLayout(): void;
  131731. /**
  131732. * Unbind the material.
  131733. */
  131734. unbind(): void;
  131735. /**
  131736. * Bind only the world matrix to the material.
  131737. * @param world The world matrix to bind.
  131738. */
  131739. bindOnlyWorldMatrix(world: Matrix): void;
  131740. /**
  131741. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  131742. * @param world The world matrix to bind.
  131743. * @param subMesh The submesh to bind for.
  131744. */
  131745. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  131746. /**
  131747. * Checks to see if a texture is used in the material.
  131748. * @param texture - Base texture to use.
  131749. * @returns - Boolean specifying if a texture is used in the material.
  131750. */
  131751. hasTexture(texture: BaseTexture): boolean;
  131752. /**
  131753. * Dispose the material.
  131754. * @param forceDisposeEffect Force disposal of the associated effect.
  131755. * @param forceDisposeTextures Force disposal of the associated textures.
  131756. */
  131757. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  131758. /**
  131759. * Clones the material.
  131760. * @param name The cloned name.
  131761. * @returns The cloned material.
  131762. */
  131763. clone(name: string): BackgroundMaterial;
  131764. /**
  131765. * Serializes the current material to its JSON representation.
  131766. * @returns The JSON representation.
  131767. */
  131768. serialize(): any;
  131769. /**
  131770. * Gets the class name of the material
  131771. * @returns "BackgroundMaterial"
  131772. */
  131773. getClassName(): string;
  131774. /**
  131775. * Parse a JSON input to create back a background material.
  131776. * @param source The JSON data to parse
  131777. * @param scene The scene to create the parsed material in
  131778. * @param rootUrl The root url of the assets the material depends upon
  131779. * @returns the instantiated BackgroundMaterial.
  131780. */
  131781. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  131782. }
  131783. }
  131784. declare module BABYLON {
  131785. /**
  131786. * Represents the different options available during the creation of
  131787. * a Environment helper.
  131788. *
  131789. * This can control the default ground, skybox and image processing setup of your scene.
  131790. */
  131791. export interface IEnvironmentHelperOptions {
  131792. /**
  131793. * Specifies whether or not to create a ground.
  131794. * True by default.
  131795. */
  131796. createGround: boolean;
  131797. /**
  131798. * Specifies the ground size.
  131799. * 15 by default.
  131800. */
  131801. groundSize: number;
  131802. /**
  131803. * The texture used on the ground for the main color.
  131804. * Comes from the BabylonJS CDN by default.
  131805. *
  131806. * Remarks: Can be either a texture or a url.
  131807. */
  131808. groundTexture: string | BaseTexture;
  131809. /**
  131810. * The color mixed in the ground texture by default.
  131811. * BabylonJS clearColor by default.
  131812. */
  131813. groundColor: Color3;
  131814. /**
  131815. * Specifies the ground opacity.
  131816. * 1 by default.
  131817. */
  131818. groundOpacity: number;
  131819. /**
  131820. * Enables the ground to receive shadows.
  131821. * True by default.
  131822. */
  131823. enableGroundShadow: boolean;
  131824. /**
  131825. * Helps preventing the shadow to be fully black on the ground.
  131826. * 0.5 by default.
  131827. */
  131828. groundShadowLevel: number;
  131829. /**
  131830. * Creates a mirror texture attach to the ground.
  131831. * false by default.
  131832. */
  131833. enableGroundMirror: boolean;
  131834. /**
  131835. * Specifies the ground mirror size ratio.
  131836. * 0.3 by default as the default kernel is 64.
  131837. */
  131838. groundMirrorSizeRatio: number;
  131839. /**
  131840. * Specifies the ground mirror blur kernel size.
  131841. * 64 by default.
  131842. */
  131843. groundMirrorBlurKernel: number;
  131844. /**
  131845. * Specifies the ground mirror visibility amount.
  131846. * 1 by default
  131847. */
  131848. groundMirrorAmount: number;
  131849. /**
  131850. * Specifies the ground mirror reflectance weight.
  131851. * This uses the standard weight of the background material to setup the fresnel effect
  131852. * of the mirror.
  131853. * 1 by default.
  131854. */
  131855. groundMirrorFresnelWeight: number;
  131856. /**
  131857. * Specifies the ground mirror Falloff distance.
  131858. * This can helps reducing the size of the reflection.
  131859. * 0 by Default.
  131860. */
  131861. groundMirrorFallOffDistance: number;
  131862. /**
  131863. * Specifies the ground mirror texture type.
  131864. * Unsigned Int by Default.
  131865. */
  131866. groundMirrorTextureType: number;
  131867. /**
  131868. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  131869. * the shown objects.
  131870. */
  131871. groundYBias: number;
  131872. /**
  131873. * Specifies whether or not to create a skybox.
  131874. * True by default.
  131875. */
  131876. createSkybox: boolean;
  131877. /**
  131878. * Specifies the skybox size.
  131879. * 20 by default.
  131880. */
  131881. skyboxSize: number;
  131882. /**
  131883. * The texture used on the skybox for the main color.
  131884. * Comes from the BabylonJS CDN by default.
  131885. *
  131886. * Remarks: Can be either a texture or a url.
  131887. */
  131888. skyboxTexture: string | BaseTexture;
  131889. /**
  131890. * The color mixed in the skybox texture by default.
  131891. * BabylonJS clearColor by default.
  131892. */
  131893. skyboxColor: Color3;
  131894. /**
  131895. * The background rotation around the Y axis of the scene.
  131896. * This helps aligning the key lights of your scene with the background.
  131897. * 0 by default.
  131898. */
  131899. backgroundYRotation: number;
  131900. /**
  131901. * Compute automatically the size of the elements to best fit with the scene.
  131902. */
  131903. sizeAuto: boolean;
  131904. /**
  131905. * Default position of the rootMesh if autoSize is not true.
  131906. */
  131907. rootPosition: Vector3;
  131908. /**
  131909. * Sets up the image processing in the scene.
  131910. * true by default.
  131911. */
  131912. setupImageProcessing: boolean;
  131913. /**
  131914. * The texture used as your environment texture in the scene.
  131915. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  131916. *
  131917. * Remarks: Can be either a texture or a url.
  131918. */
  131919. environmentTexture: string | BaseTexture;
  131920. /**
  131921. * The value of the exposure to apply to the scene.
  131922. * 0.6 by default if setupImageProcessing is true.
  131923. */
  131924. cameraExposure: number;
  131925. /**
  131926. * The value of the contrast to apply to the scene.
  131927. * 1.6 by default if setupImageProcessing is true.
  131928. */
  131929. cameraContrast: number;
  131930. /**
  131931. * Specifies whether or not tonemapping should be enabled in the scene.
  131932. * true by default if setupImageProcessing is true.
  131933. */
  131934. toneMappingEnabled: boolean;
  131935. }
  131936. /**
  131937. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  131938. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  131939. * It also helps with the default setup of your imageProcessing configuration.
  131940. */
  131941. export class EnvironmentHelper {
  131942. /**
  131943. * Default ground texture URL.
  131944. */
  131945. private static _groundTextureCDNUrl;
  131946. /**
  131947. * Default skybox texture URL.
  131948. */
  131949. private static _skyboxTextureCDNUrl;
  131950. /**
  131951. * Default environment texture URL.
  131952. */
  131953. private static _environmentTextureCDNUrl;
  131954. /**
  131955. * Creates the default options for the helper.
  131956. */
  131957. private static _getDefaultOptions;
  131958. private _rootMesh;
  131959. /**
  131960. * Gets the root mesh created by the helper.
  131961. */
  131962. get rootMesh(): Mesh;
  131963. private _skybox;
  131964. /**
  131965. * Gets the skybox created by the helper.
  131966. */
  131967. get skybox(): Nullable<Mesh>;
  131968. private _skyboxTexture;
  131969. /**
  131970. * Gets the skybox texture created by the helper.
  131971. */
  131972. get skyboxTexture(): Nullable<BaseTexture>;
  131973. private _skyboxMaterial;
  131974. /**
  131975. * Gets the skybox material created by the helper.
  131976. */
  131977. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  131978. private _ground;
  131979. /**
  131980. * Gets the ground mesh created by the helper.
  131981. */
  131982. get ground(): Nullable<Mesh>;
  131983. private _groundTexture;
  131984. /**
  131985. * Gets the ground texture created by the helper.
  131986. */
  131987. get groundTexture(): Nullable<BaseTexture>;
  131988. private _groundMirror;
  131989. /**
  131990. * Gets the ground mirror created by the helper.
  131991. */
  131992. get groundMirror(): Nullable<MirrorTexture>;
  131993. /**
  131994. * Gets the ground mirror render list to helps pushing the meshes
  131995. * you wish in the ground reflection.
  131996. */
  131997. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  131998. private _groundMaterial;
  131999. /**
  132000. * Gets the ground material created by the helper.
  132001. */
  132002. get groundMaterial(): Nullable<BackgroundMaterial>;
  132003. /**
  132004. * Stores the creation options.
  132005. */
  132006. private readonly _scene;
  132007. private _options;
  132008. /**
  132009. * This observable will be notified with any error during the creation of the environment,
  132010. * mainly texture creation errors.
  132011. */
  132012. onErrorObservable: Observable<{
  132013. message?: string;
  132014. exception?: any;
  132015. }>;
  132016. /**
  132017. * constructor
  132018. * @param options Defines the options we want to customize the helper
  132019. * @param scene The scene to add the material to
  132020. */
  132021. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  132022. /**
  132023. * Updates the background according to the new options
  132024. * @param options
  132025. */
  132026. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  132027. /**
  132028. * Sets the primary color of all the available elements.
  132029. * @param color the main color to affect to the ground and the background
  132030. */
  132031. setMainColor(color: Color3): void;
  132032. /**
  132033. * Setup the image processing according to the specified options.
  132034. */
  132035. private _setupImageProcessing;
  132036. /**
  132037. * Setup the environment texture according to the specified options.
  132038. */
  132039. private _setupEnvironmentTexture;
  132040. /**
  132041. * Setup the background according to the specified options.
  132042. */
  132043. private _setupBackground;
  132044. /**
  132045. * Get the scene sizes according to the setup.
  132046. */
  132047. private _getSceneSize;
  132048. /**
  132049. * Setup the ground according to the specified options.
  132050. */
  132051. private _setupGround;
  132052. /**
  132053. * Setup the ground material according to the specified options.
  132054. */
  132055. private _setupGroundMaterial;
  132056. /**
  132057. * Setup the ground diffuse texture according to the specified options.
  132058. */
  132059. private _setupGroundDiffuseTexture;
  132060. /**
  132061. * Setup the ground mirror texture according to the specified options.
  132062. */
  132063. private _setupGroundMirrorTexture;
  132064. /**
  132065. * Setup the ground to receive the mirror texture.
  132066. */
  132067. private _setupMirrorInGroundMaterial;
  132068. /**
  132069. * Setup the skybox according to the specified options.
  132070. */
  132071. private _setupSkybox;
  132072. /**
  132073. * Setup the skybox material according to the specified options.
  132074. */
  132075. private _setupSkyboxMaterial;
  132076. /**
  132077. * Setup the skybox reflection texture according to the specified options.
  132078. */
  132079. private _setupSkyboxReflectionTexture;
  132080. private _errorHandler;
  132081. /**
  132082. * Dispose all the elements created by the Helper.
  132083. */
  132084. dispose(): void;
  132085. }
  132086. }
  132087. declare module BABYLON {
  132088. /**
  132089. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  132090. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  132091. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  132092. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  132093. */
  132094. export class PhotoDome extends TransformNode {
  132095. /**
  132096. * Define the image as a Monoscopic panoramic 360 image.
  132097. */
  132098. static readonly MODE_MONOSCOPIC: number;
  132099. /**
  132100. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  132101. */
  132102. static readonly MODE_TOPBOTTOM: number;
  132103. /**
  132104. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  132105. */
  132106. static readonly MODE_SIDEBYSIDE: number;
  132107. private _useDirectMapping;
  132108. /**
  132109. * The texture being displayed on the sphere
  132110. */
  132111. protected _photoTexture: Texture;
  132112. /**
  132113. * Gets or sets the texture being displayed on the sphere
  132114. */
  132115. get photoTexture(): Texture;
  132116. set photoTexture(value: Texture);
  132117. /**
  132118. * Observable raised when an error occured while loading the 360 image
  132119. */
  132120. onLoadErrorObservable: Observable<string>;
  132121. /**
  132122. * The skybox material
  132123. */
  132124. protected _material: BackgroundMaterial;
  132125. /**
  132126. * The surface used for the skybox
  132127. */
  132128. protected _mesh: Mesh;
  132129. /**
  132130. * Gets the mesh used for the skybox.
  132131. */
  132132. get mesh(): Mesh;
  132133. /**
  132134. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  132135. * Also see the options.resolution property.
  132136. */
  132137. get fovMultiplier(): number;
  132138. set fovMultiplier(value: number);
  132139. private _imageMode;
  132140. /**
  132141. * Gets or set the current video mode for the video. It can be:
  132142. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  132143. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  132144. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  132145. */
  132146. get imageMode(): number;
  132147. set imageMode(value: number);
  132148. /**
  132149. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  132150. * @param name Element's name, child elements will append suffixes for their own names.
  132151. * @param urlsOfPhoto defines the url of the photo to display
  132152. * @param options defines an object containing optional or exposed sub element properties
  132153. * @param onError defines a callback called when an error occured while loading the texture
  132154. */
  132155. constructor(name: string, urlOfPhoto: string, options: {
  132156. resolution?: number;
  132157. size?: number;
  132158. useDirectMapping?: boolean;
  132159. faceForward?: boolean;
  132160. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  132161. private _onBeforeCameraRenderObserver;
  132162. private _changeImageMode;
  132163. /**
  132164. * Releases resources associated with this node.
  132165. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  132166. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  132167. */
  132168. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  132169. }
  132170. }
  132171. declare module BABYLON {
  132172. /**
  132173. * Class used to host RGBD texture specific utilities
  132174. */
  132175. export class RGBDTextureTools {
  132176. /**
  132177. * Expand the RGBD Texture from RGBD to Half Float if possible.
  132178. * @param texture the texture to expand.
  132179. */
  132180. static ExpandRGBDTexture(texture: Texture): void;
  132181. }
  132182. }
  132183. declare module BABYLON {
  132184. /**
  132185. * Class used to host texture specific utilities
  132186. */
  132187. export class BRDFTextureTools {
  132188. /**
  132189. * Prevents texture cache collision
  132190. */
  132191. private static _instanceNumber;
  132192. /**
  132193. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  132194. * @param scene defines the hosting scene
  132195. * @returns the environment BRDF texture
  132196. */
  132197. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  132198. private static _environmentBRDFBase64Texture;
  132199. }
  132200. }
  132201. declare module BABYLON {
  132202. /**
  132203. * @hidden
  132204. */
  132205. export interface IMaterialClearCoatDefines {
  132206. CLEARCOAT: boolean;
  132207. CLEARCOAT_DEFAULTIOR: boolean;
  132208. CLEARCOAT_TEXTURE: boolean;
  132209. CLEARCOAT_TEXTUREDIRECTUV: number;
  132210. CLEARCOAT_BUMP: boolean;
  132211. CLEARCOAT_BUMPDIRECTUV: number;
  132212. CLEARCOAT_TINT: boolean;
  132213. CLEARCOAT_TINT_TEXTURE: boolean;
  132214. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  132215. /** @hidden */
  132216. _areTexturesDirty: boolean;
  132217. }
  132218. /**
  132219. * Define the code related to the clear coat parameters of the pbr material.
  132220. */
  132221. export class PBRClearCoatConfiguration {
  132222. /**
  132223. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  132224. * The default fits with a polyurethane material.
  132225. */
  132226. private static readonly _DefaultIndexOfRefraction;
  132227. private _isEnabled;
  132228. /**
  132229. * Defines if the clear coat is enabled in the material.
  132230. */
  132231. isEnabled: boolean;
  132232. /**
  132233. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  132234. */
  132235. intensity: number;
  132236. /**
  132237. * Defines the clear coat layer roughness.
  132238. */
  132239. roughness: number;
  132240. private _indexOfRefraction;
  132241. /**
  132242. * Defines the index of refraction of the clear coat.
  132243. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  132244. * The default fits with a polyurethane material.
  132245. * Changing the default value is more performance intensive.
  132246. */
  132247. indexOfRefraction: number;
  132248. private _texture;
  132249. /**
  132250. * Stores the clear coat values in a texture.
  132251. */
  132252. texture: Nullable<BaseTexture>;
  132253. private _bumpTexture;
  132254. /**
  132255. * Define the clear coat specific bump texture.
  132256. */
  132257. bumpTexture: Nullable<BaseTexture>;
  132258. private _isTintEnabled;
  132259. /**
  132260. * Defines if the clear coat tint is enabled in the material.
  132261. */
  132262. isTintEnabled: boolean;
  132263. /**
  132264. * Defines the clear coat tint of the material.
  132265. * This is only use if tint is enabled
  132266. */
  132267. tintColor: Color3;
  132268. /**
  132269. * Defines the distance at which the tint color should be found in the
  132270. * clear coat media.
  132271. * This is only use if tint is enabled
  132272. */
  132273. tintColorAtDistance: number;
  132274. /**
  132275. * Defines the clear coat layer thickness.
  132276. * This is only use if tint is enabled
  132277. */
  132278. tintThickness: number;
  132279. private _tintTexture;
  132280. /**
  132281. * Stores the clear tint values in a texture.
  132282. * rgb is tint
  132283. * a is a thickness factor
  132284. */
  132285. tintTexture: Nullable<BaseTexture>;
  132286. /** @hidden */
  132287. private _internalMarkAllSubMeshesAsTexturesDirty;
  132288. /** @hidden */
  132289. _markAllSubMeshesAsTexturesDirty(): void;
  132290. /**
  132291. * Instantiate a new istance of clear coat configuration.
  132292. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132293. */
  132294. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  132295. /**
  132296. * Gets wehter the submesh is ready to be used or not.
  132297. * @param defines the list of "defines" to update.
  132298. * @param scene defines the scene the material belongs to.
  132299. * @param engine defines the engine the material belongs to.
  132300. * @param disableBumpMap defines wether the material disables bump or not.
  132301. * @returns - boolean indicating that the submesh is ready or not.
  132302. */
  132303. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  132304. /**
  132305. * Checks to see if a texture is used in the material.
  132306. * @param defines the list of "defines" to update.
  132307. * @param scene defines the scene to the material belongs to.
  132308. */
  132309. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  132310. /**
  132311. * Binds the material data.
  132312. * @param uniformBuffer defines the Uniform buffer to fill in.
  132313. * @param scene defines the scene the material belongs to.
  132314. * @param engine defines the engine the material belongs to.
  132315. * @param disableBumpMap defines wether the material disables bump or not.
  132316. * @param isFrozen defines wether the material is frozen or not.
  132317. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  132318. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  132319. */
  132320. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  132321. /**
  132322. * Checks to see if a texture is used in the material.
  132323. * @param texture - Base texture to use.
  132324. * @returns - Boolean specifying if a texture is used in the material.
  132325. */
  132326. hasTexture(texture: BaseTexture): boolean;
  132327. /**
  132328. * Returns an array of the actively used textures.
  132329. * @param activeTextures Array of BaseTextures
  132330. */
  132331. getActiveTextures(activeTextures: BaseTexture[]): void;
  132332. /**
  132333. * Returns the animatable textures.
  132334. * @param animatables Array of animatable textures.
  132335. */
  132336. getAnimatables(animatables: IAnimatable[]): void;
  132337. /**
  132338. * Disposes the resources of the material.
  132339. * @param forceDisposeTextures - Forces the disposal of all textures.
  132340. */
  132341. dispose(forceDisposeTextures?: boolean): void;
  132342. /**
  132343. * Get the current class name of the texture useful for serialization or dynamic coding.
  132344. * @returns "PBRClearCoatConfiguration"
  132345. */
  132346. getClassName(): string;
  132347. /**
  132348. * Add fallbacks to the effect fallbacks list.
  132349. * @param defines defines the Base texture to use.
  132350. * @param fallbacks defines the current fallback list.
  132351. * @param currentRank defines the current fallback rank.
  132352. * @returns the new fallback rank.
  132353. */
  132354. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  132355. /**
  132356. * Add the required uniforms to the current list.
  132357. * @param uniforms defines the current uniform list.
  132358. */
  132359. static AddUniforms(uniforms: string[]): void;
  132360. /**
  132361. * Add the required samplers to the current list.
  132362. * @param samplers defines the current sampler list.
  132363. */
  132364. static AddSamplers(samplers: string[]): void;
  132365. /**
  132366. * Add the required uniforms to the current buffer.
  132367. * @param uniformBuffer defines the current uniform buffer.
  132368. */
  132369. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  132370. /**
  132371. * Makes a duplicate of the current configuration into another one.
  132372. * @param clearCoatConfiguration define the config where to copy the info
  132373. */
  132374. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  132375. /**
  132376. * Serializes this clear coat configuration.
  132377. * @returns - An object with the serialized config.
  132378. */
  132379. serialize(): any;
  132380. /**
  132381. * Parses a anisotropy Configuration from a serialized object.
  132382. * @param source - Serialized object.
  132383. * @param scene Defines the scene we are parsing for
  132384. * @param rootUrl Defines the rootUrl to load from
  132385. */
  132386. parse(source: any, scene: Scene, rootUrl: string): void;
  132387. }
  132388. }
  132389. declare module BABYLON {
  132390. /**
  132391. * @hidden
  132392. */
  132393. export interface IMaterialAnisotropicDefines {
  132394. ANISOTROPIC: boolean;
  132395. ANISOTROPIC_TEXTURE: boolean;
  132396. ANISOTROPIC_TEXTUREDIRECTUV: number;
  132397. MAINUV1: boolean;
  132398. _areTexturesDirty: boolean;
  132399. _needUVs: boolean;
  132400. }
  132401. /**
  132402. * Define the code related to the anisotropic parameters of the pbr material.
  132403. */
  132404. export class PBRAnisotropicConfiguration {
  132405. private _isEnabled;
  132406. /**
  132407. * Defines if the anisotropy is enabled in the material.
  132408. */
  132409. isEnabled: boolean;
  132410. /**
  132411. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  132412. */
  132413. intensity: number;
  132414. /**
  132415. * Defines if the effect is along the tangents, bitangents or in between.
  132416. * By default, the effect is "strectching" the highlights along the tangents.
  132417. */
  132418. direction: Vector2;
  132419. private _texture;
  132420. /**
  132421. * Stores the anisotropy values in a texture.
  132422. * rg is direction (like normal from -1 to 1)
  132423. * b is a intensity
  132424. */
  132425. texture: Nullable<BaseTexture>;
  132426. /** @hidden */
  132427. private _internalMarkAllSubMeshesAsTexturesDirty;
  132428. /** @hidden */
  132429. _markAllSubMeshesAsTexturesDirty(): void;
  132430. /**
  132431. * Instantiate a new istance of anisotropy configuration.
  132432. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132433. */
  132434. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  132435. /**
  132436. * Specifies that the submesh is ready to be used.
  132437. * @param defines the list of "defines" to update.
  132438. * @param scene defines the scene the material belongs to.
  132439. * @returns - boolean indicating that the submesh is ready or not.
  132440. */
  132441. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  132442. /**
  132443. * Checks to see if a texture is used in the material.
  132444. * @param defines the list of "defines" to update.
  132445. * @param mesh the mesh we are preparing the defines for.
  132446. * @param scene defines the scene the material belongs to.
  132447. */
  132448. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  132449. /**
  132450. * Binds the material data.
  132451. * @param uniformBuffer defines the Uniform buffer to fill in.
  132452. * @param scene defines the scene the material belongs to.
  132453. * @param isFrozen defines wether the material is frozen or not.
  132454. */
  132455. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  132456. /**
  132457. * Checks to see if a texture is used in the material.
  132458. * @param texture - Base texture to use.
  132459. * @returns - Boolean specifying if a texture is used in the material.
  132460. */
  132461. hasTexture(texture: BaseTexture): boolean;
  132462. /**
  132463. * Returns an array of the actively used textures.
  132464. * @param activeTextures Array of BaseTextures
  132465. */
  132466. getActiveTextures(activeTextures: BaseTexture[]): void;
  132467. /**
  132468. * Returns the animatable textures.
  132469. * @param animatables Array of animatable textures.
  132470. */
  132471. getAnimatables(animatables: IAnimatable[]): void;
  132472. /**
  132473. * Disposes the resources of the material.
  132474. * @param forceDisposeTextures - Forces the disposal of all textures.
  132475. */
  132476. dispose(forceDisposeTextures?: boolean): void;
  132477. /**
  132478. * Get the current class name of the texture useful for serialization or dynamic coding.
  132479. * @returns "PBRAnisotropicConfiguration"
  132480. */
  132481. getClassName(): string;
  132482. /**
  132483. * Add fallbacks to the effect fallbacks list.
  132484. * @param defines defines the Base texture to use.
  132485. * @param fallbacks defines the current fallback list.
  132486. * @param currentRank defines the current fallback rank.
  132487. * @returns the new fallback rank.
  132488. */
  132489. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  132490. /**
  132491. * Add the required uniforms to the current list.
  132492. * @param uniforms defines the current uniform list.
  132493. */
  132494. static AddUniforms(uniforms: string[]): void;
  132495. /**
  132496. * Add the required uniforms to the current buffer.
  132497. * @param uniformBuffer defines the current uniform buffer.
  132498. */
  132499. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  132500. /**
  132501. * Add the required samplers to the current list.
  132502. * @param samplers defines the current sampler list.
  132503. */
  132504. static AddSamplers(samplers: string[]): void;
  132505. /**
  132506. * Makes a duplicate of the current configuration into another one.
  132507. * @param anisotropicConfiguration define the config where to copy the info
  132508. */
  132509. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  132510. /**
  132511. * Serializes this anisotropy configuration.
  132512. * @returns - An object with the serialized config.
  132513. */
  132514. serialize(): any;
  132515. /**
  132516. * Parses a anisotropy Configuration from a serialized object.
  132517. * @param source - Serialized object.
  132518. * @param scene Defines the scene we are parsing for
  132519. * @param rootUrl Defines the rootUrl to load from
  132520. */
  132521. parse(source: any, scene: Scene, rootUrl: string): void;
  132522. }
  132523. }
  132524. declare module BABYLON {
  132525. /**
  132526. * @hidden
  132527. */
  132528. export interface IMaterialBRDFDefines {
  132529. BRDF_V_HEIGHT_CORRELATED: boolean;
  132530. MS_BRDF_ENERGY_CONSERVATION: boolean;
  132531. SPHERICAL_HARMONICS: boolean;
  132532. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  132533. /** @hidden */
  132534. _areMiscDirty: boolean;
  132535. }
  132536. /**
  132537. * Define the code related to the BRDF parameters of the pbr material.
  132538. */
  132539. export class PBRBRDFConfiguration {
  132540. /**
  132541. * Default value used for the energy conservation.
  132542. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  132543. */
  132544. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  132545. /**
  132546. * Default value used for the Smith Visibility Height Correlated mode.
  132547. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  132548. */
  132549. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  132550. /**
  132551. * Default value used for the IBL diffuse part.
  132552. * This can help switching back to the polynomials mode globally which is a tiny bit
  132553. * less GPU intensive at the drawback of a lower quality.
  132554. */
  132555. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  132556. /**
  132557. * Default value used for activating energy conservation for the specular workflow.
  132558. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  132559. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  132560. */
  132561. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  132562. private _useEnergyConservation;
  132563. /**
  132564. * Defines if the material uses energy conservation.
  132565. */
  132566. useEnergyConservation: boolean;
  132567. private _useSmithVisibilityHeightCorrelated;
  132568. /**
  132569. * LEGACY Mode set to false
  132570. * Defines if the material uses height smith correlated visibility term.
  132571. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  132572. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  132573. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  132574. * Not relying on height correlated will also disable energy conservation.
  132575. */
  132576. useSmithVisibilityHeightCorrelated: boolean;
  132577. private _useSphericalHarmonics;
  132578. /**
  132579. * LEGACY Mode set to false
  132580. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  132581. * diffuse part of the IBL.
  132582. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  132583. * to the ground truth.
  132584. */
  132585. useSphericalHarmonics: boolean;
  132586. private _useSpecularGlossinessInputEnergyConservation;
  132587. /**
  132588. * Defines if the material uses energy conservation, when the specular workflow is active.
  132589. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  132590. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  132591. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  132592. */
  132593. useSpecularGlossinessInputEnergyConservation: boolean;
  132594. /** @hidden */
  132595. private _internalMarkAllSubMeshesAsMiscDirty;
  132596. /** @hidden */
  132597. _markAllSubMeshesAsMiscDirty(): void;
  132598. /**
  132599. * Instantiate a new istance of clear coat configuration.
  132600. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  132601. */
  132602. constructor(markAllSubMeshesAsMiscDirty: () => void);
  132603. /**
  132604. * Checks to see if a texture is used in the material.
  132605. * @param defines the list of "defines" to update.
  132606. */
  132607. prepareDefines(defines: IMaterialBRDFDefines): void;
  132608. /**
  132609. * Get the current class name of the texture useful for serialization or dynamic coding.
  132610. * @returns "PBRClearCoatConfiguration"
  132611. */
  132612. getClassName(): string;
  132613. /**
  132614. * Makes a duplicate of the current configuration into another one.
  132615. * @param brdfConfiguration define the config where to copy the info
  132616. */
  132617. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  132618. /**
  132619. * Serializes this BRDF configuration.
  132620. * @returns - An object with the serialized config.
  132621. */
  132622. serialize(): any;
  132623. /**
  132624. * Parses a anisotropy Configuration from a serialized object.
  132625. * @param source - Serialized object.
  132626. * @param scene Defines the scene we are parsing for
  132627. * @param rootUrl Defines the rootUrl to load from
  132628. */
  132629. parse(source: any, scene: Scene, rootUrl: string): void;
  132630. }
  132631. }
  132632. declare module BABYLON {
  132633. /**
  132634. * @hidden
  132635. */
  132636. export interface IMaterialSheenDefines {
  132637. SHEEN: boolean;
  132638. SHEEN_TEXTURE: boolean;
  132639. SHEEN_TEXTUREDIRECTUV: number;
  132640. SHEEN_LINKWITHALBEDO: boolean;
  132641. SHEEN_ROUGHNESS: boolean;
  132642. SHEEN_ALBEDOSCALING: boolean;
  132643. /** @hidden */
  132644. _areTexturesDirty: boolean;
  132645. }
  132646. /**
  132647. * Define the code related to the Sheen parameters of the pbr material.
  132648. */
  132649. export class PBRSheenConfiguration {
  132650. private _isEnabled;
  132651. /**
  132652. * Defines if the material uses sheen.
  132653. */
  132654. isEnabled: boolean;
  132655. private _linkSheenWithAlbedo;
  132656. /**
  132657. * Defines if the sheen is linked to the sheen color.
  132658. */
  132659. linkSheenWithAlbedo: boolean;
  132660. /**
  132661. * Defines the sheen intensity.
  132662. */
  132663. intensity: number;
  132664. /**
  132665. * Defines the sheen color.
  132666. */
  132667. color: Color3;
  132668. private _texture;
  132669. /**
  132670. * Stores the sheen tint values in a texture.
  132671. * rgb is tint
  132672. * a is a intensity or roughness if roughness has been defined
  132673. */
  132674. texture: Nullable<BaseTexture>;
  132675. private _roughness;
  132676. /**
  132677. * Defines the sheen roughness.
  132678. * It is not taken into account if linkSheenWithAlbedo is true.
  132679. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  132680. */
  132681. roughness: Nullable<number>;
  132682. private _albedoScaling;
  132683. /**
  132684. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  132685. * It allows the strength of the sheen effect to not depend on the base color of the material,
  132686. * making it easier to setup and tweak the effect
  132687. */
  132688. albedoScaling: boolean;
  132689. /** @hidden */
  132690. private _internalMarkAllSubMeshesAsTexturesDirty;
  132691. /** @hidden */
  132692. _markAllSubMeshesAsTexturesDirty(): void;
  132693. /**
  132694. * Instantiate a new istance of clear coat configuration.
  132695. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132696. */
  132697. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  132698. /**
  132699. * Specifies that the submesh is ready to be used.
  132700. * @param defines the list of "defines" to update.
  132701. * @param scene defines the scene the material belongs to.
  132702. * @returns - boolean indicating that the submesh is ready or not.
  132703. */
  132704. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  132705. /**
  132706. * Checks to see if a texture is used in the material.
  132707. * @param defines the list of "defines" to update.
  132708. * @param scene defines the scene the material belongs to.
  132709. */
  132710. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  132711. /**
  132712. * Binds the material data.
  132713. * @param uniformBuffer defines the Uniform buffer to fill in.
  132714. * @param scene defines the scene the material belongs to.
  132715. * @param isFrozen defines wether the material is frozen or not.
  132716. */
  132717. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  132718. /**
  132719. * Checks to see if a texture is used in the material.
  132720. * @param texture - Base texture to use.
  132721. * @returns - Boolean specifying if a texture is used in the material.
  132722. */
  132723. hasTexture(texture: BaseTexture): boolean;
  132724. /**
  132725. * Returns an array of the actively used textures.
  132726. * @param activeTextures Array of BaseTextures
  132727. */
  132728. getActiveTextures(activeTextures: BaseTexture[]): void;
  132729. /**
  132730. * Returns the animatable textures.
  132731. * @param animatables Array of animatable textures.
  132732. */
  132733. getAnimatables(animatables: IAnimatable[]): void;
  132734. /**
  132735. * Disposes the resources of the material.
  132736. * @param forceDisposeTextures - Forces the disposal of all textures.
  132737. */
  132738. dispose(forceDisposeTextures?: boolean): void;
  132739. /**
  132740. * Get the current class name of the texture useful for serialization or dynamic coding.
  132741. * @returns "PBRSheenConfiguration"
  132742. */
  132743. getClassName(): string;
  132744. /**
  132745. * Add fallbacks to the effect fallbacks list.
  132746. * @param defines defines the Base texture to use.
  132747. * @param fallbacks defines the current fallback list.
  132748. * @param currentRank defines the current fallback rank.
  132749. * @returns the new fallback rank.
  132750. */
  132751. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  132752. /**
  132753. * Add the required uniforms to the current list.
  132754. * @param uniforms defines the current uniform list.
  132755. */
  132756. static AddUniforms(uniforms: string[]): void;
  132757. /**
  132758. * Add the required uniforms to the current buffer.
  132759. * @param uniformBuffer defines the current uniform buffer.
  132760. */
  132761. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  132762. /**
  132763. * Add the required samplers to the current list.
  132764. * @param samplers defines the current sampler list.
  132765. */
  132766. static AddSamplers(samplers: string[]): void;
  132767. /**
  132768. * Makes a duplicate of the current configuration into another one.
  132769. * @param sheenConfiguration define the config where to copy the info
  132770. */
  132771. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  132772. /**
  132773. * Serializes this BRDF configuration.
  132774. * @returns - An object with the serialized config.
  132775. */
  132776. serialize(): any;
  132777. /**
  132778. * Parses a anisotropy Configuration from a serialized object.
  132779. * @param source - Serialized object.
  132780. * @param scene Defines the scene we are parsing for
  132781. * @param rootUrl Defines the rootUrl to load from
  132782. */
  132783. parse(source: any, scene: Scene, rootUrl: string): void;
  132784. }
  132785. }
  132786. declare module BABYLON {
  132787. /**
  132788. * @hidden
  132789. */
  132790. export interface IMaterialSubSurfaceDefines {
  132791. SUBSURFACE: boolean;
  132792. SS_REFRACTION: boolean;
  132793. SS_TRANSLUCENCY: boolean;
  132794. SS_SCATTERING: boolean;
  132795. SS_THICKNESSANDMASK_TEXTURE: boolean;
  132796. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  132797. SS_REFRACTIONMAP_3D: boolean;
  132798. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  132799. SS_LODINREFRACTIONALPHA: boolean;
  132800. SS_GAMMAREFRACTION: boolean;
  132801. SS_RGBDREFRACTION: boolean;
  132802. SS_LINEARSPECULARREFRACTION: boolean;
  132803. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  132804. SS_ALBEDOFORREFRACTIONTINT: boolean;
  132805. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  132806. /** @hidden */
  132807. _areTexturesDirty: boolean;
  132808. }
  132809. /**
  132810. * Define the code related to the sub surface parameters of the pbr material.
  132811. */
  132812. export class PBRSubSurfaceConfiguration {
  132813. private _isRefractionEnabled;
  132814. /**
  132815. * Defines if the refraction is enabled in the material.
  132816. */
  132817. isRefractionEnabled: boolean;
  132818. private _isTranslucencyEnabled;
  132819. /**
  132820. * Defines if the translucency is enabled in the material.
  132821. */
  132822. isTranslucencyEnabled: boolean;
  132823. private _isScatteringEnabled;
  132824. /**
  132825. * Defines if the sub surface scattering is enabled in the material.
  132826. */
  132827. isScatteringEnabled: boolean;
  132828. private _scatteringDiffusionProfileIndex;
  132829. /**
  132830. * Diffusion profile for subsurface scattering.
  132831. * Useful for better scattering in the skins or foliages.
  132832. */
  132833. get scatteringDiffusionProfile(): Nullable<Color3>;
  132834. set scatteringDiffusionProfile(c: Nullable<Color3>);
  132835. /**
  132836. * Defines the refraction intensity of the material.
  132837. * The refraction when enabled replaces the Diffuse part of the material.
  132838. * The intensity helps transitionning between diffuse and refraction.
  132839. */
  132840. refractionIntensity: number;
  132841. /**
  132842. * Defines the translucency intensity of the material.
  132843. * When translucency has been enabled, this defines how much of the "translucency"
  132844. * is addded to the diffuse part of the material.
  132845. */
  132846. translucencyIntensity: number;
  132847. /**
  132848. * Defines the scattering intensity of the material.
  132849. * When scattering has been enabled, this defines how much of the "scattered light"
  132850. * is addded to the diffuse part of the material.
  132851. */
  132852. scatteringIntensity: number;
  132853. /**
  132854. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  132855. */
  132856. useAlbedoToTintRefraction: boolean;
  132857. private _thicknessTexture;
  132858. /**
  132859. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  132860. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  132861. * 0 would mean minimumThickness
  132862. * 1 would mean maximumThickness
  132863. * The other channels might be use as a mask to vary the different effects intensity.
  132864. */
  132865. thicknessTexture: Nullable<BaseTexture>;
  132866. private _refractionTexture;
  132867. /**
  132868. * Defines the texture to use for refraction.
  132869. */
  132870. refractionTexture: Nullable<BaseTexture>;
  132871. private _indexOfRefraction;
  132872. /**
  132873. * Index of refraction of the material base layer.
  132874. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  132875. *
  132876. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  132877. *
  132878. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  132879. */
  132880. indexOfRefraction: number;
  132881. private _volumeIndexOfRefraction;
  132882. /**
  132883. * Index of refraction of the material's volume.
  132884. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  132885. *
  132886. * This ONLY impacts refraction. If not provided or given a non-valid value,
  132887. * the volume will use the same IOR as the surface.
  132888. */
  132889. get volumeIndexOfRefraction(): number;
  132890. set volumeIndexOfRefraction(value: number);
  132891. private _invertRefractionY;
  132892. /**
  132893. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  132894. */
  132895. invertRefractionY: boolean;
  132896. private _linkRefractionWithTransparency;
  132897. /**
  132898. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  132899. * Materials half opaque for instance using refraction could benefit from this control.
  132900. */
  132901. linkRefractionWithTransparency: boolean;
  132902. /**
  132903. * Defines the minimum thickness stored in the thickness map.
  132904. * If no thickness map is defined, this value will be used to simulate thickness.
  132905. */
  132906. minimumThickness: number;
  132907. /**
  132908. * Defines the maximum thickness stored in the thickness map.
  132909. */
  132910. maximumThickness: number;
  132911. /**
  132912. * Defines the volume tint of the material.
  132913. * This is used for both translucency and scattering.
  132914. */
  132915. tintColor: Color3;
  132916. /**
  132917. * Defines the distance at which the tint color should be found in the media.
  132918. * This is used for refraction only.
  132919. */
  132920. tintColorAtDistance: number;
  132921. /**
  132922. * Defines how far each channel transmit through the media.
  132923. * It is defined as a color to simplify it selection.
  132924. */
  132925. diffusionDistance: Color3;
  132926. private _useMaskFromThicknessTexture;
  132927. /**
  132928. * Stores the intensity of the different subsurface effects in the thickness texture.
  132929. * * the green channel is the translucency intensity.
  132930. * * the blue channel is the scattering intensity.
  132931. * * the alpha channel is the refraction intensity.
  132932. */
  132933. useMaskFromThicknessTexture: boolean;
  132934. private _scene;
  132935. /** @hidden */
  132936. private _internalMarkAllSubMeshesAsTexturesDirty;
  132937. private _internalMarkScenePrePassDirty;
  132938. /** @hidden */
  132939. _markAllSubMeshesAsTexturesDirty(): void;
  132940. /** @hidden */
  132941. _markScenePrePassDirty(): void;
  132942. /**
  132943. * Instantiate a new istance of sub surface configuration.
  132944. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132945. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  132946. * @param scene The scene
  132947. */
  132948. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  132949. /**
  132950. * Gets wehter the submesh is ready to be used or not.
  132951. * @param defines the list of "defines" to update.
  132952. * @param scene defines the scene the material belongs to.
  132953. * @returns - boolean indicating that the submesh is ready or not.
  132954. */
  132955. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  132956. /**
  132957. * Checks to see if a texture is used in the material.
  132958. * @param defines the list of "defines" to update.
  132959. * @param scene defines the scene to the material belongs to.
  132960. */
  132961. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  132962. /**
  132963. * Binds the material data.
  132964. * @param uniformBuffer defines the Uniform buffer to fill in.
  132965. * @param scene defines the scene the material belongs to.
  132966. * @param engine defines the engine the material belongs to.
  132967. * @param isFrozen defines whether the material is frozen or not.
  132968. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  132969. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  132970. */
  132971. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  132972. /**
  132973. * Unbinds the material from the mesh.
  132974. * @param activeEffect defines the effect that should be unbound from.
  132975. * @returns true if unbound, otherwise false
  132976. */
  132977. unbind(activeEffect: Effect): boolean;
  132978. /**
  132979. * Returns the texture used for refraction or null if none is used.
  132980. * @param scene defines the scene the material belongs to.
  132981. * @returns - Refraction texture if present. If no refraction texture and refraction
  132982. * is linked with transparency, returns environment texture. Otherwise, returns null.
  132983. */
  132984. private _getRefractionTexture;
  132985. /**
  132986. * Returns true if alpha blending should be disabled.
  132987. */
  132988. get disableAlphaBlending(): boolean;
  132989. /**
  132990. * Fills the list of render target textures.
  132991. * @param renderTargets the list of render targets to update
  132992. */
  132993. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  132994. /**
  132995. * Checks to see if a texture is used in the material.
  132996. * @param texture - Base texture to use.
  132997. * @returns - Boolean specifying if a texture is used in the material.
  132998. */
  132999. hasTexture(texture: BaseTexture): boolean;
  133000. /**
  133001. * Gets a boolean indicating that current material needs to register RTT
  133002. * @returns true if this uses a render target otherwise false.
  133003. */
  133004. hasRenderTargetTextures(): boolean;
  133005. /**
  133006. * Returns an array of the actively used textures.
  133007. * @param activeTextures Array of BaseTextures
  133008. */
  133009. getActiveTextures(activeTextures: BaseTexture[]): void;
  133010. /**
  133011. * Returns the animatable textures.
  133012. * @param animatables Array of animatable textures.
  133013. */
  133014. getAnimatables(animatables: IAnimatable[]): void;
  133015. /**
  133016. * Disposes the resources of the material.
  133017. * @param forceDisposeTextures - Forces the disposal of all textures.
  133018. */
  133019. dispose(forceDisposeTextures?: boolean): void;
  133020. /**
  133021. * Get the current class name of the texture useful for serialization or dynamic coding.
  133022. * @returns "PBRSubSurfaceConfiguration"
  133023. */
  133024. getClassName(): string;
  133025. /**
  133026. * Add fallbacks to the effect fallbacks list.
  133027. * @param defines defines the Base texture to use.
  133028. * @param fallbacks defines the current fallback list.
  133029. * @param currentRank defines the current fallback rank.
  133030. * @returns the new fallback rank.
  133031. */
  133032. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  133033. /**
  133034. * Add the required uniforms to the current list.
  133035. * @param uniforms defines the current uniform list.
  133036. */
  133037. static AddUniforms(uniforms: string[]): void;
  133038. /**
  133039. * Add the required samplers to the current list.
  133040. * @param samplers defines the current sampler list.
  133041. */
  133042. static AddSamplers(samplers: string[]): void;
  133043. /**
  133044. * Add the required uniforms to the current buffer.
  133045. * @param uniformBuffer defines the current uniform buffer.
  133046. */
  133047. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  133048. /**
  133049. * Makes a duplicate of the current configuration into another one.
  133050. * @param configuration define the config where to copy the info
  133051. */
  133052. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  133053. /**
  133054. * Serializes this Sub Surface configuration.
  133055. * @returns - An object with the serialized config.
  133056. */
  133057. serialize(): any;
  133058. /**
  133059. * Parses a anisotropy Configuration from a serialized object.
  133060. * @param source - Serialized object.
  133061. * @param scene Defines the scene we are parsing for
  133062. * @param rootUrl Defines the rootUrl to load from
  133063. */
  133064. parse(source: any, scene: Scene, rootUrl: string): void;
  133065. }
  133066. }
  133067. declare module BABYLON {
  133068. /** @hidden */
  133069. export var prePassDeclaration: {
  133070. name: string;
  133071. shader: string;
  133072. };
  133073. }
  133074. declare module BABYLON {
  133075. /** @hidden */
  133076. export var pbrFragmentDeclaration: {
  133077. name: string;
  133078. shader: string;
  133079. };
  133080. }
  133081. declare module BABYLON {
  133082. /** @hidden */
  133083. export var pbrUboDeclaration: {
  133084. name: string;
  133085. shader: string;
  133086. };
  133087. }
  133088. declare module BABYLON {
  133089. /** @hidden */
  133090. export var pbrFragmentExtraDeclaration: {
  133091. name: string;
  133092. shader: string;
  133093. };
  133094. }
  133095. declare module BABYLON {
  133096. /** @hidden */
  133097. export var pbrFragmentSamplersDeclaration: {
  133098. name: string;
  133099. shader: string;
  133100. };
  133101. }
  133102. declare module BABYLON {
  133103. /** @hidden */
  133104. export var subSurfaceScatteringFunctions: {
  133105. name: string;
  133106. shader: string;
  133107. };
  133108. }
  133109. declare module BABYLON {
  133110. /** @hidden */
  133111. export var importanceSampling: {
  133112. name: string;
  133113. shader: string;
  133114. };
  133115. }
  133116. declare module BABYLON {
  133117. /** @hidden */
  133118. export var pbrHelperFunctions: {
  133119. name: string;
  133120. shader: string;
  133121. };
  133122. }
  133123. declare module BABYLON {
  133124. /** @hidden */
  133125. export var harmonicsFunctions: {
  133126. name: string;
  133127. shader: string;
  133128. };
  133129. }
  133130. declare module BABYLON {
  133131. /** @hidden */
  133132. export var pbrDirectLightingSetupFunctions: {
  133133. name: string;
  133134. shader: string;
  133135. };
  133136. }
  133137. declare module BABYLON {
  133138. /** @hidden */
  133139. export var pbrDirectLightingFalloffFunctions: {
  133140. name: string;
  133141. shader: string;
  133142. };
  133143. }
  133144. declare module BABYLON {
  133145. /** @hidden */
  133146. export var pbrBRDFFunctions: {
  133147. name: string;
  133148. shader: string;
  133149. };
  133150. }
  133151. declare module BABYLON {
  133152. /** @hidden */
  133153. export var hdrFilteringFunctions: {
  133154. name: string;
  133155. shader: string;
  133156. };
  133157. }
  133158. declare module BABYLON {
  133159. /** @hidden */
  133160. export var pbrDirectLightingFunctions: {
  133161. name: string;
  133162. shader: string;
  133163. };
  133164. }
  133165. declare module BABYLON {
  133166. /** @hidden */
  133167. export var pbrIBLFunctions: {
  133168. name: string;
  133169. shader: string;
  133170. };
  133171. }
  133172. declare module BABYLON {
  133173. /** @hidden */
  133174. export var pbrBlockAlbedoOpacity: {
  133175. name: string;
  133176. shader: string;
  133177. };
  133178. }
  133179. declare module BABYLON {
  133180. /** @hidden */
  133181. export var pbrBlockReflectivity: {
  133182. name: string;
  133183. shader: string;
  133184. };
  133185. }
  133186. declare module BABYLON {
  133187. /** @hidden */
  133188. export var pbrBlockAmbientOcclusion: {
  133189. name: string;
  133190. shader: string;
  133191. };
  133192. }
  133193. declare module BABYLON {
  133194. /** @hidden */
  133195. export var pbrBlockAlphaFresnel: {
  133196. name: string;
  133197. shader: string;
  133198. };
  133199. }
  133200. declare module BABYLON {
  133201. /** @hidden */
  133202. export var pbrBlockAnisotropic: {
  133203. name: string;
  133204. shader: string;
  133205. };
  133206. }
  133207. declare module BABYLON {
  133208. /** @hidden */
  133209. export var pbrBlockReflection: {
  133210. name: string;
  133211. shader: string;
  133212. };
  133213. }
  133214. declare module BABYLON {
  133215. /** @hidden */
  133216. export var pbrBlockSheen: {
  133217. name: string;
  133218. shader: string;
  133219. };
  133220. }
  133221. declare module BABYLON {
  133222. /** @hidden */
  133223. export var pbrBlockClearcoat: {
  133224. name: string;
  133225. shader: string;
  133226. };
  133227. }
  133228. declare module BABYLON {
  133229. /** @hidden */
  133230. export var pbrBlockSubSurface: {
  133231. name: string;
  133232. shader: string;
  133233. };
  133234. }
  133235. declare module BABYLON {
  133236. /** @hidden */
  133237. export var pbrBlockNormalGeometric: {
  133238. name: string;
  133239. shader: string;
  133240. };
  133241. }
  133242. declare module BABYLON {
  133243. /** @hidden */
  133244. export var pbrBlockNormalFinal: {
  133245. name: string;
  133246. shader: string;
  133247. };
  133248. }
  133249. declare module BABYLON {
  133250. /** @hidden */
  133251. export var pbrBlockGeometryInfo: {
  133252. name: string;
  133253. shader: string;
  133254. };
  133255. }
  133256. declare module BABYLON {
  133257. /** @hidden */
  133258. export var pbrBlockReflectance0: {
  133259. name: string;
  133260. shader: string;
  133261. };
  133262. }
  133263. declare module BABYLON {
  133264. /** @hidden */
  133265. export var pbrBlockReflectance: {
  133266. name: string;
  133267. shader: string;
  133268. };
  133269. }
  133270. declare module BABYLON {
  133271. /** @hidden */
  133272. export var pbrBlockDirectLighting: {
  133273. name: string;
  133274. shader: string;
  133275. };
  133276. }
  133277. declare module BABYLON {
  133278. /** @hidden */
  133279. export var pbrBlockFinalLitComponents: {
  133280. name: string;
  133281. shader: string;
  133282. };
  133283. }
  133284. declare module BABYLON {
  133285. /** @hidden */
  133286. export var pbrBlockFinalUnlitComponents: {
  133287. name: string;
  133288. shader: string;
  133289. };
  133290. }
  133291. declare module BABYLON {
  133292. /** @hidden */
  133293. export var pbrBlockFinalColorComposition: {
  133294. name: string;
  133295. shader: string;
  133296. };
  133297. }
  133298. declare module BABYLON {
  133299. /** @hidden */
  133300. export var pbrBlockImageProcessing: {
  133301. name: string;
  133302. shader: string;
  133303. };
  133304. }
  133305. declare module BABYLON {
  133306. /** @hidden */
  133307. export var pbrDebug: {
  133308. name: string;
  133309. shader: string;
  133310. };
  133311. }
  133312. declare module BABYLON {
  133313. /** @hidden */
  133314. export var pbrPixelShader: {
  133315. name: string;
  133316. shader: string;
  133317. };
  133318. }
  133319. declare module BABYLON {
  133320. /** @hidden */
  133321. export var pbrVertexDeclaration: {
  133322. name: string;
  133323. shader: string;
  133324. };
  133325. }
  133326. declare module BABYLON {
  133327. /** @hidden */
  133328. export var pbrVertexShader: {
  133329. name: string;
  133330. shader: string;
  133331. };
  133332. }
  133333. declare module BABYLON {
  133334. /**
  133335. * Manages the defines for the PBR Material.
  133336. * @hidden
  133337. */
  133338. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  133339. PBR: boolean;
  133340. NUM_SAMPLES: string;
  133341. REALTIME_FILTERING: boolean;
  133342. MAINUV1: boolean;
  133343. MAINUV2: boolean;
  133344. UV1: boolean;
  133345. UV2: boolean;
  133346. ALBEDO: boolean;
  133347. GAMMAALBEDO: boolean;
  133348. ALBEDODIRECTUV: number;
  133349. VERTEXCOLOR: boolean;
  133350. DETAIL: boolean;
  133351. DETAILDIRECTUV: number;
  133352. DETAIL_NORMALBLENDMETHOD: number;
  133353. AMBIENT: boolean;
  133354. AMBIENTDIRECTUV: number;
  133355. AMBIENTINGRAYSCALE: boolean;
  133356. OPACITY: boolean;
  133357. VERTEXALPHA: boolean;
  133358. OPACITYDIRECTUV: number;
  133359. OPACITYRGB: boolean;
  133360. ALPHATEST: boolean;
  133361. DEPTHPREPASS: boolean;
  133362. ALPHABLEND: boolean;
  133363. ALPHAFROMALBEDO: boolean;
  133364. ALPHATESTVALUE: string;
  133365. SPECULAROVERALPHA: boolean;
  133366. RADIANCEOVERALPHA: boolean;
  133367. ALPHAFRESNEL: boolean;
  133368. LINEARALPHAFRESNEL: boolean;
  133369. PREMULTIPLYALPHA: boolean;
  133370. EMISSIVE: boolean;
  133371. EMISSIVEDIRECTUV: number;
  133372. REFLECTIVITY: boolean;
  133373. REFLECTIVITYDIRECTUV: number;
  133374. SPECULARTERM: boolean;
  133375. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  133376. MICROSURFACEAUTOMATIC: boolean;
  133377. LODBASEDMICROSFURACE: boolean;
  133378. MICROSURFACEMAP: boolean;
  133379. MICROSURFACEMAPDIRECTUV: number;
  133380. METALLICWORKFLOW: boolean;
  133381. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  133382. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  133383. METALLNESSSTOREINMETALMAPBLUE: boolean;
  133384. AOSTOREINMETALMAPRED: boolean;
  133385. METALLIC_REFLECTANCE: boolean;
  133386. METALLIC_REFLECTANCEDIRECTUV: number;
  133387. ENVIRONMENTBRDF: boolean;
  133388. ENVIRONMENTBRDF_RGBD: boolean;
  133389. NORMAL: boolean;
  133390. TANGENT: boolean;
  133391. BUMP: boolean;
  133392. BUMPDIRECTUV: number;
  133393. OBJECTSPACE_NORMALMAP: boolean;
  133394. PARALLAX: boolean;
  133395. PARALLAXOCCLUSION: boolean;
  133396. NORMALXYSCALE: boolean;
  133397. LIGHTMAP: boolean;
  133398. LIGHTMAPDIRECTUV: number;
  133399. USELIGHTMAPASSHADOWMAP: boolean;
  133400. GAMMALIGHTMAP: boolean;
  133401. RGBDLIGHTMAP: boolean;
  133402. REFLECTION: boolean;
  133403. REFLECTIONMAP_3D: boolean;
  133404. REFLECTIONMAP_SPHERICAL: boolean;
  133405. REFLECTIONMAP_PLANAR: boolean;
  133406. REFLECTIONMAP_CUBIC: boolean;
  133407. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  133408. REFLECTIONMAP_PROJECTION: boolean;
  133409. REFLECTIONMAP_SKYBOX: boolean;
  133410. REFLECTIONMAP_EXPLICIT: boolean;
  133411. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  133412. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  133413. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  133414. INVERTCUBICMAP: boolean;
  133415. USESPHERICALFROMREFLECTIONMAP: boolean;
  133416. USEIRRADIANCEMAP: boolean;
  133417. SPHERICAL_HARMONICS: boolean;
  133418. USESPHERICALINVERTEX: boolean;
  133419. REFLECTIONMAP_OPPOSITEZ: boolean;
  133420. LODINREFLECTIONALPHA: boolean;
  133421. GAMMAREFLECTION: boolean;
  133422. RGBDREFLECTION: boolean;
  133423. LINEARSPECULARREFLECTION: boolean;
  133424. RADIANCEOCCLUSION: boolean;
  133425. HORIZONOCCLUSION: boolean;
  133426. INSTANCES: boolean;
  133427. THIN_INSTANCES: boolean;
  133428. PREPASS: boolean;
  133429. SCENE_MRT_COUNT: number;
  133430. NUM_BONE_INFLUENCERS: number;
  133431. BonesPerMesh: number;
  133432. BONETEXTURE: boolean;
  133433. NONUNIFORMSCALING: boolean;
  133434. MORPHTARGETS: boolean;
  133435. MORPHTARGETS_NORMAL: boolean;
  133436. MORPHTARGETS_TANGENT: boolean;
  133437. MORPHTARGETS_UV: boolean;
  133438. NUM_MORPH_INFLUENCERS: number;
  133439. IMAGEPROCESSING: boolean;
  133440. VIGNETTE: boolean;
  133441. VIGNETTEBLENDMODEMULTIPLY: boolean;
  133442. VIGNETTEBLENDMODEOPAQUE: boolean;
  133443. TONEMAPPING: boolean;
  133444. TONEMAPPING_ACES: boolean;
  133445. CONTRAST: boolean;
  133446. COLORCURVES: boolean;
  133447. COLORGRADING: boolean;
  133448. COLORGRADING3D: boolean;
  133449. SAMPLER3DGREENDEPTH: boolean;
  133450. SAMPLER3DBGRMAP: boolean;
  133451. IMAGEPROCESSINGPOSTPROCESS: boolean;
  133452. EXPOSURE: boolean;
  133453. MULTIVIEW: boolean;
  133454. USEPHYSICALLIGHTFALLOFF: boolean;
  133455. USEGLTFLIGHTFALLOFF: boolean;
  133456. TWOSIDEDLIGHTING: boolean;
  133457. SHADOWFLOAT: boolean;
  133458. CLIPPLANE: boolean;
  133459. CLIPPLANE2: boolean;
  133460. CLIPPLANE3: boolean;
  133461. CLIPPLANE4: boolean;
  133462. CLIPPLANE5: boolean;
  133463. CLIPPLANE6: boolean;
  133464. POINTSIZE: boolean;
  133465. FOG: boolean;
  133466. LOGARITHMICDEPTH: boolean;
  133467. FORCENORMALFORWARD: boolean;
  133468. SPECULARAA: boolean;
  133469. CLEARCOAT: boolean;
  133470. CLEARCOAT_DEFAULTIOR: boolean;
  133471. CLEARCOAT_TEXTURE: boolean;
  133472. CLEARCOAT_TEXTUREDIRECTUV: number;
  133473. CLEARCOAT_BUMP: boolean;
  133474. CLEARCOAT_BUMPDIRECTUV: number;
  133475. CLEARCOAT_TINT: boolean;
  133476. CLEARCOAT_TINT_TEXTURE: boolean;
  133477. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  133478. ANISOTROPIC: boolean;
  133479. ANISOTROPIC_TEXTURE: boolean;
  133480. ANISOTROPIC_TEXTUREDIRECTUV: number;
  133481. BRDF_V_HEIGHT_CORRELATED: boolean;
  133482. MS_BRDF_ENERGY_CONSERVATION: boolean;
  133483. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  133484. SHEEN: boolean;
  133485. SHEEN_TEXTURE: boolean;
  133486. SHEEN_TEXTUREDIRECTUV: number;
  133487. SHEEN_LINKWITHALBEDO: boolean;
  133488. SHEEN_ROUGHNESS: boolean;
  133489. SHEEN_ALBEDOSCALING: boolean;
  133490. SUBSURFACE: boolean;
  133491. SS_REFRACTION: boolean;
  133492. SS_TRANSLUCENCY: boolean;
  133493. SS_SCATTERING: boolean;
  133494. SS_THICKNESSANDMASK_TEXTURE: boolean;
  133495. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  133496. SS_REFRACTIONMAP_3D: boolean;
  133497. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  133498. SS_LODINREFRACTIONALPHA: boolean;
  133499. SS_GAMMAREFRACTION: boolean;
  133500. SS_RGBDREFRACTION: boolean;
  133501. SS_LINEARSPECULARREFRACTION: boolean;
  133502. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  133503. SS_ALBEDOFORREFRACTIONTINT: boolean;
  133504. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  133505. UNLIT: boolean;
  133506. DEBUGMODE: number;
  133507. /**
  133508. * Initializes the PBR Material defines.
  133509. */
  133510. constructor();
  133511. /**
  133512. * Resets the PBR Material defines.
  133513. */
  133514. reset(): void;
  133515. }
  133516. /**
  133517. * The Physically based material base class of BJS.
  133518. *
  133519. * This offers the main features of a standard PBR material.
  133520. * For more information, please refer to the documentation :
  133521. * https://doc.babylonjs.com/how_to/physically_based_rendering
  133522. */
  133523. export abstract class PBRBaseMaterial extends PushMaterial {
  133524. /**
  133525. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  133526. */
  133527. static readonly PBRMATERIAL_OPAQUE: number;
  133528. /**
  133529. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  133530. */
  133531. static readonly PBRMATERIAL_ALPHATEST: number;
  133532. /**
  133533. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  133534. */
  133535. static readonly PBRMATERIAL_ALPHABLEND: number;
  133536. /**
  133537. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  133538. * They are also discarded below the alpha cutoff threshold to improve performances.
  133539. */
  133540. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  133541. /**
  133542. * Defines the default value of how much AO map is occluding the analytical lights
  133543. * (point spot...).
  133544. */
  133545. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  133546. /**
  133547. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  133548. */
  133549. static readonly LIGHTFALLOFF_PHYSICAL: number;
  133550. /**
  133551. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  133552. * to enhance interoperability with other engines.
  133553. */
  133554. static readonly LIGHTFALLOFF_GLTF: number;
  133555. /**
  133556. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  133557. * to enhance interoperability with other materials.
  133558. */
  133559. static readonly LIGHTFALLOFF_STANDARD: number;
  133560. /**
  133561. * Intensity of the direct lights e.g. the four lights available in your scene.
  133562. * This impacts both the direct diffuse and specular highlights.
  133563. */
  133564. protected _directIntensity: number;
  133565. /**
  133566. * Intensity of the emissive part of the material.
  133567. * This helps controlling the emissive effect without modifying the emissive color.
  133568. */
  133569. protected _emissiveIntensity: number;
  133570. /**
  133571. * Intensity of the environment e.g. how much the environment will light the object
  133572. * either through harmonics for rough material or through the refelction for shiny ones.
  133573. */
  133574. protected _environmentIntensity: number;
  133575. /**
  133576. * This is a special control allowing the reduction of the specular highlights coming from the
  133577. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  133578. */
  133579. protected _specularIntensity: number;
  133580. /**
  133581. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  133582. */
  133583. private _lightingInfos;
  133584. /**
  133585. * Debug Control allowing disabling the bump map on this material.
  133586. */
  133587. protected _disableBumpMap: boolean;
  133588. /**
  133589. * AKA Diffuse Texture in standard nomenclature.
  133590. */
  133591. protected _albedoTexture: Nullable<BaseTexture>;
  133592. /**
  133593. * AKA Occlusion Texture in other nomenclature.
  133594. */
  133595. protected _ambientTexture: Nullable<BaseTexture>;
  133596. /**
  133597. * AKA Occlusion Texture Intensity in other nomenclature.
  133598. */
  133599. protected _ambientTextureStrength: number;
  133600. /**
  133601. * Defines how much the AO map is occluding the analytical lights (point spot...).
  133602. * 1 means it completely occludes it
  133603. * 0 mean it has no impact
  133604. */
  133605. protected _ambientTextureImpactOnAnalyticalLights: number;
  133606. /**
  133607. * Stores the alpha values in a texture.
  133608. */
  133609. protected _opacityTexture: Nullable<BaseTexture>;
  133610. /**
  133611. * Stores the reflection values in a texture.
  133612. */
  133613. protected _reflectionTexture: Nullable<BaseTexture>;
  133614. /**
  133615. * Stores the emissive values in a texture.
  133616. */
  133617. protected _emissiveTexture: Nullable<BaseTexture>;
  133618. /**
  133619. * AKA Specular texture in other nomenclature.
  133620. */
  133621. protected _reflectivityTexture: Nullable<BaseTexture>;
  133622. /**
  133623. * Used to switch from specular/glossiness to metallic/roughness workflow.
  133624. */
  133625. protected _metallicTexture: Nullable<BaseTexture>;
  133626. /**
  133627. * Specifies the metallic scalar of the metallic/roughness workflow.
  133628. * Can also be used to scale the metalness values of the metallic texture.
  133629. */
  133630. protected _metallic: Nullable<number>;
  133631. /**
  133632. * Specifies the roughness scalar of the metallic/roughness workflow.
  133633. * Can also be used to scale the roughness values of the metallic texture.
  133634. */
  133635. protected _roughness: Nullable<number>;
  133636. /**
  133637. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  133638. * By default the indexOfrefraction is used to compute F0;
  133639. *
  133640. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  133641. *
  133642. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  133643. * F90 = metallicReflectanceColor;
  133644. */
  133645. protected _metallicF0Factor: number;
  133646. /**
  133647. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  133648. * By default the F90 is always 1;
  133649. *
  133650. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  133651. *
  133652. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  133653. * F90 = metallicReflectanceColor;
  133654. */
  133655. protected _metallicReflectanceColor: Color3;
  133656. /**
  133657. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  133658. * This is multiply against the scalar values defined in the material.
  133659. */
  133660. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  133661. /**
  133662. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  133663. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  133664. */
  133665. protected _microSurfaceTexture: Nullable<BaseTexture>;
  133666. /**
  133667. * Stores surface normal data used to displace a mesh in a texture.
  133668. */
  133669. protected _bumpTexture: Nullable<BaseTexture>;
  133670. /**
  133671. * Stores the pre-calculated light information of a mesh in a texture.
  133672. */
  133673. protected _lightmapTexture: Nullable<BaseTexture>;
  133674. /**
  133675. * The color of a material in ambient lighting.
  133676. */
  133677. protected _ambientColor: Color3;
  133678. /**
  133679. * AKA Diffuse Color in other nomenclature.
  133680. */
  133681. protected _albedoColor: Color3;
  133682. /**
  133683. * AKA Specular Color in other nomenclature.
  133684. */
  133685. protected _reflectivityColor: Color3;
  133686. /**
  133687. * The color applied when light is reflected from a material.
  133688. */
  133689. protected _reflectionColor: Color3;
  133690. /**
  133691. * The color applied when light is emitted from a material.
  133692. */
  133693. protected _emissiveColor: Color3;
  133694. /**
  133695. * AKA Glossiness in other nomenclature.
  133696. */
  133697. protected _microSurface: number;
  133698. /**
  133699. * Specifies that the material will use the light map as a show map.
  133700. */
  133701. protected _useLightmapAsShadowmap: boolean;
  133702. /**
  133703. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  133704. * makes the reflect vector face the model (under horizon).
  133705. */
  133706. protected _useHorizonOcclusion: boolean;
  133707. /**
  133708. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  133709. * too much the area relying on ambient texture to define their ambient occlusion.
  133710. */
  133711. protected _useRadianceOcclusion: boolean;
  133712. /**
  133713. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  133714. */
  133715. protected _useAlphaFromAlbedoTexture: boolean;
  133716. /**
  133717. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  133718. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  133719. */
  133720. protected _useSpecularOverAlpha: boolean;
  133721. /**
  133722. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  133723. */
  133724. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  133725. /**
  133726. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  133727. */
  133728. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  133729. /**
  133730. * Specifies if the metallic texture contains the roughness information in its green channel.
  133731. */
  133732. protected _useRoughnessFromMetallicTextureGreen: boolean;
  133733. /**
  133734. * Specifies if the metallic texture contains the metallness information in its blue channel.
  133735. */
  133736. protected _useMetallnessFromMetallicTextureBlue: boolean;
  133737. /**
  133738. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  133739. */
  133740. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  133741. /**
  133742. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  133743. */
  133744. protected _useAmbientInGrayScale: boolean;
  133745. /**
  133746. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  133747. * The material will try to infer what glossiness each pixel should be.
  133748. */
  133749. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  133750. /**
  133751. * Defines the falloff type used in this material.
  133752. * It by default is Physical.
  133753. */
  133754. protected _lightFalloff: number;
  133755. /**
  133756. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  133757. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  133758. */
  133759. protected _useRadianceOverAlpha: boolean;
  133760. /**
  133761. * Allows using an object space normal map (instead of tangent space).
  133762. */
  133763. protected _useObjectSpaceNormalMap: boolean;
  133764. /**
  133765. * Allows using the bump map in parallax mode.
  133766. */
  133767. protected _useParallax: boolean;
  133768. /**
  133769. * Allows using the bump map in parallax occlusion mode.
  133770. */
  133771. protected _useParallaxOcclusion: boolean;
  133772. /**
  133773. * Controls the scale bias of the parallax mode.
  133774. */
  133775. protected _parallaxScaleBias: number;
  133776. /**
  133777. * If sets to true, disables all the lights affecting the material.
  133778. */
  133779. protected _disableLighting: boolean;
  133780. /**
  133781. * Number of Simultaneous lights allowed on the material.
  133782. */
  133783. protected _maxSimultaneousLights: number;
  133784. /**
  133785. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  133786. */
  133787. protected _invertNormalMapX: boolean;
  133788. /**
  133789. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  133790. */
  133791. protected _invertNormalMapY: boolean;
  133792. /**
  133793. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  133794. */
  133795. protected _twoSidedLighting: boolean;
  133796. /**
  133797. * Defines the alpha limits in alpha test mode.
  133798. */
  133799. protected _alphaCutOff: number;
  133800. /**
  133801. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  133802. */
  133803. protected _forceAlphaTest: boolean;
  133804. /**
  133805. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  133806. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  133807. */
  133808. protected _useAlphaFresnel: boolean;
  133809. /**
  133810. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  133811. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  133812. */
  133813. protected _useLinearAlphaFresnel: boolean;
  133814. /**
  133815. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  133816. * from cos thetav and roughness:
  133817. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  133818. */
  133819. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  133820. /**
  133821. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  133822. */
  133823. protected _forceIrradianceInFragment: boolean;
  133824. private _realTimeFiltering;
  133825. /**
  133826. * Enables realtime filtering on the texture.
  133827. */
  133828. get realTimeFiltering(): boolean;
  133829. set realTimeFiltering(b: boolean);
  133830. private _realTimeFilteringQuality;
  133831. /**
  133832. * Quality switch for realtime filtering
  133833. */
  133834. get realTimeFilteringQuality(): number;
  133835. set realTimeFilteringQuality(n: number);
  133836. /**
  133837. * Should this material render to several textures at once
  133838. */
  133839. get shouldRenderToMRT(): boolean;
  133840. /**
  133841. * Force normal to face away from face.
  133842. */
  133843. protected _forceNormalForward: boolean;
  133844. /**
  133845. * Enables specular anti aliasing in the PBR shader.
  133846. * It will both interacts on the Geometry for analytical and IBL lighting.
  133847. * It also prefilter the roughness map based on the bump values.
  133848. */
  133849. protected _enableSpecularAntiAliasing: boolean;
  133850. /**
  133851. * Default configuration related to image processing available in the PBR Material.
  133852. */
  133853. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  133854. /**
  133855. * Keep track of the image processing observer to allow dispose and replace.
  133856. */
  133857. private _imageProcessingObserver;
  133858. /**
  133859. * Attaches a new image processing configuration to the PBR Material.
  133860. * @param configuration
  133861. */
  133862. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  133863. /**
  133864. * Stores the available render targets.
  133865. */
  133866. private _renderTargets;
  133867. /**
  133868. * Sets the global ambient color for the material used in lighting calculations.
  133869. */
  133870. private _globalAmbientColor;
  133871. /**
  133872. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  133873. */
  133874. private _useLogarithmicDepth;
  133875. /**
  133876. * If set to true, no lighting calculations will be applied.
  133877. */
  133878. private _unlit;
  133879. private _debugMode;
  133880. /**
  133881. * @hidden
  133882. * This is reserved for the inspector.
  133883. * Defines the material debug mode.
  133884. * It helps seeing only some components of the material while troubleshooting.
  133885. */
  133886. debugMode: number;
  133887. /**
  133888. * @hidden
  133889. * This is reserved for the inspector.
  133890. * Specify from where on screen the debug mode should start.
  133891. * The value goes from -1 (full screen) to 1 (not visible)
  133892. * It helps with side by side comparison against the final render
  133893. * This defaults to -1
  133894. */
  133895. private debugLimit;
  133896. /**
  133897. * @hidden
  133898. * This is reserved for the inspector.
  133899. * As the default viewing range might not be enough (if the ambient is really small for instance)
  133900. * You can use the factor to better multiply the final value.
  133901. */
  133902. private debugFactor;
  133903. /**
  133904. * Defines the clear coat layer parameters for the material.
  133905. */
  133906. readonly clearCoat: PBRClearCoatConfiguration;
  133907. /**
  133908. * Defines the anisotropic parameters for the material.
  133909. */
  133910. readonly anisotropy: PBRAnisotropicConfiguration;
  133911. /**
  133912. * Defines the BRDF parameters for the material.
  133913. */
  133914. readonly brdf: PBRBRDFConfiguration;
  133915. /**
  133916. * Defines the Sheen parameters for the material.
  133917. */
  133918. readonly sheen: PBRSheenConfiguration;
  133919. /**
  133920. * Defines the SubSurface parameters for the material.
  133921. */
  133922. readonly subSurface: PBRSubSurfaceConfiguration;
  133923. /**
  133924. * Defines the detail map parameters for the material.
  133925. */
  133926. readonly detailMap: DetailMapConfiguration;
  133927. protected _rebuildInParallel: boolean;
  133928. /**
  133929. * Instantiates a new PBRMaterial instance.
  133930. *
  133931. * @param name The material name
  133932. * @param scene The scene the material will be use in.
  133933. */
  133934. constructor(name: string, scene: Scene);
  133935. /**
  133936. * Gets a boolean indicating that current material needs to register RTT
  133937. */
  133938. get hasRenderTargetTextures(): boolean;
  133939. /**
  133940. * Gets the name of the material class.
  133941. */
  133942. getClassName(): string;
  133943. /**
  133944. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  133945. */
  133946. get useLogarithmicDepth(): boolean;
  133947. /**
  133948. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  133949. */
  133950. set useLogarithmicDepth(value: boolean);
  133951. /**
  133952. * Returns true if alpha blending should be disabled.
  133953. */
  133954. protected get _disableAlphaBlending(): boolean;
  133955. /**
  133956. * Specifies whether or not this material should be rendered in alpha blend mode.
  133957. */
  133958. needAlphaBlending(): boolean;
  133959. /**
  133960. * Specifies whether or not this material should be rendered in alpha test mode.
  133961. */
  133962. needAlphaTesting(): boolean;
  133963. /**
  133964. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  133965. */
  133966. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  133967. /**
  133968. * Gets the texture used for the alpha test.
  133969. */
  133970. getAlphaTestTexture(): Nullable<BaseTexture>;
  133971. /**
  133972. * Specifies that the submesh is ready to be used.
  133973. * @param mesh - BJS mesh.
  133974. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  133975. * @param useInstances - Specifies that instances should be used.
  133976. * @returns - boolean indicating that the submesh is ready or not.
  133977. */
  133978. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  133979. /**
  133980. * Specifies if the material uses metallic roughness workflow.
  133981. * @returns boolean specifiying if the material uses metallic roughness workflow.
  133982. */
  133983. isMetallicWorkflow(): boolean;
  133984. private _prepareEffect;
  133985. private _prepareDefines;
  133986. /**
  133987. * Force shader compilation
  133988. */
  133989. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  133990. /**
  133991. * Initializes the uniform buffer layout for the shader.
  133992. */
  133993. buildUniformLayout(): void;
  133994. /**
  133995. * Unbinds the material from the mesh
  133996. */
  133997. unbind(): void;
  133998. /**
  133999. * Binds the submesh data.
  134000. * @param world - The world matrix.
  134001. * @param mesh - The BJS mesh.
  134002. * @param subMesh - A submesh of the BJS mesh.
  134003. */
  134004. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  134005. /**
  134006. * Returns the animatable textures.
  134007. * @returns - Array of animatable textures.
  134008. */
  134009. getAnimatables(): IAnimatable[];
  134010. /**
  134011. * Returns the texture used for reflections.
  134012. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  134013. */
  134014. private _getReflectionTexture;
  134015. /**
  134016. * Returns an array of the actively used textures.
  134017. * @returns - Array of BaseTextures
  134018. */
  134019. getActiveTextures(): BaseTexture[];
  134020. /**
  134021. * Checks to see if a texture is used in the material.
  134022. * @param texture - Base texture to use.
  134023. * @returns - Boolean specifying if a texture is used in the material.
  134024. */
  134025. hasTexture(texture: BaseTexture): boolean;
  134026. /**
  134027. * Disposes the resources of the material.
  134028. * @param forceDisposeEffect - Forces the disposal of effects.
  134029. * @param forceDisposeTextures - Forces the disposal of all textures.
  134030. */
  134031. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  134032. }
  134033. }
  134034. declare module BABYLON {
  134035. /**
  134036. * The Physically based material of BJS.
  134037. *
  134038. * This offers the main features of a standard PBR material.
  134039. * For more information, please refer to the documentation :
  134040. * https://doc.babylonjs.com/how_to/physically_based_rendering
  134041. */
  134042. export class PBRMaterial extends PBRBaseMaterial {
  134043. /**
  134044. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  134045. */
  134046. static readonly PBRMATERIAL_OPAQUE: number;
  134047. /**
  134048. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  134049. */
  134050. static readonly PBRMATERIAL_ALPHATEST: number;
  134051. /**
  134052. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  134053. */
  134054. static readonly PBRMATERIAL_ALPHABLEND: number;
  134055. /**
  134056. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  134057. * They are also discarded below the alpha cutoff threshold to improve performances.
  134058. */
  134059. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  134060. /**
  134061. * Defines the default value of how much AO map is occluding the analytical lights
  134062. * (point spot...).
  134063. */
  134064. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  134065. /**
  134066. * Intensity of the direct lights e.g. the four lights available in your scene.
  134067. * This impacts both the direct diffuse and specular highlights.
  134068. */
  134069. directIntensity: number;
  134070. /**
  134071. * Intensity of the emissive part of the material.
  134072. * This helps controlling the emissive effect without modifying the emissive color.
  134073. */
  134074. emissiveIntensity: number;
  134075. /**
  134076. * Intensity of the environment e.g. how much the environment will light the object
  134077. * either through harmonics for rough material or through the refelction for shiny ones.
  134078. */
  134079. environmentIntensity: number;
  134080. /**
  134081. * This is a special control allowing the reduction of the specular highlights coming from the
  134082. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  134083. */
  134084. specularIntensity: number;
  134085. /**
  134086. * Debug Control allowing disabling the bump map on this material.
  134087. */
  134088. disableBumpMap: boolean;
  134089. /**
  134090. * AKA Diffuse Texture in standard nomenclature.
  134091. */
  134092. albedoTexture: BaseTexture;
  134093. /**
  134094. * AKA Occlusion Texture in other nomenclature.
  134095. */
  134096. ambientTexture: BaseTexture;
  134097. /**
  134098. * AKA Occlusion Texture Intensity in other nomenclature.
  134099. */
  134100. ambientTextureStrength: number;
  134101. /**
  134102. * Defines how much the AO map is occluding the analytical lights (point spot...).
  134103. * 1 means it completely occludes it
  134104. * 0 mean it has no impact
  134105. */
  134106. ambientTextureImpactOnAnalyticalLights: number;
  134107. /**
  134108. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  134109. */
  134110. opacityTexture: BaseTexture;
  134111. /**
  134112. * Stores the reflection values in a texture.
  134113. */
  134114. reflectionTexture: Nullable<BaseTexture>;
  134115. /**
  134116. * Stores the emissive values in a texture.
  134117. */
  134118. emissiveTexture: BaseTexture;
  134119. /**
  134120. * AKA Specular texture in other nomenclature.
  134121. */
  134122. reflectivityTexture: BaseTexture;
  134123. /**
  134124. * Used to switch from specular/glossiness to metallic/roughness workflow.
  134125. */
  134126. metallicTexture: BaseTexture;
  134127. /**
  134128. * Specifies the metallic scalar of the metallic/roughness workflow.
  134129. * Can also be used to scale the metalness values of the metallic texture.
  134130. */
  134131. metallic: Nullable<number>;
  134132. /**
  134133. * Specifies the roughness scalar of the metallic/roughness workflow.
  134134. * Can also be used to scale the roughness values of the metallic texture.
  134135. */
  134136. roughness: Nullable<number>;
  134137. /**
  134138. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  134139. * By default the indexOfrefraction is used to compute F0;
  134140. *
  134141. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  134142. *
  134143. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  134144. * F90 = metallicReflectanceColor;
  134145. */
  134146. metallicF0Factor: number;
  134147. /**
  134148. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  134149. * By default the F90 is always 1;
  134150. *
  134151. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  134152. *
  134153. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  134154. * F90 = metallicReflectanceColor;
  134155. */
  134156. metallicReflectanceColor: Color3;
  134157. /**
  134158. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  134159. * This is multiply against the scalar values defined in the material.
  134160. */
  134161. metallicReflectanceTexture: Nullable<BaseTexture>;
  134162. /**
  134163. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  134164. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  134165. */
  134166. microSurfaceTexture: BaseTexture;
  134167. /**
  134168. * Stores surface normal data used to displace a mesh in a texture.
  134169. */
  134170. bumpTexture: BaseTexture;
  134171. /**
  134172. * Stores the pre-calculated light information of a mesh in a texture.
  134173. */
  134174. lightmapTexture: BaseTexture;
  134175. /**
  134176. * Stores the refracted light information in a texture.
  134177. */
  134178. get refractionTexture(): Nullable<BaseTexture>;
  134179. set refractionTexture(value: Nullable<BaseTexture>);
  134180. /**
  134181. * The color of a material in ambient lighting.
  134182. */
  134183. ambientColor: Color3;
  134184. /**
  134185. * AKA Diffuse Color in other nomenclature.
  134186. */
  134187. albedoColor: Color3;
  134188. /**
  134189. * AKA Specular Color in other nomenclature.
  134190. */
  134191. reflectivityColor: Color3;
  134192. /**
  134193. * The color reflected from the material.
  134194. */
  134195. reflectionColor: Color3;
  134196. /**
  134197. * The color emitted from the material.
  134198. */
  134199. emissiveColor: Color3;
  134200. /**
  134201. * AKA Glossiness in other nomenclature.
  134202. */
  134203. microSurface: number;
  134204. /**
  134205. * Index of refraction of the material base layer.
  134206. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  134207. *
  134208. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  134209. *
  134210. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  134211. */
  134212. get indexOfRefraction(): number;
  134213. set indexOfRefraction(value: number);
  134214. /**
  134215. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  134216. */
  134217. get invertRefractionY(): boolean;
  134218. set invertRefractionY(value: boolean);
  134219. /**
  134220. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  134221. * Materials half opaque for instance using refraction could benefit from this control.
  134222. */
  134223. get linkRefractionWithTransparency(): boolean;
  134224. set linkRefractionWithTransparency(value: boolean);
  134225. /**
  134226. * If true, the light map contains occlusion information instead of lighting info.
  134227. */
  134228. useLightmapAsShadowmap: boolean;
  134229. /**
  134230. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  134231. */
  134232. useAlphaFromAlbedoTexture: boolean;
  134233. /**
  134234. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  134235. */
  134236. forceAlphaTest: boolean;
  134237. /**
  134238. * Defines the alpha limits in alpha test mode.
  134239. */
  134240. alphaCutOff: number;
  134241. /**
  134242. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  134243. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  134244. */
  134245. useSpecularOverAlpha: boolean;
  134246. /**
  134247. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  134248. */
  134249. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  134250. /**
  134251. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  134252. */
  134253. useRoughnessFromMetallicTextureAlpha: boolean;
  134254. /**
  134255. * Specifies if the metallic texture contains the roughness information in its green channel.
  134256. */
  134257. useRoughnessFromMetallicTextureGreen: boolean;
  134258. /**
  134259. * Specifies if the metallic texture contains the metallness information in its blue channel.
  134260. */
  134261. useMetallnessFromMetallicTextureBlue: boolean;
  134262. /**
  134263. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  134264. */
  134265. useAmbientOcclusionFromMetallicTextureRed: boolean;
  134266. /**
  134267. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  134268. */
  134269. useAmbientInGrayScale: boolean;
  134270. /**
  134271. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  134272. * The material will try to infer what glossiness each pixel should be.
  134273. */
  134274. useAutoMicroSurfaceFromReflectivityMap: boolean;
  134275. /**
  134276. * BJS is using an harcoded light falloff based on a manually sets up range.
  134277. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  134278. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  134279. */
  134280. get usePhysicalLightFalloff(): boolean;
  134281. /**
  134282. * BJS is using an harcoded light falloff based on a manually sets up range.
  134283. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  134284. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  134285. */
  134286. set usePhysicalLightFalloff(value: boolean);
  134287. /**
  134288. * In order to support the falloff compatibility with gltf, a special mode has been added
  134289. * to reproduce the gltf light falloff.
  134290. */
  134291. get useGLTFLightFalloff(): boolean;
  134292. /**
  134293. * In order to support the falloff compatibility with gltf, a special mode has been added
  134294. * to reproduce the gltf light falloff.
  134295. */
  134296. set useGLTFLightFalloff(value: boolean);
  134297. /**
  134298. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  134299. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  134300. */
  134301. useRadianceOverAlpha: boolean;
  134302. /**
  134303. * Allows using an object space normal map (instead of tangent space).
  134304. */
  134305. useObjectSpaceNormalMap: boolean;
  134306. /**
  134307. * Allows using the bump map in parallax mode.
  134308. */
  134309. useParallax: boolean;
  134310. /**
  134311. * Allows using the bump map in parallax occlusion mode.
  134312. */
  134313. useParallaxOcclusion: boolean;
  134314. /**
  134315. * Controls the scale bias of the parallax mode.
  134316. */
  134317. parallaxScaleBias: number;
  134318. /**
  134319. * If sets to true, disables all the lights affecting the material.
  134320. */
  134321. disableLighting: boolean;
  134322. /**
  134323. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  134324. */
  134325. forceIrradianceInFragment: boolean;
  134326. /**
  134327. * Number of Simultaneous lights allowed on the material.
  134328. */
  134329. maxSimultaneousLights: number;
  134330. /**
  134331. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  134332. */
  134333. invertNormalMapX: boolean;
  134334. /**
  134335. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  134336. */
  134337. invertNormalMapY: boolean;
  134338. /**
  134339. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  134340. */
  134341. twoSidedLighting: boolean;
  134342. /**
  134343. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  134344. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  134345. */
  134346. useAlphaFresnel: boolean;
  134347. /**
  134348. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  134349. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  134350. */
  134351. useLinearAlphaFresnel: boolean;
  134352. /**
  134353. * Let user defines the brdf lookup texture used for IBL.
  134354. * A default 8bit version is embedded but you could point at :
  134355. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  134356. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  134357. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  134358. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  134359. */
  134360. environmentBRDFTexture: Nullable<BaseTexture>;
  134361. /**
  134362. * Force normal to face away from face.
  134363. */
  134364. forceNormalForward: boolean;
  134365. /**
  134366. * Enables specular anti aliasing in the PBR shader.
  134367. * It will both interacts on the Geometry for analytical and IBL lighting.
  134368. * It also prefilter the roughness map based on the bump values.
  134369. */
  134370. enableSpecularAntiAliasing: boolean;
  134371. /**
  134372. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  134373. * makes the reflect vector face the model (under horizon).
  134374. */
  134375. useHorizonOcclusion: boolean;
  134376. /**
  134377. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  134378. * too much the area relying on ambient texture to define their ambient occlusion.
  134379. */
  134380. useRadianceOcclusion: boolean;
  134381. /**
  134382. * If set to true, no lighting calculations will be applied.
  134383. */
  134384. unlit: boolean;
  134385. /**
  134386. * Gets the image processing configuration used either in this material.
  134387. */
  134388. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  134389. /**
  134390. * Sets the Default image processing configuration used either in the this material.
  134391. *
  134392. * If sets to null, the scene one is in use.
  134393. */
  134394. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  134395. /**
  134396. * Gets wether the color curves effect is enabled.
  134397. */
  134398. get cameraColorCurvesEnabled(): boolean;
  134399. /**
  134400. * Sets wether the color curves effect is enabled.
  134401. */
  134402. set cameraColorCurvesEnabled(value: boolean);
  134403. /**
  134404. * Gets wether the color grading effect is enabled.
  134405. */
  134406. get cameraColorGradingEnabled(): boolean;
  134407. /**
  134408. * Gets wether the color grading effect is enabled.
  134409. */
  134410. set cameraColorGradingEnabled(value: boolean);
  134411. /**
  134412. * Gets wether tonemapping is enabled or not.
  134413. */
  134414. get cameraToneMappingEnabled(): boolean;
  134415. /**
  134416. * Sets wether tonemapping is enabled or not
  134417. */
  134418. set cameraToneMappingEnabled(value: boolean);
  134419. /**
  134420. * The camera exposure used on this material.
  134421. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  134422. * This corresponds to a photographic exposure.
  134423. */
  134424. get cameraExposure(): number;
  134425. /**
  134426. * The camera exposure used on this material.
  134427. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  134428. * This corresponds to a photographic exposure.
  134429. */
  134430. set cameraExposure(value: number);
  134431. /**
  134432. * Gets The camera contrast used on this material.
  134433. */
  134434. get cameraContrast(): number;
  134435. /**
  134436. * Sets The camera contrast used on this material.
  134437. */
  134438. set cameraContrast(value: number);
  134439. /**
  134440. * Gets the Color Grading 2D Lookup Texture.
  134441. */
  134442. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  134443. /**
  134444. * Sets the Color Grading 2D Lookup Texture.
  134445. */
  134446. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  134447. /**
  134448. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134449. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134450. * 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;
  134451. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134452. */
  134453. get cameraColorCurves(): Nullable<ColorCurves>;
  134454. /**
  134455. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134456. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134457. * 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;
  134458. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134459. */
  134460. set cameraColorCurves(value: Nullable<ColorCurves>);
  134461. /**
  134462. * Instantiates a new PBRMaterial instance.
  134463. *
  134464. * @param name The material name
  134465. * @param scene The scene the material will be use in.
  134466. */
  134467. constructor(name: string, scene: Scene);
  134468. /**
  134469. * Returns the name of this material class.
  134470. */
  134471. getClassName(): string;
  134472. /**
  134473. * Makes a duplicate of the current material.
  134474. * @param name - name to use for the new material.
  134475. */
  134476. clone(name: string): PBRMaterial;
  134477. /**
  134478. * Serializes this PBR Material.
  134479. * @returns - An object with the serialized material.
  134480. */
  134481. serialize(): any;
  134482. /**
  134483. * Parses a PBR Material from a serialized object.
  134484. * @param source - Serialized object.
  134485. * @param scene - BJS scene instance.
  134486. * @param rootUrl - url for the scene object
  134487. * @returns - PBRMaterial
  134488. */
  134489. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  134490. }
  134491. }
  134492. declare module BABYLON {
  134493. /**
  134494. * Direct draw surface info
  134495. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  134496. */
  134497. export interface DDSInfo {
  134498. /**
  134499. * Width of the texture
  134500. */
  134501. width: number;
  134502. /**
  134503. * Width of the texture
  134504. */
  134505. height: number;
  134506. /**
  134507. * Number of Mipmaps for the texture
  134508. * @see https://en.wikipedia.org/wiki/Mipmap
  134509. */
  134510. mipmapCount: number;
  134511. /**
  134512. * If the textures format is a known fourCC format
  134513. * @see https://www.fourcc.org/
  134514. */
  134515. isFourCC: boolean;
  134516. /**
  134517. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  134518. */
  134519. isRGB: boolean;
  134520. /**
  134521. * If the texture is a lumincance format
  134522. */
  134523. isLuminance: boolean;
  134524. /**
  134525. * If this is a cube texture
  134526. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  134527. */
  134528. isCube: boolean;
  134529. /**
  134530. * If the texture is a compressed format eg. FOURCC_DXT1
  134531. */
  134532. isCompressed: boolean;
  134533. /**
  134534. * The dxgiFormat of the texture
  134535. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  134536. */
  134537. dxgiFormat: number;
  134538. /**
  134539. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  134540. */
  134541. textureType: number;
  134542. /**
  134543. * Sphericle polynomial created for the dds texture
  134544. */
  134545. sphericalPolynomial?: SphericalPolynomial;
  134546. }
  134547. /**
  134548. * Class used to provide DDS decompression tools
  134549. */
  134550. export class DDSTools {
  134551. /**
  134552. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  134553. */
  134554. static StoreLODInAlphaChannel: boolean;
  134555. /**
  134556. * Gets DDS information from an array buffer
  134557. * @param data defines the array buffer view to read data from
  134558. * @returns the DDS information
  134559. */
  134560. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  134561. private static _FloatView;
  134562. private static _Int32View;
  134563. private static _ToHalfFloat;
  134564. private static _FromHalfFloat;
  134565. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  134566. private static _GetHalfFloatRGBAArrayBuffer;
  134567. private static _GetFloatRGBAArrayBuffer;
  134568. private static _GetFloatAsUIntRGBAArrayBuffer;
  134569. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  134570. private static _GetRGBAArrayBuffer;
  134571. private static _ExtractLongWordOrder;
  134572. private static _GetRGBArrayBuffer;
  134573. private static _GetLuminanceArrayBuffer;
  134574. /**
  134575. * Uploads DDS Levels to a Babylon Texture
  134576. * @hidden
  134577. */
  134578. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  134579. }
  134580. interface ThinEngine {
  134581. /**
  134582. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  134583. * @param rootUrl defines the url where the file to load is located
  134584. * @param scene defines the current scene
  134585. * @param lodScale defines scale to apply to the mip map selection
  134586. * @param lodOffset defines offset to apply to the mip map selection
  134587. * @param onLoad defines an optional callback raised when the texture is loaded
  134588. * @param onError defines an optional callback raised if there is an issue to load the texture
  134589. * @param format defines the format of the data
  134590. * @param forcedExtension defines the extension to use to pick the right loader
  134591. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  134592. * @returns the cube texture as an InternalTexture
  134593. */
  134594. 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;
  134595. }
  134596. }
  134597. declare module BABYLON {
  134598. /**
  134599. * Implementation of the DDS Texture Loader.
  134600. * @hidden
  134601. */
  134602. export class _DDSTextureLoader implements IInternalTextureLoader {
  134603. /**
  134604. * Defines wether the loader supports cascade loading the different faces.
  134605. */
  134606. readonly supportCascades: boolean;
  134607. /**
  134608. * This returns if the loader support the current file information.
  134609. * @param extension defines the file extension of the file being loaded
  134610. * @returns true if the loader can load the specified file
  134611. */
  134612. canLoad(extension: string): boolean;
  134613. /**
  134614. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  134615. * @param data contains the texture data
  134616. * @param texture defines the BabylonJS internal texture
  134617. * @param createPolynomials will be true if polynomials have been requested
  134618. * @param onLoad defines the callback to trigger once the texture is ready
  134619. * @param onError defines the callback to trigger in case of error
  134620. */
  134621. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  134622. /**
  134623. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  134624. * @param data contains the texture data
  134625. * @param texture defines the BabylonJS internal texture
  134626. * @param callback defines the method to call once ready to upload
  134627. */
  134628. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  134629. }
  134630. }
  134631. declare module BABYLON {
  134632. /**
  134633. * Implementation of the ENV Texture Loader.
  134634. * @hidden
  134635. */
  134636. export class _ENVTextureLoader implements IInternalTextureLoader {
  134637. /**
  134638. * Defines wether the loader supports cascade loading the different faces.
  134639. */
  134640. readonly supportCascades: boolean;
  134641. /**
  134642. * This returns if the loader support the current file information.
  134643. * @param extension defines the file extension of the file being loaded
  134644. * @returns true if the loader can load the specified file
  134645. */
  134646. canLoad(extension: string): boolean;
  134647. /**
  134648. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  134649. * @param data contains the texture data
  134650. * @param texture defines the BabylonJS internal texture
  134651. * @param createPolynomials will be true if polynomials have been requested
  134652. * @param onLoad defines the callback to trigger once the texture is ready
  134653. * @param onError defines the callback to trigger in case of error
  134654. */
  134655. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  134656. /**
  134657. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  134658. * @param data contains the texture data
  134659. * @param texture defines the BabylonJS internal texture
  134660. * @param callback defines the method to call once ready to upload
  134661. */
  134662. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  134663. }
  134664. }
  134665. declare module BABYLON {
  134666. /**
  134667. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  134668. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  134669. */
  134670. export class KhronosTextureContainer {
  134671. /** contents of the KTX container file */
  134672. data: ArrayBufferView;
  134673. private static HEADER_LEN;
  134674. private static COMPRESSED_2D;
  134675. private static COMPRESSED_3D;
  134676. private static TEX_2D;
  134677. private static TEX_3D;
  134678. /**
  134679. * Gets the openGL type
  134680. */
  134681. glType: number;
  134682. /**
  134683. * Gets the openGL type size
  134684. */
  134685. glTypeSize: number;
  134686. /**
  134687. * Gets the openGL format
  134688. */
  134689. glFormat: number;
  134690. /**
  134691. * Gets the openGL internal format
  134692. */
  134693. glInternalFormat: number;
  134694. /**
  134695. * Gets the base internal format
  134696. */
  134697. glBaseInternalFormat: number;
  134698. /**
  134699. * Gets image width in pixel
  134700. */
  134701. pixelWidth: number;
  134702. /**
  134703. * Gets image height in pixel
  134704. */
  134705. pixelHeight: number;
  134706. /**
  134707. * Gets image depth in pixels
  134708. */
  134709. pixelDepth: number;
  134710. /**
  134711. * Gets the number of array elements
  134712. */
  134713. numberOfArrayElements: number;
  134714. /**
  134715. * Gets the number of faces
  134716. */
  134717. numberOfFaces: number;
  134718. /**
  134719. * Gets the number of mipmap levels
  134720. */
  134721. numberOfMipmapLevels: number;
  134722. /**
  134723. * Gets the bytes of key value data
  134724. */
  134725. bytesOfKeyValueData: number;
  134726. /**
  134727. * Gets the load type
  134728. */
  134729. loadType: number;
  134730. /**
  134731. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  134732. */
  134733. isInvalid: boolean;
  134734. /**
  134735. * Creates a new KhronosTextureContainer
  134736. * @param data contents of the KTX container file
  134737. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  134738. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  134739. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  134740. */
  134741. constructor(
  134742. /** contents of the KTX container file */
  134743. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  134744. /**
  134745. * Uploads KTX content to a Babylon Texture.
  134746. * It is assumed that the texture has already been created & is currently bound
  134747. * @hidden
  134748. */
  134749. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  134750. private _upload2DCompressedLevels;
  134751. /**
  134752. * Checks if the given data starts with a KTX file identifier.
  134753. * @param data the data to check
  134754. * @returns true if the data is a KTX file or false otherwise
  134755. */
  134756. static IsValid(data: ArrayBufferView): boolean;
  134757. }
  134758. }
  134759. declare module BABYLON {
  134760. /**
  134761. * Class for loading KTX2 files
  134762. * !!! Experimental Extension Subject to Changes !!!
  134763. * @hidden
  134764. */
  134765. export class KhronosTextureContainer2 {
  134766. private static _ModulePromise;
  134767. private static _TranscodeFormat;
  134768. constructor(engine: ThinEngine);
  134769. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  134770. private _determineTranscodeFormat;
  134771. /**
  134772. * Checks if the given data starts with a KTX2 file identifier.
  134773. * @param data the data to check
  134774. * @returns true if the data is a KTX2 file or false otherwise
  134775. */
  134776. static IsValid(data: ArrayBufferView): boolean;
  134777. }
  134778. }
  134779. declare module BABYLON {
  134780. /**
  134781. * Implementation of the KTX Texture Loader.
  134782. * @hidden
  134783. */
  134784. export class _KTXTextureLoader implements IInternalTextureLoader {
  134785. /**
  134786. * Defines wether the loader supports cascade loading the different faces.
  134787. */
  134788. readonly supportCascades: boolean;
  134789. /**
  134790. * This returns if the loader support the current file information.
  134791. * @param extension defines the file extension of the file being loaded
  134792. * @param mimeType defines the optional mime type of the file being loaded
  134793. * @returns true if the loader can load the specified file
  134794. */
  134795. canLoad(extension: string, mimeType?: string): boolean;
  134796. /**
  134797. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  134798. * @param data contains the texture data
  134799. * @param texture defines the BabylonJS internal texture
  134800. * @param createPolynomials will be true if polynomials have been requested
  134801. * @param onLoad defines the callback to trigger once the texture is ready
  134802. * @param onError defines the callback to trigger in case of error
  134803. */
  134804. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  134805. /**
  134806. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  134807. * @param data contains the texture data
  134808. * @param texture defines the BabylonJS internal texture
  134809. * @param callback defines the method to call once ready to upload
  134810. */
  134811. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  134812. }
  134813. }
  134814. declare module BABYLON {
  134815. /** @hidden */
  134816. export var _forceSceneHelpersToBundle: boolean;
  134817. interface Scene {
  134818. /**
  134819. * Creates a default light for the scene.
  134820. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  134821. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  134822. */
  134823. createDefaultLight(replace?: boolean): void;
  134824. /**
  134825. * Creates a default camera for the scene.
  134826. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  134827. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  134828. * @param replace has default false, when true replaces the active camera in the scene
  134829. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  134830. */
  134831. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  134832. /**
  134833. * Creates a default camera and a default light.
  134834. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  134835. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  134836. * @param replace has the default false, when true replaces the active camera/light in the scene
  134837. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  134838. */
  134839. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  134840. /**
  134841. * Creates a new sky box
  134842. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  134843. * @param environmentTexture defines the texture to use as environment texture
  134844. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  134845. * @param scale defines the overall scale of the skybox
  134846. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  134847. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  134848. * @returns a new mesh holding the sky box
  134849. */
  134850. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  134851. /**
  134852. * Creates a new environment
  134853. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  134854. * @param options defines the options you can use to configure the environment
  134855. * @returns the new EnvironmentHelper
  134856. */
  134857. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  134858. /**
  134859. * Creates a new VREXperienceHelper
  134860. * @see https://doc.babylonjs.com/how_to/webvr_helper
  134861. * @param webVROptions defines the options used to create the new VREXperienceHelper
  134862. * @returns a new VREXperienceHelper
  134863. */
  134864. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  134865. /**
  134866. * Creates a new WebXRDefaultExperience
  134867. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  134868. * @param options experience options
  134869. * @returns a promise for a new WebXRDefaultExperience
  134870. */
  134871. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  134872. }
  134873. }
  134874. declare module BABYLON {
  134875. /**
  134876. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  134877. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  134878. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  134879. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  134880. */
  134881. export class VideoDome extends TransformNode {
  134882. /**
  134883. * Define the video source as a Monoscopic panoramic 360 video.
  134884. */
  134885. static readonly MODE_MONOSCOPIC: number;
  134886. /**
  134887. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  134888. */
  134889. static readonly MODE_TOPBOTTOM: number;
  134890. /**
  134891. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  134892. */
  134893. static readonly MODE_SIDEBYSIDE: number;
  134894. private _halfDome;
  134895. private _useDirectMapping;
  134896. /**
  134897. * The video texture being displayed on the sphere
  134898. */
  134899. protected _videoTexture: VideoTexture;
  134900. /**
  134901. * Gets the video texture being displayed on the sphere
  134902. */
  134903. get videoTexture(): VideoTexture;
  134904. /**
  134905. * The skybox material
  134906. */
  134907. protected _material: BackgroundMaterial;
  134908. /**
  134909. * The surface used for the skybox
  134910. */
  134911. protected _mesh: Mesh;
  134912. /**
  134913. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  134914. */
  134915. private _halfDomeMask;
  134916. /**
  134917. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  134918. * Also see the options.resolution property.
  134919. */
  134920. get fovMultiplier(): number;
  134921. set fovMultiplier(value: number);
  134922. private _videoMode;
  134923. /**
  134924. * Gets or set the current video mode for the video. It can be:
  134925. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  134926. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  134927. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  134928. */
  134929. get videoMode(): number;
  134930. set videoMode(value: number);
  134931. /**
  134932. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  134933. *
  134934. */
  134935. get halfDome(): boolean;
  134936. /**
  134937. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  134938. */
  134939. set halfDome(enabled: boolean);
  134940. /**
  134941. * Oberserver used in Stereoscopic VR Mode.
  134942. */
  134943. private _onBeforeCameraRenderObserver;
  134944. /**
  134945. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  134946. * @param name Element's name, child elements will append suffixes for their own names.
  134947. * @param urlsOrVideo defines the url(s) or the video element to use
  134948. * @param options An object containing optional or exposed sub element properties
  134949. */
  134950. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  134951. resolution?: number;
  134952. clickToPlay?: boolean;
  134953. autoPlay?: boolean;
  134954. loop?: boolean;
  134955. size?: number;
  134956. poster?: string;
  134957. faceForward?: boolean;
  134958. useDirectMapping?: boolean;
  134959. halfDomeMode?: boolean;
  134960. }, scene: Scene);
  134961. private _changeVideoMode;
  134962. /**
  134963. * Releases resources associated with this node.
  134964. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  134965. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  134966. */
  134967. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  134968. }
  134969. }
  134970. declare module BABYLON {
  134971. /**
  134972. * This class can be used to get instrumentation data from a Babylon engine
  134973. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  134974. */
  134975. export class EngineInstrumentation implements IDisposable {
  134976. /**
  134977. * Define the instrumented engine.
  134978. */
  134979. engine: Engine;
  134980. private _captureGPUFrameTime;
  134981. private _gpuFrameTimeToken;
  134982. private _gpuFrameTime;
  134983. private _captureShaderCompilationTime;
  134984. private _shaderCompilationTime;
  134985. private _onBeginFrameObserver;
  134986. private _onEndFrameObserver;
  134987. private _onBeforeShaderCompilationObserver;
  134988. private _onAfterShaderCompilationObserver;
  134989. /**
  134990. * Gets the perf counter used for GPU frame time
  134991. */
  134992. get gpuFrameTimeCounter(): PerfCounter;
  134993. /**
  134994. * Gets the GPU frame time capture status
  134995. */
  134996. get captureGPUFrameTime(): boolean;
  134997. /**
  134998. * Enable or disable the GPU frame time capture
  134999. */
  135000. set captureGPUFrameTime(value: boolean);
  135001. /**
  135002. * Gets the perf counter used for shader compilation time
  135003. */
  135004. get shaderCompilationTimeCounter(): PerfCounter;
  135005. /**
  135006. * Gets the shader compilation time capture status
  135007. */
  135008. get captureShaderCompilationTime(): boolean;
  135009. /**
  135010. * Enable or disable the shader compilation time capture
  135011. */
  135012. set captureShaderCompilationTime(value: boolean);
  135013. /**
  135014. * Instantiates a new engine instrumentation.
  135015. * This class can be used to get instrumentation data from a Babylon engine
  135016. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  135017. * @param engine Defines the engine to instrument
  135018. */
  135019. constructor(
  135020. /**
  135021. * Define the instrumented engine.
  135022. */
  135023. engine: Engine);
  135024. /**
  135025. * Dispose and release associated resources.
  135026. */
  135027. dispose(): void;
  135028. }
  135029. }
  135030. declare module BABYLON {
  135031. /**
  135032. * This class can be used to get instrumentation data from a Babylon engine
  135033. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  135034. */
  135035. export class SceneInstrumentation implements IDisposable {
  135036. /**
  135037. * Defines the scene to instrument
  135038. */
  135039. scene: Scene;
  135040. private _captureActiveMeshesEvaluationTime;
  135041. private _activeMeshesEvaluationTime;
  135042. private _captureRenderTargetsRenderTime;
  135043. private _renderTargetsRenderTime;
  135044. private _captureFrameTime;
  135045. private _frameTime;
  135046. private _captureRenderTime;
  135047. private _renderTime;
  135048. private _captureInterFrameTime;
  135049. private _interFrameTime;
  135050. private _captureParticlesRenderTime;
  135051. private _particlesRenderTime;
  135052. private _captureSpritesRenderTime;
  135053. private _spritesRenderTime;
  135054. private _capturePhysicsTime;
  135055. private _physicsTime;
  135056. private _captureAnimationsTime;
  135057. private _animationsTime;
  135058. private _captureCameraRenderTime;
  135059. private _cameraRenderTime;
  135060. private _onBeforeActiveMeshesEvaluationObserver;
  135061. private _onAfterActiveMeshesEvaluationObserver;
  135062. private _onBeforeRenderTargetsRenderObserver;
  135063. private _onAfterRenderTargetsRenderObserver;
  135064. private _onAfterRenderObserver;
  135065. private _onBeforeDrawPhaseObserver;
  135066. private _onAfterDrawPhaseObserver;
  135067. private _onBeforeAnimationsObserver;
  135068. private _onBeforeParticlesRenderingObserver;
  135069. private _onAfterParticlesRenderingObserver;
  135070. private _onBeforeSpritesRenderingObserver;
  135071. private _onAfterSpritesRenderingObserver;
  135072. private _onBeforePhysicsObserver;
  135073. private _onAfterPhysicsObserver;
  135074. private _onAfterAnimationsObserver;
  135075. private _onBeforeCameraRenderObserver;
  135076. private _onAfterCameraRenderObserver;
  135077. /**
  135078. * Gets the perf counter used for active meshes evaluation time
  135079. */
  135080. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  135081. /**
  135082. * Gets the active meshes evaluation time capture status
  135083. */
  135084. get captureActiveMeshesEvaluationTime(): boolean;
  135085. /**
  135086. * Enable or disable the active meshes evaluation time capture
  135087. */
  135088. set captureActiveMeshesEvaluationTime(value: boolean);
  135089. /**
  135090. * Gets the perf counter used for render targets render time
  135091. */
  135092. get renderTargetsRenderTimeCounter(): PerfCounter;
  135093. /**
  135094. * Gets the render targets render time capture status
  135095. */
  135096. get captureRenderTargetsRenderTime(): boolean;
  135097. /**
  135098. * Enable or disable the render targets render time capture
  135099. */
  135100. set captureRenderTargetsRenderTime(value: boolean);
  135101. /**
  135102. * Gets the perf counter used for particles render time
  135103. */
  135104. get particlesRenderTimeCounter(): PerfCounter;
  135105. /**
  135106. * Gets the particles render time capture status
  135107. */
  135108. get captureParticlesRenderTime(): boolean;
  135109. /**
  135110. * Enable or disable the particles render time capture
  135111. */
  135112. set captureParticlesRenderTime(value: boolean);
  135113. /**
  135114. * Gets the perf counter used for sprites render time
  135115. */
  135116. get spritesRenderTimeCounter(): PerfCounter;
  135117. /**
  135118. * Gets the sprites render time capture status
  135119. */
  135120. get captureSpritesRenderTime(): boolean;
  135121. /**
  135122. * Enable or disable the sprites render time capture
  135123. */
  135124. set captureSpritesRenderTime(value: boolean);
  135125. /**
  135126. * Gets the perf counter used for physics time
  135127. */
  135128. get physicsTimeCounter(): PerfCounter;
  135129. /**
  135130. * Gets the physics time capture status
  135131. */
  135132. get capturePhysicsTime(): boolean;
  135133. /**
  135134. * Enable or disable the physics time capture
  135135. */
  135136. set capturePhysicsTime(value: boolean);
  135137. /**
  135138. * Gets the perf counter used for animations time
  135139. */
  135140. get animationsTimeCounter(): PerfCounter;
  135141. /**
  135142. * Gets the animations time capture status
  135143. */
  135144. get captureAnimationsTime(): boolean;
  135145. /**
  135146. * Enable or disable the animations time capture
  135147. */
  135148. set captureAnimationsTime(value: boolean);
  135149. /**
  135150. * Gets the perf counter used for frame time capture
  135151. */
  135152. get frameTimeCounter(): PerfCounter;
  135153. /**
  135154. * Gets the frame time capture status
  135155. */
  135156. get captureFrameTime(): boolean;
  135157. /**
  135158. * Enable or disable the frame time capture
  135159. */
  135160. set captureFrameTime(value: boolean);
  135161. /**
  135162. * Gets the perf counter used for inter-frames time capture
  135163. */
  135164. get interFrameTimeCounter(): PerfCounter;
  135165. /**
  135166. * Gets the inter-frames time capture status
  135167. */
  135168. get captureInterFrameTime(): boolean;
  135169. /**
  135170. * Enable or disable the inter-frames time capture
  135171. */
  135172. set captureInterFrameTime(value: boolean);
  135173. /**
  135174. * Gets the perf counter used for render time capture
  135175. */
  135176. get renderTimeCounter(): PerfCounter;
  135177. /**
  135178. * Gets the render time capture status
  135179. */
  135180. get captureRenderTime(): boolean;
  135181. /**
  135182. * Enable or disable the render time capture
  135183. */
  135184. set captureRenderTime(value: boolean);
  135185. /**
  135186. * Gets the perf counter used for camera render time capture
  135187. */
  135188. get cameraRenderTimeCounter(): PerfCounter;
  135189. /**
  135190. * Gets the camera render time capture status
  135191. */
  135192. get captureCameraRenderTime(): boolean;
  135193. /**
  135194. * Enable or disable the camera render time capture
  135195. */
  135196. set captureCameraRenderTime(value: boolean);
  135197. /**
  135198. * Gets the perf counter used for draw calls
  135199. */
  135200. get drawCallsCounter(): PerfCounter;
  135201. /**
  135202. * Instantiates a new scene instrumentation.
  135203. * This class can be used to get instrumentation data from a Babylon engine
  135204. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  135205. * @param scene Defines the scene to instrument
  135206. */
  135207. constructor(
  135208. /**
  135209. * Defines the scene to instrument
  135210. */
  135211. scene: Scene);
  135212. /**
  135213. * Dispose and release associated resources.
  135214. */
  135215. dispose(): void;
  135216. }
  135217. }
  135218. declare module BABYLON {
  135219. /** @hidden */
  135220. export var glowMapGenerationPixelShader: {
  135221. name: string;
  135222. shader: string;
  135223. };
  135224. }
  135225. declare module BABYLON {
  135226. /** @hidden */
  135227. export var glowMapGenerationVertexShader: {
  135228. name: string;
  135229. shader: string;
  135230. };
  135231. }
  135232. declare module BABYLON {
  135233. /**
  135234. * Effect layer options. This helps customizing the behaviour
  135235. * of the effect layer.
  135236. */
  135237. export interface IEffectLayerOptions {
  135238. /**
  135239. * Multiplication factor apply to the canvas size to compute the render target size
  135240. * used to generated the objects (the smaller the faster).
  135241. */
  135242. mainTextureRatio: number;
  135243. /**
  135244. * Enforces a fixed size texture to ensure effect stability across devices.
  135245. */
  135246. mainTextureFixedSize?: number;
  135247. /**
  135248. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  135249. */
  135250. alphaBlendingMode: number;
  135251. /**
  135252. * The camera attached to the layer.
  135253. */
  135254. camera: Nullable<Camera>;
  135255. /**
  135256. * The rendering group to draw the layer in.
  135257. */
  135258. renderingGroupId: number;
  135259. }
  135260. /**
  135261. * The effect layer Helps adding post process effect blended with the main pass.
  135262. *
  135263. * This can be for instance use to generate glow or higlight effects on the scene.
  135264. *
  135265. * The effect layer class can not be used directly and is intented to inherited from to be
  135266. * customized per effects.
  135267. */
  135268. export abstract class EffectLayer {
  135269. private _vertexBuffers;
  135270. private _indexBuffer;
  135271. private _cachedDefines;
  135272. private _effectLayerMapGenerationEffect;
  135273. private _effectLayerOptions;
  135274. private _mergeEffect;
  135275. protected _scene: Scene;
  135276. protected _engine: Engine;
  135277. protected _maxSize: number;
  135278. protected _mainTextureDesiredSize: ISize;
  135279. protected _mainTexture: RenderTargetTexture;
  135280. protected _shouldRender: boolean;
  135281. protected _postProcesses: PostProcess[];
  135282. protected _textures: BaseTexture[];
  135283. protected _emissiveTextureAndColor: {
  135284. texture: Nullable<BaseTexture>;
  135285. color: Color4;
  135286. };
  135287. /**
  135288. * The name of the layer
  135289. */
  135290. name: string;
  135291. /**
  135292. * The clear color of the texture used to generate the glow map.
  135293. */
  135294. neutralColor: Color4;
  135295. /**
  135296. * Specifies whether the highlight layer is enabled or not.
  135297. */
  135298. isEnabled: boolean;
  135299. /**
  135300. * Gets the camera attached to the layer.
  135301. */
  135302. get camera(): Nullable<Camera>;
  135303. /**
  135304. * Gets the rendering group id the layer should render in.
  135305. */
  135306. get renderingGroupId(): number;
  135307. set renderingGroupId(renderingGroupId: number);
  135308. /**
  135309. * An event triggered when the effect layer has been disposed.
  135310. */
  135311. onDisposeObservable: Observable<EffectLayer>;
  135312. /**
  135313. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  135314. */
  135315. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  135316. /**
  135317. * An event triggered when the generated texture is being merged in the scene.
  135318. */
  135319. onBeforeComposeObservable: Observable<EffectLayer>;
  135320. /**
  135321. * An event triggered when the mesh is rendered into the effect render target.
  135322. */
  135323. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  135324. /**
  135325. * An event triggered after the mesh has been rendered into the effect render target.
  135326. */
  135327. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  135328. /**
  135329. * An event triggered when the generated texture has been merged in the scene.
  135330. */
  135331. onAfterComposeObservable: Observable<EffectLayer>;
  135332. /**
  135333. * An event triggered when the efffect layer changes its size.
  135334. */
  135335. onSizeChangedObservable: Observable<EffectLayer>;
  135336. /** @hidden */
  135337. static _SceneComponentInitialization: (scene: Scene) => void;
  135338. /**
  135339. * Instantiates a new effect Layer and references it in the scene.
  135340. * @param name The name of the layer
  135341. * @param scene The scene to use the layer in
  135342. */
  135343. constructor(
  135344. /** The Friendly of the effect in the scene */
  135345. name: string, scene: Scene);
  135346. /**
  135347. * Get the effect name of the layer.
  135348. * @return The effect name
  135349. */
  135350. abstract getEffectName(): string;
  135351. /**
  135352. * Checks for the readiness of the element composing the layer.
  135353. * @param subMesh the mesh to check for
  135354. * @param useInstances specify whether or not to use instances to render the mesh
  135355. * @return true if ready otherwise, false
  135356. */
  135357. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135358. /**
  135359. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  135360. * @returns true if the effect requires stencil during the main canvas render pass.
  135361. */
  135362. abstract needStencil(): boolean;
  135363. /**
  135364. * Create the merge effect. This is the shader use to blit the information back
  135365. * to the main canvas at the end of the scene rendering.
  135366. * @returns The effect containing the shader used to merge the effect on the main canvas
  135367. */
  135368. protected abstract _createMergeEffect(): Effect;
  135369. /**
  135370. * Creates the render target textures and post processes used in the effect layer.
  135371. */
  135372. protected abstract _createTextureAndPostProcesses(): void;
  135373. /**
  135374. * Implementation specific of rendering the generating effect on the main canvas.
  135375. * @param effect The effect used to render through
  135376. */
  135377. protected abstract _internalRender(effect: Effect): void;
  135378. /**
  135379. * Sets the required values for both the emissive texture and and the main color.
  135380. */
  135381. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  135382. /**
  135383. * Free any resources and references associated to a mesh.
  135384. * Internal use
  135385. * @param mesh The mesh to free.
  135386. */
  135387. abstract _disposeMesh(mesh: Mesh): void;
  135388. /**
  135389. * Serializes this layer (Glow or Highlight for example)
  135390. * @returns a serialized layer object
  135391. */
  135392. abstract serialize?(): any;
  135393. /**
  135394. * Initializes the effect layer with the required options.
  135395. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  135396. */
  135397. protected _init(options: Partial<IEffectLayerOptions>): void;
  135398. /**
  135399. * Generates the index buffer of the full screen quad blending to the main canvas.
  135400. */
  135401. private _generateIndexBuffer;
  135402. /**
  135403. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  135404. */
  135405. private _generateVertexBuffer;
  135406. /**
  135407. * Sets the main texture desired size which is the closest power of two
  135408. * of the engine canvas size.
  135409. */
  135410. private _setMainTextureSize;
  135411. /**
  135412. * Creates the main texture for the effect layer.
  135413. */
  135414. protected _createMainTexture(): void;
  135415. /**
  135416. * Adds specific effects defines.
  135417. * @param defines The defines to add specifics to.
  135418. */
  135419. protected _addCustomEffectDefines(defines: string[]): void;
  135420. /**
  135421. * Checks for the readiness of the element composing the layer.
  135422. * @param subMesh the mesh to check for
  135423. * @param useInstances specify whether or not to use instances to render the mesh
  135424. * @param emissiveTexture the associated emissive texture used to generate the glow
  135425. * @return true if ready otherwise, false
  135426. */
  135427. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  135428. /**
  135429. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  135430. */
  135431. render(): void;
  135432. /**
  135433. * Determine if a given mesh will be used in the current effect.
  135434. * @param mesh mesh to test
  135435. * @returns true if the mesh will be used
  135436. */
  135437. hasMesh(mesh: AbstractMesh): boolean;
  135438. /**
  135439. * Returns true if the layer contains information to display, otherwise false.
  135440. * @returns true if the glow layer should be rendered
  135441. */
  135442. shouldRender(): boolean;
  135443. /**
  135444. * Returns true if the mesh should render, otherwise false.
  135445. * @param mesh The mesh to render
  135446. * @returns true if it should render otherwise false
  135447. */
  135448. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  135449. /**
  135450. * Returns true if the mesh can be rendered, otherwise false.
  135451. * @param mesh The mesh to render
  135452. * @param material The material used on the mesh
  135453. * @returns true if it can be rendered otherwise false
  135454. */
  135455. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  135456. /**
  135457. * Returns true if the mesh should render, otherwise false.
  135458. * @param mesh The mesh to render
  135459. * @returns true if it should render otherwise false
  135460. */
  135461. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  135462. /**
  135463. * Renders the submesh passed in parameter to the generation map.
  135464. */
  135465. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  135466. /**
  135467. * Defines whether the current material of the mesh should be use to render the effect.
  135468. * @param mesh defines the current mesh to render
  135469. */
  135470. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  135471. /**
  135472. * Rebuild the required buffers.
  135473. * @hidden Internal use only.
  135474. */
  135475. _rebuild(): void;
  135476. /**
  135477. * Dispose only the render target textures and post process.
  135478. */
  135479. private _disposeTextureAndPostProcesses;
  135480. /**
  135481. * Dispose the highlight layer and free resources.
  135482. */
  135483. dispose(): void;
  135484. /**
  135485. * Gets the class name of the effect layer
  135486. * @returns the string with the class name of the effect layer
  135487. */
  135488. getClassName(): string;
  135489. /**
  135490. * Creates an effect layer from parsed effect layer data
  135491. * @param parsedEffectLayer defines effect layer data
  135492. * @param scene defines the current scene
  135493. * @param rootUrl defines the root URL containing the effect layer information
  135494. * @returns a parsed effect Layer
  135495. */
  135496. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  135497. }
  135498. }
  135499. declare module BABYLON {
  135500. interface AbstractScene {
  135501. /**
  135502. * The list of effect layers (highlights/glow) added to the scene
  135503. * @see https://doc.babylonjs.com/how_to/highlight_layer
  135504. * @see https://doc.babylonjs.com/how_to/glow_layer
  135505. */
  135506. effectLayers: Array<EffectLayer>;
  135507. /**
  135508. * Removes the given effect layer from this scene.
  135509. * @param toRemove defines the effect layer to remove
  135510. * @returns the index of the removed effect layer
  135511. */
  135512. removeEffectLayer(toRemove: EffectLayer): number;
  135513. /**
  135514. * Adds the given effect layer to this scene
  135515. * @param newEffectLayer defines the effect layer to add
  135516. */
  135517. addEffectLayer(newEffectLayer: EffectLayer): void;
  135518. }
  135519. /**
  135520. * Defines the layer scene component responsible to manage any effect layers
  135521. * in a given scene.
  135522. */
  135523. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  135524. /**
  135525. * The component name helpfull to identify the component in the list of scene components.
  135526. */
  135527. readonly name: string;
  135528. /**
  135529. * The scene the component belongs to.
  135530. */
  135531. scene: Scene;
  135532. private _engine;
  135533. private _renderEffects;
  135534. private _needStencil;
  135535. private _previousStencilState;
  135536. /**
  135537. * Creates a new instance of the component for the given scene
  135538. * @param scene Defines the scene to register the component in
  135539. */
  135540. constructor(scene: Scene);
  135541. /**
  135542. * Registers the component in a given scene
  135543. */
  135544. register(): void;
  135545. /**
  135546. * Rebuilds the elements related to this component in case of
  135547. * context lost for instance.
  135548. */
  135549. rebuild(): void;
  135550. /**
  135551. * Serializes the component data to the specified json object
  135552. * @param serializationObject The object to serialize to
  135553. */
  135554. serialize(serializationObject: any): void;
  135555. /**
  135556. * Adds all the elements from the container to the scene
  135557. * @param container the container holding the elements
  135558. */
  135559. addFromContainer(container: AbstractScene): void;
  135560. /**
  135561. * Removes all the elements in the container from the scene
  135562. * @param container contains the elements to remove
  135563. * @param dispose if the removed element should be disposed (default: false)
  135564. */
  135565. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  135566. /**
  135567. * Disposes the component and the associated ressources.
  135568. */
  135569. dispose(): void;
  135570. private _isReadyForMesh;
  135571. private _renderMainTexture;
  135572. private _setStencil;
  135573. private _setStencilBack;
  135574. private _draw;
  135575. private _drawCamera;
  135576. private _drawRenderingGroup;
  135577. }
  135578. }
  135579. declare module BABYLON {
  135580. /** @hidden */
  135581. export var glowMapMergePixelShader: {
  135582. name: string;
  135583. shader: string;
  135584. };
  135585. }
  135586. declare module BABYLON {
  135587. /** @hidden */
  135588. export var glowMapMergeVertexShader: {
  135589. name: string;
  135590. shader: string;
  135591. };
  135592. }
  135593. declare module BABYLON {
  135594. interface AbstractScene {
  135595. /**
  135596. * Return a the first highlight layer of the scene with a given name.
  135597. * @param name The name of the highlight layer to look for.
  135598. * @return The highlight layer if found otherwise null.
  135599. */
  135600. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  135601. }
  135602. /**
  135603. * Glow layer options. This helps customizing the behaviour
  135604. * of the glow layer.
  135605. */
  135606. export interface IGlowLayerOptions {
  135607. /**
  135608. * Multiplication factor apply to the canvas size to compute the render target size
  135609. * used to generated the glowing objects (the smaller the faster).
  135610. */
  135611. mainTextureRatio: number;
  135612. /**
  135613. * Enforces a fixed size texture to ensure resize independant blur.
  135614. */
  135615. mainTextureFixedSize?: number;
  135616. /**
  135617. * How big is the kernel of the blur texture.
  135618. */
  135619. blurKernelSize: number;
  135620. /**
  135621. * The camera attached to the layer.
  135622. */
  135623. camera: Nullable<Camera>;
  135624. /**
  135625. * Enable MSAA by chosing the number of samples.
  135626. */
  135627. mainTextureSamples?: number;
  135628. /**
  135629. * The rendering group to draw the layer in.
  135630. */
  135631. renderingGroupId: number;
  135632. }
  135633. /**
  135634. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  135635. *
  135636. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  135637. *
  135638. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  135639. */
  135640. export class GlowLayer extends EffectLayer {
  135641. /**
  135642. * Effect Name of the layer.
  135643. */
  135644. static readonly EffectName: string;
  135645. /**
  135646. * The default blur kernel size used for the glow.
  135647. */
  135648. static DefaultBlurKernelSize: number;
  135649. /**
  135650. * The default texture size ratio used for the glow.
  135651. */
  135652. static DefaultTextureRatio: number;
  135653. /**
  135654. * Sets the kernel size of the blur.
  135655. */
  135656. set blurKernelSize(value: number);
  135657. /**
  135658. * Gets the kernel size of the blur.
  135659. */
  135660. get blurKernelSize(): number;
  135661. /**
  135662. * Sets the glow intensity.
  135663. */
  135664. set intensity(value: number);
  135665. /**
  135666. * Gets the glow intensity.
  135667. */
  135668. get intensity(): number;
  135669. private _options;
  135670. private _intensity;
  135671. private _horizontalBlurPostprocess1;
  135672. private _verticalBlurPostprocess1;
  135673. private _horizontalBlurPostprocess2;
  135674. private _verticalBlurPostprocess2;
  135675. private _blurTexture1;
  135676. private _blurTexture2;
  135677. private _postProcesses1;
  135678. private _postProcesses2;
  135679. private _includedOnlyMeshes;
  135680. private _excludedMeshes;
  135681. private _meshesUsingTheirOwnMaterials;
  135682. /**
  135683. * Callback used to let the user override the color selection on a per mesh basis
  135684. */
  135685. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  135686. /**
  135687. * Callback used to let the user override the texture selection on a per mesh basis
  135688. */
  135689. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  135690. /**
  135691. * Instantiates a new glow Layer and references it to the scene.
  135692. * @param name The name of the layer
  135693. * @param scene The scene to use the layer in
  135694. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  135695. */
  135696. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  135697. /**
  135698. * Get the effect name of the layer.
  135699. * @return The effect name
  135700. */
  135701. getEffectName(): string;
  135702. /**
  135703. * Create the merge effect. This is the shader use to blit the information back
  135704. * to the main canvas at the end of the scene rendering.
  135705. */
  135706. protected _createMergeEffect(): Effect;
  135707. /**
  135708. * Creates the render target textures and post processes used in the glow layer.
  135709. */
  135710. protected _createTextureAndPostProcesses(): void;
  135711. /**
  135712. * Checks for the readiness of the element composing the layer.
  135713. * @param subMesh the mesh to check for
  135714. * @param useInstances specify wether or not to use instances to render the mesh
  135715. * @param emissiveTexture the associated emissive texture used to generate the glow
  135716. * @return true if ready otherwise, false
  135717. */
  135718. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135719. /**
  135720. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  135721. */
  135722. needStencil(): boolean;
  135723. /**
  135724. * Returns true if the mesh can be rendered, otherwise false.
  135725. * @param mesh The mesh to render
  135726. * @param material The material used on the mesh
  135727. * @returns true if it can be rendered otherwise false
  135728. */
  135729. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  135730. /**
  135731. * Implementation specific of rendering the generating effect on the main canvas.
  135732. * @param effect The effect used to render through
  135733. */
  135734. protected _internalRender(effect: Effect): void;
  135735. /**
  135736. * Sets the required values for both the emissive texture and and the main color.
  135737. */
  135738. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  135739. /**
  135740. * Returns true if the mesh should render, otherwise false.
  135741. * @param mesh The mesh to render
  135742. * @returns true if it should render otherwise false
  135743. */
  135744. protected _shouldRenderMesh(mesh: Mesh): boolean;
  135745. /**
  135746. * Adds specific effects defines.
  135747. * @param defines The defines to add specifics to.
  135748. */
  135749. protected _addCustomEffectDefines(defines: string[]): void;
  135750. /**
  135751. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  135752. * @param mesh The mesh to exclude from the glow layer
  135753. */
  135754. addExcludedMesh(mesh: Mesh): void;
  135755. /**
  135756. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  135757. * @param mesh The mesh to remove
  135758. */
  135759. removeExcludedMesh(mesh: Mesh): void;
  135760. /**
  135761. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  135762. * @param mesh The mesh to include in the glow layer
  135763. */
  135764. addIncludedOnlyMesh(mesh: Mesh): void;
  135765. /**
  135766. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  135767. * @param mesh The mesh to remove
  135768. */
  135769. removeIncludedOnlyMesh(mesh: Mesh): void;
  135770. /**
  135771. * Determine if a given mesh will be used in the glow layer
  135772. * @param mesh The mesh to test
  135773. * @returns true if the mesh will be highlighted by the current glow layer
  135774. */
  135775. hasMesh(mesh: AbstractMesh): boolean;
  135776. /**
  135777. * Defines whether the current material of the mesh should be use to render the effect.
  135778. * @param mesh defines the current mesh to render
  135779. */
  135780. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  135781. /**
  135782. * Add a mesh to be rendered through its own material and not with emissive only.
  135783. * @param mesh The mesh for which we need to use its material
  135784. */
  135785. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  135786. /**
  135787. * Remove a mesh from being rendered through its own material and not with emissive only.
  135788. * @param mesh The mesh for which we need to not use its material
  135789. */
  135790. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  135791. /**
  135792. * Free any resources and references associated to a mesh.
  135793. * Internal use
  135794. * @param mesh The mesh to free.
  135795. * @hidden
  135796. */
  135797. _disposeMesh(mesh: Mesh): void;
  135798. /**
  135799. * Gets the class name of the effect layer
  135800. * @returns the string with the class name of the effect layer
  135801. */
  135802. getClassName(): string;
  135803. /**
  135804. * Serializes this glow layer
  135805. * @returns a serialized glow layer object
  135806. */
  135807. serialize(): any;
  135808. /**
  135809. * Creates a Glow Layer from parsed glow layer data
  135810. * @param parsedGlowLayer defines glow layer data
  135811. * @param scene defines the current scene
  135812. * @param rootUrl defines the root URL containing the glow layer information
  135813. * @returns a parsed Glow Layer
  135814. */
  135815. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  135816. }
  135817. }
  135818. declare module BABYLON {
  135819. /** @hidden */
  135820. export var glowBlurPostProcessPixelShader: {
  135821. name: string;
  135822. shader: string;
  135823. };
  135824. }
  135825. declare module BABYLON {
  135826. interface AbstractScene {
  135827. /**
  135828. * Return a the first highlight layer of the scene with a given name.
  135829. * @param name The name of the highlight layer to look for.
  135830. * @return The highlight layer if found otherwise null.
  135831. */
  135832. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  135833. }
  135834. /**
  135835. * Highlight layer options. This helps customizing the behaviour
  135836. * of the highlight layer.
  135837. */
  135838. export interface IHighlightLayerOptions {
  135839. /**
  135840. * Multiplication factor apply to the canvas size to compute the render target size
  135841. * used to generated the glowing objects (the smaller the faster).
  135842. */
  135843. mainTextureRatio: number;
  135844. /**
  135845. * Enforces a fixed size texture to ensure resize independant blur.
  135846. */
  135847. mainTextureFixedSize?: number;
  135848. /**
  135849. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  135850. * of the picture to blur (the smaller the faster).
  135851. */
  135852. blurTextureSizeRatio: number;
  135853. /**
  135854. * How big in texel of the blur texture is the vertical blur.
  135855. */
  135856. blurVerticalSize: number;
  135857. /**
  135858. * How big in texel of the blur texture is the horizontal blur.
  135859. */
  135860. blurHorizontalSize: number;
  135861. /**
  135862. * Alpha blending mode used to apply the blur. Default is combine.
  135863. */
  135864. alphaBlendingMode: number;
  135865. /**
  135866. * The camera attached to the layer.
  135867. */
  135868. camera: Nullable<Camera>;
  135869. /**
  135870. * Should we display highlight as a solid stroke?
  135871. */
  135872. isStroke?: boolean;
  135873. /**
  135874. * The rendering group to draw the layer in.
  135875. */
  135876. renderingGroupId: number;
  135877. }
  135878. /**
  135879. * The highlight layer Helps adding a glow effect around a mesh.
  135880. *
  135881. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  135882. * glowy meshes to your scene.
  135883. *
  135884. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  135885. */
  135886. export class HighlightLayer extends EffectLayer {
  135887. name: string;
  135888. /**
  135889. * Effect Name of the highlight layer.
  135890. */
  135891. static readonly EffectName: string;
  135892. /**
  135893. * The neutral color used during the preparation of the glow effect.
  135894. * This is black by default as the blend operation is a blend operation.
  135895. */
  135896. static NeutralColor: Color4;
  135897. /**
  135898. * Stencil value used for glowing meshes.
  135899. */
  135900. static GlowingMeshStencilReference: number;
  135901. /**
  135902. * Stencil value used for the other meshes in the scene.
  135903. */
  135904. static NormalMeshStencilReference: number;
  135905. /**
  135906. * Specifies whether or not the inner glow is ACTIVE in the layer.
  135907. */
  135908. innerGlow: boolean;
  135909. /**
  135910. * Specifies whether or not the outer glow is ACTIVE in the layer.
  135911. */
  135912. outerGlow: boolean;
  135913. /**
  135914. * Specifies the horizontal size of the blur.
  135915. */
  135916. set blurHorizontalSize(value: number);
  135917. /**
  135918. * Specifies the vertical size of the blur.
  135919. */
  135920. set blurVerticalSize(value: number);
  135921. /**
  135922. * Gets the horizontal size of the blur.
  135923. */
  135924. get blurHorizontalSize(): number;
  135925. /**
  135926. * Gets the vertical size of the blur.
  135927. */
  135928. get blurVerticalSize(): number;
  135929. /**
  135930. * An event triggered when the highlight layer is being blurred.
  135931. */
  135932. onBeforeBlurObservable: Observable<HighlightLayer>;
  135933. /**
  135934. * An event triggered when the highlight layer has been blurred.
  135935. */
  135936. onAfterBlurObservable: Observable<HighlightLayer>;
  135937. private _instanceGlowingMeshStencilReference;
  135938. private _options;
  135939. private _downSamplePostprocess;
  135940. private _horizontalBlurPostprocess;
  135941. private _verticalBlurPostprocess;
  135942. private _blurTexture;
  135943. private _meshes;
  135944. private _excludedMeshes;
  135945. /**
  135946. * Instantiates a new highlight Layer and references it to the scene..
  135947. * @param name The name of the layer
  135948. * @param scene The scene to use the layer in
  135949. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  135950. */
  135951. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  135952. /**
  135953. * Get the effect name of the layer.
  135954. * @return The effect name
  135955. */
  135956. getEffectName(): string;
  135957. /**
  135958. * Create the merge effect. This is the shader use to blit the information back
  135959. * to the main canvas at the end of the scene rendering.
  135960. */
  135961. protected _createMergeEffect(): Effect;
  135962. /**
  135963. * Creates the render target textures and post processes used in the highlight layer.
  135964. */
  135965. protected _createTextureAndPostProcesses(): void;
  135966. /**
  135967. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  135968. */
  135969. needStencil(): boolean;
  135970. /**
  135971. * Checks for the readiness of the element composing the layer.
  135972. * @param subMesh the mesh to check for
  135973. * @param useInstances specify wether or not to use instances to render the mesh
  135974. * @param emissiveTexture the associated emissive texture used to generate the glow
  135975. * @return true if ready otherwise, false
  135976. */
  135977. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135978. /**
  135979. * Implementation specific of rendering the generating effect on the main canvas.
  135980. * @param effect The effect used to render through
  135981. */
  135982. protected _internalRender(effect: Effect): void;
  135983. /**
  135984. * Returns true if the layer contains information to display, otherwise false.
  135985. */
  135986. shouldRender(): boolean;
  135987. /**
  135988. * Returns true if the mesh should render, otherwise false.
  135989. * @param mesh The mesh to render
  135990. * @returns true if it should render otherwise false
  135991. */
  135992. protected _shouldRenderMesh(mesh: Mesh): boolean;
  135993. /**
  135994. * Returns true if the mesh can be rendered, otherwise false.
  135995. * @param mesh The mesh to render
  135996. * @param material The material used on the mesh
  135997. * @returns true if it can be rendered otherwise false
  135998. */
  135999. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  136000. /**
  136001. * Adds specific effects defines.
  136002. * @param defines The defines to add specifics to.
  136003. */
  136004. protected _addCustomEffectDefines(defines: string[]): void;
  136005. /**
  136006. * Sets the required values for both the emissive texture and and the main color.
  136007. */
  136008. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  136009. /**
  136010. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  136011. * @param mesh The mesh to exclude from the highlight layer
  136012. */
  136013. addExcludedMesh(mesh: Mesh): void;
  136014. /**
  136015. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  136016. * @param mesh The mesh to highlight
  136017. */
  136018. removeExcludedMesh(mesh: Mesh): void;
  136019. /**
  136020. * Determine if a given mesh will be highlighted by the current HighlightLayer
  136021. * @param mesh mesh to test
  136022. * @returns true if the mesh will be highlighted by the current HighlightLayer
  136023. */
  136024. hasMesh(mesh: AbstractMesh): boolean;
  136025. /**
  136026. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  136027. * @param mesh The mesh to highlight
  136028. * @param color The color of the highlight
  136029. * @param glowEmissiveOnly Extract the glow from the emissive texture
  136030. */
  136031. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  136032. /**
  136033. * Remove a mesh from the highlight layer in order to make it stop glowing.
  136034. * @param mesh The mesh to highlight
  136035. */
  136036. removeMesh(mesh: Mesh): void;
  136037. /**
  136038. * Remove all the meshes currently referenced in the highlight layer
  136039. */
  136040. removeAllMeshes(): void;
  136041. /**
  136042. * Force the stencil to the normal expected value for none glowing parts
  136043. */
  136044. private _defaultStencilReference;
  136045. /**
  136046. * Free any resources and references associated to a mesh.
  136047. * Internal use
  136048. * @param mesh The mesh to free.
  136049. * @hidden
  136050. */
  136051. _disposeMesh(mesh: Mesh): void;
  136052. /**
  136053. * Dispose the highlight layer and free resources.
  136054. */
  136055. dispose(): void;
  136056. /**
  136057. * Gets the class name of the effect layer
  136058. * @returns the string with the class name of the effect layer
  136059. */
  136060. getClassName(): string;
  136061. /**
  136062. * Serializes this Highlight layer
  136063. * @returns a serialized Highlight layer object
  136064. */
  136065. serialize(): any;
  136066. /**
  136067. * Creates a Highlight layer from parsed Highlight layer data
  136068. * @param parsedHightlightLayer defines the Highlight layer data
  136069. * @param scene defines the current scene
  136070. * @param rootUrl defines the root URL containing the Highlight layer information
  136071. * @returns a parsed Highlight layer
  136072. */
  136073. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  136074. }
  136075. }
  136076. declare module BABYLON {
  136077. interface AbstractScene {
  136078. /**
  136079. * The list of layers (background and foreground) of the scene
  136080. */
  136081. layers: Array<Layer>;
  136082. }
  136083. /**
  136084. * Defines the layer scene component responsible to manage any layers
  136085. * in a given scene.
  136086. */
  136087. export class LayerSceneComponent implements ISceneComponent {
  136088. /**
  136089. * The component name helpfull to identify the component in the list of scene components.
  136090. */
  136091. readonly name: string;
  136092. /**
  136093. * The scene the component belongs to.
  136094. */
  136095. scene: Scene;
  136096. private _engine;
  136097. /**
  136098. * Creates a new instance of the component for the given scene
  136099. * @param scene Defines the scene to register the component in
  136100. */
  136101. constructor(scene: Scene);
  136102. /**
  136103. * Registers the component in a given scene
  136104. */
  136105. register(): void;
  136106. /**
  136107. * Rebuilds the elements related to this component in case of
  136108. * context lost for instance.
  136109. */
  136110. rebuild(): void;
  136111. /**
  136112. * Disposes the component and the associated ressources.
  136113. */
  136114. dispose(): void;
  136115. private _draw;
  136116. private _drawCameraPredicate;
  136117. private _drawCameraBackground;
  136118. private _drawCameraForeground;
  136119. private _drawRenderTargetPredicate;
  136120. private _drawRenderTargetBackground;
  136121. private _drawRenderTargetForeground;
  136122. /**
  136123. * Adds all the elements from the container to the scene
  136124. * @param container the container holding the elements
  136125. */
  136126. addFromContainer(container: AbstractScene): void;
  136127. /**
  136128. * Removes all the elements in the container from the scene
  136129. * @param container contains the elements to remove
  136130. * @param dispose if the removed element should be disposed (default: false)
  136131. */
  136132. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  136133. }
  136134. }
  136135. declare module BABYLON {
  136136. /** @hidden */
  136137. export var layerPixelShader: {
  136138. name: string;
  136139. shader: string;
  136140. };
  136141. }
  136142. declare module BABYLON {
  136143. /** @hidden */
  136144. export var layerVertexShader: {
  136145. name: string;
  136146. shader: string;
  136147. };
  136148. }
  136149. declare module BABYLON {
  136150. /**
  136151. * This represents a full screen 2d layer.
  136152. * This can be useful to display a picture in the background of your scene for instance.
  136153. * @see https://www.babylonjs-playground.com/#08A2BS#1
  136154. */
  136155. export class Layer {
  136156. /**
  136157. * Define the name of the layer.
  136158. */
  136159. name: string;
  136160. /**
  136161. * Define the texture the layer should display.
  136162. */
  136163. texture: Nullable<Texture>;
  136164. /**
  136165. * Is the layer in background or foreground.
  136166. */
  136167. isBackground: boolean;
  136168. /**
  136169. * Define the color of the layer (instead of texture).
  136170. */
  136171. color: Color4;
  136172. /**
  136173. * Define the scale of the layer in order to zoom in out of the texture.
  136174. */
  136175. scale: Vector2;
  136176. /**
  136177. * Define an offset for the layer in order to shift the texture.
  136178. */
  136179. offset: Vector2;
  136180. /**
  136181. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  136182. */
  136183. alphaBlendingMode: number;
  136184. /**
  136185. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  136186. * Alpha test will not mix with the background color in case of transparency.
  136187. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  136188. */
  136189. alphaTest: boolean;
  136190. /**
  136191. * Define a mask to restrict the layer to only some of the scene cameras.
  136192. */
  136193. layerMask: number;
  136194. /**
  136195. * Define the list of render target the layer is visible into.
  136196. */
  136197. renderTargetTextures: RenderTargetTexture[];
  136198. /**
  136199. * Define if the layer is only used in renderTarget or if it also
  136200. * renders in the main frame buffer of the canvas.
  136201. */
  136202. renderOnlyInRenderTargetTextures: boolean;
  136203. private _scene;
  136204. private _vertexBuffers;
  136205. private _indexBuffer;
  136206. private _effect;
  136207. private _previousDefines;
  136208. /**
  136209. * An event triggered when the layer is disposed.
  136210. */
  136211. onDisposeObservable: Observable<Layer>;
  136212. private _onDisposeObserver;
  136213. /**
  136214. * Back compatibility with callback before the onDisposeObservable existed.
  136215. * The set callback will be triggered when the layer has been disposed.
  136216. */
  136217. set onDispose(callback: () => void);
  136218. /**
  136219. * An event triggered before rendering the scene
  136220. */
  136221. onBeforeRenderObservable: Observable<Layer>;
  136222. private _onBeforeRenderObserver;
  136223. /**
  136224. * Back compatibility with callback before the onBeforeRenderObservable existed.
  136225. * The set callback will be triggered just before rendering the layer.
  136226. */
  136227. set onBeforeRender(callback: () => void);
  136228. /**
  136229. * An event triggered after rendering the scene
  136230. */
  136231. onAfterRenderObservable: Observable<Layer>;
  136232. private _onAfterRenderObserver;
  136233. /**
  136234. * Back compatibility with callback before the onAfterRenderObservable existed.
  136235. * The set callback will be triggered just after rendering the layer.
  136236. */
  136237. set onAfterRender(callback: () => void);
  136238. /**
  136239. * Instantiates a new layer.
  136240. * This represents a full screen 2d layer.
  136241. * This can be useful to display a picture in the background of your scene for instance.
  136242. * @see https://www.babylonjs-playground.com/#08A2BS#1
  136243. * @param name Define the name of the layer in the scene
  136244. * @param imgUrl Define the url of the texture to display in the layer
  136245. * @param scene Define the scene the layer belongs to
  136246. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  136247. * @param color Defines a color for the layer
  136248. */
  136249. constructor(
  136250. /**
  136251. * Define the name of the layer.
  136252. */
  136253. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  136254. private _createIndexBuffer;
  136255. /** @hidden */
  136256. _rebuild(): void;
  136257. /**
  136258. * Renders the layer in the scene.
  136259. */
  136260. render(): void;
  136261. /**
  136262. * Disposes and releases the associated ressources.
  136263. */
  136264. dispose(): void;
  136265. }
  136266. }
  136267. declare module BABYLON {
  136268. /** @hidden */
  136269. export var lensFlarePixelShader: {
  136270. name: string;
  136271. shader: string;
  136272. };
  136273. }
  136274. declare module BABYLON {
  136275. /** @hidden */
  136276. export var lensFlareVertexShader: {
  136277. name: string;
  136278. shader: string;
  136279. };
  136280. }
  136281. declare module BABYLON {
  136282. /**
  136283. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  136284. * It is usually composed of several `lensFlare`.
  136285. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136286. */
  136287. export class LensFlareSystem {
  136288. /**
  136289. * Define the name of the lens flare system
  136290. */
  136291. name: string;
  136292. /**
  136293. * List of lens flares used in this system.
  136294. */
  136295. lensFlares: LensFlare[];
  136296. /**
  136297. * Define a limit from the border the lens flare can be visible.
  136298. */
  136299. borderLimit: number;
  136300. /**
  136301. * Define a viewport border we do not want to see the lens flare in.
  136302. */
  136303. viewportBorder: number;
  136304. /**
  136305. * Define a predicate which could limit the list of meshes able to occlude the effect.
  136306. */
  136307. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  136308. /**
  136309. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  136310. */
  136311. layerMask: number;
  136312. /**
  136313. * Define the id of the lens flare system in the scene.
  136314. * (equal to name by default)
  136315. */
  136316. id: string;
  136317. private _scene;
  136318. private _emitter;
  136319. private _vertexBuffers;
  136320. private _indexBuffer;
  136321. private _effect;
  136322. private _positionX;
  136323. private _positionY;
  136324. private _isEnabled;
  136325. /** @hidden */
  136326. static _SceneComponentInitialization: (scene: Scene) => void;
  136327. /**
  136328. * Instantiates a lens flare system.
  136329. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  136330. * It is usually composed of several `lensFlare`.
  136331. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136332. * @param name Define the name of the lens flare system in the scene
  136333. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  136334. * @param scene Define the scene the lens flare system belongs to
  136335. */
  136336. constructor(
  136337. /**
  136338. * Define the name of the lens flare system
  136339. */
  136340. name: string, emitter: any, scene: Scene);
  136341. /**
  136342. * Define if the lens flare system is enabled.
  136343. */
  136344. get isEnabled(): boolean;
  136345. set isEnabled(value: boolean);
  136346. /**
  136347. * Get the scene the effects belongs to.
  136348. * @returns the scene holding the lens flare system
  136349. */
  136350. getScene(): Scene;
  136351. /**
  136352. * Get the emitter of the lens flare system.
  136353. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  136354. * @returns the emitter of the lens flare system
  136355. */
  136356. getEmitter(): any;
  136357. /**
  136358. * Set the emitter of the lens flare system.
  136359. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  136360. * @param newEmitter Define the new emitter of the system
  136361. */
  136362. setEmitter(newEmitter: any): void;
  136363. /**
  136364. * Get the lens flare system emitter position.
  136365. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  136366. * @returns the position
  136367. */
  136368. getEmitterPosition(): Vector3;
  136369. /**
  136370. * @hidden
  136371. */
  136372. computeEffectivePosition(globalViewport: Viewport): boolean;
  136373. /** @hidden */
  136374. _isVisible(): boolean;
  136375. /**
  136376. * @hidden
  136377. */
  136378. render(): boolean;
  136379. /**
  136380. * Dispose and release the lens flare with its associated resources.
  136381. */
  136382. dispose(): void;
  136383. /**
  136384. * Parse a lens flare system from a JSON repressentation
  136385. * @param parsedLensFlareSystem Define the JSON to parse
  136386. * @param scene Define the scene the parsed system should be instantiated in
  136387. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  136388. * @returns the parsed system
  136389. */
  136390. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  136391. /**
  136392. * Serialize the current Lens Flare System into a JSON representation.
  136393. * @returns the serialized JSON
  136394. */
  136395. serialize(): any;
  136396. }
  136397. }
  136398. declare module BABYLON {
  136399. /**
  136400. * This represents one of the lens effect in a `lensFlareSystem`.
  136401. * It controls one of the indiviual texture used in the effect.
  136402. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136403. */
  136404. export class LensFlare {
  136405. /**
  136406. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  136407. */
  136408. size: number;
  136409. /**
  136410. * 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.
  136411. */
  136412. position: number;
  136413. /**
  136414. * Define the lens color.
  136415. */
  136416. color: Color3;
  136417. /**
  136418. * Define the lens texture.
  136419. */
  136420. texture: Nullable<Texture>;
  136421. /**
  136422. * Define the alpha mode to render this particular lens.
  136423. */
  136424. alphaMode: number;
  136425. private _system;
  136426. /**
  136427. * Creates a new Lens Flare.
  136428. * This represents one of the lens effect in a `lensFlareSystem`.
  136429. * It controls one of the indiviual texture used in the effect.
  136430. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136431. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  136432. * @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.
  136433. * @param color Define the lens color
  136434. * @param imgUrl Define the lens texture url
  136435. * @param system Define the `lensFlareSystem` this flare is part of
  136436. * @returns The newly created Lens Flare
  136437. */
  136438. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  136439. /**
  136440. * Instantiates a new Lens Flare.
  136441. * This represents one of the lens effect in a `lensFlareSystem`.
  136442. * It controls one of the indiviual texture used in the effect.
  136443. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136444. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  136445. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  136446. * @param color Define the lens color
  136447. * @param imgUrl Define the lens texture url
  136448. * @param system Define the `lensFlareSystem` this flare is part of
  136449. */
  136450. constructor(
  136451. /**
  136452. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  136453. */
  136454. size: number,
  136455. /**
  136456. * 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.
  136457. */
  136458. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  136459. /**
  136460. * Dispose and release the lens flare with its associated resources.
  136461. */
  136462. dispose(): void;
  136463. }
  136464. }
  136465. declare module BABYLON {
  136466. interface AbstractScene {
  136467. /**
  136468. * The list of lens flare system added to the scene
  136469. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136470. */
  136471. lensFlareSystems: Array<LensFlareSystem>;
  136472. /**
  136473. * Removes the given lens flare system from this scene.
  136474. * @param toRemove The lens flare system to remove
  136475. * @returns The index of the removed lens flare system
  136476. */
  136477. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  136478. /**
  136479. * Adds the given lens flare system to this scene
  136480. * @param newLensFlareSystem The lens flare system to add
  136481. */
  136482. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  136483. /**
  136484. * Gets a lens flare system using its name
  136485. * @param name defines the name to look for
  136486. * @returns the lens flare system or null if not found
  136487. */
  136488. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  136489. /**
  136490. * Gets a lens flare system using its id
  136491. * @param id defines the id to look for
  136492. * @returns the lens flare system or null if not found
  136493. */
  136494. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  136495. }
  136496. /**
  136497. * Defines the lens flare scene component responsible to manage any lens flares
  136498. * in a given scene.
  136499. */
  136500. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  136501. /**
  136502. * The component name helpfull to identify the component in the list of scene components.
  136503. */
  136504. readonly name: string;
  136505. /**
  136506. * The scene the component belongs to.
  136507. */
  136508. scene: Scene;
  136509. /**
  136510. * Creates a new instance of the component for the given scene
  136511. * @param scene Defines the scene to register the component in
  136512. */
  136513. constructor(scene: Scene);
  136514. /**
  136515. * Registers the component in a given scene
  136516. */
  136517. register(): void;
  136518. /**
  136519. * Rebuilds the elements related to this component in case of
  136520. * context lost for instance.
  136521. */
  136522. rebuild(): void;
  136523. /**
  136524. * Adds all the elements from the container to the scene
  136525. * @param container the container holding the elements
  136526. */
  136527. addFromContainer(container: AbstractScene): void;
  136528. /**
  136529. * Removes all the elements in the container from the scene
  136530. * @param container contains the elements to remove
  136531. * @param dispose if the removed element should be disposed (default: false)
  136532. */
  136533. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  136534. /**
  136535. * Serializes the component data to the specified json object
  136536. * @param serializationObject The object to serialize to
  136537. */
  136538. serialize(serializationObject: any): void;
  136539. /**
  136540. * Disposes the component and the associated ressources.
  136541. */
  136542. dispose(): void;
  136543. private _draw;
  136544. }
  136545. }
  136546. declare module BABYLON {
  136547. /** @hidden */
  136548. export var depthPixelShader: {
  136549. name: string;
  136550. shader: string;
  136551. };
  136552. }
  136553. declare module BABYLON {
  136554. /** @hidden */
  136555. export var depthVertexShader: {
  136556. name: string;
  136557. shader: string;
  136558. };
  136559. }
  136560. declare module BABYLON {
  136561. /**
  136562. * This represents a depth renderer in Babylon.
  136563. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  136564. */
  136565. export class DepthRenderer {
  136566. private _scene;
  136567. private _depthMap;
  136568. private _effect;
  136569. private readonly _storeNonLinearDepth;
  136570. private readonly _clearColor;
  136571. /** Get if the depth renderer is using packed depth or not */
  136572. readonly isPacked: boolean;
  136573. private _cachedDefines;
  136574. private _camera;
  136575. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  136576. enabled: boolean;
  136577. /**
  136578. * Specifiess that the depth renderer will only be used within
  136579. * the camera it is created for.
  136580. * This can help forcing its rendering during the camera processing.
  136581. */
  136582. useOnlyInActiveCamera: boolean;
  136583. /** @hidden */
  136584. static _SceneComponentInitialization: (scene: Scene) => void;
  136585. /**
  136586. * Instantiates a depth renderer
  136587. * @param scene The scene the renderer belongs to
  136588. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  136589. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  136590. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  136591. */
  136592. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  136593. /**
  136594. * Creates the depth rendering effect and checks if the effect is ready.
  136595. * @param subMesh The submesh to be used to render the depth map of
  136596. * @param useInstances If multiple world instances should be used
  136597. * @returns if the depth renderer is ready to render the depth map
  136598. */
  136599. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  136600. /**
  136601. * Gets the texture which the depth map will be written to.
  136602. * @returns The depth map texture
  136603. */
  136604. getDepthMap(): RenderTargetTexture;
  136605. /**
  136606. * Disposes of the depth renderer.
  136607. */
  136608. dispose(): void;
  136609. }
  136610. }
  136611. declare module BABYLON {
  136612. /** @hidden */
  136613. export var minmaxReduxPixelShader: {
  136614. name: string;
  136615. shader: string;
  136616. };
  136617. }
  136618. declare module BABYLON {
  136619. /**
  136620. * This class computes a min/max reduction from a texture: it means it computes the minimum
  136621. * and maximum values from all values of the texture.
  136622. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  136623. * The source values are read from the red channel of the texture.
  136624. */
  136625. export class MinMaxReducer {
  136626. /**
  136627. * Observable triggered when the computation has been performed
  136628. */
  136629. onAfterReductionPerformed: Observable<{
  136630. min: number;
  136631. max: number;
  136632. }>;
  136633. protected _camera: Camera;
  136634. protected _sourceTexture: Nullable<RenderTargetTexture>;
  136635. protected _reductionSteps: Nullable<Array<PostProcess>>;
  136636. protected _postProcessManager: PostProcessManager;
  136637. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  136638. protected _forceFullscreenViewport: boolean;
  136639. /**
  136640. * Creates a min/max reducer
  136641. * @param camera The camera to use for the post processes
  136642. */
  136643. constructor(camera: Camera);
  136644. /**
  136645. * Gets the texture used to read the values from.
  136646. */
  136647. get sourceTexture(): Nullable<RenderTargetTexture>;
  136648. /**
  136649. * Sets the source texture to read the values from.
  136650. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  136651. * because in such textures '1' value must not be taken into account to compute the maximum
  136652. * as this value is used to clear the texture.
  136653. * Note that the computation is not activated by calling this function, you must call activate() for that!
  136654. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  136655. * @param depthRedux Indicates if the texture is a depth texture or not
  136656. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  136657. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  136658. */
  136659. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  136660. /**
  136661. * Defines the refresh rate of the computation.
  136662. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  136663. */
  136664. get refreshRate(): number;
  136665. set refreshRate(value: number);
  136666. protected _activated: boolean;
  136667. /**
  136668. * Gets the activation status of the reducer
  136669. */
  136670. get activated(): boolean;
  136671. /**
  136672. * Activates the reduction computation.
  136673. * When activated, the observers registered in onAfterReductionPerformed are
  136674. * called after the compuation is performed
  136675. */
  136676. activate(): void;
  136677. /**
  136678. * Deactivates the reduction computation.
  136679. */
  136680. deactivate(): void;
  136681. /**
  136682. * Disposes the min/max reducer
  136683. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  136684. */
  136685. dispose(disposeAll?: boolean): void;
  136686. }
  136687. }
  136688. declare module BABYLON {
  136689. /**
  136690. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  136691. */
  136692. export class DepthReducer extends MinMaxReducer {
  136693. private _depthRenderer;
  136694. private _depthRendererId;
  136695. /**
  136696. * Gets the depth renderer used for the computation.
  136697. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  136698. */
  136699. get depthRenderer(): Nullable<DepthRenderer>;
  136700. /**
  136701. * Creates a depth reducer
  136702. * @param camera The camera used to render the depth texture
  136703. */
  136704. constructor(camera: Camera);
  136705. /**
  136706. * Sets the depth renderer to use to generate the depth map
  136707. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  136708. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  136709. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  136710. */
  136711. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  136712. /** @hidden */
  136713. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  136714. /**
  136715. * Activates the reduction computation.
  136716. * When activated, the observers registered in onAfterReductionPerformed are
  136717. * called after the compuation is performed
  136718. */
  136719. activate(): void;
  136720. /**
  136721. * Deactivates the reduction computation.
  136722. */
  136723. deactivate(): void;
  136724. /**
  136725. * Disposes the depth reducer
  136726. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  136727. */
  136728. dispose(disposeAll?: boolean): void;
  136729. }
  136730. }
  136731. declare module BABYLON {
  136732. /**
  136733. * A CSM implementation allowing casting shadows on large scenes.
  136734. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  136735. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  136736. */
  136737. export class CascadedShadowGenerator extends ShadowGenerator {
  136738. private static readonly frustumCornersNDCSpace;
  136739. /**
  136740. * Name of the CSM class
  136741. */
  136742. static CLASSNAME: string;
  136743. /**
  136744. * Defines the default number of cascades used by the CSM.
  136745. */
  136746. static readonly DEFAULT_CASCADES_COUNT: number;
  136747. /**
  136748. * Defines the minimum number of cascades used by the CSM.
  136749. */
  136750. static readonly MIN_CASCADES_COUNT: number;
  136751. /**
  136752. * Defines the maximum number of cascades used by the CSM.
  136753. */
  136754. static readonly MAX_CASCADES_COUNT: number;
  136755. protected _validateFilter(filter: number): number;
  136756. /**
  136757. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  136758. */
  136759. penumbraDarkness: number;
  136760. private _numCascades;
  136761. /**
  136762. * Gets or set the number of cascades used by the CSM.
  136763. */
  136764. get numCascades(): number;
  136765. set numCascades(value: number);
  136766. /**
  136767. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  136768. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  136769. */
  136770. stabilizeCascades: boolean;
  136771. private _freezeShadowCastersBoundingInfo;
  136772. private _freezeShadowCastersBoundingInfoObservable;
  136773. /**
  136774. * Enables or disables the shadow casters bounding info computation.
  136775. * If your shadow casters don't move, you can disable this feature.
  136776. * If it is enabled, the bounding box computation is done every frame.
  136777. */
  136778. get freezeShadowCastersBoundingInfo(): boolean;
  136779. set freezeShadowCastersBoundingInfo(freeze: boolean);
  136780. private _scbiMin;
  136781. private _scbiMax;
  136782. protected _computeShadowCastersBoundingInfo(): void;
  136783. protected _shadowCastersBoundingInfo: BoundingInfo;
  136784. /**
  136785. * Gets or sets the shadow casters bounding info.
  136786. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  136787. * so that the system won't overwrite the bounds you provide
  136788. */
  136789. get shadowCastersBoundingInfo(): BoundingInfo;
  136790. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  136791. protected _breaksAreDirty: boolean;
  136792. protected _minDistance: number;
  136793. protected _maxDistance: number;
  136794. /**
  136795. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  136796. *
  136797. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  136798. * If you don't know these values, simply leave them to their defaults and don't call this function.
  136799. * @param min minimal distance for the breaks (default to 0.)
  136800. * @param max maximal distance for the breaks (default to 1.)
  136801. */
  136802. setMinMaxDistance(min: number, max: number): void;
  136803. /** Gets the minimal distance used in the cascade break computation */
  136804. get minDistance(): number;
  136805. /** Gets the maximal distance used in the cascade break computation */
  136806. get maxDistance(): number;
  136807. /**
  136808. * Gets the class name of that object
  136809. * @returns "CascadedShadowGenerator"
  136810. */
  136811. getClassName(): string;
  136812. private _cascadeMinExtents;
  136813. private _cascadeMaxExtents;
  136814. /**
  136815. * Gets a cascade minimum extents
  136816. * @param cascadeIndex index of the cascade
  136817. * @returns the minimum cascade extents
  136818. */
  136819. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  136820. /**
  136821. * Gets a cascade maximum extents
  136822. * @param cascadeIndex index of the cascade
  136823. * @returns the maximum cascade extents
  136824. */
  136825. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  136826. private _cascades;
  136827. private _currentLayer;
  136828. private _viewSpaceFrustumsZ;
  136829. private _viewMatrices;
  136830. private _projectionMatrices;
  136831. private _transformMatrices;
  136832. private _transformMatricesAsArray;
  136833. private _frustumLengths;
  136834. private _lightSizeUVCorrection;
  136835. private _depthCorrection;
  136836. private _frustumCornersWorldSpace;
  136837. private _frustumCenter;
  136838. private _shadowCameraPos;
  136839. private _shadowMaxZ;
  136840. /**
  136841. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  136842. * It defaults to camera.maxZ
  136843. */
  136844. get shadowMaxZ(): number;
  136845. /**
  136846. * Sets the shadow max z distance.
  136847. */
  136848. set shadowMaxZ(value: number);
  136849. protected _debug: boolean;
  136850. /**
  136851. * Gets or sets the debug flag.
  136852. * When enabled, the cascades are materialized by different colors on the screen.
  136853. */
  136854. get debug(): boolean;
  136855. set debug(dbg: boolean);
  136856. private _depthClamp;
  136857. /**
  136858. * Gets or sets the depth clamping value.
  136859. *
  136860. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  136861. * to account for the shadow casters far away.
  136862. *
  136863. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  136864. */
  136865. get depthClamp(): boolean;
  136866. set depthClamp(value: boolean);
  136867. private _cascadeBlendPercentage;
  136868. /**
  136869. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  136870. * It defaults to 0.1 (10% blending).
  136871. */
  136872. get cascadeBlendPercentage(): number;
  136873. set cascadeBlendPercentage(value: number);
  136874. private _lambda;
  136875. /**
  136876. * Gets or set the lambda parameter.
  136877. * This parameter is used to split the camera frustum and create the cascades.
  136878. * It's a value between 0. and 1.: If 0, the split is a uniform split of the frustum, if 1 it is a logarithmic split.
  136879. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  136880. */
  136881. get lambda(): number;
  136882. set lambda(value: number);
  136883. /**
  136884. * Gets the view matrix corresponding to a given cascade
  136885. * @param cascadeNum cascade to retrieve the view matrix from
  136886. * @returns the cascade view matrix
  136887. */
  136888. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  136889. /**
  136890. * Gets the projection matrix corresponding to a given cascade
  136891. * @param cascadeNum cascade to retrieve the projection matrix from
  136892. * @returns the cascade projection matrix
  136893. */
  136894. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  136895. /**
  136896. * Gets the transformation matrix corresponding to a given cascade
  136897. * @param cascadeNum cascade to retrieve the transformation matrix from
  136898. * @returns the cascade transformation matrix
  136899. */
  136900. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  136901. private _depthRenderer;
  136902. /**
  136903. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  136904. *
  136905. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  136906. *
  136907. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  136908. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  136909. * @param depthRenderer The depth renderer to use when autoCalcDepthBounds is enabled. If you pass null or don't call this function at all, a depth renderer will be automatically created
  136910. */
  136911. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  136912. private _depthReducer;
  136913. private _autoCalcDepthBounds;
  136914. /**
  136915. * Gets or sets the autoCalcDepthBounds property.
  136916. *
  136917. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  136918. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  136919. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  136920. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  136921. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  136922. */
  136923. get autoCalcDepthBounds(): boolean;
  136924. set autoCalcDepthBounds(value: boolean);
  136925. /**
  136926. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  136927. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  136928. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  136929. * for setting the refresh rate on the renderer yourself!
  136930. */
  136931. get autoCalcDepthBoundsRefreshRate(): number;
  136932. set autoCalcDepthBoundsRefreshRate(value: number);
  136933. /**
  136934. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  136935. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  136936. * you change the camera near/far planes!
  136937. */
  136938. splitFrustum(): void;
  136939. private _splitFrustum;
  136940. private _computeMatrices;
  136941. private _computeFrustumInWorldSpace;
  136942. private _computeCascadeFrustum;
  136943. /**
  136944. * Support test.
  136945. */
  136946. static get IsSupported(): boolean;
  136947. /** @hidden */
  136948. static _SceneComponentInitialization: (scene: Scene) => void;
  136949. /**
  136950. * Creates a Cascaded Shadow Generator object.
  136951. * A ShadowGenerator is the required tool to use the shadows.
  136952. * Each directional light casting shadows needs to use its own ShadowGenerator.
  136953. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  136954. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  136955. * @param light The directional light object generating the shadows.
  136956. * @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.
  136957. */
  136958. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  136959. protected _initializeGenerator(): void;
  136960. protected _createTargetRenderTexture(): void;
  136961. protected _initializeShadowMap(): void;
  136962. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  136963. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  136964. /**
  136965. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  136966. * @param defines Defines of the material we want to update
  136967. * @param lightIndex Index of the light in the enabled light list of the material
  136968. */
  136969. prepareDefines(defines: any, lightIndex: number): void;
  136970. /**
  136971. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  136972. * defined in the generator but impacting the effect).
  136973. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  136974. * @param effect The effect we are binfing the information for
  136975. */
  136976. bindShadowLight(lightIndex: string, effect: Effect): void;
  136977. /**
  136978. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  136979. * (eq to view projection * shadow projection matrices)
  136980. * @returns The transform matrix used to create the shadow map
  136981. */
  136982. getTransformMatrix(): Matrix;
  136983. /**
  136984. * Disposes the ShadowGenerator.
  136985. * Returns nothing.
  136986. */
  136987. dispose(): void;
  136988. /**
  136989. * Serializes the shadow generator setup to a json object.
  136990. * @returns The serialized JSON object
  136991. */
  136992. serialize(): any;
  136993. /**
  136994. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  136995. * @param parsedShadowGenerator The JSON object to parse
  136996. * @param scene The scene to create the shadow map for
  136997. * @returns The parsed shadow generator
  136998. */
  136999. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  137000. }
  137001. }
  137002. declare module BABYLON {
  137003. /**
  137004. * Defines the shadow generator component responsible to manage any shadow generators
  137005. * in a given scene.
  137006. */
  137007. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  137008. /**
  137009. * The component name helpfull to identify the component in the list of scene components.
  137010. */
  137011. readonly name: string;
  137012. /**
  137013. * The scene the component belongs to.
  137014. */
  137015. scene: Scene;
  137016. /**
  137017. * Creates a new instance of the component for the given scene
  137018. * @param scene Defines the scene to register the component in
  137019. */
  137020. constructor(scene: Scene);
  137021. /**
  137022. * Registers the component in a given scene
  137023. */
  137024. register(): void;
  137025. /**
  137026. * Rebuilds the elements related to this component in case of
  137027. * context lost for instance.
  137028. */
  137029. rebuild(): void;
  137030. /**
  137031. * Serializes the component data to the specified json object
  137032. * @param serializationObject The object to serialize to
  137033. */
  137034. serialize(serializationObject: any): void;
  137035. /**
  137036. * Adds all the elements from the container to the scene
  137037. * @param container the container holding the elements
  137038. */
  137039. addFromContainer(container: AbstractScene): void;
  137040. /**
  137041. * Removes all the elements in the container from the scene
  137042. * @param container contains the elements to remove
  137043. * @param dispose if the removed element should be disposed (default: false)
  137044. */
  137045. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  137046. /**
  137047. * Rebuilds the elements related to this component in case of
  137048. * context lost for instance.
  137049. */
  137050. dispose(): void;
  137051. private _gatherRenderTargets;
  137052. }
  137053. }
  137054. declare module BABYLON {
  137055. /**
  137056. * A point light is a light defined by an unique point in world space.
  137057. * The light is emitted in every direction from this point.
  137058. * A good example of a point light is a standard light bulb.
  137059. * Documentation: https://doc.babylonjs.com/babylon101/lights
  137060. */
  137061. export class PointLight extends ShadowLight {
  137062. private _shadowAngle;
  137063. /**
  137064. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  137065. * This specifies what angle the shadow will use to be created.
  137066. *
  137067. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  137068. */
  137069. get shadowAngle(): number;
  137070. /**
  137071. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  137072. * This specifies what angle the shadow will use to be created.
  137073. *
  137074. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  137075. */
  137076. set shadowAngle(value: number);
  137077. /**
  137078. * Gets the direction if it has been set.
  137079. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  137080. */
  137081. get direction(): Vector3;
  137082. /**
  137083. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  137084. */
  137085. set direction(value: Vector3);
  137086. /**
  137087. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  137088. * A PointLight emits the light in every direction.
  137089. * It can cast shadows.
  137090. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  137091. * ```javascript
  137092. * var pointLight = new PointLight("pl", camera.position, scene);
  137093. * ```
  137094. * Documentation : https://doc.babylonjs.com/babylon101/lights
  137095. * @param name The light friendly name
  137096. * @param position The position of the point light in the scene
  137097. * @param scene The scene the lights belongs to
  137098. */
  137099. constructor(name: string, position: Vector3, scene: Scene);
  137100. /**
  137101. * Returns the string "PointLight"
  137102. * @returns the class name
  137103. */
  137104. getClassName(): string;
  137105. /**
  137106. * Returns the integer 0.
  137107. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  137108. */
  137109. getTypeID(): number;
  137110. /**
  137111. * Specifies wether or not the shadowmap should be a cube texture.
  137112. * @returns true if the shadowmap needs to be a cube texture.
  137113. */
  137114. needCube(): boolean;
  137115. /**
  137116. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  137117. * @param faceIndex The index of the face we are computed the direction to generate shadow
  137118. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  137119. */
  137120. getShadowDirection(faceIndex?: number): Vector3;
  137121. /**
  137122. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  137123. * - fov = PI / 2
  137124. * - aspect ratio : 1.0
  137125. * - z-near and far equal to the active camera minZ and maxZ.
  137126. * Returns the PointLight.
  137127. */
  137128. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  137129. protected _buildUniformLayout(): void;
  137130. /**
  137131. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  137132. * @param effect The effect to update
  137133. * @param lightIndex The index of the light in the effect to update
  137134. * @returns The point light
  137135. */
  137136. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  137137. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  137138. /**
  137139. * Prepares the list of defines specific to the light type.
  137140. * @param defines the list of defines
  137141. * @param lightIndex defines the index of the light for the effect
  137142. */
  137143. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  137144. }
  137145. }
  137146. declare module BABYLON {
  137147. /**
  137148. * Header information of HDR texture files.
  137149. */
  137150. export interface HDRInfo {
  137151. /**
  137152. * The height of the texture in pixels.
  137153. */
  137154. height: number;
  137155. /**
  137156. * The width of the texture in pixels.
  137157. */
  137158. width: number;
  137159. /**
  137160. * The index of the beginning of the data in the binary file.
  137161. */
  137162. dataPosition: number;
  137163. }
  137164. /**
  137165. * This groups tools to convert HDR texture to native colors array.
  137166. */
  137167. export class HDRTools {
  137168. private static Ldexp;
  137169. private static Rgbe2float;
  137170. private static readStringLine;
  137171. /**
  137172. * Reads header information from an RGBE texture stored in a native array.
  137173. * More information on this format are available here:
  137174. * https://en.wikipedia.org/wiki/RGBE_image_format
  137175. *
  137176. * @param uint8array The binary file stored in native array.
  137177. * @return The header information.
  137178. */
  137179. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  137180. /**
  137181. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  137182. * This RGBE texture needs to store the information as a panorama.
  137183. *
  137184. * More information on this format are available here:
  137185. * https://en.wikipedia.org/wiki/RGBE_image_format
  137186. *
  137187. * @param buffer The binary file stored in an array buffer.
  137188. * @param size The expected size of the extracted cubemap.
  137189. * @return The Cube Map information.
  137190. */
  137191. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  137192. /**
  137193. * Returns the pixels data extracted from an RGBE texture.
  137194. * This pixels will be stored left to right up to down in the R G B order in one array.
  137195. *
  137196. * More information on this format are available here:
  137197. * https://en.wikipedia.org/wiki/RGBE_image_format
  137198. *
  137199. * @param uint8array The binary file stored in an array buffer.
  137200. * @param hdrInfo The header information of the file.
  137201. * @return The pixels data in RGB right to left up to down order.
  137202. */
  137203. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  137204. private static RGBE_ReadPixels_RLE;
  137205. }
  137206. }
  137207. declare module BABYLON {
  137208. /**
  137209. * Effect Render Options
  137210. */
  137211. export interface IEffectRendererOptions {
  137212. /**
  137213. * Defines the vertices positions.
  137214. */
  137215. positions?: number[];
  137216. /**
  137217. * Defines the indices.
  137218. */
  137219. indices?: number[];
  137220. }
  137221. /**
  137222. * Helper class to render one or more effects.
  137223. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  137224. */
  137225. export class EffectRenderer {
  137226. private engine;
  137227. private static _DefaultOptions;
  137228. private _vertexBuffers;
  137229. private _indexBuffer;
  137230. private _fullscreenViewport;
  137231. /**
  137232. * Creates an effect renderer
  137233. * @param engine the engine to use for rendering
  137234. * @param options defines the options of the effect renderer
  137235. */
  137236. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  137237. /**
  137238. * Sets the current viewport in normalized coordinates 0-1
  137239. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  137240. */
  137241. setViewport(viewport?: Viewport): void;
  137242. /**
  137243. * Binds the embedded attributes buffer to the effect.
  137244. * @param effect Defines the effect to bind the attributes for
  137245. */
  137246. bindBuffers(effect: Effect): void;
  137247. /**
  137248. * Sets the current effect wrapper to use during draw.
  137249. * The effect needs to be ready before calling this api.
  137250. * This also sets the default full screen position attribute.
  137251. * @param effectWrapper Defines the effect to draw with
  137252. */
  137253. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  137254. /**
  137255. * Restores engine states
  137256. */
  137257. restoreStates(): void;
  137258. /**
  137259. * Draws a full screen quad.
  137260. */
  137261. draw(): void;
  137262. private isRenderTargetTexture;
  137263. /**
  137264. * renders one or more effects to a specified texture
  137265. * @param effectWrapper the effect to renderer
  137266. * @param outputTexture texture to draw to, if null it will render to the screen.
  137267. */
  137268. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  137269. /**
  137270. * Disposes of the effect renderer
  137271. */
  137272. dispose(): void;
  137273. }
  137274. /**
  137275. * Options to create an EffectWrapper
  137276. */
  137277. interface EffectWrapperCreationOptions {
  137278. /**
  137279. * Engine to use to create the effect
  137280. */
  137281. engine: ThinEngine;
  137282. /**
  137283. * Fragment shader for the effect
  137284. */
  137285. fragmentShader: string;
  137286. /**
  137287. * Use the shader store instead of direct source code
  137288. */
  137289. useShaderStore?: boolean;
  137290. /**
  137291. * Vertex shader for the effect
  137292. */
  137293. vertexShader?: string;
  137294. /**
  137295. * Attributes to use in the shader
  137296. */
  137297. attributeNames?: Array<string>;
  137298. /**
  137299. * Uniforms to use in the shader
  137300. */
  137301. uniformNames?: Array<string>;
  137302. /**
  137303. * Texture sampler names to use in the shader
  137304. */
  137305. samplerNames?: Array<string>;
  137306. /**
  137307. * Defines to use in the shader
  137308. */
  137309. defines?: Array<string>;
  137310. /**
  137311. * Callback when effect is compiled
  137312. */
  137313. onCompiled?: Nullable<(effect: Effect) => void>;
  137314. /**
  137315. * The friendly name of the effect displayed in Spector.
  137316. */
  137317. name?: string;
  137318. }
  137319. /**
  137320. * Wraps an effect to be used for rendering
  137321. */
  137322. export class EffectWrapper {
  137323. /**
  137324. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  137325. */
  137326. onApplyObservable: Observable<{}>;
  137327. /**
  137328. * The underlying effect
  137329. */
  137330. effect: Effect;
  137331. /**
  137332. * Creates an effect to be renderer
  137333. * @param creationOptions options to create the effect
  137334. */
  137335. constructor(creationOptions: EffectWrapperCreationOptions);
  137336. /**
  137337. * Disposes of the effect wrapper
  137338. */
  137339. dispose(): void;
  137340. }
  137341. }
  137342. declare module BABYLON {
  137343. /** @hidden */
  137344. export var hdrFilteringVertexShader: {
  137345. name: string;
  137346. shader: string;
  137347. };
  137348. }
  137349. declare module BABYLON {
  137350. /** @hidden */
  137351. export var hdrFilteringPixelShader: {
  137352. name: string;
  137353. shader: string;
  137354. };
  137355. }
  137356. declare module BABYLON {
  137357. /**
  137358. * Options for texture filtering
  137359. */
  137360. interface IHDRFilteringOptions {
  137361. /**
  137362. * Scales pixel intensity for the input HDR map.
  137363. */
  137364. hdrScale?: number;
  137365. /**
  137366. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  137367. */
  137368. quality?: number;
  137369. }
  137370. /**
  137371. * Filters HDR maps to get correct renderings of PBR reflections
  137372. */
  137373. export class HDRFiltering {
  137374. private _engine;
  137375. private _effectRenderer;
  137376. private _effectWrapper;
  137377. private _lodGenerationOffset;
  137378. private _lodGenerationScale;
  137379. /**
  137380. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  137381. * you care about baking speed.
  137382. */
  137383. quality: number;
  137384. /**
  137385. * Scales pixel intensity for the input HDR map.
  137386. */
  137387. hdrScale: number;
  137388. /**
  137389. * Instantiates HDR filter for reflection maps
  137390. *
  137391. * @param engine Thin engine
  137392. * @param options Options
  137393. */
  137394. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  137395. private _createRenderTarget;
  137396. private _prefilterInternal;
  137397. private _createEffect;
  137398. /**
  137399. * Get a value indicating if the filter is ready to be used
  137400. * @param texture Texture to filter
  137401. * @returns true if the filter is ready
  137402. */
  137403. isReady(texture: BaseTexture): boolean;
  137404. /**
  137405. * Prefilters a cube texture to have mipmap levels representing roughness values.
  137406. * Prefiltering will be invoked at the end of next rendering pass.
  137407. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  137408. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  137409. * @param texture Texture to filter
  137410. * @param onFinished Callback when filtering is done
  137411. * @return Promise called when prefiltering is done
  137412. */
  137413. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  137414. }
  137415. }
  137416. declare module BABYLON {
  137417. /**
  137418. * This represents a texture coming from an HDR input.
  137419. *
  137420. * The only supported format is currently panorama picture stored in RGBE format.
  137421. * Example of such files can be found on HDRLib: http://hdrlib.com/
  137422. */
  137423. export class HDRCubeTexture extends BaseTexture {
  137424. private static _facesMapping;
  137425. private _generateHarmonics;
  137426. private _noMipmap;
  137427. private _prefilterOnLoad;
  137428. private _textureMatrix;
  137429. private _size;
  137430. private _onLoad;
  137431. private _onError;
  137432. /**
  137433. * The texture URL.
  137434. */
  137435. url: string;
  137436. /**
  137437. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  137438. */
  137439. coordinatesMode: number;
  137440. protected _isBlocking: boolean;
  137441. /**
  137442. * Sets wether or not the texture is blocking during loading.
  137443. */
  137444. set isBlocking(value: boolean);
  137445. /**
  137446. * Gets wether or not the texture is blocking during loading.
  137447. */
  137448. get isBlocking(): boolean;
  137449. protected _rotationY: number;
  137450. /**
  137451. * Sets texture matrix rotation angle around Y axis in radians.
  137452. */
  137453. set rotationY(value: number);
  137454. /**
  137455. * Gets texture matrix rotation angle around Y axis radians.
  137456. */
  137457. get rotationY(): number;
  137458. /**
  137459. * Gets or sets the center of the bounding box associated with the cube texture
  137460. * It must define where the camera used to render the texture was set
  137461. */
  137462. boundingBoxPosition: Vector3;
  137463. private _boundingBoxSize;
  137464. /**
  137465. * Gets or sets the size of the bounding box associated with the cube texture
  137466. * When defined, the cubemap will switch to local mode
  137467. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  137468. * @example https://www.babylonjs-playground.com/#RNASML
  137469. */
  137470. set boundingBoxSize(value: Vector3);
  137471. get boundingBoxSize(): Vector3;
  137472. /**
  137473. * Instantiates an HDRTexture from the following parameters.
  137474. *
  137475. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  137476. * @param sceneOrEngine The scene or engine the texture will be used in
  137477. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  137478. * @param noMipmap Forces to not generate the mipmap if true
  137479. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  137480. * @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)
  137481. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  137482. */
  137483. constructor(url: string, sceneOrEngine: Scene | ThinEngine, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, prefilterOnLoad?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  137484. /**
  137485. * Get the current class name of the texture useful for serialization or dynamic coding.
  137486. * @returns "HDRCubeTexture"
  137487. */
  137488. getClassName(): string;
  137489. /**
  137490. * Occurs when the file is raw .hdr file.
  137491. */
  137492. private loadTexture;
  137493. clone(): HDRCubeTexture;
  137494. delayLoad(): void;
  137495. /**
  137496. * Get the texture reflection matrix used to rotate/transform the reflection.
  137497. * @returns the reflection matrix
  137498. */
  137499. getReflectionTextureMatrix(): Matrix;
  137500. /**
  137501. * Set the texture reflection matrix used to rotate/transform the reflection.
  137502. * @param value Define the reflection matrix to set
  137503. */
  137504. setReflectionTextureMatrix(value: Matrix): void;
  137505. /**
  137506. * Parses a JSON representation of an HDR Texture in order to create the texture
  137507. * @param parsedTexture Define the JSON representation
  137508. * @param scene Define the scene the texture should be created in
  137509. * @param rootUrl Define the root url in case we need to load relative dependencies
  137510. * @returns the newly created texture after parsing
  137511. */
  137512. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  137513. serialize(): any;
  137514. }
  137515. }
  137516. declare module BABYLON {
  137517. /**
  137518. * Class used to control physics engine
  137519. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  137520. */
  137521. export class PhysicsEngine implements IPhysicsEngine {
  137522. private _physicsPlugin;
  137523. /**
  137524. * Global value used to control the smallest number supported by the simulation
  137525. */
  137526. static Epsilon: number;
  137527. private _impostors;
  137528. private _joints;
  137529. private _subTimeStep;
  137530. /**
  137531. * Gets the gravity vector used by the simulation
  137532. */
  137533. gravity: Vector3;
  137534. /**
  137535. * Factory used to create the default physics plugin.
  137536. * @returns The default physics plugin
  137537. */
  137538. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  137539. /**
  137540. * Creates a new Physics Engine
  137541. * @param gravity defines the gravity vector used by the simulation
  137542. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  137543. */
  137544. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  137545. /**
  137546. * Sets the gravity vector used by the simulation
  137547. * @param gravity defines the gravity vector to use
  137548. */
  137549. setGravity(gravity: Vector3): void;
  137550. /**
  137551. * Set the time step of the physics engine.
  137552. * Default is 1/60.
  137553. * To slow it down, enter 1/600 for example.
  137554. * To speed it up, 1/30
  137555. * @param newTimeStep defines the new timestep to apply to this world.
  137556. */
  137557. setTimeStep(newTimeStep?: number): void;
  137558. /**
  137559. * Get the time step of the physics engine.
  137560. * @returns the current time step
  137561. */
  137562. getTimeStep(): number;
  137563. /**
  137564. * Set the sub time step of the physics engine.
  137565. * Default is 0 meaning there is no sub steps
  137566. * To increase physics resolution precision, set a small value (like 1 ms)
  137567. * @param subTimeStep defines the new sub timestep used for physics resolution.
  137568. */
  137569. setSubTimeStep(subTimeStep?: number): void;
  137570. /**
  137571. * Get the sub time step of the physics engine.
  137572. * @returns the current sub time step
  137573. */
  137574. getSubTimeStep(): number;
  137575. /**
  137576. * Release all resources
  137577. */
  137578. dispose(): void;
  137579. /**
  137580. * Gets the name of the current physics plugin
  137581. * @returns the name of the plugin
  137582. */
  137583. getPhysicsPluginName(): string;
  137584. /**
  137585. * Adding a new impostor for the impostor tracking.
  137586. * This will be done by the impostor itself.
  137587. * @param impostor the impostor to add
  137588. */
  137589. addImpostor(impostor: PhysicsImpostor): void;
  137590. /**
  137591. * Remove an impostor from the engine.
  137592. * This impostor and its mesh will not longer be updated by the physics engine.
  137593. * @param impostor the impostor to remove
  137594. */
  137595. removeImpostor(impostor: PhysicsImpostor): void;
  137596. /**
  137597. * Add a joint to the physics engine
  137598. * @param mainImpostor defines the main impostor to which the joint is added.
  137599. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  137600. * @param joint defines the joint that will connect both impostors.
  137601. */
  137602. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  137603. /**
  137604. * Removes a joint from the simulation
  137605. * @param mainImpostor defines the impostor used with the joint
  137606. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  137607. * @param joint defines the joint to remove
  137608. */
  137609. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  137610. /**
  137611. * Called by the scene. No need to call it.
  137612. * @param delta defines the timespam between frames
  137613. */
  137614. _step(delta: number): void;
  137615. /**
  137616. * Gets the current plugin used to run the simulation
  137617. * @returns current plugin
  137618. */
  137619. getPhysicsPlugin(): IPhysicsEnginePlugin;
  137620. /**
  137621. * Gets the list of physic impostors
  137622. * @returns an array of PhysicsImpostor
  137623. */
  137624. getImpostors(): Array<PhysicsImpostor>;
  137625. /**
  137626. * Gets the impostor for a physics enabled object
  137627. * @param object defines the object impersonated by the impostor
  137628. * @returns the PhysicsImpostor or null if not found
  137629. */
  137630. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  137631. /**
  137632. * Gets the impostor for a physics body object
  137633. * @param body defines physics body used by the impostor
  137634. * @returns the PhysicsImpostor or null if not found
  137635. */
  137636. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  137637. /**
  137638. * Does a raycast in the physics world
  137639. * @param from when should the ray start?
  137640. * @param to when should the ray end?
  137641. * @returns PhysicsRaycastResult
  137642. */
  137643. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137644. }
  137645. }
  137646. declare module BABYLON {
  137647. /** @hidden */
  137648. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  137649. private _useDeltaForWorldStep;
  137650. world: any;
  137651. name: string;
  137652. private _physicsMaterials;
  137653. private _fixedTimeStep;
  137654. private _cannonRaycastResult;
  137655. private _raycastResult;
  137656. private _physicsBodysToRemoveAfterStep;
  137657. private _firstFrame;
  137658. BJSCANNON: any;
  137659. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  137660. setGravity(gravity: Vector3): void;
  137661. setTimeStep(timeStep: number): void;
  137662. getTimeStep(): number;
  137663. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  137664. private _removeMarkedPhysicsBodiesFromWorld;
  137665. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137666. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137667. generatePhysicsBody(impostor: PhysicsImpostor): void;
  137668. private _processChildMeshes;
  137669. removePhysicsBody(impostor: PhysicsImpostor): void;
  137670. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  137671. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  137672. private _addMaterial;
  137673. private _checkWithEpsilon;
  137674. private _createShape;
  137675. private _createHeightmap;
  137676. private _minus90X;
  137677. private _plus90X;
  137678. private _tmpPosition;
  137679. private _tmpDeltaPosition;
  137680. private _tmpUnityRotation;
  137681. private _updatePhysicsBodyTransformation;
  137682. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  137683. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  137684. isSupported(): boolean;
  137685. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137686. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137687. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137688. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137689. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  137690. getBodyMass(impostor: PhysicsImpostor): number;
  137691. getBodyFriction(impostor: PhysicsImpostor): number;
  137692. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  137693. getBodyRestitution(impostor: PhysicsImpostor): number;
  137694. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  137695. sleepBody(impostor: PhysicsImpostor): void;
  137696. wakeUpBody(impostor: PhysicsImpostor): void;
  137697. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  137698. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  137699. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  137700. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  137701. getRadius(impostor: PhysicsImpostor): number;
  137702. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  137703. dispose(): void;
  137704. private _extendNamespace;
  137705. /**
  137706. * Does a raycast in the physics world
  137707. * @param from when should the ray start?
  137708. * @param to when should the ray end?
  137709. * @returns PhysicsRaycastResult
  137710. */
  137711. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137712. }
  137713. }
  137714. declare module BABYLON {
  137715. /** @hidden */
  137716. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  137717. private _useDeltaForWorldStep;
  137718. world: any;
  137719. name: string;
  137720. BJSOIMO: any;
  137721. private _raycastResult;
  137722. private _fixedTimeStep;
  137723. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  137724. setGravity(gravity: Vector3): void;
  137725. setTimeStep(timeStep: number): void;
  137726. getTimeStep(): number;
  137727. private _tmpImpostorsArray;
  137728. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  137729. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137730. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137731. generatePhysicsBody(impostor: PhysicsImpostor): void;
  137732. private _tmpPositionVector;
  137733. removePhysicsBody(impostor: PhysicsImpostor): void;
  137734. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  137735. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  137736. isSupported(): boolean;
  137737. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  137738. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  137739. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137740. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137741. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137742. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137743. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  137744. getBodyMass(impostor: PhysicsImpostor): number;
  137745. getBodyFriction(impostor: PhysicsImpostor): number;
  137746. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  137747. getBodyRestitution(impostor: PhysicsImpostor): number;
  137748. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  137749. sleepBody(impostor: PhysicsImpostor): void;
  137750. wakeUpBody(impostor: PhysicsImpostor): void;
  137751. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  137752. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  137753. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  137754. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  137755. getRadius(impostor: PhysicsImpostor): number;
  137756. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  137757. dispose(): void;
  137758. /**
  137759. * Does a raycast in the physics world
  137760. * @param from when should the ray start?
  137761. * @param to when should the ray end?
  137762. * @returns PhysicsRaycastResult
  137763. */
  137764. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137765. }
  137766. }
  137767. declare module BABYLON {
  137768. /**
  137769. * Class containing static functions to help procedurally build meshes
  137770. */
  137771. export class RibbonBuilder {
  137772. /**
  137773. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  137774. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  137775. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  137776. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  137777. * * 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
  137778. * * 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
  137779. * * 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
  137780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137781. * * 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
  137782. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  137783. * * 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
  137784. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  137785. * * 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
  137786. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  137787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137788. * @param name defines the name of the mesh
  137789. * @param options defines the options used to create the mesh
  137790. * @param scene defines the hosting scene
  137791. * @returns the ribbon mesh
  137792. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  137793. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137794. */
  137795. static CreateRibbon(name: string, options: {
  137796. pathArray: Vector3[][];
  137797. closeArray?: boolean;
  137798. closePath?: boolean;
  137799. offset?: number;
  137800. updatable?: boolean;
  137801. sideOrientation?: number;
  137802. frontUVs?: Vector4;
  137803. backUVs?: Vector4;
  137804. instance?: Mesh;
  137805. invertUV?: boolean;
  137806. uvs?: Vector2[];
  137807. colors?: Color4[];
  137808. }, scene?: Nullable<Scene>): Mesh;
  137809. }
  137810. }
  137811. declare module BABYLON {
  137812. /**
  137813. * Class containing static functions to help procedurally build meshes
  137814. */
  137815. export class ShapeBuilder {
  137816. /**
  137817. * 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.
  137818. * * 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.
  137819. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  137820. * * 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.
  137821. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  137822. * * 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
  137823. * * 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
  137824. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  137825. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137826. * * 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
  137827. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  137828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  137829. * @param name defines the name of the mesh
  137830. * @param options defines the options used to create the mesh
  137831. * @param scene defines the hosting scene
  137832. * @returns the extruded shape mesh
  137833. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137834. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  137835. */
  137836. static ExtrudeShape(name: string, options: {
  137837. shape: Vector3[];
  137838. path: Vector3[];
  137839. scale?: number;
  137840. rotation?: number;
  137841. cap?: number;
  137842. updatable?: boolean;
  137843. sideOrientation?: number;
  137844. frontUVs?: Vector4;
  137845. backUVs?: Vector4;
  137846. instance?: Mesh;
  137847. invertUV?: boolean;
  137848. }, scene?: Nullable<Scene>): Mesh;
  137849. /**
  137850. * Creates an custom extruded shape mesh.
  137851. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  137852. * * 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.
  137853. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  137854. * * 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
  137855. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  137856. * * 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
  137857. * * It must returns a float value that will be the scale value applied to the shape on each path point
  137858. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  137859. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  137860. * * 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
  137861. * * 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
  137862. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  137863. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137864. * * 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
  137865. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  137866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137867. * @param name defines the name of the mesh
  137868. * @param options defines the options used to create the mesh
  137869. * @param scene defines the hosting scene
  137870. * @returns the custom extruded shape mesh
  137871. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  137872. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137873. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  137874. */
  137875. static ExtrudeShapeCustom(name: string, options: {
  137876. shape: Vector3[];
  137877. path: Vector3[];
  137878. scaleFunction?: any;
  137879. rotationFunction?: any;
  137880. ribbonCloseArray?: boolean;
  137881. ribbonClosePath?: boolean;
  137882. cap?: number;
  137883. updatable?: boolean;
  137884. sideOrientation?: number;
  137885. frontUVs?: Vector4;
  137886. backUVs?: Vector4;
  137887. instance?: Mesh;
  137888. invertUV?: boolean;
  137889. }, scene?: Nullable<Scene>): Mesh;
  137890. private static _ExtrudeShapeGeneric;
  137891. }
  137892. }
  137893. declare module BABYLON {
  137894. /**
  137895. * AmmoJS Physics plugin
  137896. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  137897. * @see https://github.com/kripken/ammo.js/
  137898. */
  137899. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  137900. private _useDeltaForWorldStep;
  137901. /**
  137902. * Reference to the Ammo library
  137903. */
  137904. bjsAMMO: any;
  137905. /**
  137906. * Created ammoJS world which physics bodies are added to
  137907. */
  137908. world: any;
  137909. /**
  137910. * Name of the plugin
  137911. */
  137912. name: string;
  137913. private _timeStep;
  137914. private _fixedTimeStep;
  137915. private _maxSteps;
  137916. private _tmpQuaternion;
  137917. private _tmpAmmoTransform;
  137918. private _tmpAmmoQuaternion;
  137919. private _tmpAmmoConcreteContactResultCallback;
  137920. private _collisionConfiguration;
  137921. private _dispatcher;
  137922. private _overlappingPairCache;
  137923. private _solver;
  137924. private _softBodySolver;
  137925. private _tmpAmmoVectorA;
  137926. private _tmpAmmoVectorB;
  137927. private _tmpAmmoVectorC;
  137928. private _tmpAmmoVectorD;
  137929. private _tmpContactCallbackResult;
  137930. private _tmpAmmoVectorRCA;
  137931. private _tmpAmmoVectorRCB;
  137932. private _raycastResult;
  137933. private static readonly DISABLE_COLLISION_FLAG;
  137934. private static readonly KINEMATIC_FLAG;
  137935. private static readonly DISABLE_DEACTIVATION_FLAG;
  137936. /**
  137937. * Initializes the ammoJS plugin
  137938. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  137939. * @param ammoInjection can be used to inject your own ammo reference
  137940. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  137941. */
  137942. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  137943. /**
  137944. * Sets the gravity of the physics world (m/(s^2))
  137945. * @param gravity Gravity to set
  137946. */
  137947. setGravity(gravity: Vector3): void;
  137948. /**
  137949. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  137950. * @param timeStep timestep to use in seconds
  137951. */
  137952. setTimeStep(timeStep: number): void;
  137953. /**
  137954. * 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)
  137955. * @param fixedTimeStep fixedTimeStep to use in seconds
  137956. */
  137957. setFixedTimeStep(fixedTimeStep: number): void;
  137958. /**
  137959. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  137960. * @param maxSteps the maximum number of steps by the physics engine per frame
  137961. */
  137962. setMaxSteps(maxSteps: number): void;
  137963. /**
  137964. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  137965. * @returns the current timestep in seconds
  137966. */
  137967. getTimeStep(): number;
  137968. /**
  137969. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  137970. */
  137971. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  137972. private _isImpostorInContact;
  137973. private _isImpostorPairInContact;
  137974. private _stepSimulation;
  137975. /**
  137976. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  137977. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  137978. * After the step the babylon meshes are set to the position of the physics imposters
  137979. * @param delta amount of time to step forward
  137980. * @param impostors array of imposters to update before/after the step
  137981. */
  137982. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  137983. /**
  137984. * Update babylon mesh to match physics world object
  137985. * @param impostor imposter to match
  137986. */
  137987. private _afterSoftStep;
  137988. /**
  137989. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  137990. * @param impostor imposter to match
  137991. */
  137992. private _ropeStep;
  137993. /**
  137994. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  137995. * @param impostor imposter to match
  137996. */
  137997. private _softbodyOrClothStep;
  137998. private _tmpMatrix;
  137999. /**
  138000. * Applies an impulse on the imposter
  138001. * @param impostor imposter to apply impulse to
  138002. * @param force amount of force to be applied to the imposter
  138003. * @param contactPoint the location to apply the impulse on the imposter
  138004. */
  138005. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  138006. /**
  138007. * Applies a force on the imposter
  138008. * @param impostor imposter to apply force
  138009. * @param force amount of force to be applied to the imposter
  138010. * @param contactPoint the location to apply the force on the imposter
  138011. */
  138012. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  138013. /**
  138014. * Creates a physics body using the plugin
  138015. * @param impostor the imposter to create the physics body on
  138016. */
  138017. generatePhysicsBody(impostor: PhysicsImpostor): void;
  138018. /**
  138019. * Removes the physics body from the imposter and disposes of the body's memory
  138020. * @param impostor imposter to remove the physics body from
  138021. */
  138022. removePhysicsBody(impostor: PhysicsImpostor): void;
  138023. /**
  138024. * Generates a joint
  138025. * @param impostorJoint the imposter joint to create the joint with
  138026. */
  138027. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  138028. /**
  138029. * Removes a joint
  138030. * @param impostorJoint the imposter joint to remove the joint from
  138031. */
  138032. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  138033. private _addMeshVerts;
  138034. /**
  138035. * Initialise the soft body vertices to match its object's (mesh) vertices
  138036. * Softbody vertices (nodes) are in world space and to match this
  138037. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  138038. * @param impostor to create the softbody for
  138039. */
  138040. private _softVertexData;
  138041. /**
  138042. * Create an impostor's soft body
  138043. * @param impostor to create the softbody for
  138044. */
  138045. private _createSoftbody;
  138046. /**
  138047. * Create cloth for an impostor
  138048. * @param impostor to create the softbody for
  138049. */
  138050. private _createCloth;
  138051. /**
  138052. * Create rope for an impostor
  138053. * @param impostor to create the softbody for
  138054. */
  138055. private _createRope;
  138056. /**
  138057. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  138058. * @param impostor to create the custom physics shape for
  138059. */
  138060. private _createCustom;
  138061. private _addHullVerts;
  138062. private _createShape;
  138063. /**
  138064. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  138065. * @param impostor imposter containing the physics body and babylon object
  138066. */
  138067. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  138068. /**
  138069. * Sets the babylon object's position/rotation from the physics body's position/rotation
  138070. * @param impostor imposter containing the physics body and babylon object
  138071. * @param newPosition new position
  138072. * @param newRotation new rotation
  138073. */
  138074. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  138075. /**
  138076. * If this plugin is supported
  138077. * @returns true if its supported
  138078. */
  138079. isSupported(): boolean;
  138080. /**
  138081. * Sets the linear velocity of the physics body
  138082. * @param impostor imposter to set the velocity on
  138083. * @param velocity velocity to set
  138084. */
  138085. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  138086. /**
  138087. * Sets the angular velocity of the physics body
  138088. * @param impostor imposter to set the velocity on
  138089. * @param velocity velocity to set
  138090. */
  138091. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  138092. /**
  138093. * gets the linear velocity
  138094. * @param impostor imposter to get linear velocity from
  138095. * @returns linear velocity
  138096. */
  138097. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  138098. /**
  138099. * gets the angular velocity
  138100. * @param impostor imposter to get angular velocity from
  138101. * @returns angular velocity
  138102. */
  138103. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  138104. /**
  138105. * Sets the mass of physics body
  138106. * @param impostor imposter to set the mass on
  138107. * @param mass mass to set
  138108. */
  138109. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  138110. /**
  138111. * Gets the mass of the physics body
  138112. * @param impostor imposter to get the mass from
  138113. * @returns mass
  138114. */
  138115. getBodyMass(impostor: PhysicsImpostor): number;
  138116. /**
  138117. * Gets friction of the impostor
  138118. * @param impostor impostor to get friction from
  138119. * @returns friction value
  138120. */
  138121. getBodyFriction(impostor: PhysicsImpostor): number;
  138122. /**
  138123. * Sets friction of the impostor
  138124. * @param impostor impostor to set friction on
  138125. * @param friction friction value
  138126. */
  138127. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  138128. /**
  138129. * Gets restitution of the impostor
  138130. * @param impostor impostor to get restitution from
  138131. * @returns restitution value
  138132. */
  138133. getBodyRestitution(impostor: PhysicsImpostor): number;
  138134. /**
  138135. * Sets resitution of the impostor
  138136. * @param impostor impostor to set resitution on
  138137. * @param restitution resitution value
  138138. */
  138139. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  138140. /**
  138141. * Gets pressure inside the impostor
  138142. * @param impostor impostor to get pressure from
  138143. * @returns pressure value
  138144. */
  138145. getBodyPressure(impostor: PhysicsImpostor): number;
  138146. /**
  138147. * Sets pressure inside a soft body impostor
  138148. * Cloth and rope must remain 0 pressure
  138149. * @param impostor impostor to set pressure on
  138150. * @param pressure pressure value
  138151. */
  138152. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  138153. /**
  138154. * Gets stiffness of the impostor
  138155. * @param impostor impostor to get stiffness from
  138156. * @returns pressure value
  138157. */
  138158. getBodyStiffness(impostor: PhysicsImpostor): number;
  138159. /**
  138160. * Sets stiffness of the impostor
  138161. * @param impostor impostor to set stiffness on
  138162. * @param stiffness stiffness value from 0 to 1
  138163. */
  138164. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  138165. /**
  138166. * Gets velocityIterations of the impostor
  138167. * @param impostor impostor to get velocity iterations from
  138168. * @returns velocityIterations value
  138169. */
  138170. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  138171. /**
  138172. * Sets velocityIterations of the impostor
  138173. * @param impostor impostor to set velocity iterations on
  138174. * @param velocityIterations velocityIterations value
  138175. */
  138176. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  138177. /**
  138178. * Gets positionIterations of the impostor
  138179. * @param impostor impostor to get position iterations from
  138180. * @returns positionIterations value
  138181. */
  138182. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  138183. /**
  138184. * Sets positionIterations of the impostor
  138185. * @param impostor impostor to set position on
  138186. * @param positionIterations positionIterations value
  138187. */
  138188. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  138189. /**
  138190. * Append an anchor to a cloth object
  138191. * @param impostor is the cloth impostor to add anchor to
  138192. * @param otherImpostor is the rigid impostor to anchor to
  138193. * @param width ratio across width from 0 to 1
  138194. * @param height ratio up height from 0 to 1
  138195. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  138196. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  138197. */
  138198. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  138199. /**
  138200. * Append an hook to a rope object
  138201. * @param impostor is the rope impostor to add hook to
  138202. * @param otherImpostor is the rigid impostor to hook to
  138203. * @param length ratio along the rope from 0 to 1
  138204. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  138205. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  138206. */
  138207. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  138208. /**
  138209. * Sleeps the physics body and stops it from being active
  138210. * @param impostor impostor to sleep
  138211. */
  138212. sleepBody(impostor: PhysicsImpostor): void;
  138213. /**
  138214. * Activates the physics body
  138215. * @param impostor impostor to activate
  138216. */
  138217. wakeUpBody(impostor: PhysicsImpostor): void;
  138218. /**
  138219. * Updates the distance parameters of the joint
  138220. * @param joint joint to update
  138221. * @param maxDistance maximum distance of the joint
  138222. * @param minDistance minimum distance of the joint
  138223. */
  138224. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  138225. /**
  138226. * Sets a motor on the joint
  138227. * @param joint joint to set motor on
  138228. * @param speed speed of the motor
  138229. * @param maxForce maximum force of the motor
  138230. * @param motorIndex index of the motor
  138231. */
  138232. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  138233. /**
  138234. * Sets the motors limit
  138235. * @param joint joint to set limit on
  138236. * @param upperLimit upper limit
  138237. * @param lowerLimit lower limit
  138238. */
  138239. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  138240. /**
  138241. * Syncs the position and rotation of a mesh with the impostor
  138242. * @param mesh mesh to sync
  138243. * @param impostor impostor to update the mesh with
  138244. */
  138245. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  138246. /**
  138247. * Gets the radius of the impostor
  138248. * @param impostor impostor to get radius from
  138249. * @returns the radius
  138250. */
  138251. getRadius(impostor: PhysicsImpostor): number;
  138252. /**
  138253. * Gets the box size of the impostor
  138254. * @param impostor impostor to get box size from
  138255. * @param result the resulting box size
  138256. */
  138257. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  138258. /**
  138259. * Disposes of the impostor
  138260. */
  138261. dispose(): void;
  138262. /**
  138263. * Does a raycast in the physics world
  138264. * @param from when should the ray start?
  138265. * @param to when should the ray end?
  138266. * @returns PhysicsRaycastResult
  138267. */
  138268. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  138269. }
  138270. }
  138271. declare module BABYLON {
  138272. interface AbstractScene {
  138273. /**
  138274. * The list of reflection probes added to the scene
  138275. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  138276. */
  138277. reflectionProbes: Array<ReflectionProbe>;
  138278. /**
  138279. * Removes the given reflection probe from this scene.
  138280. * @param toRemove The reflection probe to remove
  138281. * @returns The index of the removed reflection probe
  138282. */
  138283. removeReflectionProbe(toRemove: ReflectionProbe): number;
  138284. /**
  138285. * Adds the given reflection probe to this scene.
  138286. * @param newReflectionProbe The reflection probe to add
  138287. */
  138288. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  138289. }
  138290. /**
  138291. * Class used to generate realtime reflection / refraction cube textures
  138292. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  138293. */
  138294. export class ReflectionProbe {
  138295. /** defines the name of the probe */
  138296. name: string;
  138297. private _scene;
  138298. private _renderTargetTexture;
  138299. private _projectionMatrix;
  138300. private _viewMatrix;
  138301. private _target;
  138302. private _add;
  138303. private _attachedMesh;
  138304. private _invertYAxis;
  138305. /** Gets or sets probe position (center of the cube map) */
  138306. position: Vector3;
  138307. /**
  138308. * Creates a new reflection probe
  138309. * @param name defines the name of the probe
  138310. * @param size defines the texture resolution (for each face)
  138311. * @param scene defines the hosting scene
  138312. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  138313. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  138314. */
  138315. constructor(
  138316. /** defines the name of the probe */
  138317. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  138318. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  138319. get samples(): number;
  138320. set samples(value: number);
  138321. /** Gets or sets the refresh rate to use (on every frame by default) */
  138322. get refreshRate(): number;
  138323. set refreshRate(value: number);
  138324. /**
  138325. * Gets the hosting scene
  138326. * @returns a Scene
  138327. */
  138328. getScene(): Scene;
  138329. /** Gets the internal CubeTexture used to render to */
  138330. get cubeTexture(): RenderTargetTexture;
  138331. /** Gets the list of meshes to render */
  138332. get renderList(): Nullable<AbstractMesh[]>;
  138333. /**
  138334. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  138335. * @param mesh defines the mesh to attach to
  138336. */
  138337. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  138338. /**
  138339. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  138340. * @param renderingGroupId The rendering group id corresponding to its index
  138341. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  138342. */
  138343. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  138344. /**
  138345. * Clean all associated resources
  138346. */
  138347. dispose(): void;
  138348. /**
  138349. * Converts the reflection probe information to a readable string for debug purpose.
  138350. * @param fullDetails Supports for multiple levels of logging within scene loading
  138351. * @returns the human readable reflection probe info
  138352. */
  138353. toString(fullDetails?: boolean): string;
  138354. /**
  138355. * Get the class name of the relfection probe.
  138356. * @returns "ReflectionProbe"
  138357. */
  138358. getClassName(): string;
  138359. /**
  138360. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  138361. * @returns The JSON representation of the texture
  138362. */
  138363. serialize(): any;
  138364. /**
  138365. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  138366. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  138367. * @param scene Define the scene the parsed reflection probe should be instantiated in
  138368. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  138369. * @returns The parsed reflection probe if successful
  138370. */
  138371. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  138372. }
  138373. }
  138374. declare module BABYLON {
  138375. /** @hidden */
  138376. export var _BabylonLoaderRegistered: boolean;
  138377. /**
  138378. * Helps setting up some configuration for the babylon file loader.
  138379. */
  138380. export class BabylonFileLoaderConfiguration {
  138381. /**
  138382. * The loader does not allow injecting custom physix engine into the plugins.
  138383. * Unfortunately in ES6, we need to manually inject them into the plugin.
  138384. * So you could set this variable to your engine import to make it work.
  138385. */
  138386. static LoaderInjectedPhysicsEngine: any;
  138387. }
  138388. }
  138389. declare module BABYLON {
  138390. /**
  138391. * The Physically based simple base material of BJS.
  138392. *
  138393. * This enables better naming and convention enforcements on top of the pbrMaterial.
  138394. * It is used as the base class for both the specGloss and metalRough conventions.
  138395. */
  138396. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  138397. /**
  138398. * Number of Simultaneous lights allowed on the material.
  138399. */
  138400. maxSimultaneousLights: number;
  138401. /**
  138402. * If sets to true, disables all the lights affecting the material.
  138403. */
  138404. disableLighting: boolean;
  138405. /**
  138406. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  138407. */
  138408. environmentTexture: BaseTexture;
  138409. /**
  138410. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  138411. */
  138412. invertNormalMapX: boolean;
  138413. /**
  138414. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  138415. */
  138416. invertNormalMapY: boolean;
  138417. /**
  138418. * Normal map used in the model.
  138419. */
  138420. normalTexture: BaseTexture;
  138421. /**
  138422. * Emissivie color used to self-illuminate the model.
  138423. */
  138424. emissiveColor: Color3;
  138425. /**
  138426. * Emissivie texture used to self-illuminate the model.
  138427. */
  138428. emissiveTexture: BaseTexture;
  138429. /**
  138430. * Occlusion Channel Strenght.
  138431. */
  138432. occlusionStrength: number;
  138433. /**
  138434. * Occlusion Texture of the material (adding extra occlusion effects).
  138435. */
  138436. occlusionTexture: BaseTexture;
  138437. /**
  138438. * Defines the alpha limits in alpha test mode.
  138439. */
  138440. alphaCutOff: number;
  138441. /**
  138442. * Gets the current double sided mode.
  138443. */
  138444. get doubleSided(): boolean;
  138445. /**
  138446. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  138447. */
  138448. set doubleSided(value: boolean);
  138449. /**
  138450. * Stores the pre-calculated light information of a mesh in a texture.
  138451. */
  138452. lightmapTexture: BaseTexture;
  138453. /**
  138454. * If true, the light map contains occlusion information instead of lighting info.
  138455. */
  138456. useLightmapAsShadowmap: boolean;
  138457. /**
  138458. * Instantiates a new PBRMaterial instance.
  138459. *
  138460. * @param name The material name
  138461. * @param scene The scene the material will be use in.
  138462. */
  138463. constructor(name: string, scene: Scene);
  138464. getClassName(): string;
  138465. }
  138466. }
  138467. declare module BABYLON {
  138468. /**
  138469. * The PBR material of BJS following the metal roughness convention.
  138470. *
  138471. * This fits to the PBR convention in the GLTF definition:
  138472. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  138473. */
  138474. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  138475. /**
  138476. * The base color has two different interpretations depending on the value of metalness.
  138477. * When the material is a metal, the base color is the specific measured reflectance value
  138478. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  138479. * of the material.
  138480. */
  138481. baseColor: Color3;
  138482. /**
  138483. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  138484. * well as opacity information in the alpha channel.
  138485. */
  138486. baseTexture: BaseTexture;
  138487. /**
  138488. * Specifies the metallic scalar value of the material.
  138489. * Can also be used to scale the metalness values of the metallic texture.
  138490. */
  138491. metallic: number;
  138492. /**
  138493. * Specifies the roughness scalar value of the material.
  138494. * Can also be used to scale the roughness values of the metallic texture.
  138495. */
  138496. roughness: number;
  138497. /**
  138498. * Texture containing both the metallic value in the B channel and the
  138499. * roughness value in the G channel to keep better precision.
  138500. */
  138501. metallicRoughnessTexture: BaseTexture;
  138502. /**
  138503. * Instantiates a new PBRMetalRoughnessMaterial instance.
  138504. *
  138505. * @param name The material name
  138506. * @param scene The scene the material will be use in.
  138507. */
  138508. constructor(name: string, scene: Scene);
  138509. /**
  138510. * Return the currrent class name of the material.
  138511. */
  138512. getClassName(): string;
  138513. /**
  138514. * Makes a duplicate of the current material.
  138515. * @param name - name to use for the new material.
  138516. */
  138517. clone(name: string): PBRMetallicRoughnessMaterial;
  138518. /**
  138519. * Serialize the material to a parsable JSON object.
  138520. */
  138521. serialize(): any;
  138522. /**
  138523. * Parses a JSON object correponding to the serialize function.
  138524. */
  138525. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  138526. }
  138527. }
  138528. declare module BABYLON {
  138529. /**
  138530. * The PBR material of BJS following the specular glossiness convention.
  138531. *
  138532. * This fits to the PBR convention in the GLTF definition:
  138533. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  138534. */
  138535. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  138536. /**
  138537. * Specifies the diffuse color of the material.
  138538. */
  138539. diffuseColor: Color3;
  138540. /**
  138541. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  138542. * channel.
  138543. */
  138544. diffuseTexture: BaseTexture;
  138545. /**
  138546. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  138547. */
  138548. specularColor: Color3;
  138549. /**
  138550. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  138551. */
  138552. glossiness: number;
  138553. /**
  138554. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  138555. */
  138556. specularGlossinessTexture: BaseTexture;
  138557. /**
  138558. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  138559. *
  138560. * @param name The material name
  138561. * @param scene The scene the material will be use in.
  138562. */
  138563. constructor(name: string, scene: Scene);
  138564. /**
  138565. * Return the currrent class name of the material.
  138566. */
  138567. getClassName(): string;
  138568. /**
  138569. * Makes a duplicate of the current material.
  138570. * @param name - name to use for the new material.
  138571. */
  138572. clone(name: string): PBRSpecularGlossinessMaterial;
  138573. /**
  138574. * Serialize the material to a parsable JSON object.
  138575. */
  138576. serialize(): any;
  138577. /**
  138578. * Parses a JSON object correponding to the serialize function.
  138579. */
  138580. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  138581. }
  138582. }
  138583. declare module BABYLON {
  138584. /**
  138585. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  138586. * It can help converting any input color in a desired output one. This can then be used to create effects
  138587. * from sepia, black and white to sixties or futuristic rendering...
  138588. *
  138589. * The only supported format is currently 3dl.
  138590. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  138591. */
  138592. export class ColorGradingTexture extends BaseTexture {
  138593. /**
  138594. * The texture URL.
  138595. */
  138596. url: string;
  138597. /**
  138598. * Empty line regex stored for GC.
  138599. */
  138600. private static _noneEmptyLineRegex;
  138601. private _textureMatrix;
  138602. private _onLoad;
  138603. /**
  138604. * Instantiates a ColorGradingTexture from the following parameters.
  138605. *
  138606. * @param url The location of the color gradind data (currently only supporting 3dl)
  138607. * @param sceneOrEngine The scene or engine the texture will be used in
  138608. * @param onLoad defines a callback triggered when the texture has been loaded
  138609. */
  138610. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  138611. /**
  138612. * Fires the onload event from the constructor if requested.
  138613. */
  138614. private _triggerOnLoad;
  138615. /**
  138616. * Returns the texture matrix used in most of the material.
  138617. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  138618. */
  138619. getTextureMatrix(): Matrix;
  138620. /**
  138621. * Occurs when the file being loaded is a .3dl LUT file.
  138622. */
  138623. private load3dlTexture;
  138624. /**
  138625. * Starts the loading process of the texture.
  138626. */
  138627. private loadTexture;
  138628. /**
  138629. * Clones the color gradind texture.
  138630. */
  138631. clone(): ColorGradingTexture;
  138632. /**
  138633. * Called during delayed load for textures.
  138634. */
  138635. delayLoad(): void;
  138636. /**
  138637. * Parses a color grading texture serialized by Babylon.
  138638. * @param parsedTexture The texture information being parsedTexture
  138639. * @param scene The scene to load the texture in
  138640. * @param rootUrl The root url of the data assets to load
  138641. * @return A color gradind texture
  138642. */
  138643. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  138644. /**
  138645. * Serializes the LUT texture to json format.
  138646. */
  138647. serialize(): any;
  138648. }
  138649. }
  138650. declare module BABYLON {
  138651. /**
  138652. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  138653. */
  138654. export class EquiRectangularCubeTexture extends BaseTexture {
  138655. /** The six faces of the cube. */
  138656. private static _FacesMapping;
  138657. private _noMipmap;
  138658. private _onLoad;
  138659. private _onError;
  138660. /** The size of the cubemap. */
  138661. private _size;
  138662. /** The buffer of the image. */
  138663. private _buffer;
  138664. /** The width of the input image. */
  138665. private _width;
  138666. /** The height of the input image. */
  138667. private _height;
  138668. /** The URL to the image. */
  138669. url: string;
  138670. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  138671. coordinatesMode: number;
  138672. /**
  138673. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  138674. * @param url The location of the image
  138675. * @param scene The scene the texture will be used in
  138676. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  138677. * @param noMipmap Forces to not generate the mipmap if true
  138678. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  138679. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  138680. * @param onLoad — defines a callback called when texture is loaded
  138681. * @param onError — defines a callback called if there is an error
  138682. */
  138683. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  138684. /**
  138685. * Load the image data, by putting the image on a canvas and extracting its buffer.
  138686. */
  138687. private loadImage;
  138688. /**
  138689. * Convert the image buffer into a cubemap and create a CubeTexture.
  138690. */
  138691. private loadTexture;
  138692. /**
  138693. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  138694. * @param buffer The ArrayBuffer that should be converted.
  138695. * @returns The buffer as Float32Array.
  138696. */
  138697. private getFloat32ArrayFromArrayBuffer;
  138698. /**
  138699. * Get the current class name of the texture useful for serialization or dynamic coding.
  138700. * @returns "EquiRectangularCubeTexture"
  138701. */
  138702. getClassName(): string;
  138703. /**
  138704. * Create a clone of the current EquiRectangularCubeTexture and return it.
  138705. * @returns A clone of the current EquiRectangularCubeTexture.
  138706. */
  138707. clone(): EquiRectangularCubeTexture;
  138708. }
  138709. }
  138710. declare module BABYLON {
  138711. /**
  138712. * Defines the options related to the creation of an HtmlElementTexture
  138713. */
  138714. export interface IHtmlElementTextureOptions {
  138715. /**
  138716. * Defines wether mip maps should be created or not.
  138717. */
  138718. generateMipMaps?: boolean;
  138719. /**
  138720. * Defines the sampling mode of the texture.
  138721. */
  138722. samplingMode?: number;
  138723. /**
  138724. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  138725. */
  138726. engine: Nullable<ThinEngine>;
  138727. /**
  138728. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  138729. */
  138730. scene: Nullable<Scene>;
  138731. }
  138732. /**
  138733. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  138734. * To be as efficient as possible depending on your constraints nothing aside the first upload
  138735. * is automatically managed.
  138736. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  138737. * in your application.
  138738. *
  138739. * As the update is not automatic, you need to call them manually.
  138740. */
  138741. export class HtmlElementTexture extends BaseTexture {
  138742. /**
  138743. * The texture URL.
  138744. */
  138745. element: HTMLVideoElement | HTMLCanvasElement;
  138746. private static readonly DefaultOptions;
  138747. private _textureMatrix;
  138748. private _isVideo;
  138749. private _generateMipMaps;
  138750. private _samplingMode;
  138751. /**
  138752. * Instantiates a HtmlElementTexture from the following parameters.
  138753. *
  138754. * @param name Defines the name of the texture
  138755. * @param element Defines the video or canvas the texture is filled with
  138756. * @param options Defines the other none mandatory texture creation options
  138757. */
  138758. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  138759. private _createInternalTexture;
  138760. /**
  138761. * Returns the texture matrix used in most of the material.
  138762. */
  138763. getTextureMatrix(): Matrix;
  138764. /**
  138765. * Updates the content of the texture.
  138766. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  138767. */
  138768. update(invertY?: Nullable<boolean>): void;
  138769. }
  138770. }
  138771. declare module BABYLON {
  138772. /**
  138773. * Based on jsTGALoader - Javascript loader for TGA file
  138774. * By Vincent Thibault
  138775. * @see http://blog.robrowser.com/javascript-tga-loader.html
  138776. */
  138777. export class TGATools {
  138778. private static _TYPE_INDEXED;
  138779. private static _TYPE_RGB;
  138780. private static _TYPE_GREY;
  138781. private static _TYPE_RLE_INDEXED;
  138782. private static _TYPE_RLE_RGB;
  138783. private static _TYPE_RLE_GREY;
  138784. private static _ORIGIN_MASK;
  138785. private static _ORIGIN_SHIFT;
  138786. private static _ORIGIN_BL;
  138787. private static _ORIGIN_BR;
  138788. private static _ORIGIN_UL;
  138789. private static _ORIGIN_UR;
  138790. /**
  138791. * Gets the header of a TGA file
  138792. * @param data defines the TGA data
  138793. * @returns the header
  138794. */
  138795. static GetTGAHeader(data: Uint8Array): any;
  138796. /**
  138797. * Uploads TGA content to a Babylon Texture
  138798. * @hidden
  138799. */
  138800. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  138801. /** @hidden */
  138802. 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;
  138803. /** @hidden */
  138804. 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;
  138805. /** @hidden */
  138806. 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;
  138807. /** @hidden */
  138808. 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;
  138809. /** @hidden */
  138810. 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;
  138811. /** @hidden */
  138812. 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;
  138813. }
  138814. }
  138815. declare module BABYLON {
  138816. /**
  138817. * Implementation of the TGA Texture Loader.
  138818. * @hidden
  138819. */
  138820. export class _TGATextureLoader implements IInternalTextureLoader {
  138821. /**
  138822. * Defines wether the loader supports cascade loading the different faces.
  138823. */
  138824. readonly supportCascades: boolean;
  138825. /**
  138826. * This returns if the loader support the current file information.
  138827. * @param extension defines the file extension of the file being loaded
  138828. * @returns true if the loader can load the specified file
  138829. */
  138830. canLoad(extension: string): boolean;
  138831. /**
  138832. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138833. * @param data contains the texture data
  138834. * @param texture defines the BabylonJS internal texture
  138835. * @param createPolynomials will be true if polynomials have been requested
  138836. * @param onLoad defines the callback to trigger once the texture is ready
  138837. * @param onError defines the callback to trigger in case of error
  138838. */
  138839. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138840. /**
  138841. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138842. * @param data contains the texture data
  138843. * @param texture defines the BabylonJS internal texture
  138844. * @param callback defines the method to call once ready to upload
  138845. */
  138846. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138847. }
  138848. }
  138849. declare module BABYLON {
  138850. /**
  138851. * Info about the .basis files
  138852. */
  138853. class BasisFileInfo {
  138854. /**
  138855. * If the file has alpha
  138856. */
  138857. hasAlpha: boolean;
  138858. /**
  138859. * Info about each image of the basis file
  138860. */
  138861. images: Array<{
  138862. levels: Array<{
  138863. width: number;
  138864. height: number;
  138865. transcodedPixels: ArrayBufferView;
  138866. }>;
  138867. }>;
  138868. }
  138869. /**
  138870. * Result of transcoding a basis file
  138871. */
  138872. class TranscodeResult {
  138873. /**
  138874. * Info about the .basis file
  138875. */
  138876. fileInfo: BasisFileInfo;
  138877. /**
  138878. * Format to use when loading the file
  138879. */
  138880. format: number;
  138881. }
  138882. /**
  138883. * Configuration options for the Basis transcoder
  138884. */
  138885. export class BasisTranscodeConfiguration {
  138886. /**
  138887. * Supported compression formats used to determine the supported output format of the transcoder
  138888. */
  138889. supportedCompressionFormats?: {
  138890. /**
  138891. * etc1 compression format
  138892. */
  138893. etc1?: boolean;
  138894. /**
  138895. * s3tc compression format
  138896. */
  138897. s3tc?: boolean;
  138898. /**
  138899. * pvrtc compression format
  138900. */
  138901. pvrtc?: boolean;
  138902. /**
  138903. * etc2 compression format
  138904. */
  138905. etc2?: boolean;
  138906. };
  138907. /**
  138908. * If mipmap levels should be loaded for transcoded images (Default: true)
  138909. */
  138910. loadMipmapLevels?: boolean;
  138911. /**
  138912. * Index of a single image to load (Default: all images)
  138913. */
  138914. loadSingleImage?: number;
  138915. }
  138916. /**
  138917. * Used to load .Basis files
  138918. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  138919. */
  138920. export class BasisTools {
  138921. private static _IgnoreSupportedFormats;
  138922. /**
  138923. * URL to use when loading the basis transcoder
  138924. */
  138925. static JSModuleURL: string;
  138926. /**
  138927. * URL to use when loading the wasm module for the transcoder
  138928. */
  138929. static WasmModuleURL: string;
  138930. /**
  138931. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  138932. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  138933. * @returns internal format corresponding to the Basis format
  138934. */
  138935. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  138936. private static _WorkerPromise;
  138937. private static _Worker;
  138938. private static _actionId;
  138939. private static _CreateWorkerAsync;
  138940. /**
  138941. * Transcodes a loaded image file to compressed pixel data
  138942. * @param data image data to transcode
  138943. * @param config configuration options for the transcoding
  138944. * @returns a promise resulting in the transcoded image
  138945. */
  138946. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  138947. /**
  138948. * Loads a texture from the transcode result
  138949. * @param texture texture load to
  138950. * @param transcodeResult the result of transcoding the basis file to load from
  138951. */
  138952. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  138953. }
  138954. }
  138955. declare module BABYLON {
  138956. /**
  138957. * Loader for .basis file format
  138958. */
  138959. export class _BasisTextureLoader implements IInternalTextureLoader {
  138960. /**
  138961. * Defines whether the loader supports cascade loading the different faces.
  138962. */
  138963. readonly supportCascades: boolean;
  138964. /**
  138965. * This returns if the loader support the current file information.
  138966. * @param extension defines the file extension of the file being loaded
  138967. * @returns true if the loader can load the specified file
  138968. */
  138969. canLoad(extension: string): boolean;
  138970. /**
  138971. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138972. * @param data contains the texture data
  138973. * @param texture defines the BabylonJS internal texture
  138974. * @param createPolynomials will be true if polynomials have been requested
  138975. * @param onLoad defines the callback to trigger once the texture is ready
  138976. * @param onError defines the callback to trigger in case of error
  138977. */
  138978. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138979. /**
  138980. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138981. * @param data contains the texture data
  138982. * @param texture defines the BabylonJS internal texture
  138983. * @param callback defines the method to call once ready to upload
  138984. */
  138985. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138986. }
  138987. }
  138988. declare module BABYLON {
  138989. /**
  138990. * Defines the basic options interface of a TexturePacker Frame
  138991. */
  138992. export interface ITexturePackerFrame {
  138993. /**
  138994. * The frame ID
  138995. */
  138996. id: number;
  138997. /**
  138998. * The frames Scale
  138999. */
  139000. scale: Vector2;
  139001. /**
  139002. * The Frames offset
  139003. */
  139004. offset: Vector2;
  139005. }
  139006. /**
  139007. * This is a support class for frame Data on texture packer sets.
  139008. */
  139009. export class TexturePackerFrame implements ITexturePackerFrame {
  139010. /**
  139011. * The frame ID
  139012. */
  139013. id: number;
  139014. /**
  139015. * The frames Scale
  139016. */
  139017. scale: Vector2;
  139018. /**
  139019. * The Frames offset
  139020. */
  139021. offset: Vector2;
  139022. /**
  139023. * Initializes a texture package frame.
  139024. * @param id The numerical frame identifier
  139025. * @param scale Scalar Vector2 for UV frame
  139026. * @param offset Vector2 for the frame position in UV units.
  139027. * @returns TexturePackerFrame
  139028. */
  139029. constructor(id: number, scale: Vector2, offset: Vector2);
  139030. }
  139031. }
  139032. declare module BABYLON {
  139033. /**
  139034. * Defines the basic options interface of a TexturePacker
  139035. */
  139036. export interface ITexturePackerOptions {
  139037. /**
  139038. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  139039. */
  139040. map?: string[];
  139041. /**
  139042. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  139043. */
  139044. uvsIn?: string;
  139045. /**
  139046. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  139047. */
  139048. uvsOut?: string;
  139049. /**
  139050. * number representing the layout style. Defaults to LAYOUT_STRIP
  139051. */
  139052. layout?: number;
  139053. /**
  139054. * number of columns if using custom column count layout(2). This defaults to 4.
  139055. */
  139056. colnum?: number;
  139057. /**
  139058. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  139059. */
  139060. updateInputMeshes?: boolean;
  139061. /**
  139062. * boolean flag to dispose all the source textures. Defaults to true.
  139063. */
  139064. disposeSources?: boolean;
  139065. /**
  139066. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  139067. */
  139068. fillBlanks?: boolean;
  139069. /**
  139070. * string value representing the context fill style color. Defaults to 'black'.
  139071. */
  139072. customFillColor?: string;
  139073. /**
  139074. * Width and Height Value of each Frame in the TexturePacker Sets
  139075. */
  139076. frameSize?: number;
  139077. /**
  139078. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  139079. */
  139080. paddingRatio?: number;
  139081. /**
  139082. * Number that declares the fill method for the padding gutter.
  139083. */
  139084. paddingMode?: number;
  139085. /**
  139086. * If in SUBUV_COLOR padding mode what color to use.
  139087. */
  139088. paddingColor?: Color3 | Color4;
  139089. }
  139090. /**
  139091. * Defines the basic interface of a TexturePacker JSON File
  139092. */
  139093. export interface ITexturePackerJSON {
  139094. /**
  139095. * The frame ID
  139096. */
  139097. name: string;
  139098. /**
  139099. * The base64 channel data
  139100. */
  139101. sets: any;
  139102. /**
  139103. * The options of the Packer
  139104. */
  139105. options: ITexturePackerOptions;
  139106. /**
  139107. * The frame data of the Packer
  139108. */
  139109. frames: Array<number>;
  139110. }
  139111. /**
  139112. * This is a support class that generates a series of packed texture sets.
  139113. * @see https://doc.babylonjs.com/babylon101/materials
  139114. */
  139115. export class TexturePacker {
  139116. /** Packer Layout Constant 0 */
  139117. static readonly LAYOUT_STRIP: number;
  139118. /** Packer Layout Constant 1 */
  139119. static readonly LAYOUT_POWER2: number;
  139120. /** Packer Layout Constant 2 */
  139121. static readonly LAYOUT_COLNUM: number;
  139122. /** Packer Layout Constant 0 */
  139123. static readonly SUBUV_WRAP: number;
  139124. /** Packer Layout Constant 1 */
  139125. static readonly SUBUV_EXTEND: number;
  139126. /** Packer Layout Constant 2 */
  139127. static readonly SUBUV_COLOR: number;
  139128. /** The Name of the Texture Package */
  139129. name: string;
  139130. /** The scene scope of the TexturePacker */
  139131. scene: Scene;
  139132. /** The Meshes to target */
  139133. meshes: AbstractMesh[];
  139134. /** Arguments passed with the Constructor */
  139135. options: ITexturePackerOptions;
  139136. /** The promise that is started upon initialization */
  139137. promise: Nullable<Promise<TexturePacker | string>>;
  139138. /** The Container object for the channel sets that are generated */
  139139. sets: object;
  139140. /** The Container array for the frames that are generated */
  139141. frames: TexturePackerFrame[];
  139142. /** The expected number of textures the system is parsing. */
  139143. private _expecting;
  139144. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  139145. private _paddingValue;
  139146. /**
  139147. * Initializes a texture package series from an array of meshes or a single mesh.
  139148. * @param name The name of the package
  139149. * @param meshes The target meshes to compose the package from
  139150. * @param options The arguments that texture packer should follow while building.
  139151. * @param scene The scene which the textures are scoped to.
  139152. * @returns TexturePacker
  139153. */
  139154. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  139155. /**
  139156. * Starts the package process
  139157. * @param resolve The promises resolution function
  139158. * @returns TexturePacker
  139159. */
  139160. private _createFrames;
  139161. /**
  139162. * Calculates the Size of the Channel Sets
  139163. * @returns Vector2
  139164. */
  139165. private _calculateSize;
  139166. /**
  139167. * Calculates the UV data for the frames.
  139168. * @param baseSize the base frameSize
  139169. * @param padding the base frame padding
  139170. * @param dtSize size of the Dynamic Texture for that channel
  139171. * @param dtUnits is 1/dtSize
  139172. * @param update flag to update the input meshes
  139173. */
  139174. private _calculateMeshUVFrames;
  139175. /**
  139176. * Calculates the frames Offset.
  139177. * @param index of the frame
  139178. * @returns Vector2
  139179. */
  139180. private _getFrameOffset;
  139181. /**
  139182. * Updates a Mesh to the frame data
  139183. * @param mesh that is the target
  139184. * @param frameID or the frame index
  139185. */
  139186. private _updateMeshUV;
  139187. /**
  139188. * Updates a Meshes materials to use the texture packer channels
  139189. * @param m is the mesh to target
  139190. * @param force all channels on the packer to be set.
  139191. */
  139192. private _updateTextureReferences;
  139193. /**
  139194. * Public method to set a Mesh to a frame
  139195. * @param m that is the target
  139196. * @param frameID or the frame index
  139197. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  139198. */
  139199. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  139200. /**
  139201. * Starts the async promise to compile the texture packer.
  139202. * @returns Promise<void>
  139203. */
  139204. processAsync(): Promise<void>;
  139205. /**
  139206. * Disposes all textures associated with this packer
  139207. */
  139208. dispose(): void;
  139209. /**
  139210. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  139211. * @param imageType is the image type to use.
  139212. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  139213. */
  139214. download(imageType?: string, quality?: number): void;
  139215. /**
  139216. * Public method to load a texturePacker JSON file.
  139217. * @param data of the JSON file in string format.
  139218. */
  139219. updateFromJSON(data: string): void;
  139220. }
  139221. }
  139222. declare module BABYLON {
  139223. /**
  139224. * 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.
  139225. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  139226. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  139227. */
  139228. export class CustomProceduralTexture extends ProceduralTexture {
  139229. private _animate;
  139230. private _time;
  139231. private _config;
  139232. private _texturePath;
  139233. /**
  139234. * Instantiates a new Custom Procedural Texture.
  139235. * 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.
  139236. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  139237. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  139238. * @param name Define the name of the texture
  139239. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  139240. * @param size Define the size of the texture to create
  139241. * @param scene Define the scene the texture belongs to
  139242. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  139243. * @param generateMipMaps Define if the texture should creates mip maps or not
  139244. */
  139245. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  139246. private _loadJson;
  139247. /**
  139248. * Is the texture ready to be used ? (rendered at least once)
  139249. * @returns true if ready, otherwise, false.
  139250. */
  139251. isReady(): boolean;
  139252. /**
  139253. * Render the texture to its associated render target.
  139254. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  139255. */
  139256. render(useCameraPostProcess?: boolean): void;
  139257. /**
  139258. * Update the list of dependant textures samplers in the shader.
  139259. */
  139260. updateTextures(): void;
  139261. /**
  139262. * Update the uniform values of the procedural texture in the shader.
  139263. */
  139264. updateShaderUniforms(): void;
  139265. /**
  139266. * Define if the texture animates or not.
  139267. */
  139268. get animate(): boolean;
  139269. set animate(value: boolean);
  139270. }
  139271. }
  139272. declare module BABYLON {
  139273. /** @hidden */
  139274. export var noisePixelShader: {
  139275. name: string;
  139276. shader: string;
  139277. };
  139278. }
  139279. declare module BABYLON {
  139280. /**
  139281. * Class used to generate noise procedural textures
  139282. */
  139283. export class NoiseProceduralTexture extends ProceduralTexture {
  139284. private _time;
  139285. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  139286. brightness: number;
  139287. /** Defines the number of octaves to process */
  139288. octaves: number;
  139289. /** Defines the level of persistence (0.8 by default) */
  139290. persistence: number;
  139291. /** Gets or sets animation speed factor (default is 1) */
  139292. animationSpeedFactor: number;
  139293. /**
  139294. * Creates a new NoiseProceduralTexture
  139295. * @param name defines the name fo the texture
  139296. * @param size defines the size of the texture (default is 256)
  139297. * @param scene defines the hosting scene
  139298. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  139299. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  139300. */
  139301. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  139302. private _updateShaderUniforms;
  139303. protected _getDefines(): string;
  139304. /** Generate the current state of the procedural texture */
  139305. render(useCameraPostProcess?: boolean): void;
  139306. /**
  139307. * Serializes this noise procedural texture
  139308. * @returns a serialized noise procedural texture object
  139309. */
  139310. serialize(): any;
  139311. /**
  139312. * Clone the texture.
  139313. * @returns the cloned texture
  139314. */
  139315. clone(): NoiseProceduralTexture;
  139316. /**
  139317. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  139318. * @param parsedTexture defines parsed texture data
  139319. * @param scene defines the current scene
  139320. * @param rootUrl defines the root URL containing noise procedural texture information
  139321. * @returns a parsed NoiseProceduralTexture
  139322. */
  139323. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  139324. }
  139325. }
  139326. declare module BABYLON {
  139327. /**
  139328. * Raw cube texture where the raw buffers are passed in
  139329. */
  139330. export class RawCubeTexture extends CubeTexture {
  139331. /**
  139332. * Creates a cube texture where the raw buffers are passed in.
  139333. * @param scene defines the scene the texture is attached to
  139334. * @param data defines the array of data to use to create each face
  139335. * @param size defines the size of the textures
  139336. * @param format defines the format of the data
  139337. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  139338. * @param generateMipMaps defines if the engine should generate the mip levels
  139339. * @param invertY defines if data must be stored with Y axis inverted
  139340. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  139341. * @param compression defines the compression used (null by default)
  139342. */
  139343. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  139344. /**
  139345. * Updates the raw cube texture.
  139346. * @param data defines the data to store
  139347. * @param format defines the data format
  139348. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  139349. * @param invertY defines if data must be stored with Y axis inverted
  139350. * @param compression defines the compression used (null by default)
  139351. * @param level defines which level of the texture to update
  139352. */
  139353. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  139354. /**
  139355. * Updates a raw cube texture with RGBD encoded data.
  139356. * @param data defines the array of data [mipmap][face] to use to create each face
  139357. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  139358. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  139359. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  139360. * @returns a promsie that resolves when the operation is complete
  139361. */
  139362. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  139363. /**
  139364. * Clones the raw cube texture.
  139365. * @return a new cube texture
  139366. */
  139367. clone(): CubeTexture;
  139368. /** @hidden */
  139369. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  139370. }
  139371. }
  139372. declare module BABYLON {
  139373. /**
  139374. * Class used to store 2D array textures containing user data
  139375. */
  139376. export class RawTexture2DArray extends Texture {
  139377. /** Gets or sets the texture format to use */
  139378. format: number;
  139379. /**
  139380. * Create a new RawTexture2DArray
  139381. * @param data defines the data of the texture
  139382. * @param width defines the width of the texture
  139383. * @param height defines the height of the texture
  139384. * @param depth defines the number of layers of the texture
  139385. * @param format defines the texture format to use
  139386. * @param scene defines the hosting scene
  139387. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  139388. * @param invertY defines if texture must be stored with Y axis inverted
  139389. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  139390. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  139391. */
  139392. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  139393. /** Gets or sets the texture format to use */
  139394. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  139395. /**
  139396. * Update the texture with new data
  139397. * @param data defines the data to store in the texture
  139398. */
  139399. update(data: ArrayBufferView): void;
  139400. }
  139401. }
  139402. declare module BABYLON {
  139403. /**
  139404. * Class used to store 3D textures containing user data
  139405. */
  139406. export class RawTexture3D extends Texture {
  139407. /** Gets or sets the texture format to use */
  139408. format: number;
  139409. /**
  139410. * Create a new RawTexture3D
  139411. * @param data defines the data of the texture
  139412. * @param width defines the width of the texture
  139413. * @param height defines the height of the texture
  139414. * @param depth defines the depth of the texture
  139415. * @param format defines the texture format to use
  139416. * @param scene defines the hosting scene
  139417. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  139418. * @param invertY defines if texture must be stored with Y axis inverted
  139419. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  139420. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  139421. */
  139422. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  139423. /** Gets or sets the texture format to use */
  139424. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  139425. /**
  139426. * Update the texture with new data
  139427. * @param data defines the data to store in the texture
  139428. */
  139429. update(data: ArrayBufferView): void;
  139430. }
  139431. }
  139432. declare module BABYLON {
  139433. /**
  139434. * Creates a refraction texture used by refraction channel of the standard material.
  139435. * It is like a mirror but to see through a material.
  139436. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  139437. */
  139438. export class RefractionTexture extends RenderTargetTexture {
  139439. /**
  139440. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  139441. * 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.
  139442. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  139443. */
  139444. refractionPlane: Plane;
  139445. /**
  139446. * Define how deep under the surface we should see.
  139447. */
  139448. depth: number;
  139449. /**
  139450. * Creates a refraction texture used by refraction channel of the standard material.
  139451. * It is like a mirror but to see through a material.
  139452. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  139453. * @param name Define the texture name
  139454. * @param size Define the size of the underlying texture
  139455. * @param scene Define the scene the refraction belongs to
  139456. * @param generateMipMaps Define if we need to generate mips level for the refraction
  139457. */
  139458. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  139459. /**
  139460. * Clone the refraction texture.
  139461. * @returns the cloned texture
  139462. */
  139463. clone(): RefractionTexture;
  139464. /**
  139465. * Serialize the texture to a JSON representation you could use in Parse later on
  139466. * @returns the serialized JSON representation
  139467. */
  139468. serialize(): any;
  139469. }
  139470. }
  139471. declare module BABYLON {
  139472. /**
  139473. * Block used to add support for vertex skinning (bones)
  139474. */
  139475. export class BonesBlock extends NodeMaterialBlock {
  139476. /**
  139477. * Creates a new BonesBlock
  139478. * @param name defines the block name
  139479. */
  139480. constructor(name: string);
  139481. /**
  139482. * Initialize the block and prepare the context for build
  139483. * @param state defines the state that will be used for the build
  139484. */
  139485. initialize(state: NodeMaterialBuildState): void;
  139486. /**
  139487. * Gets the current class name
  139488. * @returns the class name
  139489. */
  139490. getClassName(): string;
  139491. /**
  139492. * Gets the matrix indices input component
  139493. */
  139494. get matricesIndices(): NodeMaterialConnectionPoint;
  139495. /**
  139496. * Gets the matrix weights input component
  139497. */
  139498. get matricesWeights(): NodeMaterialConnectionPoint;
  139499. /**
  139500. * Gets the extra matrix indices input component
  139501. */
  139502. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  139503. /**
  139504. * Gets the extra matrix weights input component
  139505. */
  139506. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  139507. /**
  139508. * Gets the world input component
  139509. */
  139510. get world(): NodeMaterialConnectionPoint;
  139511. /**
  139512. * Gets the output component
  139513. */
  139514. get output(): NodeMaterialConnectionPoint;
  139515. autoConfigure(material: NodeMaterial): void;
  139516. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  139517. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139518. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139519. protected _buildBlock(state: NodeMaterialBuildState): this;
  139520. }
  139521. }
  139522. declare module BABYLON {
  139523. /**
  139524. * Block used to add support for instances
  139525. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  139526. */
  139527. export class InstancesBlock extends NodeMaterialBlock {
  139528. /**
  139529. * Creates a new InstancesBlock
  139530. * @param name defines the block name
  139531. */
  139532. constructor(name: string);
  139533. /**
  139534. * Gets the current class name
  139535. * @returns the class name
  139536. */
  139537. getClassName(): string;
  139538. /**
  139539. * Gets the first world row input component
  139540. */
  139541. get world0(): NodeMaterialConnectionPoint;
  139542. /**
  139543. * Gets the second world row input component
  139544. */
  139545. get world1(): NodeMaterialConnectionPoint;
  139546. /**
  139547. * Gets the third world row input component
  139548. */
  139549. get world2(): NodeMaterialConnectionPoint;
  139550. /**
  139551. * Gets the forth world row input component
  139552. */
  139553. get world3(): NodeMaterialConnectionPoint;
  139554. /**
  139555. * Gets the world input component
  139556. */
  139557. get world(): NodeMaterialConnectionPoint;
  139558. /**
  139559. * Gets the output component
  139560. */
  139561. get output(): NodeMaterialConnectionPoint;
  139562. /**
  139563. * Gets the isntanceID component
  139564. */
  139565. get instanceID(): NodeMaterialConnectionPoint;
  139566. autoConfigure(material: NodeMaterial): void;
  139567. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  139568. protected _buildBlock(state: NodeMaterialBuildState): this;
  139569. }
  139570. }
  139571. declare module BABYLON {
  139572. /**
  139573. * Block used to add morph targets support to vertex shader
  139574. */
  139575. export class MorphTargetsBlock extends NodeMaterialBlock {
  139576. private _repeatableContentAnchor;
  139577. /**
  139578. * Create a new MorphTargetsBlock
  139579. * @param name defines the block name
  139580. */
  139581. constructor(name: string);
  139582. /**
  139583. * Gets the current class name
  139584. * @returns the class name
  139585. */
  139586. getClassName(): string;
  139587. /**
  139588. * Gets the position input component
  139589. */
  139590. get position(): NodeMaterialConnectionPoint;
  139591. /**
  139592. * Gets the normal input component
  139593. */
  139594. get normal(): NodeMaterialConnectionPoint;
  139595. /**
  139596. * Gets the tangent input component
  139597. */
  139598. get tangent(): NodeMaterialConnectionPoint;
  139599. /**
  139600. * Gets the tangent input component
  139601. */
  139602. get uv(): NodeMaterialConnectionPoint;
  139603. /**
  139604. * Gets the position output component
  139605. */
  139606. get positionOutput(): NodeMaterialConnectionPoint;
  139607. /**
  139608. * Gets the normal output component
  139609. */
  139610. get normalOutput(): NodeMaterialConnectionPoint;
  139611. /**
  139612. * Gets the tangent output component
  139613. */
  139614. get tangentOutput(): NodeMaterialConnectionPoint;
  139615. /**
  139616. * Gets the tangent output component
  139617. */
  139618. get uvOutput(): NodeMaterialConnectionPoint;
  139619. initialize(state: NodeMaterialBuildState): void;
  139620. autoConfigure(material: NodeMaterial): void;
  139621. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139622. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139623. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  139624. protected _buildBlock(state: NodeMaterialBuildState): this;
  139625. }
  139626. }
  139627. declare module BABYLON {
  139628. /**
  139629. * Block used to get data information from a light
  139630. */
  139631. export class LightInformationBlock extends NodeMaterialBlock {
  139632. private _lightDataUniformName;
  139633. private _lightColorUniformName;
  139634. private _lightTypeDefineName;
  139635. /**
  139636. * Gets or sets the light associated with this block
  139637. */
  139638. light: Nullable<Light>;
  139639. /**
  139640. * Creates a new LightInformationBlock
  139641. * @param name defines the block name
  139642. */
  139643. constructor(name: string);
  139644. /**
  139645. * Gets the current class name
  139646. * @returns the class name
  139647. */
  139648. getClassName(): string;
  139649. /**
  139650. * Gets the world position input component
  139651. */
  139652. get worldPosition(): NodeMaterialConnectionPoint;
  139653. /**
  139654. * Gets the direction output component
  139655. */
  139656. get direction(): NodeMaterialConnectionPoint;
  139657. /**
  139658. * Gets the direction output component
  139659. */
  139660. get color(): NodeMaterialConnectionPoint;
  139661. /**
  139662. * Gets the direction output component
  139663. */
  139664. get intensity(): NodeMaterialConnectionPoint;
  139665. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139666. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139667. protected _buildBlock(state: NodeMaterialBuildState): this;
  139668. serialize(): any;
  139669. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139670. }
  139671. }
  139672. declare module BABYLON {
  139673. /**
  139674. * Block used to add image processing support to fragment shader
  139675. */
  139676. export class ImageProcessingBlock extends NodeMaterialBlock {
  139677. /**
  139678. * Create a new ImageProcessingBlock
  139679. * @param name defines the block name
  139680. */
  139681. constructor(name: string);
  139682. /**
  139683. * Gets the current class name
  139684. * @returns the class name
  139685. */
  139686. getClassName(): string;
  139687. /**
  139688. * Gets the color input component
  139689. */
  139690. get color(): NodeMaterialConnectionPoint;
  139691. /**
  139692. * Gets the output component
  139693. */
  139694. get output(): NodeMaterialConnectionPoint;
  139695. /**
  139696. * Initialize the block and prepare the context for build
  139697. * @param state defines the state that will be used for the build
  139698. */
  139699. initialize(state: NodeMaterialBuildState): void;
  139700. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  139701. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139702. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139703. protected _buildBlock(state: NodeMaterialBuildState): this;
  139704. }
  139705. }
  139706. declare module BABYLON {
  139707. /**
  139708. * Block used to pertub normals based on a normal map
  139709. */
  139710. export class PerturbNormalBlock extends NodeMaterialBlock {
  139711. private _tangentSpaceParameterName;
  139712. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  139713. invertX: boolean;
  139714. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  139715. invertY: boolean;
  139716. /**
  139717. * Create a new PerturbNormalBlock
  139718. * @param name defines the block name
  139719. */
  139720. constructor(name: string);
  139721. /**
  139722. * Gets the current class name
  139723. * @returns the class name
  139724. */
  139725. getClassName(): string;
  139726. /**
  139727. * Gets the world position input component
  139728. */
  139729. get worldPosition(): NodeMaterialConnectionPoint;
  139730. /**
  139731. * Gets the world normal input component
  139732. */
  139733. get worldNormal(): NodeMaterialConnectionPoint;
  139734. /**
  139735. * Gets the world tangent input component
  139736. */
  139737. get worldTangent(): NodeMaterialConnectionPoint;
  139738. /**
  139739. * Gets the uv input component
  139740. */
  139741. get uv(): NodeMaterialConnectionPoint;
  139742. /**
  139743. * Gets the normal map color input component
  139744. */
  139745. get normalMapColor(): NodeMaterialConnectionPoint;
  139746. /**
  139747. * Gets the strength input component
  139748. */
  139749. get strength(): NodeMaterialConnectionPoint;
  139750. /**
  139751. * Gets the output component
  139752. */
  139753. get output(): NodeMaterialConnectionPoint;
  139754. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139755. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139756. autoConfigure(material: NodeMaterial): void;
  139757. protected _buildBlock(state: NodeMaterialBuildState): this;
  139758. protected _dumpPropertiesCode(): string;
  139759. serialize(): any;
  139760. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139761. }
  139762. }
  139763. declare module BABYLON {
  139764. /**
  139765. * Block used to discard a pixel if a value is smaller than a cutoff
  139766. */
  139767. export class DiscardBlock extends NodeMaterialBlock {
  139768. /**
  139769. * Create a new DiscardBlock
  139770. * @param name defines the block name
  139771. */
  139772. constructor(name: string);
  139773. /**
  139774. * Gets the current class name
  139775. * @returns the class name
  139776. */
  139777. getClassName(): string;
  139778. /**
  139779. * Gets the color input component
  139780. */
  139781. get value(): NodeMaterialConnectionPoint;
  139782. /**
  139783. * Gets the cutoff input component
  139784. */
  139785. get cutoff(): NodeMaterialConnectionPoint;
  139786. protected _buildBlock(state: NodeMaterialBuildState): this;
  139787. }
  139788. }
  139789. declare module BABYLON {
  139790. /**
  139791. * Block used to test if the fragment shader is front facing
  139792. */
  139793. export class FrontFacingBlock extends NodeMaterialBlock {
  139794. /**
  139795. * Creates a new FrontFacingBlock
  139796. * @param name defines the block name
  139797. */
  139798. constructor(name: string);
  139799. /**
  139800. * Gets the current class name
  139801. * @returns the class name
  139802. */
  139803. getClassName(): string;
  139804. /**
  139805. * Gets the output component
  139806. */
  139807. get output(): NodeMaterialConnectionPoint;
  139808. protected _buildBlock(state: NodeMaterialBuildState): this;
  139809. }
  139810. }
  139811. declare module BABYLON {
  139812. /**
  139813. * Block used to get the derivative value on x and y of a given input
  139814. */
  139815. export class DerivativeBlock extends NodeMaterialBlock {
  139816. /**
  139817. * Create a new DerivativeBlock
  139818. * @param name defines the block name
  139819. */
  139820. constructor(name: string);
  139821. /**
  139822. * Gets the current class name
  139823. * @returns the class name
  139824. */
  139825. getClassName(): string;
  139826. /**
  139827. * Gets the input component
  139828. */
  139829. get input(): NodeMaterialConnectionPoint;
  139830. /**
  139831. * Gets the derivative output on x
  139832. */
  139833. get dx(): NodeMaterialConnectionPoint;
  139834. /**
  139835. * Gets the derivative output on y
  139836. */
  139837. get dy(): NodeMaterialConnectionPoint;
  139838. protected _buildBlock(state: NodeMaterialBuildState): this;
  139839. }
  139840. }
  139841. declare module BABYLON {
  139842. /**
  139843. * Block used to make gl_FragCoord available
  139844. */
  139845. export class FragCoordBlock extends NodeMaterialBlock {
  139846. /**
  139847. * Creates a new FragCoordBlock
  139848. * @param name defines the block name
  139849. */
  139850. constructor(name: string);
  139851. /**
  139852. * Gets the current class name
  139853. * @returns the class name
  139854. */
  139855. getClassName(): string;
  139856. /**
  139857. * Gets the xy component
  139858. */
  139859. get xy(): NodeMaterialConnectionPoint;
  139860. /**
  139861. * Gets the xyz component
  139862. */
  139863. get xyz(): NodeMaterialConnectionPoint;
  139864. /**
  139865. * Gets the xyzw component
  139866. */
  139867. get xyzw(): NodeMaterialConnectionPoint;
  139868. /**
  139869. * Gets the x component
  139870. */
  139871. get x(): NodeMaterialConnectionPoint;
  139872. /**
  139873. * Gets the y component
  139874. */
  139875. get y(): NodeMaterialConnectionPoint;
  139876. /**
  139877. * Gets the z component
  139878. */
  139879. get z(): NodeMaterialConnectionPoint;
  139880. /**
  139881. * Gets the w component
  139882. */
  139883. get output(): NodeMaterialConnectionPoint;
  139884. protected writeOutputs(state: NodeMaterialBuildState): string;
  139885. protected _buildBlock(state: NodeMaterialBuildState): this;
  139886. }
  139887. }
  139888. declare module BABYLON {
  139889. /**
  139890. * Block used to get the screen sizes
  139891. */
  139892. export class ScreenSizeBlock extends NodeMaterialBlock {
  139893. private _varName;
  139894. private _scene;
  139895. /**
  139896. * Creates a new ScreenSizeBlock
  139897. * @param name defines the block name
  139898. */
  139899. constructor(name: string);
  139900. /**
  139901. * Gets the current class name
  139902. * @returns the class name
  139903. */
  139904. getClassName(): string;
  139905. /**
  139906. * Gets the xy component
  139907. */
  139908. get xy(): NodeMaterialConnectionPoint;
  139909. /**
  139910. * Gets the x component
  139911. */
  139912. get x(): NodeMaterialConnectionPoint;
  139913. /**
  139914. * Gets the y component
  139915. */
  139916. get y(): NodeMaterialConnectionPoint;
  139917. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139918. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  139919. protected _buildBlock(state: NodeMaterialBuildState): this;
  139920. }
  139921. }
  139922. declare module BABYLON {
  139923. /**
  139924. * Block used to add support for scene fog
  139925. */
  139926. export class FogBlock extends NodeMaterialBlock {
  139927. private _fogDistanceName;
  139928. private _fogParameters;
  139929. /**
  139930. * Create a new FogBlock
  139931. * @param name defines the block name
  139932. */
  139933. constructor(name: string);
  139934. /**
  139935. * Gets the current class name
  139936. * @returns the class name
  139937. */
  139938. getClassName(): string;
  139939. /**
  139940. * Gets the world position input component
  139941. */
  139942. get worldPosition(): NodeMaterialConnectionPoint;
  139943. /**
  139944. * Gets the view input component
  139945. */
  139946. get view(): NodeMaterialConnectionPoint;
  139947. /**
  139948. * Gets the color input component
  139949. */
  139950. get input(): NodeMaterialConnectionPoint;
  139951. /**
  139952. * Gets the fog color input component
  139953. */
  139954. get fogColor(): NodeMaterialConnectionPoint;
  139955. /**
  139956. * Gets the output component
  139957. */
  139958. get output(): NodeMaterialConnectionPoint;
  139959. autoConfigure(material: NodeMaterial): void;
  139960. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139961. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139962. protected _buildBlock(state: NodeMaterialBuildState): this;
  139963. }
  139964. }
  139965. declare module BABYLON {
  139966. /**
  139967. * Block used to add light in the fragment shader
  139968. */
  139969. export class LightBlock extends NodeMaterialBlock {
  139970. private _lightId;
  139971. /**
  139972. * Gets or sets the light associated with this block
  139973. */
  139974. light: Nullable<Light>;
  139975. /**
  139976. * Create a new LightBlock
  139977. * @param name defines the block name
  139978. */
  139979. constructor(name: string);
  139980. /**
  139981. * Gets the current class name
  139982. * @returns the class name
  139983. */
  139984. getClassName(): string;
  139985. /**
  139986. * Gets the world position input component
  139987. */
  139988. get worldPosition(): NodeMaterialConnectionPoint;
  139989. /**
  139990. * Gets the world normal input component
  139991. */
  139992. get worldNormal(): NodeMaterialConnectionPoint;
  139993. /**
  139994. * Gets the camera (or eye) position component
  139995. */
  139996. get cameraPosition(): NodeMaterialConnectionPoint;
  139997. /**
  139998. * Gets the glossiness component
  139999. */
  140000. get glossiness(): NodeMaterialConnectionPoint;
  140001. /**
  140002. * Gets the glossinness power component
  140003. */
  140004. get glossPower(): NodeMaterialConnectionPoint;
  140005. /**
  140006. * Gets the diffuse color component
  140007. */
  140008. get diffuseColor(): NodeMaterialConnectionPoint;
  140009. /**
  140010. * Gets the specular color component
  140011. */
  140012. get specularColor(): NodeMaterialConnectionPoint;
  140013. /**
  140014. * Gets the diffuse output component
  140015. */
  140016. get diffuseOutput(): NodeMaterialConnectionPoint;
  140017. /**
  140018. * Gets the specular output component
  140019. */
  140020. get specularOutput(): NodeMaterialConnectionPoint;
  140021. /**
  140022. * Gets the shadow output component
  140023. */
  140024. get shadow(): NodeMaterialConnectionPoint;
  140025. autoConfigure(material: NodeMaterial): void;
  140026. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140027. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  140028. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140029. private _injectVertexCode;
  140030. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  140031. serialize(): any;
  140032. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140033. }
  140034. }
  140035. declare module BABYLON {
  140036. /**
  140037. * Block used to read a reflection texture from a sampler
  140038. */
  140039. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  140040. /**
  140041. * Create a new ReflectionTextureBlock
  140042. * @param name defines the block name
  140043. */
  140044. constructor(name: string);
  140045. /**
  140046. * Gets the current class name
  140047. * @returns the class name
  140048. */
  140049. getClassName(): string;
  140050. /**
  140051. * Gets the world position input component
  140052. */
  140053. get position(): NodeMaterialConnectionPoint;
  140054. /**
  140055. * Gets the world position input component
  140056. */
  140057. get worldPosition(): NodeMaterialConnectionPoint;
  140058. /**
  140059. * Gets the world normal input component
  140060. */
  140061. get worldNormal(): NodeMaterialConnectionPoint;
  140062. /**
  140063. * Gets the world input component
  140064. */
  140065. get world(): NodeMaterialConnectionPoint;
  140066. /**
  140067. * Gets the camera (or eye) position component
  140068. */
  140069. get cameraPosition(): NodeMaterialConnectionPoint;
  140070. /**
  140071. * Gets the view input component
  140072. */
  140073. get view(): NodeMaterialConnectionPoint;
  140074. /**
  140075. * Gets the rgb output component
  140076. */
  140077. get rgb(): NodeMaterialConnectionPoint;
  140078. /**
  140079. * Gets the rgba output component
  140080. */
  140081. get rgba(): NodeMaterialConnectionPoint;
  140082. /**
  140083. * Gets the r output component
  140084. */
  140085. get r(): NodeMaterialConnectionPoint;
  140086. /**
  140087. * Gets the g output component
  140088. */
  140089. get g(): NodeMaterialConnectionPoint;
  140090. /**
  140091. * Gets the b output component
  140092. */
  140093. get b(): NodeMaterialConnectionPoint;
  140094. /**
  140095. * Gets the a output component
  140096. */
  140097. get a(): NodeMaterialConnectionPoint;
  140098. autoConfigure(material: NodeMaterial): void;
  140099. protected _buildBlock(state: NodeMaterialBuildState): this;
  140100. }
  140101. }
  140102. declare module BABYLON {
  140103. /**
  140104. * Block used to add 2 vectors
  140105. */
  140106. export class AddBlock extends NodeMaterialBlock {
  140107. /**
  140108. * Creates a new AddBlock
  140109. * @param name defines the block name
  140110. */
  140111. constructor(name: string);
  140112. /**
  140113. * Gets the current class name
  140114. * @returns the class name
  140115. */
  140116. getClassName(): string;
  140117. /**
  140118. * Gets the left operand input component
  140119. */
  140120. get left(): NodeMaterialConnectionPoint;
  140121. /**
  140122. * Gets the right operand input component
  140123. */
  140124. get right(): NodeMaterialConnectionPoint;
  140125. /**
  140126. * Gets the output component
  140127. */
  140128. get output(): NodeMaterialConnectionPoint;
  140129. protected _buildBlock(state: NodeMaterialBuildState): this;
  140130. }
  140131. }
  140132. declare module BABYLON {
  140133. /**
  140134. * Block used to scale a vector by a float
  140135. */
  140136. export class ScaleBlock extends NodeMaterialBlock {
  140137. /**
  140138. * Creates a new ScaleBlock
  140139. * @param name defines the block name
  140140. */
  140141. constructor(name: string);
  140142. /**
  140143. * Gets the current class name
  140144. * @returns the class name
  140145. */
  140146. getClassName(): string;
  140147. /**
  140148. * Gets the input component
  140149. */
  140150. get input(): NodeMaterialConnectionPoint;
  140151. /**
  140152. * Gets the factor input component
  140153. */
  140154. get factor(): NodeMaterialConnectionPoint;
  140155. /**
  140156. * Gets the output component
  140157. */
  140158. get output(): NodeMaterialConnectionPoint;
  140159. protected _buildBlock(state: NodeMaterialBuildState): this;
  140160. }
  140161. }
  140162. declare module BABYLON {
  140163. /**
  140164. * Block used to clamp a float
  140165. */
  140166. export class ClampBlock extends NodeMaterialBlock {
  140167. /** Gets or sets the minimum range */
  140168. minimum: number;
  140169. /** Gets or sets the maximum range */
  140170. maximum: number;
  140171. /**
  140172. * Creates a new ClampBlock
  140173. * @param name defines the block name
  140174. */
  140175. constructor(name: string);
  140176. /**
  140177. * Gets the current class name
  140178. * @returns the class name
  140179. */
  140180. getClassName(): string;
  140181. /**
  140182. * Gets the value input component
  140183. */
  140184. get value(): NodeMaterialConnectionPoint;
  140185. /**
  140186. * Gets the output component
  140187. */
  140188. get output(): NodeMaterialConnectionPoint;
  140189. protected _buildBlock(state: NodeMaterialBuildState): this;
  140190. protected _dumpPropertiesCode(): string;
  140191. serialize(): any;
  140192. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140193. }
  140194. }
  140195. declare module BABYLON {
  140196. /**
  140197. * Block used to apply a cross product between 2 vectors
  140198. */
  140199. export class CrossBlock extends NodeMaterialBlock {
  140200. /**
  140201. * Creates a new CrossBlock
  140202. * @param name defines the block name
  140203. */
  140204. constructor(name: string);
  140205. /**
  140206. * Gets the current class name
  140207. * @returns the class name
  140208. */
  140209. getClassName(): string;
  140210. /**
  140211. * Gets the left operand input component
  140212. */
  140213. get left(): NodeMaterialConnectionPoint;
  140214. /**
  140215. * Gets the right operand input component
  140216. */
  140217. get right(): NodeMaterialConnectionPoint;
  140218. /**
  140219. * Gets the output component
  140220. */
  140221. get output(): NodeMaterialConnectionPoint;
  140222. protected _buildBlock(state: NodeMaterialBuildState): this;
  140223. }
  140224. }
  140225. declare module BABYLON {
  140226. /**
  140227. * Block used to apply a dot product between 2 vectors
  140228. */
  140229. export class DotBlock extends NodeMaterialBlock {
  140230. /**
  140231. * Creates a new DotBlock
  140232. * @param name defines the block name
  140233. */
  140234. constructor(name: string);
  140235. /**
  140236. * Gets the current class name
  140237. * @returns the class name
  140238. */
  140239. getClassName(): string;
  140240. /**
  140241. * Gets the left operand input component
  140242. */
  140243. get left(): NodeMaterialConnectionPoint;
  140244. /**
  140245. * Gets the right operand input component
  140246. */
  140247. get right(): NodeMaterialConnectionPoint;
  140248. /**
  140249. * Gets the output component
  140250. */
  140251. get output(): NodeMaterialConnectionPoint;
  140252. protected _buildBlock(state: NodeMaterialBuildState): this;
  140253. }
  140254. }
  140255. declare module BABYLON {
  140256. /**
  140257. * Block used to normalize a vector
  140258. */
  140259. export class NormalizeBlock extends NodeMaterialBlock {
  140260. /**
  140261. * Creates a new NormalizeBlock
  140262. * @param name defines the block name
  140263. */
  140264. constructor(name: string);
  140265. /**
  140266. * Gets the current class name
  140267. * @returns the class name
  140268. */
  140269. getClassName(): string;
  140270. /**
  140271. * Gets the input component
  140272. */
  140273. get input(): NodeMaterialConnectionPoint;
  140274. /**
  140275. * Gets the output component
  140276. */
  140277. get output(): NodeMaterialConnectionPoint;
  140278. protected _buildBlock(state: NodeMaterialBuildState): this;
  140279. }
  140280. }
  140281. declare module BABYLON {
  140282. /**
  140283. * Operations supported by the Trigonometry block
  140284. */
  140285. export enum TrigonometryBlockOperations {
  140286. /** Cos */
  140287. Cos = 0,
  140288. /** Sin */
  140289. Sin = 1,
  140290. /** Abs */
  140291. Abs = 2,
  140292. /** Exp */
  140293. Exp = 3,
  140294. /** Exp2 */
  140295. Exp2 = 4,
  140296. /** Round */
  140297. Round = 5,
  140298. /** Floor */
  140299. Floor = 6,
  140300. /** Ceiling */
  140301. Ceiling = 7,
  140302. /** Square root */
  140303. Sqrt = 8,
  140304. /** Log */
  140305. Log = 9,
  140306. /** Tangent */
  140307. Tan = 10,
  140308. /** Arc tangent */
  140309. ArcTan = 11,
  140310. /** Arc cosinus */
  140311. ArcCos = 12,
  140312. /** Arc sinus */
  140313. ArcSin = 13,
  140314. /** Fraction */
  140315. Fract = 14,
  140316. /** Sign */
  140317. Sign = 15,
  140318. /** To radians (from degrees) */
  140319. Radians = 16,
  140320. /** To degrees (from radians) */
  140321. Degrees = 17
  140322. }
  140323. /**
  140324. * Block used to apply trigonometry operation to floats
  140325. */
  140326. export class TrigonometryBlock extends NodeMaterialBlock {
  140327. /**
  140328. * Gets or sets the operation applied by the block
  140329. */
  140330. operation: TrigonometryBlockOperations;
  140331. /**
  140332. * Creates a new TrigonometryBlock
  140333. * @param name defines the block name
  140334. */
  140335. constructor(name: string);
  140336. /**
  140337. * Gets the current class name
  140338. * @returns the class name
  140339. */
  140340. getClassName(): string;
  140341. /**
  140342. * Gets the input component
  140343. */
  140344. get input(): NodeMaterialConnectionPoint;
  140345. /**
  140346. * Gets the output component
  140347. */
  140348. get output(): NodeMaterialConnectionPoint;
  140349. protected _buildBlock(state: NodeMaterialBuildState): this;
  140350. serialize(): any;
  140351. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140352. protected _dumpPropertiesCode(): string;
  140353. }
  140354. }
  140355. declare module BABYLON {
  140356. /**
  140357. * Block used to create a Color3/4 out of individual inputs (one for each component)
  140358. */
  140359. export class ColorMergerBlock extends NodeMaterialBlock {
  140360. /**
  140361. * Create a new ColorMergerBlock
  140362. * @param name defines the block name
  140363. */
  140364. constructor(name: string);
  140365. /**
  140366. * Gets the current class name
  140367. * @returns the class name
  140368. */
  140369. getClassName(): string;
  140370. /**
  140371. * Gets the rgb component (input)
  140372. */
  140373. get rgbIn(): NodeMaterialConnectionPoint;
  140374. /**
  140375. * Gets the r component (input)
  140376. */
  140377. get r(): NodeMaterialConnectionPoint;
  140378. /**
  140379. * Gets the g component (input)
  140380. */
  140381. get g(): NodeMaterialConnectionPoint;
  140382. /**
  140383. * Gets the b component (input)
  140384. */
  140385. get b(): NodeMaterialConnectionPoint;
  140386. /**
  140387. * Gets the a component (input)
  140388. */
  140389. get a(): NodeMaterialConnectionPoint;
  140390. /**
  140391. * Gets the rgba component (output)
  140392. */
  140393. get rgba(): NodeMaterialConnectionPoint;
  140394. /**
  140395. * Gets the rgb component (output)
  140396. */
  140397. get rgbOut(): NodeMaterialConnectionPoint;
  140398. /**
  140399. * Gets the rgb component (output)
  140400. * @deprecated Please use rgbOut instead.
  140401. */
  140402. get rgb(): NodeMaterialConnectionPoint;
  140403. protected _buildBlock(state: NodeMaterialBuildState): this;
  140404. }
  140405. }
  140406. declare module BABYLON {
  140407. /**
  140408. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  140409. */
  140410. export class VectorSplitterBlock extends NodeMaterialBlock {
  140411. /**
  140412. * Create a new VectorSplitterBlock
  140413. * @param name defines the block name
  140414. */
  140415. constructor(name: string);
  140416. /**
  140417. * Gets the current class name
  140418. * @returns the class name
  140419. */
  140420. getClassName(): string;
  140421. /**
  140422. * Gets the xyzw component (input)
  140423. */
  140424. get xyzw(): NodeMaterialConnectionPoint;
  140425. /**
  140426. * Gets the xyz component (input)
  140427. */
  140428. get xyzIn(): NodeMaterialConnectionPoint;
  140429. /**
  140430. * Gets the xy component (input)
  140431. */
  140432. get xyIn(): NodeMaterialConnectionPoint;
  140433. /**
  140434. * Gets the xyz component (output)
  140435. */
  140436. get xyzOut(): NodeMaterialConnectionPoint;
  140437. /**
  140438. * Gets the xy component (output)
  140439. */
  140440. get xyOut(): NodeMaterialConnectionPoint;
  140441. /**
  140442. * Gets the x component (output)
  140443. */
  140444. get x(): NodeMaterialConnectionPoint;
  140445. /**
  140446. * Gets the y component (output)
  140447. */
  140448. get y(): NodeMaterialConnectionPoint;
  140449. /**
  140450. * Gets the z component (output)
  140451. */
  140452. get z(): NodeMaterialConnectionPoint;
  140453. /**
  140454. * Gets the w component (output)
  140455. */
  140456. get w(): NodeMaterialConnectionPoint;
  140457. protected _inputRename(name: string): string;
  140458. protected _outputRename(name: string): string;
  140459. protected _buildBlock(state: NodeMaterialBuildState): this;
  140460. }
  140461. }
  140462. declare module BABYLON {
  140463. /**
  140464. * Block used to lerp between 2 values
  140465. */
  140466. export class LerpBlock extends NodeMaterialBlock {
  140467. /**
  140468. * Creates a new LerpBlock
  140469. * @param name defines the block name
  140470. */
  140471. constructor(name: string);
  140472. /**
  140473. * Gets the current class name
  140474. * @returns the class name
  140475. */
  140476. getClassName(): string;
  140477. /**
  140478. * Gets the left operand input component
  140479. */
  140480. get left(): NodeMaterialConnectionPoint;
  140481. /**
  140482. * Gets the right operand input component
  140483. */
  140484. get right(): NodeMaterialConnectionPoint;
  140485. /**
  140486. * Gets the gradient operand input component
  140487. */
  140488. get gradient(): NodeMaterialConnectionPoint;
  140489. /**
  140490. * Gets the output component
  140491. */
  140492. get output(): NodeMaterialConnectionPoint;
  140493. protected _buildBlock(state: NodeMaterialBuildState): this;
  140494. }
  140495. }
  140496. declare module BABYLON {
  140497. /**
  140498. * Block used to divide 2 vectors
  140499. */
  140500. export class DivideBlock extends NodeMaterialBlock {
  140501. /**
  140502. * Creates a new DivideBlock
  140503. * @param name defines the block name
  140504. */
  140505. constructor(name: string);
  140506. /**
  140507. * Gets the current class name
  140508. * @returns the class name
  140509. */
  140510. getClassName(): string;
  140511. /**
  140512. * Gets the left operand input component
  140513. */
  140514. get left(): NodeMaterialConnectionPoint;
  140515. /**
  140516. * Gets the right operand input component
  140517. */
  140518. get right(): NodeMaterialConnectionPoint;
  140519. /**
  140520. * Gets the output component
  140521. */
  140522. get output(): NodeMaterialConnectionPoint;
  140523. protected _buildBlock(state: NodeMaterialBuildState): this;
  140524. }
  140525. }
  140526. declare module BABYLON {
  140527. /**
  140528. * Block used to subtract 2 vectors
  140529. */
  140530. export class SubtractBlock extends NodeMaterialBlock {
  140531. /**
  140532. * Creates a new SubtractBlock
  140533. * @param name defines the block name
  140534. */
  140535. constructor(name: string);
  140536. /**
  140537. * Gets the current class name
  140538. * @returns the class name
  140539. */
  140540. getClassName(): string;
  140541. /**
  140542. * Gets the left operand input component
  140543. */
  140544. get left(): NodeMaterialConnectionPoint;
  140545. /**
  140546. * Gets the right operand input component
  140547. */
  140548. get right(): NodeMaterialConnectionPoint;
  140549. /**
  140550. * Gets the output component
  140551. */
  140552. get output(): NodeMaterialConnectionPoint;
  140553. protected _buildBlock(state: NodeMaterialBuildState): this;
  140554. }
  140555. }
  140556. declare module BABYLON {
  140557. /**
  140558. * Block used to step a value
  140559. */
  140560. export class StepBlock extends NodeMaterialBlock {
  140561. /**
  140562. * Creates a new StepBlock
  140563. * @param name defines the block name
  140564. */
  140565. constructor(name: string);
  140566. /**
  140567. * Gets the current class name
  140568. * @returns the class name
  140569. */
  140570. getClassName(): string;
  140571. /**
  140572. * Gets the value operand input component
  140573. */
  140574. get value(): NodeMaterialConnectionPoint;
  140575. /**
  140576. * Gets the edge operand input component
  140577. */
  140578. get edge(): NodeMaterialConnectionPoint;
  140579. /**
  140580. * Gets the output component
  140581. */
  140582. get output(): NodeMaterialConnectionPoint;
  140583. protected _buildBlock(state: NodeMaterialBuildState): this;
  140584. }
  140585. }
  140586. declare module BABYLON {
  140587. /**
  140588. * Block used to get the opposite (1 - x) of a value
  140589. */
  140590. export class OneMinusBlock extends NodeMaterialBlock {
  140591. /**
  140592. * Creates a new OneMinusBlock
  140593. * @param name defines the block name
  140594. */
  140595. constructor(name: string);
  140596. /**
  140597. * Gets the current class name
  140598. * @returns the class name
  140599. */
  140600. getClassName(): string;
  140601. /**
  140602. * Gets the input component
  140603. */
  140604. get input(): NodeMaterialConnectionPoint;
  140605. /**
  140606. * Gets the output component
  140607. */
  140608. get output(): NodeMaterialConnectionPoint;
  140609. protected _buildBlock(state: NodeMaterialBuildState): this;
  140610. }
  140611. }
  140612. declare module BABYLON {
  140613. /**
  140614. * Block used to get the view direction
  140615. */
  140616. export class ViewDirectionBlock extends NodeMaterialBlock {
  140617. /**
  140618. * Creates a new ViewDirectionBlock
  140619. * @param name defines the block name
  140620. */
  140621. constructor(name: string);
  140622. /**
  140623. * Gets the current class name
  140624. * @returns the class name
  140625. */
  140626. getClassName(): string;
  140627. /**
  140628. * Gets the world position component
  140629. */
  140630. get worldPosition(): NodeMaterialConnectionPoint;
  140631. /**
  140632. * Gets the camera position component
  140633. */
  140634. get cameraPosition(): NodeMaterialConnectionPoint;
  140635. /**
  140636. * Gets the output component
  140637. */
  140638. get output(): NodeMaterialConnectionPoint;
  140639. autoConfigure(material: NodeMaterial): void;
  140640. protected _buildBlock(state: NodeMaterialBuildState): this;
  140641. }
  140642. }
  140643. declare module BABYLON {
  140644. /**
  140645. * Block used to compute fresnel value
  140646. */
  140647. export class FresnelBlock extends NodeMaterialBlock {
  140648. /**
  140649. * Create a new FresnelBlock
  140650. * @param name defines the block name
  140651. */
  140652. constructor(name: string);
  140653. /**
  140654. * Gets the current class name
  140655. * @returns the class name
  140656. */
  140657. getClassName(): string;
  140658. /**
  140659. * Gets the world normal input component
  140660. */
  140661. get worldNormal(): NodeMaterialConnectionPoint;
  140662. /**
  140663. * Gets the view direction input component
  140664. */
  140665. get viewDirection(): NodeMaterialConnectionPoint;
  140666. /**
  140667. * Gets the bias input component
  140668. */
  140669. get bias(): NodeMaterialConnectionPoint;
  140670. /**
  140671. * Gets the camera (or eye) position component
  140672. */
  140673. get power(): NodeMaterialConnectionPoint;
  140674. /**
  140675. * Gets the fresnel output component
  140676. */
  140677. get fresnel(): NodeMaterialConnectionPoint;
  140678. autoConfigure(material: NodeMaterial): void;
  140679. protected _buildBlock(state: NodeMaterialBuildState): this;
  140680. }
  140681. }
  140682. declare module BABYLON {
  140683. /**
  140684. * Block used to get the max of 2 values
  140685. */
  140686. export class MaxBlock extends NodeMaterialBlock {
  140687. /**
  140688. * Creates a new MaxBlock
  140689. * @param name defines the block name
  140690. */
  140691. constructor(name: string);
  140692. /**
  140693. * Gets the current class name
  140694. * @returns the class name
  140695. */
  140696. getClassName(): string;
  140697. /**
  140698. * Gets the left operand input component
  140699. */
  140700. get left(): NodeMaterialConnectionPoint;
  140701. /**
  140702. * Gets the right operand input component
  140703. */
  140704. get right(): NodeMaterialConnectionPoint;
  140705. /**
  140706. * Gets the output component
  140707. */
  140708. get output(): NodeMaterialConnectionPoint;
  140709. protected _buildBlock(state: NodeMaterialBuildState): this;
  140710. }
  140711. }
  140712. declare module BABYLON {
  140713. /**
  140714. * Block used to get the min of 2 values
  140715. */
  140716. export class MinBlock extends NodeMaterialBlock {
  140717. /**
  140718. * Creates a new MinBlock
  140719. * @param name defines the block name
  140720. */
  140721. constructor(name: string);
  140722. /**
  140723. * Gets the current class name
  140724. * @returns the class name
  140725. */
  140726. getClassName(): string;
  140727. /**
  140728. * Gets the left operand input component
  140729. */
  140730. get left(): NodeMaterialConnectionPoint;
  140731. /**
  140732. * Gets the right operand input component
  140733. */
  140734. get right(): NodeMaterialConnectionPoint;
  140735. /**
  140736. * Gets the output component
  140737. */
  140738. get output(): NodeMaterialConnectionPoint;
  140739. protected _buildBlock(state: NodeMaterialBuildState): this;
  140740. }
  140741. }
  140742. declare module BABYLON {
  140743. /**
  140744. * Block used to get the distance between 2 values
  140745. */
  140746. export class DistanceBlock extends NodeMaterialBlock {
  140747. /**
  140748. * Creates a new DistanceBlock
  140749. * @param name defines the block name
  140750. */
  140751. constructor(name: string);
  140752. /**
  140753. * Gets the current class name
  140754. * @returns the class name
  140755. */
  140756. getClassName(): string;
  140757. /**
  140758. * Gets the left operand input component
  140759. */
  140760. get left(): NodeMaterialConnectionPoint;
  140761. /**
  140762. * Gets the right operand input component
  140763. */
  140764. get right(): NodeMaterialConnectionPoint;
  140765. /**
  140766. * Gets the output component
  140767. */
  140768. get output(): NodeMaterialConnectionPoint;
  140769. protected _buildBlock(state: NodeMaterialBuildState): this;
  140770. }
  140771. }
  140772. declare module BABYLON {
  140773. /**
  140774. * Block used to get the length of a vector
  140775. */
  140776. export class LengthBlock extends NodeMaterialBlock {
  140777. /**
  140778. * Creates a new LengthBlock
  140779. * @param name defines the block name
  140780. */
  140781. constructor(name: string);
  140782. /**
  140783. * Gets the current class name
  140784. * @returns the class name
  140785. */
  140786. getClassName(): string;
  140787. /**
  140788. * Gets the value input component
  140789. */
  140790. get value(): NodeMaterialConnectionPoint;
  140791. /**
  140792. * Gets the output component
  140793. */
  140794. get output(): NodeMaterialConnectionPoint;
  140795. protected _buildBlock(state: NodeMaterialBuildState): this;
  140796. }
  140797. }
  140798. declare module BABYLON {
  140799. /**
  140800. * Block used to get negative version of a value (i.e. x * -1)
  140801. */
  140802. export class NegateBlock extends NodeMaterialBlock {
  140803. /**
  140804. * Creates a new NegateBlock
  140805. * @param name defines the block name
  140806. */
  140807. constructor(name: string);
  140808. /**
  140809. * Gets the current class name
  140810. * @returns the class name
  140811. */
  140812. getClassName(): string;
  140813. /**
  140814. * Gets the value input component
  140815. */
  140816. get value(): NodeMaterialConnectionPoint;
  140817. /**
  140818. * Gets the output component
  140819. */
  140820. get output(): NodeMaterialConnectionPoint;
  140821. protected _buildBlock(state: NodeMaterialBuildState): this;
  140822. }
  140823. }
  140824. declare module BABYLON {
  140825. /**
  140826. * Block used to get the value of the first parameter raised to the power of the second
  140827. */
  140828. export class PowBlock extends NodeMaterialBlock {
  140829. /**
  140830. * Creates a new PowBlock
  140831. * @param name defines the block name
  140832. */
  140833. constructor(name: string);
  140834. /**
  140835. * Gets the current class name
  140836. * @returns the class name
  140837. */
  140838. getClassName(): string;
  140839. /**
  140840. * Gets the value operand input component
  140841. */
  140842. get value(): NodeMaterialConnectionPoint;
  140843. /**
  140844. * Gets the power operand input component
  140845. */
  140846. get power(): NodeMaterialConnectionPoint;
  140847. /**
  140848. * Gets the output component
  140849. */
  140850. get output(): NodeMaterialConnectionPoint;
  140851. protected _buildBlock(state: NodeMaterialBuildState): this;
  140852. }
  140853. }
  140854. declare module BABYLON {
  140855. /**
  140856. * Block used to get a random number
  140857. */
  140858. export class RandomNumberBlock extends NodeMaterialBlock {
  140859. /**
  140860. * Creates a new RandomNumberBlock
  140861. * @param name defines the block name
  140862. */
  140863. constructor(name: string);
  140864. /**
  140865. * Gets the current class name
  140866. * @returns the class name
  140867. */
  140868. getClassName(): string;
  140869. /**
  140870. * Gets the seed input component
  140871. */
  140872. get seed(): NodeMaterialConnectionPoint;
  140873. /**
  140874. * Gets the output component
  140875. */
  140876. get output(): NodeMaterialConnectionPoint;
  140877. protected _buildBlock(state: NodeMaterialBuildState): this;
  140878. }
  140879. }
  140880. declare module BABYLON {
  140881. /**
  140882. * Block used to compute arc tangent of 2 values
  140883. */
  140884. export class ArcTan2Block extends NodeMaterialBlock {
  140885. /**
  140886. * Creates a new ArcTan2Block
  140887. * @param name defines the block name
  140888. */
  140889. constructor(name: string);
  140890. /**
  140891. * Gets the current class name
  140892. * @returns the class name
  140893. */
  140894. getClassName(): string;
  140895. /**
  140896. * Gets the x operand input component
  140897. */
  140898. get x(): NodeMaterialConnectionPoint;
  140899. /**
  140900. * Gets the y operand input component
  140901. */
  140902. get y(): NodeMaterialConnectionPoint;
  140903. /**
  140904. * Gets the output component
  140905. */
  140906. get output(): NodeMaterialConnectionPoint;
  140907. protected _buildBlock(state: NodeMaterialBuildState): this;
  140908. }
  140909. }
  140910. declare module BABYLON {
  140911. /**
  140912. * Block used to smooth step a value
  140913. */
  140914. export class SmoothStepBlock extends NodeMaterialBlock {
  140915. /**
  140916. * Creates a new SmoothStepBlock
  140917. * @param name defines the block name
  140918. */
  140919. constructor(name: string);
  140920. /**
  140921. * Gets the current class name
  140922. * @returns the class name
  140923. */
  140924. getClassName(): string;
  140925. /**
  140926. * Gets the value operand input component
  140927. */
  140928. get value(): NodeMaterialConnectionPoint;
  140929. /**
  140930. * Gets the first edge operand input component
  140931. */
  140932. get edge0(): NodeMaterialConnectionPoint;
  140933. /**
  140934. * Gets the second edge operand input component
  140935. */
  140936. get edge1(): NodeMaterialConnectionPoint;
  140937. /**
  140938. * Gets the output component
  140939. */
  140940. get output(): NodeMaterialConnectionPoint;
  140941. protected _buildBlock(state: NodeMaterialBuildState): this;
  140942. }
  140943. }
  140944. declare module BABYLON {
  140945. /**
  140946. * Block used to get the reciprocal (1 / x) of a value
  140947. */
  140948. export class ReciprocalBlock extends NodeMaterialBlock {
  140949. /**
  140950. * Creates a new ReciprocalBlock
  140951. * @param name defines the block name
  140952. */
  140953. constructor(name: string);
  140954. /**
  140955. * Gets the current class name
  140956. * @returns the class name
  140957. */
  140958. getClassName(): string;
  140959. /**
  140960. * Gets the input component
  140961. */
  140962. get input(): NodeMaterialConnectionPoint;
  140963. /**
  140964. * Gets the output component
  140965. */
  140966. get output(): NodeMaterialConnectionPoint;
  140967. protected _buildBlock(state: NodeMaterialBuildState): this;
  140968. }
  140969. }
  140970. declare module BABYLON {
  140971. /**
  140972. * Block used to replace a color by another one
  140973. */
  140974. export class ReplaceColorBlock extends NodeMaterialBlock {
  140975. /**
  140976. * Creates a new ReplaceColorBlock
  140977. * @param name defines the block name
  140978. */
  140979. constructor(name: string);
  140980. /**
  140981. * Gets the current class name
  140982. * @returns the class name
  140983. */
  140984. getClassName(): string;
  140985. /**
  140986. * Gets the value input component
  140987. */
  140988. get value(): NodeMaterialConnectionPoint;
  140989. /**
  140990. * Gets the reference input component
  140991. */
  140992. get reference(): NodeMaterialConnectionPoint;
  140993. /**
  140994. * Gets the distance input component
  140995. */
  140996. get distance(): NodeMaterialConnectionPoint;
  140997. /**
  140998. * Gets the replacement input component
  140999. */
  141000. get replacement(): NodeMaterialConnectionPoint;
  141001. /**
  141002. * Gets the output component
  141003. */
  141004. get output(): NodeMaterialConnectionPoint;
  141005. protected _buildBlock(state: NodeMaterialBuildState): this;
  141006. }
  141007. }
  141008. declare module BABYLON {
  141009. /**
  141010. * Block used to posterize a value
  141011. * @see https://en.wikipedia.org/wiki/Posterization
  141012. */
  141013. export class PosterizeBlock extends NodeMaterialBlock {
  141014. /**
  141015. * Creates a new PosterizeBlock
  141016. * @param name defines the block name
  141017. */
  141018. constructor(name: string);
  141019. /**
  141020. * Gets the current class name
  141021. * @returns the class name
  141022. */
  141023. getClassName(): string;
  141024. /**
  141025. * Gets the value input component
  141026. */
  141027. get value(): NodeMaterialConnectionPoint;
  141028. /**
  141029. * Gets the steps input component
  141030. */
  141031. get steps(): NodeMaterialConnectionPoint;
  141032. /**
  141033. * Gets the output component
  141034. */
  141035. get output(): NodeMaterialConnectionPoint;
  141036. protected _buildBlock(state: NodeMaterialBuildState): this;
  141037. }
  141038. }
  141039. declare module BABYLON {
  141040. /**
  141041. * Operations supported by the Wave block
  141042. */
  141043. export enum WaveBlockKind {
  141044. /** SawTooth */
  141045. SawTooth = 0,
  141046. /** Square */
  141047. Square = 1,
  141048. /** Triangle */
  141049. Triangle = 2
  141050. }
  141051. /**
  141052. * Block used to apply wave operation to floats
  141053. */
  141054. export class WaveBlock extends NodeMaterialBlock {
  141055. /**
  141056. * Gets or sets the kibnd of wave to be applied by the block
  141057. */
  141058. kind: WaveBlockKind;
  141059. /**
  141060. * Creates a new WaveBlock
  141061. * @param name defines the block name
  141062. */
  141063. constructor(name: string);
  141064. /**
  141065. * Gets the current class name
  141066. * @returns the class name
  141067. */
  141068. getClassName(): string;
  141069. /**
  141070. * Gets the input component
  141071. */
  141072. get input(): NodeMaterialConnectionPoint;
  141073. /**
  141074. * Gets the output component
  141075. */
  141076. get output(): NodeMaterialConnectionPoint;
  141077. protected _buildBlock(state: NodeMaterialBuildState): this;
  141078. serialize(): any;
  141079. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141080. }
  141081. }
  141082. declare module BABYLON {
  141083. /**
  141084. * Class used to store a color step for the GradientBlock
  141085. */
  141086. export class GradientBlockColorStep {
  141087. /**
  141088. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  141089. */
  141090. step: number;
  141091. /**
  141092. * Gets or sets the color associated with this step
  141093. */
  141094. color: Color3;
  141095. /**
  141096. * Creates a new GradientBlockColorStep
  141097. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  141098. * @param color defines the color associated with this step
  141099. */
  141100. constructor(
  141101. /**
  141102. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  141103. */
  141104. step: number,
  141105. /**
  141106. * Gets or sets the color associated with this step
  141107. */
  141108. color: Color3);
  141109. }
  141110. /**
  141111. * Block used to return a color from a gradient based on an input value between 0 and 1
  141112. */
  141113. export class GradientBlock extends NodeMaterialBlock {
  141114. /**
  141115. * Gets or sets the list of color steps
  141116. */
  141117. colorSteps: GradientBlockColorStep[];
  141118. /**
  141119. * Creates a new GradientBlock
  141120. * @param name defines the block name
  141121. */
  141122. constructor(name: string);
  141123. /**
  141124. * Gets the current class name
  141125. * @returns the class name
  141126. */
  141127. getClassName(): string;
  141128. /**
  141129. * Gets the gradient input component
  141130. */
  141131. get gradient(): NodeMaterialConnectionPoint;
  141132. /**
  141133. * Gets the output component
  141134. */
  141135. get output(): NodeMaterialConnectionPoint;
  141136. private _writeColorConstant;
  141137. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  141138. serialize(): any;
  141139. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141140. protected _dumpPropertiesCode(): string;
  141141. }
  141142. }
  141143. declare module BABYLON {
  141144. /**
  141145. * Block used to normalize lerp between 2 values
  141146. */
  141147. export class NLerpBlock extends NodeMaterialBlock {
  141148. /**
  141149. * Creates a new NLerpBlock
  141150. * @param name defines the block name
  141151. */
  141152. constructor(name: string);
  141153. /**
  141154. * Gets the current class name
  141155. * @returns the class name
  141156. */
  141157. getClassName(): string;
  141158. /**
  141159. * Gets the left operand input component
  141160. */
  141161. get left(): NodeMaterialConnectionPoint;
  141162. /**
  141163. * Gets the right operand input component
  141164. */
  141165. get right(): NodeMaterialConnectionPoint;
  141166. /**
  141167. * Gets the gradient operand input component
  141168. */
  141169. get gradient(): NodeMaterialConnectionPoint;
  141170. /**
  141171. * Gets the output component
  141172. */
  141173. get output(): NodeMaterialConnectionPoint;
  141174. protected _buildBlock(state: NodeMaterialBuildState): this;
  141175. }
  141176. }
  141177. declare module BABYLON {
  141178. /**
  141179. * block used to Generate a Worley Noise 3D Noise Pattern
  141180. */
  141181. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  141182. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  141183. manhattanDistance: boolean;
  141184. /**
  141185. * Creates a new WorleyNoise3DBlock
  141186. * @param name defines the block name
  141187. */
  141188. constructor(name: string);
  141189. /**
  141190. * Gets the current class name
  141191. * @returns the class name
  141192. */
  141193. getClassName(): string;
  141194. /**
  141195. * Gets the seed input component
  141196. */
  141197. get seed(): NodeMaterialConnectionPoint;
  141198. /**
  141199. * Gets the jitter input component
  141200. */
  141201. get jitter(): NodeMaterialConnectionPoint;
  141202. /**
  141203. * Gets the output component
  141204. */
  141205. get output(): NodeMaterialConnectionPoint;
  141206. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  141207. /**
  141208. * Exposes the properties to the UI?
  141209. */
  141210. protected _dumpPropertiesCode(): string;
  141211. /**
  141212. * Exposes the properties to the Seralize?
  141213. */
  141214. serialize(): any;
  141215. /**
  141216. * Exposes the properties to the deseralize?
  141217. */
  141218. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141219. }
  141220. }
  141221. declare module BABYLON {
  141222. /**
  141223. * block used to Generate a Simplex Perlin 3d Noise Pattern
  141224. */
  141225. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  141226. /**
  141227. * Creates a new SimplexPerlin3DBlock
  141228. * @param name defines the block name
  141229. */
  141230. constructor(name: string);
  141231. /**
  141232. * Gets the current class name
  141233. * @returns the class name
  141234. */
  141235. getClassName(): string;
  141236. /**
  141237. * Gets the seed operand input component
  141238. */
  141239. get seed(): NodeMaterialConnectionPoint;
  141240. /**
  141241. * Gets the output component
  141242. */
  141243. get output(): NodeMaterialConnectionPoint;
  141244. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  141245. }
  141246. }
  141247. declare module BABYLON {
  141248. /**
  141249. * Block used to blend normals
  141250. */
  141251. export class NormalBlendBlock extends NodeMaterialBlock {
  141252. /**
  141253. * Creates a new NormalBlendBlock
  141254. * @param name defines the block name
  141255. */
  141256. constructor(name: string);
  141257. /**
  141258. * Gets the current class name
  141259. * @returns the class name
  141260. */
  141261. getClassName(): string;
  141262. /**
  141263. * Gets the first input component
  141264. */
  141265. get normalMap0(): NodeMaterialConnectionPoint;
  141266. /**
  141267. * Gets the second input component
  141268. */
  141269. get normalMap1(): NodeMaterialConnectionPoint;
  141270. /**
  141271. * Gets the output component
  141272. */
  141273. get output(): NodeMaterialConnectionPoint;
  141274. protected _buildBlock(state: NodeMaterialBuildState): this;
  141275. }
  141276. }
  141277. declare module BABYLON {
  141278. /**
  141279. * Block used to rotate a 2d vector by a given angle
  141280. */
  141281. export class Rotate2dBlock extends NodeMaterialBlock {
  141282. /**
  141283. * Creates a new Rotate2dBlock
  141284. * @param name defines the block name
  141285. */
  141286. constructor(name: string);
  141287. /**
  141288. * Gets the current class name
  141289. * @returns the class name
  141290. */
  141291. getClassName(): string;
  141292. /**
  141293. * Gets the input vector
  141294. */
  141295. get input(): NodeMaterialConnectionPoint;
  141296. /**
  141297. * Gets the input angle
  141298. */
  141299. get angle(): NodeMaterialConnectionPoint;
  141300. /**
  141301. * Gets the output component
  141302. */
  141303. get output(): NodeMaterialConnectionPoint;
  141304. autoConfigure(material: NodeMaterial): void;
  141305. protected _buildBlock(state: NodeMaterialBuildState): this;
  141306. }
  141307. }
  141308. declare module BABYLON {
  141309. /**
  141310. * Block used to get the reflected vector from a direction and a normal
  141311. */
  141312. export class ReflectBlock extends NodeMaterialBlock {
  141313. /**
  141314. * Creates a new ReflectBlock
  141315. * @param name defines the block name
  141316. */
  141317. constructor(name: string);
  141318. /**
  141319. * Gets the current class name
  141320. * @returns the class name
  141321. */
  141322. getClassName(): string;
  141323. /**
  141324. * Gets the incident component
  141325. */
  141326. get incident(): NodeMaterialConnectionPoint;
  141327. /**
  141328. * Gets the normal component
  141329. */
  141330. get normal(): NodeMaterialConnectionPoint;
  141331. /**
  141332. * Gets the output component
  141333. */
  141334. get output(): NodeMaterialConnectionPoint;
  141335. protected _buildBlock(state: NodeMaterialBuildState): this;
  141336. }
  141337. }
  141338. declare module BABYLON {
  141339. /**
  141340. * Block used to get the refracted vector from a direction and a normal
  141341. */
  141342. export class RefractBlock extends NodeMaterialBlock {
  141343. /**
  141344. * Creates a new RefractBlock
  141345. * @param name defines the block name
  141346. */
  141347. constructor(name: string);
  141348. /**
  141349. * Gets the current class name
  141350. * @returns the class name
  141351. */
  141352. getClassName(): string;
  141353. /**
  141354. * Gets the incident component
  141355. */
  141356. get incident(): NodeMaterialConnectionPoint;
  141357. /**
  141358. * Gets the normal component
  141359. */
  141360. get normal(): NodeMaterialConnectionPoint;
  141361. /**
  141362. * Gets the index of refraction component
  141363. */
  141364. get ior(): NodeMaterialConnectionPoint;
  141365. /**
  141366. * Gets the output component
  141367. */
  141368. get output(): NodeMaterialConnectionPoint;
  141369. protected _buildBlock(state: NodeMaterialBuildState): this;
  141370. }
  141371. }
  141372. declare module BABYLON {
  141373. /**
  141374. * Block used to desaturate a color
  141375. */
  141376. export class DesaturateBlock extends NodeMaterialBlock {
  141377. /**
  141378. * Creates a new DesaturateBlock
  141379. * @param name defines the block name
  141380. */
  141381. constructor(name: string);
  141382. /**
  141383. * Gets the current class name
  141384. * @returns the class name
  141385. */
  141386. getClassName(): string;
  141387. /**
  141388. * Gets the color operand input component
  141389. */
  141390. get color(): NodeMaterialConnectionPoint;
  141391. /**
  141392. * Gets the level operand input component
  141393. */
  141394. get level(): NodeMaterialConnectionPoint;
  141395. /**
  141396. * Gets the output component
  141397. */
  141398. get output(): NodeMaterialConnectionPoint;
  141399. protected _buildBlock(state: NodeMaterialBuildState): this;
  141400. }
  141401. }
  141402. declare module BABYLON {
  141403. /**
  141404. * Block used to implement the ambient occlusion module of the PBR material
  141405. */
  141406. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  141407. /**
  141408. * Create a new AmbientOcclusionBlock
  141409. * @param name defines the block name
  141410. */
  141411. constructor(name: string);
  141412. /**
  141413. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  141414. */
  141415. useAmbientInGrayScale: boolean;
  141416. /**
  141417. * Initialize the block and prepare the context for build
  141418. * @param state defines the state that will be used for the build
  141419. */
  141420. initialize(state: NodeMaterialBuildState): void;
  141421. /**
  141422. * Gets the current class name
  141423. * @returns the class name
  141424. */
  141425. getClassName(): string;
  141426. /**
  141427. * Gets the texture input component
  141428. */
  141429. get texture(): NodeMaterialConnectionPoint;
  141430. /**
  141431. * Gets the texture intensity component
  141432. */
  141433. get intensity(): NodeMaterialConnectionPoint;
  141434. /**
  141435. * Gets the direct light intensity input component
  141436. */
  141437. get directLightIntensity(): NodeMaterialConnectionPoint;
  141438. /**
  141439. * Gets the ambient occlusion object output component
  141440. */
  141441. get ambientOcclusion(): NodeMaterialConnectionPoint;
  141442. /**
  141443. * Gets the main code of the block (fragment side)
  141444. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  141445. * @returns the shader code
  141446. */
  141447. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  141448. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141449. protected _buildBlock(state: NodeMaterialBuildState): this;
  141450. protected _dumpPropertiesCode(): string;
  141451. serialize(): any;
  141452. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141453. }
  141454. }
  141455. declare module BABYLON {
  141456. /**
  141457. * Block used to implement the reflection module of the PBR material
  141458. */
  141459. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  141460. /** @hidden */
  141461. _defineLODReflectionAlpha: string;
  141462. /** @hidden */
  141463. _defineLinearSpecularReflection: string;
  141464. private _vEnvironmentIrradianceName;
  141465. /** @hidden */
  141466. _vReflectionMicrosurfaceInfosName: string;
  141467. /** @hidden */
  141468. _vReflectionInfosName: string;
  141469. /** @hidden */
  141470. _vReflectionFilteringInfoName: string;
  141471. private _scene;
  141472. /**
  141473. * The three properties below are set by the main PBR block prior to calling methods of this class.
  141474. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  141475. * It's less burden on the user side in the editor part.
  141476. */
  141477. /** @hidden */
  141478. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  141479. /** @hidden */
  141480. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  141481. /** @hidden */
  141482. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  141483. /**
  141484. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  141485. * diffuse part of the IBL.
  141486. */
  141487. useSphericalHarmonics: boolean;
  141488. /**
  141489. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  141490. */
  141491. forceIrradianceInFragment: boolean;
  141492. /**
  141493. * Create a new ReflectionBlock
  141494. * @param name defines the block name
  141495. */
  141496. constructor(name: string);
  141497. /**
  141498. * Gets the current class name
  141499. * @returns the class name
  141500. */
  141501. getClassName(): string;
  141502. /**
  141503. * Gets the position input component
  141504. */
  141505. get position(): NodeMaterialConnectionPoint;
  141506. /**
  141507. * Gets the world position input component
  141508. */
  141509. get worldPosition(): NodeMaterialConnectionPoint;
  141510. /**
  141511. * Gets the world normal input component
  141512. */
  141513. get worldNormal(): NodeMaterialConnectionPoint;
  141514. /**
  141515. * Gets the world input component
  141516. */
  141517. get world(): NodeMaterialConnectionPoint;
  141518. /**
  141519. * Gets the camera (or eye) position component
  141520. */
  141521. get cameraPosition(): NodeMaterialConnectionPoint;
  141522. /**
  141523. * Gets the view input component
  141524. */
  141525. get view(): NodeMaterialConnectionPoint;
  141526. /**
  141527. * Gets the color input component
  141528. */
  141529. get color(): NodeMaterialConnectionPoint;
  141530. /**
  141531. * Gets the reflection object output component
  141532. */
  141533. get reflection(): NodeMaterialConnectionPoint;
  141534. /**
  141535. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  141536. */
  141537. get hasTexture(): boolean;
  141538. /**
  141539. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  141540. */
  141541. get reflectionColor(): string;
  141542. protected _getTexture(): Nullable<BaseTexture>;
  141543. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141544. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  141545. /**
  141546. * Gets the code to inject in the vertex shader
  141547. * @param state current state of the node material building
  141548. * @returns the shader code
  141549. */
  141550. handleVertexSide(state: NodeMaterialBuildState): string;
  141551. /**
  141552. * Gets the main code of the block (fragment side)
  141553. * @param state current state of the node material building
  141554. * @param normalVarName name of the existing variable corresponding to the normal
  141555. * @returns the shader code
  141556. */
  141557. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  141558. protected _buildBlock(state: NodeMaterialBuildState): this;
  141559. protected _dumpPropertiesCode(): string;
  141560. serialize(): any;
  141561. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141562. }
  141563. }
  141564. declare module BABYLON {
  141565. /**
  141566. * Block used to implement the sheen module of the PBR material
  141567. */
  141568. export class SheenBlock extends NodeMaterialBlock {
  141569. /**
  141570. * Create a new SheenBlock
  141571. * @param name defines the block name
  141572. */
  141573. constructor(name: string);
  141574. /**
  141575. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  141576. * It allows the strength of the sheen effect to not depend on the base color of the material,
  141577. * making it easier to setup and tweak the effect
  141578. */
  141579. albedoScaling: boolean;
  141580. /**
  141581. * Defines if the sheen is linked to the sheen color.
  141582. */
  141583. linkSheenWithAlbedo: boolean;
  141584. /**
  141585. * Initialize the block and prepare the context for build
  141586. * @param state defines the state that will be used for the build
  141587. */
  141588. initialize(state: NodeMaterialBuildState): void;
  141589. /**
  141590. * Gets the current class name
  141591. * @returns the class name
  141592. */
  141593. getClassName(): string;
  141594. /**
  141595. * Gets the intensity input component
  141596. */
  141597. get intensity(): NodeMaterialConnectionPoint;
  141598. /**
  141599. * Gets the color input component
  141600. */
  141601. get color(): NodeMaterialConnectionPoint;
  141602. /**
  141603. * Gets the roughness input component
  141604. */
  141605. get roughness(): NodeMaterialConnectionPoint;
  141606. /**
  141607. * Gets the sheen object output component
  141608. */
  141609. get sheen(): NodeMaterialConnectionPoint;
  141610. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141611. /**
  141612. * Gets the main code of the block (fragment side)
  141613. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  141614. * @returns the shader code
  141615. */
  141616. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  141617. protected _buildBlock(state: NodeMaterialBuildState): this;
  141618. protected _dumpPropertiesCode(): string;
  141619. serialize(): any;
  141620. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141621. }
  141622. }
  141623. declare module BABYLON {
  141624. /**
  141625. * Block used to implement the reflectivity module of the PBR material
  141626. */
  141627. export class ReflectivityBlock extends NodeMaterialBlock {
  141628. private _metallicReflectanceColor;
  141629. private _metallicF0Factor;
  141630. /** @hidden */
  141631. _vMetallicReflectanceFactorsName: string;
  141632. /**
  141633. * The property below is set by the main PBR block prior to calling methods of this class.
  141634. */
  141635. /** @hidden */
  141636. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  141637. /**
  141638. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  141639. */
  141640. useAmbientOcclusionFromMetallicTextureRed: boolean;
  141641. /**
  141642. * Specifies if the metallic texture contains the metallness information in its blue channel.
  141643. */
  141644. useMetallnessFromMetallicTextureBlue: boolean;
  141645. /**
  141646. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  141647. */
  141648. useRoughnessFromMetallicTextureAlpha: boolean;
  141649. /**
  141650. * Specifies if the metallic texture contains the roughness information in its green channel.
  141651. */
  141652. useRoughnessFromMetallicTextureGreen: boolean;
  141653. /**
  141654. * Create a new ReflectivityBlock
  141655. * @param name defines the block name
  141656. */
  141657. constructor(name: string);
  141658. /**
  141659. * Initialize the block and prepare the context for build
  141660. * @param state defines the state that will be used for the build
  141661. */
  141662. initialize(state: NodeMaterialBuildState): void;
  141663. /**
  141664. * Gets the current class name
  141665. * @returns the class name
  141666. */
  141667. getClassName(): string;
  141668. /**
  141669. * Gets the metallic input component
  141670. */
  141671. get metallic(): NodeMaterialConnectionPoint;
  141672. /**
  141673. * Gets the roughness input component
  141674. */
  141675. get roughness(): NodeMaterialConnectionPoint;
  141676. /**
  141677. * Gets the texture input component
  141678. */
  141679. get texture(): NodeMaterialConnectionPoint;
  141680. /**
  141681. * Gets the reflectivity object output component
  141682. */
  141683. get reflectivity(): NodeMaterialConnectionPoint;
  141684. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  141685. /**
  141686. * Gets the main code of the block (fragment side)
  141687. * @param state current state of the node material building
  141688. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  141689. * @returns the shader code
  141690. */
  141691. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  141692. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141693. protected _buildBlock(state: NodeMaterialBuildState): this;
  141694. protected _dumpPropertiesCode(): string;
  141695. serialize(): any;
  141696. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141697. }
  141698. }
  141699. declare module BABYLON {
  141700. /**
  141701. * Block used to implement the anisotropy module of the PBR material
  141702. */
  141703. export class AnisotropyBlock extends NodeMaterialBlock {
  141704. /**
  141705. * The two properties below are set by the main PBR block prior to calling methods of this class.
  141706. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  141707. * It's less burden on the user side in the editor part.
  141708. */
  141709. /** @hidden */
  141710. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  141711. /** @hidden */
  141712. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  141713. /**
  141714. * Create a new AnisotropyBlock
  141715. * @param name defines the block name
  141716. */
  141717. constructor(name: string);
  141718. /**
  141719. * Initialize the block and prepare the context for build
  141720. * @param state defines the state that will be used for the build
  141721. */
  141722. initialize(state: NodeMaterialBuildState): void;
  141723. /**
  141724. * Gets the current class name
  141725. * @returns the class name
  141726. */
  141727. getClassName(): string;
  141728. /**
  141729. * Gets the intensity input component
  141730. */
  141731. get intensity(): NodeMaterialConnectionPoint;
  141732. /**
  141733. * Gets the direction input component
  141734. */
  141735. get direction(): NodeMaterialConnectionPoint;
  141736. /**
  141737. * Gets the texture input component
  141738. */
  141739. get texture(): NodeMaterialConnectionPoint;
  141740. /**
  141741. * Gets the uv input component
  141742. */
  141743. get uv(): NodeMaterialConnectionPoint;
  141744. /**
  141745. * Gets the worldTangent input component
  141746. */
  141747. get worldTangent(): NodeMaterialConnectionPoint;
  141748. /**
  141749. * Gets the anisotropy object output component
  141750. */
  141751. get anisotropy(): NodeMaterialConnectionPoint;
  141752. private _generateTBNSpace;
  141753. /**
  141754. * Gets the main code of the block (fragment side)
  141755. * @param state current state of the node material building
  141756. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  141757. * @returns the shader code
  141758. */
  141759. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  141760. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141761. protected _buildBlock(state: NodeMaterialBuildState): this;
  141762. }
  141763. }
  141764. declare module BABYLON {
  141765. /**
  141766. * Block used to implement the clear coat module of the PBR material
  141767. */
  141768. export class ClearCoatBlock extends NodeMaterialBlock {
  141769. private _scene;
  141770. /**
  141771. * Create a new ClearCoatBlock
  141772. * @param name defines the block name
  141773. */
  141774. constructor(name: string);
  141775. /**
  141776. * Initialize the block and prepare the context for build
  141777. * @param state defines the state that will be used for the build
  141778. */
  141779. initialize(state: NodeMaterialBuildState): void;
  141780. /**
  141781. * Gets the current class name
  141782. * @returns the class name
  141783. */
  141784. getClassName(): string;
  141785. /**
  141786. * Gets the intensity input component
  141787. */
  141788. get intensity(): NodeMaterialConnectionPoint;
  141789. /**
  141790. * Gets the roughness input component
  141791. */
  141792. get roughness(): NodeMaterialConnectionPoint;
  141793. /**
  141794. * Gets the ior input component
  141795. */
  141796. get ior(): NodeMaterialConnectionPoint;
  141797. /**
  141798. * Gets the texture input component
  141799. */
  141800. get texture(): NodeMaterialConnectionPoint;
  141801. /**
  141802. * Gets the bump texture input component
  141803. */
  141804. get bumpTexture(): NodeMaterialConnectionPoint;
  141805. /**
  141806. * Gets the uv input component
  141807. */
  141808. get uv(): NodeMaterialConnectionPoint;
  141809. /**
  141810. * Gets the tint color input component
  141811. */
  141812. get tintColor(): NodeMaterialConnectionPoint;
  141813. /**
  141814. * Gets the tint "at distance" input component
  141815. */
  141816. get tintAtDistance(): NodeMaterialConnectionPoint;
  141817. /**
  141818. * Gets the tint thickness input component
  141819. */
  141820. get tintThickness(): NodeMaterialConnectionPoint;
  141821. /**
  141822. * Gets the world tangent input component
  141823. */
  141824. get worldTangent(): NodeMaterialConnectionPoint;
  141825. /**
  141826. * Gets the clear coat object output component
  141827. */
  141828. get clearcoat(): NodeMaterialConnectionPoint;
  141829. autoConfigure(material: NodeMaterial): void;
  141830. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141831. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  141832. private _generateTBNSpace;
  141833. /**
  141834. * Gets the main code of the block (fragment side)
  141835. * @param state current state of the node material building
  141836. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  141837. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  141838. * @param worldPosVarName name of the variable holding the world position
  141839. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  141840. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  141841. * @param worldNormalVarName name of the variable holding the world normal
  141842. * @returns the shader code
  141843. */
  141844. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  141845. protected _buildBlock(state: NodeMaterialBuildState): this;
  141846. }
  141847. }
  141848. declare module BABYLON {
  141849. /**
  141850. * Block used to implement the sub surface module of the PBR material
  141851. */
  141852. export class SubSurfaceBlock extends NodeMaterialBlock {
  141853. /**
  141854. * Create a new SubSurfaceBlock
  141855. * @param name defines the block name
  141856. */
  141857. constructor(name: string);
  141858. /**
  141859. * Stores the intensity of the different subsurface effects in the thickness texture.
  141860. * * the green channel is the translucency intensity.
  141861. * * the blue channel is the scattering intensity.
  141862. * * the alpha channel is the refraction intensity.
  141863. */
  141864. useMaskFromThicknessTexture: boolean;
  141865. /**
  141866. * Initialize the block and prepare the context for build
  141867. * @param state defines the state that will be used for the build
  141868. */
  141869. initialize(state: NodeMaterialBuildState): void;
  141870. /**
  141871. * Gets the current class name
  141872. * @returns the class name
  141873. */
  141874. getClassName(): string;
  141875. /**
  141876. * Gets the min thickness input component
  141877. */
  141878. get minThickness(): NodeMaterialConnectionPoint;
  141879. /**
  141880. * Gets the max thickness input component
  141881. */
  141882. get maxThickness(): NodeMaterialConnectionPoint;
  141883. /**
  141884. * Gets the thickness texture component
  141885. */
  141886. get thicknessTexture(): NodeMaterialConnectionPoint;
  141887. /**
  141888. * Gets the tint color input component
  141889. */
  141890. get tintColor(): NodeMaterialConnectionPoint;
  141891. /**
  141892. * Gets the translucency intensity input component
  141893. */
  141894. get translucencyIntensity(): NodeMaterialConnectionPoint;
  141895. /**
  141896. * Gets the translucency diffusion distance input component
  141897. */
  141898. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  141899. /**
  141900. * Gets the refraction object parameters
  141901. */
  141902. get refraction(): NodeMaterialConnectionPoint;
  141903. /**
  141904. * Gets the sub surface object output component
  141905. */
  141906. get subsurface(): NodeMaterialConnectionPoint;
  141907. autoConfigure(material: NodeMaterial): void;
  141908. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141909. /**
  141910. * Gets the main code of the block (fragment side)
  141911. * @param state current state of the node material building
  141912. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  141913. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  141914. * @param worldPosVarName name of the variable holding the world position
  141915. * @returns the shader code
  141916. */
  141917. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  141918. protected _buildBlock(state: NodeMaterialBuildState): this;
  141919. }
  141920. }
  141921. declare module BABYLON {
  141922. /**
  141923. * Block used to implement the PBR metallic/roughness model
  141924. */
  141925. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  141926. /**
  141927. * Gets or sets the light associated with this block
  141928. */
  141929. light: Nullable<Light>;
  141930. private _lightId;
  141931. private _scene;
  141932. private _environmentBRDFTexture;
  141933. private _environmentBrdfSamplerName;
  141934. private _vNormalWName;
  141935. private _invertNormalName;
  141936. /**
  141937. * Create a new ReflectionBlock
  141938. * @param name defines the block name
  141939. */
  141940. constructor(name: string);
  141941. /**
  141942. * Intensity of the direct lights e.g. the four lights available in your scene.
  141943. * This impacts both the direct diffuse and specular highlights.
  141944. */
  141945. directIntensity: number;
  141946. /**
  141947. * Intensity of the environment e.g. how much the environment will light the object
  141948. * either through harmonics for rough material or through the refelction for shiny ones.
  141949. */
  141950. environmentIntensity: number;
  141951. /**
  141952. * This is a special control allowing the reduction of the specular highlights coming from the
  141953. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  141954. */
  141955. specularIntensity: number;
  141956. /**
  141957. * Defines the falloff type used in this material.
  141958. * It by default is Physical.
  141959. */
  141960. lightFalloff: number;
  141961. /**
  141962. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  141963. */
  141964. useAlphaFromAlbedoTexture: boolean;
  141965. /**
  141966. * Specifies that alpha test should be used
  141967. */
  141968. useAlphaTest: boolean;
  141969. /**
  141970. * Defines the alpha limits in alpha test mode.
  141971. */
  141972. alphaTestCutoff: number;
  141973. /**
  141974. * Specifies that alpha blending should be used
  141975. */
  141976. useAlphaBlending: boolean;
  141977. /**
  141978. * Defines if the alpha value should be determined via the rgb values.
  141979. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  141980. */
  141981. opacityRGB: boolean;
  141982. /**
  141983. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  141984. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  141985. */
  141986. useRadianceOverAlpha: boolean;
  141987. /**
  141988. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  141989. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  141990. */
  141991. useSpecularOverAlpha: boolean;
  141992. /**
  141993. * Enables specular anti aliasing in the PBR shader.
  141994. * It will both interacts on the Geometry for analytical and IBL lighting.
  141995. * It also prefilter the roughness map based on the bump values.
  141996. */
  141997. enableSpecularAntiAliasing: boolean;
  141998. /**
  141999. * Enables realtime filtering on the texture.
  142000. */
  142001. realTimeFiltering: boolean;
  142002. /**
  142003. * Quality switch for realtime filtering
  142004. */
  142005. realTimeFilteringQuality: number;
  142006. /**
  142007. * Defines if the material uses energy conservation.
  142008. */
  142009. useEnergyConservation: boolean;
  142010. /**
  142011. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  142012. * too much the area relying on ambient texture to define their ambient occlusion.
  142013. */
  142014. useRadianceOcclusion: boolean;
  142015. /**
  142016. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  142017. * makes the reflect vector face the model (under horizon).
  142018. */
  142019. useHorizonOcclusion: boolean;
  142020. /**
  142021. * If set to true, no lighting calculations will be applied.
  142022. */
  142023. unlit: boolean;
  142024. /**
  142025. * Force normal to face away from face.
  142026. */
  142027. forceNormalForward: boolean;
  142028. /**
  142029. * Defines the material debug mode.
  142030. * It helps seeing only some components of the material while troubleshooting.
  142031. */
  142032. debugMode: number;
  142033. /**
  142034. * Specify from where on screen the debug mode should start.
  142035. * The value goes from -1 (full screen) to 1 (not visible)
  142036. * It helps with side by side comparison against the final render
  142037. * This defaults to 0
  142038. */
  142039. debugLimit: number;
  142040. /**
  142041. * As the default viewing range might not be enough (if the ambient is really small for instance)
  142042. * You can use the factor to better multiply the final value.
  142043. */
  142044. debugFactor: number;
  142045. /**
  142046. * Initialize the block and prepare the context for build
  142047. * @param state defines the state that will be used for the build
  142048. */
  142049. initialize(state: NodeMaterialBuildState): void;
  142050. /**
  142051. * Gets the current class name
  142052. * @returns the class name
  142053. */
  142054. getClassName(): string;
  142055. /**
  142056. * Gets the world position input component
  142057. */
  142058. get worldPosition(): NodeMaterialConnectionPoint;
  142059. /**
  142060. * Gets the world normal input component
  142061. */
  142062. get worldNormal(): NodeMaterialConnectionPoint;
  142063. /**
  142064. * Gets the perturbed normal input component
  142065. */
  142066. get perturbedNormal(): NodeMaterialConnectionPoint;
  142067. /**
  142068. * Gets the camera position input component
  142069. */
  142070. get cameraPosition(): NodeMaterialConnectionPoint;
  142071. /**
  142072. * Gets the base color input component
  142073. */
  142074. get baseColor(): NodeMaterialConnectionPoint;
  142075. /**
  142076. * Gets the opacity texture input component
  142077. */
  142078. get opacityTexture(): NodeMaterialConnectionPoint;
  142079. /**
  142080. * Gets the ambient color input component
  142081. */
  142082. get ambientColor(): NodeMaterialConnectionPoint;
  142083. /**
  142084. * Gets the reflectivity object parameters
  142085. */
  142086. get reflectivity(): NodeMaterialConnectionPoint;
  142087. /**
  142088. * Gets the ambient occlusion object parameters
  142089. */
  142090. get ambientOcclusion(): NodeMaterialConnectionPoint;
  142091. /**
  142092. * Gets the reflection object parameters
  142093. */
  142094. get reflection(): NodeMaterialConnectionPoint;
  142095. /**
  142096. * Gets the sheen object parameters
  142097. */
  142098. get sheen(): NodeMaterialConnectionPoint;
  142099. /**
  142100. * Gets the clear coat object parameters
  142101. */
  142102. get clearcoat(): NodeMaterialConnectionPoint;
  142103. /**
  142104. * Gets the sub surface object parameters
  142105. */
  142106. get subsurface(): NodeMaterialConnectionPoint;
  142107. /**
  142108. * Gets the anisotropy object parameters
  142109. */
  142110. get anisotropy(): NodeMaterialConnectionPoint;
  142111. /**
  142112. * Gets the ambient output component
  142113. */
  142114. get ambient(): NodeMaterialConnectionPoint;
  142115. /**
  142116. * Gets the diffuse output component
  142117. */
  142118. get diffuse(): NodeMaterialConnectionPoint;
  142119. /**
  142120. * Gets the specular output component
  142121. */
  142122. get specular(): NodeMaterialConnectionPoint;
  142123. /**
  142124. * Gets the sheen output component
  142125. */
  142126. get sheenDir(): NodeMaterialConnectionPoint;
  142127. /**
  142128. * Gets the clear coat output component
  142129. */
  142130. get clearcoatDir(): NodeMaterialConnectionPoint;
  142131. /**
  142132. * Gets the indirect diffuse output component
  142133. */
  142134. get diffuseIndirect(): NodeMaterialConnectionPoint;
  142135. /**
  142136. * Gets the indirect specular output component
  142137. */
  142138. get specularIndirect(): NodeMaterialConnectionPoint;
  142139. /**
  142140. * Gets the indirect sheen output component
  142141. */
  142142. get sheenIndirect(): NodeMaterialConnectionPoint;
  142143. /**
  142144. * Gets the indirect clear coat output component
  142145. */
  142146. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  142147. /**
  142148. * Gets the refraction output component
  142149. */
  142150. get refraction(): NodeMaterialConnectionPoint;
  142151. /**
  142152. * Gets the global lighting output component
  142153. */
  142154. get lighting(): NodeMaterialConnectionPoint;
  142155. /**
  142156. * Gets the shadow output component
  142157. */
  142158. get shadow(): NodeMaterialConnectionPoint;
  142159. /**
  142160. * Gets the alpha output component
  142161. */
  142162. get alpha(): NodeMaterialConnectionPoint;
  142163. autoConfigure(material: NodeMaterial): void;
  142164. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142165. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  142166. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142167. private _injectVertexCode;
  142168. /**
  142169. * Gets the code corresponding to the albedo/opacity module
  142170. * @returns the shader code
  142171. */
  142172. getAlbedoOpacityCode(): string;
  142173. protected _buildBlock(state: NodeMaterialBuildState): this;
  142174. protected _dumpPropertiesCode(): string;
  142175. serialize(): any;
  142176. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142177. }
  142178. }
  142179. declare module BABYLON {
  142180. /**
  142181. * Block used to compute value of one parameter modulo another
  142182. */
  142183. export class ModBlock extends NodeMaterialBlock {
  142184. /**
  142185. * Creates a new ModBlock
  142186. * @param name defines the block name
  142187. */
  142188. constructor(name: string);
  142189. /**
  142190. * Gets the current class name
  142191. * @returns the class name
  142192. */
  142193. getClassName(): string;
  142194. /**
  142195. * Gets the left operand input component
  142196. */
  142197. get left(): NodeMaterialConnectionPoint;
  142198. /**
  142199. * Gets the right operand input component
  142200. */
  142201. get right(): NodeMaterialConnectionPoint;
  142202. /**
  142203. * Gets the output component
  142204. */
  142205. get output(): NodeMaterialConnectionPoint;
  142206. protected _buildBlock(state: NodeMaterialBuildState): this;
  142207. }
  142208. }
  142209. declare module BABYLON {
  142210. /**
  142211. * Helper class to push actions to a pool of workers.
  142212. */
  142213. export class WorkerPool implements IDisposable {
  142214. private _workerInfos;
  142215. private _pendingActions;
  142216. /**
  142217. * Constructor
  142218. * @param workers Array of workers to use for actions
  142219. */
  142220. constructor(workers: Array<Worker>);
  142221. /**
  142222. * Terminates all workers and clears any pending actions.
  142223. */
  142224. dispose(): void;
  142225. /**
  142226. * Pushes an action to the worker pool. If all the workers are active, the action will be
  142227. * pended until a worker has completed its action.
  142228. * @param action The action to perform. Call onComplete when the action is complete.
  142229. */
  142230. push(action: (worker: Worker, onComplete: () => void) => void): void;
  142231. private _execute;
  142232. }
  142233. }
  142234. declare module BABYLON {
  142235. /**
  142236. * Configuration for Draco compression
  142237. */
  142238. export interface IDracoCompressionConfiguration {
  142239. /**
  142240. * Configuration for the decoder.
  142241. */
  142242. decoder: {
  142243. /**
  142244. * The url to the WebAssembly module.
  142245. */
  142246. wasmUrl?: string;
  142247. /**
  142248. * The url to the WebAssembly binary.
  142249. */
  142250. wasmBinaryUrl?: string;
  142251. /**
  142252. * The url to the fallback JavaScript module.
  142253. */
  142254. fallbackUrl?: string;
  142255. };
  142256. }
  142257. /**
  142258. * Draco compression (https://google.github.io/draco/)
  142259. *
  142260. * This class wraps the Draco module.
  142261. *
  142262. * **Encoder**
  142263. *
  142264. * The encoder is not currently implemented.
  142265. *
  142266. * **Decoder**
  142267. *
  142268. * 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.
  142269. *
  142270. * To update the configuration, use the following code:
  142271. * ```javascript
  142272. * DracoCompression.Configuration = {
  142273. * decoder: {
  142274. * wasmUrl: "<url to the WebAssembly library>",
  142275. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  142276. * fallbackUrl: "<url to the fallback JavaScript library>",
  142277. * }
  142278. * };
  142279. * ```
  142280. *
  142281. * 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.
  142282. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  142283. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  142284. *
  142285. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  142286. * ```javascript
  142287. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  142288. * ```
  142289. *
  142290. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  142291. */
  142292. export class DracoCompression implements IDisposable {
  142293. private _workerPoolPromise?;
  142294. private _decoderModulePromise?;
  142295. /**
  142296. * The configuration. Defaults to the following urls:
  142297. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  142298. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  142299. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  142300. */
  142301. static Configuration: IDracoCompressionConfiguration;
  142302. /**
  142303. * Returns true if the decoder configuration is available.
  142304. */
  142305. static get DecoderAvailable(): boolean;
  142306. /**
  142307. * Default number of workers to create when creating the draco compression object.
  142308. */
  142309. static DefaultNumWorkers: number;
  142310. private static GetDefaultNumWorkers;
  142311. private static _Default;
  142312. /**
  142313. * Default instance for the draco compression object.
  142314. */
  142315. static get Default(): DracoCompression;
  142316. /**
  142317. * Constructor
  142318. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  142319. */
  142320. constructor(numWorkers?: number);
  142321. /**
  142322. * Stop all async operations and release resources.
  142323. */
  142324. dispose(): void;
  142325. /**
  142326. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  142327. * @returns a promise that resolves when ready
  142328. */
  142329. whenReadyAsync(): Promise<void>;
  142330. /**
  142331. * Decode Draco compressed mesh data to vertex data.
  142332. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  142333. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  142334. * @returns A promise that resolves with the decoded vertex data
  142335. */
  142336. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  142337. [kind: string]: number;
  142338. }): Promise<VertexData>;
  142339. }
  142340. }
  142341. declare module BABYLON {
  142342. /**
  142343. * Class for building Constructive Solid Geometry
  142344. */
  142345. export class CSG {
  142346. private polygons;
  142347. /**
  142348. * The world matrix
  142349. */
  142350. matrix: Matrix;
  142351. /**
  142352. * Stores the position
  142353. */
  142354. position: Vector3;
  142355. /**
  142356. * Stores the rotation
  142357. */
  142358. rotation: Vector3;
  142359. /**
  142360. * Stores the rotation quaternion
  142361. */
  142362. rotationQuaternion: Nullable<Quaternion>;
  142363. /**
  142364. * Stores the scaling vector
  142365. */
  142366. scaling: Vector3;
  142367. /**
  142368. * Convert the Mesh to CSG
  142369. * @param mesh The Mesh to convert to CSG
  142370. * @returns A new CSG from the Mesh
  142371. */
  142372. static FromMesh(mesh: Mesh): CSG;
  142373. /**
  142374. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  142375. * @param polygons Polygons used to construct a CSG solid
  142376. */
  142377. private static FromPolygons;
  142378. /**
  142379. * Clones, or makes a deep copy, of the CSG
  142380. * @returns A new CSG
  142381. */
  142382. clone(): CSG;
  142383. /**
  142384. * Unions this CSG with another CSG
  142385. * @param csg The CSG to union against this CSG
  142386. * @returns The unioned CSG
  142387. */
  142388. union(csg: CSG): CSG;
  142389. /**
  142390. * Unions this CSG with another CSG in place
  142391. * @param csg The CSG to union against this CSG
  142392. */
  142393. unionInPlace(csg: CSG): void;
  142394. /**
  142395. * Subtracts this CSG with another CSG
  142396. * @param csg The CSG to subtract against this CSG
  142397. * @returns A new CSG
  142398. */
  142399. subtract(csg: CSG): CSG;
  142400. /**
  142401. * Subtracts this CSG with another CSG in place
  142402. * @param csg The CSG to subtact against this CSG
  142403. */
  142404. subtractInPlace(csg: CSG): void;
  142405. /**
  142406. * Intersect this CSG with another CSG
  142407. * @param csg The CSG to intersect against this CSG
  142408. * @returns A new CSG
  142409. */
  142410. intersect(csg: CSG): CSG;
  142411. /**
  142412. * Intersects this CSG with another CSG in place
  142413. * @param csg The CSG to intersect against this CSG
  142414. */
  142415. intersectInPlace(csg: CSG): void;
  142416. /**
  142417. * Return a new CSG solid with solid and empty space switched. This solid is
  142418. * not modified.
  142419. * @returns A new CSG solid with solid and empty space switched
  142420. */
  142421. inverse(): CSG;
  142422. /**
  142423. * Inverses the CSG in place
  142424. */
  142425. inverseInPlace(): void;
  142426. /**
  142427. * This is used to keep meshes transformations so they can be restored
  142428. * when we build back a Babylon Mesh
  142429. * NB : All CSG operations are performed in world coordinates
  142430. * @param csg The CSG to copy the transform attributes from
  142431. * @returns This CSG
  142432. */
  142433. copyTransformAttributes(csg: CSG): CSG;
  142434. /**
  142435. * Build Raw mesh from CSG
  142436. * Coordinates here are in world space
  142437. * @param name The name of the mesh geometry
  142438. * @param scene The Scene
  142439. * @param keepSubMeshes Specifies if the submeshes should be kept
  142440. * @returns A new Mesh
  142441. */
  142442. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  142443. /**
  142444. * Build Mesh from CSG taking material and transforms into account
  142445. * @param name The name of the Mesh
  142446. * @param material The material of the Mesh
  142447. * @param scene The Scene
  142448. * @param keepSubMeshes Specifies if submeshes should be kept
  142449. * @returns The new Mesh
  142450. */
  142451. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  142452. }
  142453. }
  142454. declare module BABYLON {
  142455. /**
  142456. * Class used to create a trail following a mesh
  142457. */
  142458. export class TrailMesh extends Mesh {
  142459. private _generator;
  142460. private _autoStart;
  142461. private _running;
  142462. private _diameter;
  142463. private _length;
  142464. private _sectionPolygonPointsCount;
  142465. private _sectionVectors;
  142466. private _sectionNormalVectors;
  142467. private _beforeRenderObserver;
  142468. /**
  142469. * @constructor
  142470. * @param name The value used by scene.getMeshByName() to do a lookup.
  142471. * @param generator The mesh or transform node to generate a trail.
  142472. * @param scene The scene to add this mesh to.
  142473. * @param diameter Diameter of trailing mesh. Default is 1.
  142474. * @param length Length of trailing mesh. Default is 60.
  142475. * @param autoStart Automatically start trailing mesh. Default true.
  142476. */
  142477. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  142478. /**
  142479. * "TrailMesh"
  142480. * @returns "TrailMesh"
  142481. */
  142482. getClassName(): string;
  142483. private _createMesh;
  142484. /**
  142485. * Start trailing mesh.
  142486. */
  142487. start(): void;
  142488. /**
  142489. * Stop trailing mesh.
  142490. */
  142491. stop(): void;
  142492. /**
  142493. * Update trailing mesh geometry.
  142494. */
  142495. update(): void;
  142496. /**
  142497. * Returns a new TrailMesh object.
  142498. * @param name is a string, the name given to the new mesh
  142499. * @param newGenerator use new generator object for cloned trail mesh
  142500. * @returns a new mesh
  142501. */
  142502. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  142503. /**
  142504. * Serializes this trail mesh
  142505. * @param serializationObject object to write serialization to
  142506. */
  142507. serialize(serializationObject: any): void;
  142508. /**
  142509. * Parses a serialized trail mesh
  142510. * @param parsedMesh the serialized mesh
  142511. * @param scene the scene to create the trail mesh in
  142512. * @returns the created trail mesh
  142513. */
  142514. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  142515. }
  142516. }
  142517. declare module BABYLON {
  142518. /**
  142519. * Class containing static functions to help procedurally build meshes
  142520. */
  142521. export class TiledBoxBuilder {
  142522. /**
  142523. * Creates a box mesh
  142524. * faceTiles sets the pattern, tile size and number of tiles for a face * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements)
  142525. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142526. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142527. * * 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
  142528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142529. * @param name defines the name of the mesh
  142530. * @param options defines the options used to create the mesh
  142531. * @param scene defines the hosting scene
  142532. * @returns the box mesh
  142533. */
  142534. static CreateTiledBox(name: string, options: {
  142535. pattern?: number;
  142536. width?: number;
  142537. height?: number;
  142538. depth?: number;
  142539. tileSize?: number;
  142540. tileWidth?: number;
  142541. tileHeight?: number;
  142542. alignHorizontal?: number;
  142543. alignVertical?: number;
  142544. faceUV?: Vector4[];
  142545. faceColors?: Color4[];
  142546. sideOrientation?: number;
  142547. updatable?: boolean;
  142548. }, scene?: Nullable<Scene>): Mesh;
  142549. }
  142550. }
  142551. declare module BABYLON {
  142552. /**
  142553. * Class containing static functions to help procedurally build meshes
  142554. */
  142555. export class TorusKnotBuilder {
  142556. /**
  142557. * Creates a torus knot mesh
  142558. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  142559. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  142560. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  142561. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  142562. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142563. * * 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
  142564. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142565. * @param name defines the name of the mesh
  142566. * @param options defines the options used to create the mesh
  142567. * @param scene defines the hosting scene
  142568. * @returns the torus knot mesh
  142569. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  142570. */
  142571. static CreateTorusKnot(name: string, options: {
  142572. radius?: number;
  142573. tube?: number;
  142574. radialSegments?: number;
  142575. tubularSegments?: number;
  142576. p?: number;
  142577. q?: number;
  142578. updatable?: boolean;
  142579. sideOrientation?: number;
  142580. frontUVs?: Vector4;
  142581. backUVs?: Vector4;
  142582. }, scene: any): Mesh;
  142583. }
  142584. }
  142585. declare module BABYLON {
  142586. /**
  142587. * Polygon
  142588. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  142589. */
  142590. export class Polygon {
  142591. /**
  142592. * Creates a rectangle
  142593. * @param xmin bottom X coord
  142594. * @param ymin bottom Y coord
  142595. * @param xmax top X coord
  142596. * @param ymax top Y coord
  142597. * @returns points that make the resulting rectation
  142598. */
  142599. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  142600. /**
  142601. * Creates a circle
  142602. * @param radius radius of circle
  142603. * @param cx scale in x
  142604. * @param cy scale in y
  142605. * @param numberOfSides number of sides that make up the circle
  142606. * @returns points that make the resulting circle
  142607. */
  142608. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  142609. /**
  142610. * Creates a polygon from input string
  142611. * @param input Input polygon data
  142612. * @returns the parsed points
  142613. */
  142614. static Parse(input: string): Vector2[];
  142615. /**
  142616. * Starts building a polygon from x and y coordinates
  142617. * @param x x coordinate
  142618. * @param y y coordinate
  142619. * @returns the started path2
  142620. */
  142621. static StartingAt(x: number, y: number): Path2;
  142622. }
  142623. /**
  142624. * Builds a polygon
  142625. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  142626. */
  142627. export class PolygonMeshBuilder {
  142628. private _points;
  142629. private _outlinepoints;
  142630. private _holes;
  142631. private _name;
  142632. private _scene;
  142633. private _epoints;
  142634. private _eholes;
  142635. private _addToepoint;
  142636. /**
  142637. * Babylon reference to the earcut plugin.
  142638. */
  142639. bjsEarcut: any;
  142640. /**
  142641. * Creates a PolygonMeshBuilder
  142642. * @param name name of the builder
  142643. * @param contours Path of the polygon
  142644. * @param scene scene to add to when creating the mesh
  142645. * @param earcutInjection can be used to inject your own earcut reference
  142646. */
  142647. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  142648. /**
  142649. * Adds a whole within the polygon
  142650. * @param hole Array of points defining the hole
  142651. * @returns this
  142652. */
  142653. addHole(hole: Vector2[]): PolygonMeshBuilder;
  142654. /**
  142655. * Creates the polygon
  142656. * @param updatable If the mesh should be updatable
  142657. * @param depth The depth of the mesh created
  142658. * @returns the created mesh
  142659. */
  142660. build(updatable?: boolean, depth?: number): Mesh;
  142661. /**
  142662. * Creates the polygon
  142663. * @param depth The depth of the mesh created
  142664. * @returns the created VertexData
  142665. */
  142666. buildVertexData(depth?: number): VertexData;
  142667. /**
  142668. * Adds a side to the polygon
  142669. * @param positions points that make the polygon
  142670. * @param normals normals of the polygon
  142671. * @param uvs uvs of the polygon
  142672. * @param indices indices of the polygon
  142673. * @param bounds bounds of the polygon
  142674. * @param points points of the polygon
  142675. * @param depth depth of the polygon
  142676. * @param flip flip of the polygon
  142677. */
  142678. private addSide;
  142679. }
  142680. }
  142681. declare module BABYLON {
  142682. /**
  142683. * Class containing static functions to help procedurally build meshes
  142684. */
  142685. export class PolygonBuilder {
  142686. /**
  142687. * Creates a polygon mesh
  142688. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  142689. * * 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
  142690. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  142691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142692. * * 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)
  142693. * * Remember you can only change the shape positions, not their number when updating a polygon
  142694. * @param name defines the name of the mesh
  142695. * @param options defines the options used to create the mesh
  142696. * @param scene defines the hosting scene
  142697. * @param earcutInjection can be used to inject your own earcut reference
  142698. * @returns the polygon mesh
  142699. */
  142700. static CreatePolygon(name: string, options: {
  142701. shape: Vector3[];
  142702. holes?: Vector3[][];
  142703. depth?: number;
  142704. faceUV?: Vector4[];
  142705. faceColors?: Color4[];
  142706. updatable?: boolean;
  142707. sideOrientation?: number;
  142708. frontUVs?: Vector4;
  142709. backUVs?: Vector4;
  142710. wrap?: boolean;
  142711. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  142712. /**
  142713. * Creates an extruded polygon mesh, with depth in the Y direction.
  142714. * * 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)
  142715. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142716. * @param name defines the name of the mesh
  142717. * @param options defines the options used to create the mesh
  142718. * @param scene defines the hosting scene
  142719. * @param earcutInjection can be used to inject your own earcut reference
  142720. * @returns the polygon mesh
  142721. */
  142722. static ExtrudePolygon(name: string, options: {
  142723. shape: Vector3[];
  142724. holes?: Vector3[][];
  142725. depth?: number;
  142726. faceUV?: Vector4[];
  142727. faceColors?: Color4[];
  142728. updatable?: boolean;
  142729. sideOrientation?: number;
  142730. frontUVs?: Vector4;
  142731. backUVs?: Vector4;
  142732. wrap?: boolean;
  142733. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  142734. }
  142735. }
  142736. declare module BABYLON {
  142737. /**
  142738. * Class containing static functions to help procedurally build meshes
  142739. */
  142740. export class LatheBuilder {
  142741. /**
  142742. * Creates lathe mesh.
  142743. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  142744. * * 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
  142745. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  142746. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  142747. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  142748. * * 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
  142749. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  142750. * * 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
  142751. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142752. * * 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
  142753. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142755. * @param name defines the name of the mesh
  142756. * @param options defines the options used to create the mesh
  142757. * @param scene defines the hosting scene
  142758. * @returns the lathe mesh
  142759. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  142760. */
  142761. static CreateLathe(name: string, options: {
  142762. shape: Vector3[];
  142763. radius?: number;
  142764. tessellation?: number;
  142765. clip?: number;
  142766. arc?: number;
  142767. closed?: boolean;
  142768. updatable?: boolean;
  142769. sideOrientation?: number;
  142770. frontUVs?: Vector4;
  142771. backUVs?: Vector4;
  142772. cap?: number;
  142773. invertUV?: boolean;
  142774. }, scene?: Nullable<Scene>): Mesh;
  142775. }
  142776. }
  142777. declare module BABYLON {
  142778. /**
  142779. * Class containing static functions to help procedurally build meshes
  142780. */
  142781. export class TiledPlaneBuilder {
  142782. /**
  142783. * Creates a tiled plane mesh
  142784. * * The parameter `pattern` will, depending on value, do nothing or
  142785. * * * flip (reflect about central vertical) alternate tiles across and up
  142786. * * * flip every tile on alternate rows
  142787. * * * rotate (180 degs) alternate tiles across and up
  142788. * * * rotate every tile on alternate rows
  142789. * * * flip and rotate alternate tiles across and up
  142790. * * * flip and rotate every tile on alternate rows
  142791. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  142792. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  142793. * * 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
  142794. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  142795. * * 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)
  142796. * * 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)
  142797. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  142798. * @param name defines the name of the mesh
  142799. * @param options defines the options used to create the mesh
  142800. * @param scene defines the hosting scene
  142801. * @returns the box mesh
  142802. */
  142803. static CreateTiledPlane(name: string, options: {
  142804. pattern?: number;
  142805. tileSize?: number;
  142806. tileWidth?: number;
  142807. tileHeight?: number;
  142808. size?: number;
  142809. width?: number;
  142810. height?: number;
  142811. alignHorizontal?: number;
  142812. alignVertical?: number;
  142813. sideOrientation?: number;
  142814. frontUVs?: Vector4;
  142815. backUVs?: Vector4;
  142816. updatable?: boolean;
  142817. }, scene?: Nullable<Scene>): Mesh;
  142818. }
  142819. }
  142820. declare module BABYLON {
  142821. /**
  142822. * Class containing static functions to help procedurally build meshes
  142823. */
  142824. export class TubeBuilder {
  142825. /**
  142826. * Creates a tube mesh.
  142827. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  142828. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  142829. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  142830. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  142831. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  142832. * * 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)
  142833. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  142834. * * 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
  142835. * * 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
  142836. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142837. * * 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
  142838. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142840. * @param name defines the name of the mesh
  142841. * @param options defines the options used to create the mesh
  142842. * @param scene defines the hosting scene
  142843. * @returns the tube mesh
  142844. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142845. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  142846. */
  142847. static CreateTube(name: string, options: {
  142848. path: Vector3[];
  142849. radius?: number;
  142850. tessellation?: number;
  142851. radiusFunction?: {
  142852. (i: number, distance: number): number;
  142853. };
  142854. cap?: number;
  142855. arc?: number;
  142856. updatable?: boolean;
  142857. sideOrientation?: number;
  142858. frontUVs?: Vector4;
  142859. backUVs?: Vector4;
  142860. instance?: Mesh;
  142861. invertUV?: boolean;
  142862. }, scene?: Nullable<Scene>): Mesh;
  142863. }
  142864. }
  142865. declare module BABYLON {
  142866. /**
  142867. * Class containing static functions to help procedurally build meshes
  142868. */
  142869. export class IcoSphereBuilder {
  142870. /**
  142871. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  142872. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  142873. * * 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`)
  142874. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  142875. * * 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
  142876. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142877. * * 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
  142878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142879. * @param name defines the name of the mesh
  142880. * @param options defines the options used to create the mesh
  142881. * @param scene defines the hosting scene
  142882. * @returns the icosahedron mesh
  142883. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  142884. */
  142885. static CreateIcoSphere(name: string, options: {
  142886. radius?: number;
  142887. radiusX?: number;
  142888. radiusY?: number;
  142889. radiusZ?: number;
  142890. flat?: boolean;
  142891. subdivisions?: number;
  142892. sideOrientation?: number;
  142893. frontUVs?: Vector4;
  142894. backUVs?: Vector4;
  142895. updatable?: boolean;
  142896. }, scene?: Nullable<Scene>): Mesh;
  142897. }
  142898. }
  142899. declare module BABYLON {
  142900. /**
  142901. * Class containing static functions to help procedurally build meshes
  142902. */
  142903. export class DecalBuilder {
  142904. /**
  142905. * Creates a decal mesh.
  142906. * 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
  142907. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  142908. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  142909. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  142910. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  142911. * @param name defines the name of the mesh
  142912. * @param sourceMesh defines the mesh where the decal must be applied
  142913. * @param options defines the options used to create the mesh
  142914. * @param scene defines the hosting scene
  142915. * @returns the decal mesh
  142916. * @see https://doc.babylonjs.com/how_to/decals
  142917. */
  142918. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  142919. position?: Vector3;
  142920. normal?: Vector3;
  142921. size?: Vector3;
  142922. angle?: number;
  142923. }): Mesh;
  142924. }
  142925. }
  142926. declare module BABYLON {
  142927. /**
  142928. * Class containing static functions to help procedurally build meshes
  142929. */
  142930. export class MeshBuilder {
  142931. /**
  142932. * Creates a box mesh
  142933. * * The parameter `size` sets the size (float) of each box side (default 1)
  142934. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  142935. * * 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)
  142936. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142937. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142938. * * 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
  142939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142940. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  142941. * @param name defines the name of the mesh
  142942. * @param options defines the options used to create the mesh
  142943. * @param scene defines the hosting scene
  142944. * @returns the box mesh
  142945. */
  142946. static CreateBox(name: string, options: {
  142947. size?: number;
  142948. width?: number;
  142949. height?: number;
  142950. depth?: number;
  142951. faceUV?: Vector4[];
  142952. faceColors?: Color4[];
  142953. sideOrientation?: number;
  142954. frontUVs?: Vector4;
  142955. backUVs?: Vector4;
  142956. wrap?: boolean;
  142957. topBaseAt?: number;
  142958. bottomBaseAt?: number;
  142959. updatable?: boolean;
  142960. }, scene?: Nullable<Scene>): Mesh;
  142961. /**
  142962. * Creates a tiled box mesh
  142963. * * faceTiles sets the pattern, tile size and number of tiles for a face
  142964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142965. * @param name defines the name of the mesh
  142966. * @param options defines the options used to create the mesh
  142967. * @param scene defines the hosting scene
  142968. * @returns the tiled box mesh
  142969. */
  142970. static CreateTiledBox(name: string, options: {
  142971. pattern?: number;
  142972. size?: number;
  142973. width?: number;
  142974. height?: number;
  142975. depth: number;
  142976. tileSize?: number;
  142977. tileWidth?: number;
  142978. tileHeight?: number;
  142979. faceUV?: Vector4[];
  142980. faceColors?: Color4[];
  142981. alignHorizontal?: number;
  142982. alignVertical?: number;
  142983. sideOrientation?: number;
  142984. updatable?: boolean;
  142985. }, scene?: Nullable<Scene>): Mesh;
  142986. /**
  142987. * Creates a sphere mesh
  142988. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  142989. * * 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`)
  142990. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  142991. * * 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
  142992. * * 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)
  142993. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142994. * * 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
  142995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142996. * @param name defines the name of the mesh
  142997. * @param options defines the options used to create the mesh
  142998. * @param scene defines the hosting scene
  142999. * @returns the sphere mesh
  143000. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  143001. */
  143002. static CreateSphere(name: string, options: {
  143003. segments?: number;
  143004. diameter?: number;
  143005. diameterX?: number;
  143006. diameterY?: number;
  143007. diameterZ?: number;
  143008. arc?: number;
  143009. slice?: number;
  143010. sideOrientation?: number;
  143011. frontUVs?: Vector4;
  143012. backUVs?: Vector4;
  143013. updatable?: boolean;
  143014. }, scene?: Nullable<Scene>): Mesh;
  143015. /**
  143016. * Creates a plane polygonal mesh. By default, this is a disc
  143017. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  143018. * * 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
  143019. * * 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
  143020. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143021. * * 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
  143022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143023. * @param name defines the name of the mesh
  143024. * @param options defines the options used to create the mesh
  143025. * @param scene defines the hosting scene
  143026. * @returns the plane polygonal mesh
  143027. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  143028. */
  143029. static CreateDisc(name: string, options: {
  143030. radius?: number;
  143031. tessellation?: number;
  143032. arc?: number;
  143033. updatable?: boolean;
  143034. sideOrientation?: number;
  143035. frontUVs?: Vector4;
  143036. backUVs?: Vector4;
  143037. }, scene?: Nullable<Scene>): Mesh;
  143038. /**
  143039. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  143040. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  143041. * * 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`)
  143042. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  143043. * * 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
  143044. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143045. * * 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
  143046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143047. * @param name defines the name of the mesh
  143048. * @param options defines the options used to create the mesh
  143049. * @param scene defines the hosting scene
  143050. * @returns the icosahedron mesh
  143051. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  143052. */
  143053. static CreateIcoSphere(name: string, options: {
  143054. radius?: number;
  143055. radiusX?: number;
  143056. radiusY?: number;
  143057. radiusZ?: number;
  143058. flat?: boolean;
  143059. subdivisions?: number;
  143060. sideOrientation?: number;
  143061. frontUVs?: Vector4;
  143062. backUVs?: Vector4;
  143063. updatable?: boolean;
  143064. }, scene?: Nullable<Scene>): Mesh;
  143065. /**
  143066. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  143067. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  143068. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  143069. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  143070. * * 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
  143071. * * 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
  143072. * * 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
  143073. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143074. * * 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
  143075. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143076. * * 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
  143077. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  143078. * * 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
  143079. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  143080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143081. * @param name defines the name of the mesh
  143082. * @param options defines the options used to create the mesh
  143083. * @param scene defines the hosting scene
  143084. * @returns the ribbon mesh
  143085. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  143086. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143087. */
  143088. static CreateRibbon(name: string, options: {
  143089. pathArray: Vector3[][];
  143090. closeArray?: boolean;
  143091. closePath?: boolean;
  143092. offset?: number;
  143093. updatable?: boolean;
  143094. sideOrientation?: number;
  143095. frontUVs?: Vector4;
  143096. backUVs?: Vector4;
  143097. instance?: Mesh;
  143098. invertUV?: boolean;
  143099. uvs?: Vector2[];
  143100. colors?: Color4[];
  143101. }, scene?: Nullable<Scene>): Mesh;
  143102. /**
  143103. * Creates a cylinder or a cone mesh
  143104. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  143105. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  143106. * * 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.
  143107. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  143108. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  143109. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  143110. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  143111. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  143112. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  143113. * * 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).
  143114. * * 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
  143115. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  143116. * * 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
  143117. * * 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.
  143118. * * If `enclose` is false, a ring surface is one element.
  143119. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  143120. * * 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
  143121. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143122. * * 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
  143123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143124. * @param name defines the name of the mesh
  143125. * @param options defines the options used to create the mesh
  143126. * @param scene defines the hosting scene
  143127. * @returns the cylinder mesh
  143128. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  143129. */
  143130. static CreateCylinder(name: string, options: {
  143131. height?: number;
  143132. diameterTop?: number;
  143133. diameterBottom?: number;
  143134. diameter?: number;
  143135. tessellation?: number;
  143136. subdivisions?: number;
  143137. arc?: number;
  143138. faceColors?: Color4[];
  143139. faceUV?: Vector4[];
  143140. updatable?: boolean;
  143141. hasRings?: boolean;
  143142. enclose?: boolean;
  143143. cap?: number;
  143144. sideOrientation?: number;
  143145. frontUVs?: Vector4;
  143146. backUVs?: Vector4;
  143147. }, scene?: Nullable<Scene>): Mesh;
  143148. /**
  143149. * Creates a torus mesh
  143150. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  143151. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  143152. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  143153. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143154. * * 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
  143155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143156. * @param name defines the name of the mesh
  143157. * @param options defines the options used to create the mesh
  143158. * @param scene defines the hosting scene
  143159. * @returns the torus mesh
  143160. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  143161. */
  143162. static CreateTorus(name: string, options: {
  143163. diameter?: number;
  143164. thickness?: number;
  143165. tessellation?: number;
  143166. updatable?: boolean;
  143167. sideOrientation?: number;
  143168. frontUVs?: Vector4;
  143169. backUVs?: Vector4;
  143170. }, scene?: Nullable<Scene>): Mesh;
  143171. /**
  143172. * Creates a torus knot mesh
  143173. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  143174. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  143175. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  143176. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  143177. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143178. * * 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
  143179. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143180. * @param name defines the name of the mesh
  143181. * @param options defines the options used to create the mesh
  143182. * @param scene defines the hosting scene
  143183. * @returns the torus knot mesh
  143184. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  143185. */
  143186. static CreateTorusKnot(name: string, options: {
  143187. radius?: number;
  143188. tube?: number;
  143189. radialSegments?: number;
  143190. tubularSegments?: number;
  143191. p?: number;
  143192. q?: number;
  143193. updatable?: boolean;
  143194. sideOrientation?: number;
  143195. frontUVs?: Vector4;
  143196. backUVs?: Vector4;
  143197. }, scene?: Nullable<Scene>): Mesh;
  143198. /**
  143199. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  143200. * * 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
  143201. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  143202. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  143203. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  143204. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  143205. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  143206. * * 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
  143207. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  143208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143209. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  143210. * @param name defines the name of the new line system
  143211. * @param options defines the options used to create the line system
  143212. * @param scene defines the hosting scene
  143213. * @returns a new line system mesh
  143214. */
  143215. static CreateLineSystem(name: string, options: {
  143216. lines: Vector3[][];
  143217. updatable?: boolean;
  143218. instance?: Nullable<LinesMesh>;
  143219. colors?: Nullable<Color4[][]>;
  143220. useVertexAlpha?: boolean;
  143221. }, scene: Nullable<Scene>): LinesMesh;
  143222. /**
  143223. * Creates a line mesh
  143224. * 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
  143225. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  143226. * * The parameter `points` is an array successive Vector3
  143227. * * 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
  143228. * * The optional parameter `colors` is an array of successive Color4, one per line point
  143229. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  143230. * * When updating an instance, remember that only point positions can change, not the number of points
  143231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143232. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  143233. * @param name defines the name of the new line system
  143234. * @param options defines the options used to create the line system
  143235. * @param scene defines the hosting scene
  143236. * @returns a new line mesh
  143237. */
  143238. static CreateLines(name: string, options: {
  143239. points: Vector3[];
  143240. updatable?: boolean;
  143241. instance?: Nullable<LinesMesh>;
  143242. colors?: Color4[];
  143243. useVertexAlpha?: boolean;
  143244. }, scene?: Nullable<Scene>): LinesMesh;
  143245. /**
  143246. * Creates a dashed line mesh
  143247. * * 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
  143248. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  143249. * * The parameter `points` is an array successive Vector3
  143250. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  143251. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  143252. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  143253. * * 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
  143254. * * When updating an instance, remember that only point positions can change, not the number of points
  143255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143256. * @param name defines the name of the mesh
  143257. * @param options defines the options used to create the mesh
  143258. * @param scene defines the hosting scene
  143259. * @returns the dashed line mesh
  143260. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  143261. */
  143262. static CreateDashedLines(name: string, options: {
  143263. points: Vector3[];
  143264. dashSize?: number;
  143265. gapSize?: number;
  143266. dashNb?: number;
  143267. updatable?: boolean;
  143268. instance?: LinesMesh;
  143269. }, scene?: Nullable<Scene>): LinesMesh;
  143270. /**
  143271. * 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.
  143272. * * 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.
  143273. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  143274. * * 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.
  143275. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  143276. * * 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
  143277. * * 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
  143278. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  143279. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143280. * * 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
  143281. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  143282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143283. * @param name defines the name of the mesh
  143284. * @param options defines the options used to create the mesh
  143285. * @param scene defines the hosting scene
  143286. * @returns the extruded shape mesh
  143287. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143288. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  143289. */
  143290. static ExtrudeShape(name: string, options: {
  143291. shape: Vector3[];
  143292. path: Vector3[];
  143293. scale?: number;
  143294. rotation?: number;
  143295. cap?: number;
  143296. updatable?: boolean;
  143297. sideOrientation?: number;
  143298. frontUVs?: Vector4;
  143299. backUVs?: Vector4;
  143300. instance?: Mesh;
  143301. invertUV?: boolean;
  143302. }, scene?: Nullable<Scene>): Mesh;
  143303. /**
  143304. * Creates an custom extruded shape mesh.
  143305. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  143306. * * 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.
  143307. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  143308. * * 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
  143309. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  143310. * * 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
  143311. * * It must returns a float value that will be the scale value applied to the shape on each path point
  143312. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  143313. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  143314. * * 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
  143315. * * 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
  143316. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  143317. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143318. * * 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
  143319. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143321. * @param name defines the name of the mesh
  143322. * @param options defines the options used to create the mesh
  143323. * @param scene defines the hosting scene
  143324. * @returns the custom extruded shape mesh
  143325. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  143326. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143327. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  143328. */
  143329. static ExtrudeShapeCustom(name: string, options: {
  143330. shape: Vector3[];
  143331. path: Vector3[];
  143332. scaleFunction?: any;
  143333. rotationFunction?: any;
  143334. ribbonCloseArray?: boolean;
  143335. ribbonClosePath?: boolean;
  143336. cap?: number;
  143337. updatable?: boolean;
  143338. sideOrientation?: number;
  143339. frontUVs?: Vector4;
  143340. backUVs?: Vector4;
  143341. instance?: Mesh;
  143342. invertUV?: boolean;
  143343. }, scene?: Nullable<Scene>): Mesh;
  143344. /**
  143345. * Creates lathe mesh.
  143346. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  143347. * * 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
  143348. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  143349. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  143350. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  143351. * * 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
  143352. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  143353. * * 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
  143354. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143355. * * 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
  143356. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143358. * @param name defines the name of the mesh
  143359. * @param options defines the options used to create the mesh
  143360. * @param scene defines the hosting scene
  143361. * @returns the lathe mesh
  143362. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  143363. */
  143364. static CreateLathe(name: string, options: {
  143365. shape: Vector3[];
  143366. radius?: number;
  143367. tessellation?: number;
  143368. clip?: number;
  143369. arc?: number;
  143370. closed?: boolean;
  143371. updatable?: boolean;
  143372. sideOrientation?: number;
  143373. frontUVs?: Vector4;
  143374. backUVs?: Vector4;
  143375. cap?: number;
  143376. invertUV?: boolean;
  143377. }, scene?: Nullable<Scene>): Mesh;
  143378. /**
  143379. * Creates a tiled plane mesh
  143380. * * You can set a limited pattern arrangement with the tiles
  143381. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143382. * * 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
  143383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143384. * @param name defines the name of the mesh
  143385. * @param options defines the options used to create the mesh
  143386. * @param scene defines the hosting scene
  143387. * @returns the plane mesh
  143388. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  143389. */
  143390. static CreateTiledPlane(name: string, options: {
  143391. pattern?: number;
  143392. tileSize?: number;
  143393. tileWidth?: number;
  143394. tileHeight?: number;
  143395. size?: number;
  143396. width?: number;
  143397. height?: number;
  143398. alignHorizontal?: number;
  143399. alignVertical?: number;
  143400. sideOrientation?: number;
  143401. frontUVs?: Vector4;
  143402. backUVs?: Vector4;
  143403. updatable?: boolean;
  143404. }, scene?: Nullable<Scene>): Mesh;
  143405. /**
  143406. * Creates a plane mesh
  143407. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  143408. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  143409. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  143410. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143411. * * 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
  143412. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143413. * @param name defines the name of the mesh
  143414. * @param options defines the options used to create the mesh
  143415. * @param scene defines the hosting scene
  143416. * @returns the plane mesh
  143417. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  143418. */
  143419. static CreatePlane(name: string, options: {
  143420. size?: number;
  143421. width?: number;
  143422. height?: number;
  143423. sideOrientation?: number;
  143424. frontUVs?: Vector4;
  143425. backUVs?: Vector4;
  143426. updatable?: boolean;
  143427. sourcePlane?: Plane;
  143428. }, scene?: Nullable<Scene>): Mesh;
  143429. /**
  143430. * Creates a ground mesh
  143431. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  143432. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  143433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143434. * @param name defines the name of the mesh
  143435. * @param options defines the options used to create the mesh
  143436. * @param scene defines the hosting scene
  143437. * @returns the ground mesh
  143438. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  143439. */
  143440. static CreateGround(name: string, options: {
  143441. width?: number;
  143442. height?: number;
  143443. subdivisions?: number;
  143444. subdivisionsX?: number;
  143445. subdivisionsY?: number;
  143446. updatable?: boolean;
  143447. }, scene?: Nullable<Scene>): Mesh;
  143448. /**
  143449. * Creates a tiled ground mesh
  143450. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  143451. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  143452. * * 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
  143453. * * 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
  143454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143455. * @param name defines the name of the mesh
  143456. * @param options defines the options used to create the mesh
  143457. * @param scene defines the hosting scene
  143458. * @returns the tiled ground mesh
  143459. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  143460. */
  143461. static CreateTiledGround(name: string, options: {
  143462. xmin: number;
  143463. zmin: number;
  143464. xmax: number;
  143465. zmax: number;
  143466. subdivisions?: {
  143467. w: number;
  143468. h: number;
  143469. };
  143470. precision?: {
  143471. w: number;
  143472. h: number;
  143473. };
  143474. updatable?: boolean;
  143475. }, scene?: Nullable<Scene>): Mesh;
  143476. /**
  143477. * Creates a ground mesh from a height map
  143478. * * The parameter `url` sets the URL of the height map image resource.
  143479. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  143480. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  143481. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  143482. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  143483. * * 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.
  143484. * * 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).
  143485. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  143486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143487. * @param name defines the name of the mesh
  143488. * @param url defines the url to the height map
  143489. * @param options defines the options used to create the mesh
  143490. * @param scene defines the hosting scene
  143491. * @returns the ground mesh
  143492. * @see https://doc.babylonjs.com/babylon101/height_map
  143493. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  143494. */
  143495. static CreateGroundFromHeightMap(name: string, url: string, options: {
  143496. width?: number;
  143497. height?: number;
  143498. subdivisions?: number;
  143499. minHeight?: number;
  143500. maxHeight?: number;
  143501. colorFilter?: Color3;
  143502. alphaFilter?: number;
  143503. updatable?: boolean;
  143504. onReady?: (mesh: GroundMesh) => void;
  143505. }, scene?: Nullable<Scene>): GroundMesh;
  143506. /**
  143507. * Creates a polygon mesh
  143508. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  143509. * * 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
  143510. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  143511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143512. * * 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)
  143513. * * Remember you can only change the shape positions, not their number when updating a polygon
  143514. * @param name defines the name of the mesh
  143515. * @param options defines the options used to create the mesh
  143516. * @param scene defines the hosting scene
  143517. * @param earcutInjection can be used to inject your own earcut reference
  143518. * @returns the polygon mesh
  143519. */
  143520. static CreatePolygon(name: string, options: {
  143521. shape: Vector3[];
  143522. holes?: Vector3[][];
  143523. depth?: number;
  143524. faceUV?: Vector4[];
  143525. faceColors?: Color4[];
  143526. updatable?: boolean;
  143527. sideOrientation?: number;
  143528. frontUVs?: Vector4;
  143529. backUVs?: Vector4;
  143530. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  143531. /**
  143532. * Creates an extruded polygon mesh, with depth in the Y direction.
  143533. * * 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)
  143534. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  143535. * @param name defines the name of the mesh
  143536. * @param options defines the options used to create the mesh
  143537. * @param scene defines the hosting scene
  143538. * @param earcutInjection can be used to inject your own earcut reference
  143539. * @returns the polygon mesh
  143540. */
  143541. static ExtrudePolygon(name: string, options: {
  143542. shape: Vector3[];
  143543. holes?: Vector3[][];
  143544. depth?: number;
  143545. faceUV?: Vector4[];
  143546. faceColors?: Color4[];
  143547. updatable?: boolean;
  143548. sideOrientation?: number;
  143549. frontUVs?: Vector4;
  143550. backUVs?: Vector4;
  143551. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  143552. /**
  143553. * Creates a tube mesh.
  143554. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  143555. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  143556. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  143557. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  143558. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  143559. * * 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)
  143560. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  143561. * * 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
  143562. * * 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
  143563. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143564. * * 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
  143565. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143567. * @param name defines the name of the mesh
  143568. * @param options defines the options used to create the mesh
  143569. * @param scene defines the hosting scene
  143570. * @returns the tube mesh
  143571. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143572. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  143573. */
  143574. static CreateTube(name: string, options: {
  143575. path: Vector3[];
  143576. radius?: number;
  143577. tessellation?: number;
  143578. radiusFunction?: {
  143579. (i: number, distance: number): number;
  143580. };
  143581. cap?: number;
  143582. arc?: number;
  143583. updatable?: boolean;
  143584. sideOrientation?: number;
  143585. frontUVs?: Vector4;
  143586. backUVs?: Vector4;
  143587. instance?: Mesh;
  143588. invertUV?: boolean;
  143589. }, scene?: Nullable<Scene>): Mesh;
  143590. /**
  143591. * Creates a polyhedron mesh
  143592. * * 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
  143593. * * The parameter `size` (positive float, default 1) sets the polygon size
  143594. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  143595. * * 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`
  143596. * * 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
  143597. * * 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)`)
  143598. * * 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
  143599. * * 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
  143600. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143601. * * 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
  143602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143603. * @param name defines the name of the mesh
  143604. * @param options defines the options used to create the mesh
  143605. * @param scene defines the hosting scene
  143606. * @returns the polyhedron mesh
  143607. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  143608. */
  143609. static CreatePolyhedron(name: string, options: {
  143610. type?: number;
  143611. size?: number;
  143612. sizeX?: number;
  143613. sizeY?: number;
  143614. sizeZ?: number;
  143615. custom?: any;
  143616. faceUV?: Vector4[];
  143617. faceColors?: Color4[];
  143618. flat?: boolean;
  143619. updatable?: boolean;
  143620. sideOrientation?: number;
  143621. frontUVs?: Vector4;
  143622. backUVs?: Vector4;
  143623. }, scene?: Nullable<Scene>): Mesh;
  143624. /**
  143625. * Creates a decal mesh.
  143626. * 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
  143627. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  143628. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  143629. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  143630. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  143631. * @param name defines the name of the mesh
  143632. * @param sourceMesh defines the mesh where the decal must be applied
  143633. * @param options defines the options used to create the mesh
  143634. * @param scene defines the hosting scene
  143635. * @returns the decal mesh
  143636. * @see https://doc.babylonjs.com/how_to/decals
  143637. */
  143638. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  143639. position?: Vector3;
  143640. normal?: Vector3;
  143641. size?: Vector3;
  143642. angle?: number;
  143643. }): Mesh;
  143644. }
  143645. }
  143646. declare module BABYLON {
  143647. /**
  143648. * A simplifier interface for future simplification implementations
  143649. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143650. */
  143651. export interface ISimplifier {
  143652. /**
  143653. * Simplification of a given mesh according to the given settings.
  143654. * Since this requires computation, it is assumed that the function runs async.
  143655. * @param settings The settings of the simplification, including quality and distance
  143656. * @param successCallback A callback that will be called after the mesh was simplified.
  143657. * @param errorCallback in case of an error, this callback will be called. optional.
  143658. */
  143659. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  143660. }
  143661. /**
  143662. * Expected simplification settings.
  143663. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  143664. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143665. */
  143666. export interface ISimplificationSettings {
  143667. /**
  143668. * Gets or sets the expected quality
  143669. */
  143670. quality: number;
  143671. /**
  143672. * Gets or sets the distance when this optimized version should be used
  143673. */
  143674. distance: number;
  143675. /**
  143676. * Gets an already optimized mesh
  143677. */
  143678. optimizeMesh?: boolean;
  143679. }
  143680. /**
  143681. * Class used to specify simplification options
  143682. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143683. */
  143684. export class SimplificationSettings implements ISimplificationSettings {
  143685. /** expected quality */
  143686. quality: number;
  143687. /** distance when this optimized version should be used */
  143688. distance: number;
  143689. /** already optimized mesh */
  143690. optimizeMesh?: boolean | undefined;
  143691. /**
  143692. * Creates a SimplificationSettings
  143693. * @param quality expected quality
  143694. * @param distance distance when this optimized version should be used
  143695. * @param optimizeMesh already optimized mesh
  143696. */
  143697. constructor(
  143698. /** expected quality */
  143699. quality: number,
  143700. /** distance when this optimized version should be used */
  143701. distance: number,
  143702. /** already optimized mesh */
  143703. optimizeMesh?: boolean | undefined);
  143704. }
  143705. /**
  143706. * Interface used to define a simplification task
  143707. */
  143708. export interface ISimplificationTask {
  143709. /**
  143710. * Array of settings
  143711. */
  143712. settings: Array<ISimplificationSettings>;
  143713. /**
  143714. * Simplification type
  143715. */
  143716. simplificationType: SimplificationType;
  143717. /**
  143718. * Mesh to simplify
  143719. */
  143720. mesh: Mesh;
  143721. /**
  143722. * Callback called on success
  143723. */
  143724. successCallback?: () => void;
  143725. /**
  143726. * Defines if parallel processing can be used
  143727. */
  143728. parallelProcessing: boolean;
  143729. }
  143730. /**
  143731. * Queue used to order the simplification tasks
  143732. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143733. */
  143734. export class SimplificationQueue {
  143735. private _simplificationArray;
  143736. /**
  143737. * Gets a boolean indicating that the process is still running
  143738. */
  143739. running: boolean;
  143740. /**
  143741. * Creates a new queue
  143742. */
  143743. constructor();
  143744. /**
  143745. * Adds a new simplification task
  143746. * @param task defines a task to add
  143747. */
  143748. addTask(task: ISimplificationTask): void;
  143749. /**
  143750. * Execute next task
  143751. */
  143752. executeNext(): void;
  143753. /**
  143754. * Execute a simplification task
  143755. * @param task defines the task to run
  143756. */
  143757. runSimplification(task: ISimplificationTask): void;
  143758. private getSimplifier;
  143759. }
  143760. /**
  143761. * The implemented types of simplification
  143762. * At the moment only Quadratic Error Decimation is implemented
  143763. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143764. */
  143765. export enum SimplificationType {
  143766. /** Quadratic error decimation */
  143767. QUADRATIC = 0
  143768. }
  143769. /**
  143770. * An implementation of the Quadratic Error simplification algorithm.
  143771. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  143772. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  143773. * @author RaananW
  143774. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143775. */
  143776. export class QuadraticErrorSimplification implements ISimplifier {
  143777. private _mesh;
  143778. private triangles;
  143779. private vertices;
  143780. private references;
  143781. private _reconstructedMesh;
  143782. /** Gets or sets the number pf sync interations */
  143783. syncIterations: number;
  143784. /** Gets or sets the aggressiveness of the simplifier */
  143785. aggressiveness: number;
  143786. /** Gets or sets the number of allowed iterations for decimation */
  143787. decimationIterations: number;
  143788. /** Gets or sets the espilon to use for bounding box computation */
  143789. boundingBoxEpsilon: number;
  143790. /**
  143791. * Creates a new QuadraticErrorSimplification
  143792. * @param _mesh defines the target mesh
  143793. */
  143794. constructor(_mesh: Mesh);
  143795. /**
  143796. * Simplification of a given mesh according to the given settings.
  143797. * Since this requires computation, it is assumed that the function runs async.
  143798. * @param settings The settings of the simplification, including quality and distance
  143799. * @param successCallback A callback that will be called after the mesh was simplified.
  143800. */
  143801. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  143802. private runDecimation;
  143803. private initWithMesh;
  143804. private init;
  143805. private reconstructMesh;
  143806. private initDecimatedMesh;
  143807. private isFlipped;
  143808. private updateTriangles;
  143809. private identifyBorder;
  143810. private updateMesh;
  143811. private vertexError;
  143812. private calculateError;
  143813. }
  143814. }
  143815. declare module BABYLON {
  143816. interface Scene {
  143817. /** @hidden (Backing field) */
  143818. _simplificationQueue: SimplificationQueue;
  143819. /**
  143820. * Gets or sets the simplification queue attached to the scene
  143821. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143822. */
  143823. simplificationQueue: SimplificationQueue;
  143824. }
  143825. interface Mesh {
  143826. /**
  143827. * Simplify the mesh according to the given array of settings.
  143828. * Function will return immediately and will simplify async
  143829. * @param settings a collection of simplification settings
  143830. * @param parallelProcessing should all levels calculate parallel or one after the other
  143831. * @param simplificationType the type of simplification to run
  143832. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  143833. * @returns the current mesh
  143834. */
  143835. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  143836. }
  143837. /**
  143838. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  143839. * created in a scene
  143840. */
  143841. export class SimplicationQueueSceneComponent implements ISceneComponent {
  143842. /**
  143843. * The component name helpfull to identify the component in the list of scene components.
  143844. */
  143845. readonly name: string;
  143846. /**
  143847. * The scene the component belongs to.
  143848. */
  143849. scene: Scene;
  143850. /**
  143851. * Creates a new instance of the component for the given scene
  143852. * @param scene Defines the scene to register the component in
  143853. */
  143854. constructor(scene: Scene);
  143855. /**
  143856. * Registers the component in a given scene
  143857. */
  143858. register(): void;
  143859. /**
  143860. * Rebuilds the elements related to this component in case of
  143861. * context lost for instance.
  143862. */
  143863. rebuild(): void;
  143864. /**
  143865. * Disposes the component and the associated ressources
  143866. */
  143867. dispose(): void;
  143868. private _beforeCameraUpdate;
  143869. }
  143870. }
  143871. declare module BABYLON {
  143872. interface Mesh {
  143873. /**
  143874. * Creates a new thin instance
  143875. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  143876. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  143877. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  143878. */
  143879. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  143880. /**
  143881. * Adds the transformation (matrix) of the current mesh as a thin instance
  143882. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  143883. * @returns the thin instance index number
  143884. */
  143885. thinInstanceAddSelf(refresh: boolean): number;
  143886. /**
  143887. * Registers a custom attribute to be used with thin instances
  143888. * @param kind name of the attribute
  143889. * @param stride size in floats of the attribute
  143890. */
  143891. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  143892. /**
  143893. * Sets the matrix of a thin instance
  143894. * @param index index of the thin instance
  143895. * @param matrix matrix to set
  143896. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  143897. */
  143898. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  143899. /**
  143900. * Sets the value of a custom attribute for a thin instance
  143901. * @param kind name of the attribute
  143902. * @param index index of the thin instance
  143903. * @param value value to set
  143904. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  143905. */
  143906. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  143907. /**
  143908. * Gets / sets the number of thin instances to display. Note that you can't set a number higher than what the underlying buffer can handle.
  143909. */
  143910. thinInstanceCount: number;
  143911. /**
  143912. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  143913. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  143914. * @param buffer buffer to set
  143915. * @param stride size in floats of each value of the buffer
  143916. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  143917. */
  143918. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  143919. /**
  143920. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  143921. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  143922. */
  143923. thinInstanceBufferUpdated(kind: string): void;
  143924. /**
  143925. * Refreshes the bounding info, taking into account all the thin instances defined
  143926. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  143927. */
  143928. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  143929. /** @hidden */
  143930. _thinInstanceInitializeUserStorage(): void;
  143931. /** @hidden */
  143932. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  143933. /** @hidden */
  143934. _userThinInstanceBuffersStorage: {
  143935. data: {
  143936. [key: string]: Float32Array;
  143937. };
  143938. sizes: {
  143939. [key: string]: number;
  143940. };
  143941. vertexBuffers: {
  143942. [key: string]: Nullable<VertexBuffer>;
  143943. };
  143944. strides: {
  143945. [key: string]: number;
  143946. };
  143947. };
  143948. }
  143949. }
  143950. declare module BABYLON {
  143951. /**
  143952. * Navigation plugin interface to add navigation constrained by a navigation mesh
  143953. */
  143954. export interface INavigationEnginePlugin {
  143955. /**
  143956. * plugin name
  143957. */
  143958. name: string;
  143959. /**
  143960. * Creates a navigation mesh
  143961. * @param meshes array of all the geometry used to compute the navigatio mesh
  143962. * @param parameters bunch of parameters used to filter geometry
  143963. */
  143964. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  143965. /**
  143966. * Create a navigation mesh debug mesh
  143967. * @param scene is where the mesh will be added
  143968. * @returns debug display mesh
  143969. */
  143970. createDebugNavMesh(scene: Scene): Mesh;
  143971. /**
  143972. * Get a navigation mesh constrained position, closest to the parameter position
  143973. * @param position world position
  143974. * @returns the closest point to position constrained by the navigation mesh
  143975. */
  143976. getClosestPoint(position: Vector3): Vector3;
  143977. /**
  143978. * Get a navigation mesh constrained position, closest to the parameter position
  143979. * @param position world position
  143980. * @param result output the closest point to position constrained by the navigation mesh
  143981. */
  143982. getClosestPointToRef(position: Vector3, result: Vector3): void;
  143983. /**
  143984. * Get a navigation mesh constrained position, within a particular radius
  143985. * @param position world position
  143986. * @param maxRadius the maximum distance to the constrained world position
  143987. * @returns the closest point to position constrained by the navigation mesh
  143988. */
  143989. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  143990. /**
  143991. * Get a navigation mesh constrained position, within a particular radius
  143992. * @param position world position
  143993. * @param maxRadius the maximum distance to the constrained world position
  143994. * @param result output the closest point to position constrained by the navigation mesh
  143995. */
  143996. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  143997. /**
  143998. * Compute the final position from a segment made of destination-position
  143999. * @param position world position
  144000. * @param destination world position
  144001. * @returns the resulting point along the navmesh
  144002. */
  144003. moveAlong(position: Vector3, destination: Vector3): Vector3;
  144004. /**
  144005. * Compute the final position from a segment made of destination-position
  144006. * @param position world position
  144007. * @param destination world position
  144008. * @param result output the resulting point along the navmesh
  144009. */
  144010. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  144011. /**
  144012. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  144013. * @param start world position
  144014. * @param end world position
  144015. * @returns array containing world position composing the path
  144016. */
  144017. computePath(start: Vector3, end: Vector3): Vector3[];
  144018. /**
  144019. * If this plugin is supported
  144020. * @returns true if plugin is supported
  144021. */
  144022. isSupported(): boolean;
  144023. /**
  144024. * Create a new Crowd so you can add agents
  144025. * @param maxAgents the maximum agent count in the crowd
  144026. * @param maxAgentRadius the maximum radius an agent can have
  144027. * @param scene to attach the crowd to
  144028. * @returns the crowd you can add agents to
  144029. */
  144030. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  144031. /**
  144032. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  144033. * The queries will try to find a solution within those bounds
  144034. * default is (1,1,1)
  144035. * @param extent x,y,z value that define the extent around the queries point of reference
  144036. */
  144037. setDefaultQueryExtent(extent: Vector3): void;
  144038. /**
  144039. * Get the Bounding box extent specified by setDefaultQueryExtent
  144040. * @returns the box extent values
  144041. */
  144042. getDefaultQueryExtent(): Vector3;
  144043. /**
  144044. * build the navmesh from a previously saved state using getNavmeshData
  144045. * @param data the Uint8Array returned by getNavmeshData
  144046. */
  144047. buildFromNavmeshData(data: Uint8Array): void;
  144048. /**
  144049. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  144050. * @returns data the Uint8Array that can be saved and reused
  144051. */
  144052. getNavmeshData(): Uint8Array;
  144053. /**
  144054. * Get the Bounding box extent result specified by setDefaultQueryExtent
  144055. * @param result output the box extent values
  144056. */
  144057. getDefaultQueryExtentToRef(result: Vector3): void;
  144058. /**
  144059. * Release all resources
  144060. */
  144061. dispose(): void;
  144062. }
  144063. /**
  144064. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  144065. */
  144066. export interface ICrowd {
  144067. /**
  144068. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  144069. * You can attach anything to that node. The node position is updated in the scene update tick.
  144070. * @param pos world position that will be constrained by the navigation mesh
  144071. * @param parameters agent parameters
  144072. * @param transform hooked to the agent that will be update by the scene
  144073. * @returns agent index
  144074. */
  144075. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  144076. /**
  144077. * Returns the agent position in world space
  144078. * @param index agent index returned by addAgent
  144079. * @returns world space position
  144080. */
  144081. getAgentPosition(index: number): Vector3;
  144082. /**
  144083. * Gets the agent position result in world space
  144084. * @param index agent index returned by addAgent
  144085. * @param result output world space position
  144086. */
  144087. getAgentPositionToRef(index: number, result: Vector3): void;
  144088. /**
  144089. * Gets the agent velocity in world space
  144090. * @param index agent index returned by addAgent
  144091. * @returns world space velocity
  144092. */
  144093. getAgentVelocity(index: number): Vector3;
  144094. /**
  144095. * Gets the agent velocity result in world space
  144096. * @param index agent index returned by addAgent
  144097. * @param result output world space velocity
  144098. */
  144099. getAgentVelocityToRef(index: number, result: Vector3): void;
  144100. /**
  144101. * remove a particular agent previously created
  144102. * @param index agent index returned by addAgent
  144103. */
  144104. removeAgent(index: number): void;
  144105. /**
  144106. * get the list of all agents attached to this crowd
  144107. * @returns list of agent indices
  144108. */
  144109. getAgents(): number[];
  144110. /**
  144111. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  144112. * @param deltaTime in seconds
  144113. */
  144114. update(deltaTime: number): void;
  144115. /**
  144116. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  144117. * @param index agent index returned by addAgent
  144118. * @param destination targeted world position
  144119. */
  144120. agentGoto(index: number, destination: Vector3): void;
  144121. /**
  144122. * Teleport the agent to a new position
  144123. * @param index agent index returned by addAgent
  144124. * @param destination targeted world position
  144125. */
  144126. agentTeleport(index: number, destination: Vector3): void;
  144127. /**
  144128. * Update agent parameters
  144129. * @param index agent index returned by addAgent
  144130. * @param parameters agent parameters
  144131. */
  144132. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  144133. /**
  144134. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  144135. * The queries will try to find a solution within those bounds
  144136. * default is (1,1,1)
  144137. * @param extent x,y,z value that define the extent around the queries point of reference
  144138. */
  144139. setDefaultQueryExtent(extent: Vector3): void;
  144140. /**
  144141. * Get the Bounding box extent specified by setDefaultQueryExtent
  144142. * @returns the box extent values
  144143. */
  144144. getDefaultQueryExtent(): Vector3;
  144145. /**
  144146. * Get the Bounding box extent result specified by setDefaultQueryExtent
  144147. * @param result output the box extent values
  144148. */
  144149. getDefaultQueryExtentToRef(result: Vector3): void;
  144150. /**
  144151. * Release all resources
  144152. */
  144153. dispose(): void;
  144154. }
  144155. /**
  144156. * Configures an agent
  144157. */
  144158. export interface IAgentParameters {
  144159. /**
  144160. * Agent radius. [Limit: >= 0]
  144161. */
  144162. radius: number;
  144163. /**
  144164. * Agent height. [Limit: > 0]
  144165. */
  144166. height: number;
  144167. /**
  144168. * Maximum allowed acceleration. [Limit: >= 0]
  144169. */
  144170. maxAcceleration: number;
  144171. /**
  144172. * Maximum allowed speed. [Limit: >= 0]
  144173. */
  144174. maxSpeed: number;
  144175. /**
  144176. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  144177. */
  144178. collisionQueryRange: number;
  144179. /**
  144180. * The path visibility optimization range. [Limit: > 0]
  144181. */
  144182. pathOptimizationRange: number;
  144183. /**
  144184. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  144185. */
  144186. separationWeight: number;
  144187. }
  144188. /**
  144189. * Configures the navigation mesh creation
  144190. */
  144191. export interface INavMeshParameters {
  144192. /**
  144193. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  144194. */
  144195. cs: number;
  144196. /**
  144197. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  144198. */
  144199. ch: number;
  144200. /**
  144201. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  144202. */
  144203. walkableSlopeAngle: number;
  144204. /**
  144205. * Minimum floor to 'ceiling' height that will still allow the floor area to
  144206. * be considered walkable. [Limit: >= 3] [Units: vx]
  144207. */
  144208. walkableHeight: number;
  144209. /**
  144210. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  144211. */
  144212. walkableClimb: number;
  144213. /**
  144214. * The distance to erode/shrink the walkable area of the heightfield away from
  144215. * obstructions. [Limit: >=0] [Units: vx]
  144216. */
  144217. walkableRadius: number;
  144218. /**
  144219. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  144220. */
  144221. maxEdgeLen: number;
  144222. /**
  144223. * The maximum distance a simplfied contour's border edges should deviate
  144224. * the original raw contour. [Limit: >=0] [Units: vx]
  144225. */
  144226. maxSimplificationError: number;
  144227. /**
  144228. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  144229. */
  144230. minRegionArea: number;
  144231. /**
  144232. * Any regions with a span count smaller than this value will, if possible,
  144233. * be merged with larger regions. [Limit: >=0] [Units: vx]
  144234. */
  144235. mergeRegionArea: number;
  144236. /**
  144237. * The maximum number of vertices allowed for polygons generated during the
  144238. * contour to polygon conversion process. [Limit: >= 3]
  144239. */
  144240. maxVertsPerPoly: number;
  144241. /**
  144242. * Sets the sampling distance to use when generating the detail mesh.
  144243. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  144244. */
  144245. detailSampleDist: number;
  144246. /**
  144247. * The maximum distance the detail mesh surface should deviate from heightfield
  144248. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  144249. */
  144250. detailSampleMaxError: number;
  144251. }
  144252. }
  144253. declare module BABYLON {
  144254. /**
  144255. * RecastJS navigation plugin
  144256. */
  144257. export class RecastJSPlugin implements INavigationEnginePlugin {
  144258. /**
  144259. * Reference to the Recast library
  144260. */
  144261. bjsRECAST: any;
  144262. /**
  144263. * plugin name
  144264. */
  144265. name: string;
  144266. /**
  144267. * the first navmesh created. We might extend this to support multiple navmeshes
  144268. */
  144269. navMesh: any;
  144270. /**
  144271. * Initializes the recastJS plugin
  144272. * @param recastInjection can be used to inject your own recast reference
  144273. */
  144274. constructor(recastInjection?: any);
  144275. /**
  144276. * Creates a navigation mesh
  144277. * @param meshes array of all the geometry used to compute the navigatio mesh
  144278. * @param parameters bunch of parameters used to filter geometry
  144279. */
  144280. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  144281. /**
  144282. * Create a navigation mesh debug mesh
  144283. * @param scene is where the mesh will be added
  144284. * @returns debug display mesh
  144285. */
  144286. createDebugNavMesh(scene: Scene): Mesh;
  144287. /**
  144288. * Get a navigation mesh constrained position, closest to the parameter position
  144289. * @param position world position
  144290. * @returns the closest point to position constrained by the navigation mesh
  144291. */
  144292. getClosestPoint(position: Vector3): Vector3;
  144293. /**
  144294. * Get a navigation mesh constrained position, closest to the parameter position
  144295. * @param position world position
  144296. * @param result output the closest point to position constrained by the navigation mesh
  144297. */
  144298. getClosestPointToRef(position: Vector3, result: Vector3): void;
  144299. /**
  144300. * Get a navigation mesh constrained position, within a particular radius
  144301. * @param position world position
  144302. * @param maxRadius the maximum distance to the constrained world position
  144303. * @returns the closest point to position constrained by the navigation mesh
  144304. */
  144305. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  144306. /**
  144307. * Get a navigation mesh constrained position, within a particular radius
  144308. * @param position world position
  144309. * @param maxRadius the maximum distance to the constrained world position
  144310. * @param result output the closest point to position constrained by the navigation mesh
  144311. */
  144312. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  144313. /**
  144314. * Compute the final position from a segment made of destination-position
  144315. * @param position world position
  144316. * @param destination world position
  144317. * @returns the resulting point along the navmesh
  144318. */
  144319. moveAlong(position: Vector3, destination: Vector3): Vector3;
  144320. /**
  144321. * Compute the final position from a segment made of destination-position
  144322. * @param position world position
  144323. * @param destination world position
  144324. * @param result output the resulting point along the navmesh
  144325. */
  144326. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  144327. /**
  144328. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  144329. * @param start world position
  144330. * @param end world position
  144331. * @returns array containing world position composing the path
  144332. */
  144333. computePath(start: Vector3, end: Vector3): Vector3[];
  144334. /**
  144335. * Create a new Crowd so you can add agents
  144336. * @param maxAgents the maximum agent count in the crowd
  144337. * @param maxAgentRadius the maximum radius an agent can have
  144338. * @param scene to attach the crowd to
  144339. * @returns the crowd you can add agents to
  144340. */
  144341. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  144342. /**
  144343. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  144344. * The queries will try to find a solution within those bounds
  144345. * default is (1,1,1)
  144346. * @param extent x,y,z value that define the extent around the queries point of reference
  144347. */
  144348. setDefaultQueryExtent(extent: Vector3): void;
  144349. /**
  144350. * Get the Bounding box extent specified by setDefaultQueryExtent
  144351. * @returns the box extent values
  144352. */
  144353. getDefaultQueryExtent(): Vector3;
  144354. /**
  144355. * build the navmesh from a previously saved state using getNavmeshData
  144356. * @param data the Uint8Array returned by getNavmeshData
  144357. */
  144358. buildFromNavmeshData(data: Uint8Array): void;
  144359. /**
  144360. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  144361. * @returns data the Uint8Array that can be saved and reused
  144362. */
  144363. getNavmeshData(): Uint8Array;
  144364. /**
  144365. * Get the Bounding box extent result specified by setDefaultQueryExtent
  144366. * @param result output the box extent values
  144367. */
  144368. getDefaultQueryExtentToRef(result: Vector3): void;
  144369. /**
  144370. * Disposes
  144371. */
  144372. dispose(): void;
  144373. /**
  144374. * If this plugin is supported
  144375. * @returns true if plugin is supported
  144376. */
  144377. isSupported(): boolean;
  144378. }
  144379. /**
  144380. * Recast detour crowd implementation
  144381. */
  144382. export class RecastJSCrowd implements ICrowd {
  144383. /**
  144384. * Recast/detour plugin
  144385. */
  144386. bjsRECASTPlugin: RecastJSPlugin;
  144387. /**
  144388. * Link to the detour crowd
  144389. */
  144390. recastCrowd: any;
  144391. /**
  144392. * One transform per agent
  144393. */
  144394. transforms: TransformNode[];
  144395. /**
  144396. * All agents created
  144397. */
  144398. agents: number[];
  144399. /**
  144400. * Link to the scene is kept to unregister the crowd from the scene
  144401. */
  144402. private _scene;
  144403. /**
  144404. * Observer for crowd updates
  144405. */
  144406. private _onBeforeAnimationsObserver;
  144407. /**
  144408. * Constructor
  144409. * @param plugin recastJS plugin
  144410. * @param maxAgents the maximum agent count in the crowd
  144411. * @param maxAgentRadius the maximum radius an agent can have
  144412. * @param scene to attach the crowd to
  144413. * @returns the crowd you can add agents to
  144414. */
  144415. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  144416. /**
  144417. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  144418. * You can attach anything to that node. The node position is updated in the scene update tick.
  144419. * @param pos world position that will be constrained by the navigation mesh
  144420. * @param parameters agent parameters
  144421. * @param transform hooked to the agent that will be update by the scene
  144422. * @returns agent index
  144423. */
  144424. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  144425. /**
  144426. * Returns the agent position in world space
  144427. * @param index agent index returned by addAgent
  144428. * @returns world space position
  144429. */
  144430. getAgentPosition(index: number): Vector3;
  144431. /**
  144432. * Returns the agent position result in world space
  144433. * @param index agent index returned by addAgent
  144434. * @param result output world space position
  144435. */
  144436. getAgentPositionToRef(index: number, result: Vector3): void;
  144437. /**
  144438. * Returns the agent velocity in world space
  144439. * @param index agent index returned by addAgent
  144440. * @returns world space velocity
  144441. */
  144442. getAgentVelocity(index: number): Vector3;
  144443. /**
  144444. * Returns the agent velocity result in world space
  144445. * @param index agent index returned by addAgent
  144446. * @param result output world space velocity
  144447. */
  144448. getAgentVelocityToRef(index: number, result: Vector3): void;
  144449. /**
  144450. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  144451. * @param index agent index returned by addAgent
  144452. * @param destination targeted world position
  144453. */
  144454. agentGoto(index: number, destination: Vector3): void;
  144455. /**
  144456. * Teleport the agent to a new position
  144457. * @param index agent index returned by addAgent
  144458. * @param destination targeted world position
  144459. */
  144460. agentTeleport(index: number, destination: Vector3): void;
  144461. /**
  144462. * Update agent parameters
  144463. * @param index agent index returned by addAgent
  144464. * @param parameters agent parameters
  144465. */
  144466. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  144467. /**
  144468. * remove a particular agent previously created
  144469. * @param index agent index returned by addAgent
  144470. */
  144471. removeAgent(index: number): void;
  144472. /**
  144473. * get the list of all agents attached to this crowd
  144474. * @returns list of agent indices
  144475. */
  144476. getAgents(): number[];
  144477. /**
  144478. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  144479. * @param deltaTime in seconds
  144480. */
  144481. update(deltaTime: number): void;
  144482. /**
  144483. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  144484. * The queries will try to find a solution within those bounds
  144485. * default is (1,1,1)
  144486. * @param extent x,y,z value that define the extent around the queries point of reference
  144487. */
  144488. setDefaultQueryExtent(extent: Vector3): void;
  144489. /**
  144490. * Get the Bounding box extent specified by setDefaultQueryExtent
  144491. * @returns the box extent values
  144492. */
  144493. getDefaultQueryExtent(): Vector3;
  144494. /**
  144495. * Get the Bounding box extent result specified by setDefaultQueryExtent
  144496. * @param result output the box extent values
  144497. */
  144498. getDefaultQueryExtentToRef(result: Vector3): void;
  144499. /**
  144500. * Release all resources
  144501. */
  144502. dispose(): void;
  144503. }
  144504. }
  144505. declare module BABYLON {
  144506. /**
  144507. * Class used to enable access to IndexedDB
  144508. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  144509. */
  144510. export class Database implements IOfflineProvider {
  144511. private _callbackManifestChecked;
  144512. private _currentSceneUrl;
  144513. private _db;
  144514. private _enableSceneOffline;
  144515. private _enableTexturesOffline;
  144516. private _manifestVersionFound;
  144517. private _mustUpdateRessources;
  144518. private _hasReachedQuota;
  144519. private _isSupported;
  144520. private _idbFactory;
  144521. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  144522. private static IsUASupportingBlobStorage;
  144523. /**
  144524. * Gets a boolean indicating if Database storate is enabled (off by default)
  144525. */
  144526. static IDBStorageEnabled: boolean;
  144527. /**
  144528. * Gets a boolean indicating if scene must be saved in the database
  144529. */
  144530. get enableSceneOffline(): boolean;
  144531. /**
  144532. * Gets a boolean indicating if textures must be saved in the database
  144533. */
  144534. get enableTexturesOffline(): boolean;
  144535. /**
  144536. * Creates a new Database
  144537. * @param urlToScene defines the url to load the scene
  144538. * @param callbackManifestChecked defines the callback to use when manifest is checked
  144539. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  144540. */
  144541. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  144542. private static _ParseURL;
  144543. private static _ReturnFullUrlLocation;
  144544. private _checkManifestFile;
  144545. /**
  144546. * Open the database and make it available
  144547. * @param successCallback defines the callback to call on success
  144548. * @param errorCallback defines the callback to call on error
  144549. */
  144550. open(successCallback: () => void, errorCallback: () => void): void;
  144551. /**
  144552. * Loads an image from the database
  144553. * @param url defines the url to load from
  144554. * @param image defines the target DOM image
  144555. */
  144556. loadImage(url: string, image: HTMLImageElement): void;
  144557. private _loadImageFromDBAsync;
  144558. private _saveImageIntoDBAsync;
  144559. private _checkVersionFromDB;
  144560. private _loadVersionFromDBAsync;
  144561. private _saveVersionIntoDBAsync;
  144562. /**
  144563. * Loads a file from database
  144564. * @param url defines the URL to load from
  144565. * @param sceneLoaded defines a callback to call on success
  144566. * @param progressCallBack defines a callback to call when progress changed
  144567. * @param errorCallback defines a callback to call on error
  144568. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  144569. */
  144570. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  144571. private _loadFileAsync;
  144572. private _saveFileAsync;
  144573. /**
  144574. * Validates if xhr data is correct
  144575. * @param xhr defines the request to validate
  144576. * @param dataType defines the expected data type
  144577. * @returns true if data is correct
  144578. */
  144579. private static _ValidateXHRData;
  144580. }
  144581. }
  144582. declare module BABYLON {
  144583. /** @hidden */
  144584. export var gpuUpdateParticlesPixelShader: {
  144585. name: string;
  144586. shader: string;
  144587. };
  144588. }
  144589. declare module BABYLON {
  144590. /** @hidden */
  144591. export var gpuUpdateParticlesVertexShader: {
  144592. name: string;
  144593. shader: string;
  144594. };
  144595. }
  144596. declare module BABYLON {
  144597. /** @hidden */
  144598. export var clipPlaneFragmentDeclaration2: {
  144599. name: string;
  144600. shader: string;
  144601. };
  144602. }
  144603. declare module BABYLON {
  144604. /** @hidden */
  144605. export var gpuRenderParticlesPixelShader: {
  144606. name: string;
  144607. shader: string;
  144608. };
  144609. }
  144610. declare module BABYLON {
  144611. /** @hidden */
  144612. export var clipPlaneVertexDeclaration2: {
  144613. name: string;
  144614. shader: string;
  144615. };
  144616. }
  144617. declare module BABYLON {
  144618. /** @hidden */
  144619. export var gpuRenderParticlesVertexShader: {
  144620. name: string;
  144621. shader: string;
  144622. };
  144623. }
  144624. declare module BABYLON {
  144625. /**
  144626. * This represents a GPU particle system in Babylon
  144627. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  144628. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  144629. */
  144630. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  144631. /**
  144632. * The layer mask we are rendering the particles through.
  144633. */
  144634. layerMask: number;
  144635. private _capacity;
  144636. private _activeCount;
  144637. private _currentActiveCount;
  144638. private _accumulatedCount;
  144639. private _renderEffect;
  144640. private _updateEffect;
  144641. private _buffer0;
  144642. private _buffer1;
  144643. private _spriteBuffer;
  144644. private _updateVAO;
  144645. private _renderVAO;
  144646. private _targetIndex;
  144647. private _sourceBuffer;
  144648. private _targetBuffer;
  144649. private _engine;
  144650. private _currentRenderId;
  144651. private _started;
  144652. private _stopped;
  144653. private _timeDelta;
  144654. private _randomTexture;
  144655. private _randomTexture2;
  144656. private _attributesStrideSize;
  144657. private _updateEffectOptions;
  144658. private _randomTextureSize;
  144659. private _actualFrame;
  144660. private _customEffect;
  144661. private readonly _rawTextureWidth;
  144662. /**
  144663. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  144664. */
  144665. static get IsSupported(): boolean;
  144666. /**
  144667. * An event triggered when the system is disposed.
  144668. */
  144669. onDisposeObservable: Observable<IParticleSystem>;
  144670. /**
  144671. * Gets the maximum number of particles active at the same time.
  144672. * @returns The max number of active particles.
  144673. */
  144674. getCapacity(): number;
  144675. /**
  144676. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  144677. * to override the particles.
  144678. */
  144679. forceDepthWrite: boolean;
  144680. /**
  144681. * Gets or set the number of active particles
  144682. */
  144683. get activeParticleCount(): number;
  144684. set activeParticleCount(value: number);
  144685. private _preWarmDone;
  144686. /**
  144687. * Specifies if the particles are updated in emitter local space or world space.
  144688. */
  144689. isLocal: boolean;
  144690. /**
  144691. * Is this system ready to be used/rendered
  144692. * @return true if the system is ready
  144693. */
  144694. isReady(): boolean;
  144695. /**
  144696. * Gets if the system has been started. (Note: this will still be true after stop is called)
  144697. * @returns True if it has been started, otherwise false.
  144698. */
  144699. isStarted(): boolean;
  144700. /**
  144701. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  144702. * @returns True if it has been stopped, otherwise false.
  144703. */
  144704. isStopped(): boolean;
  144705. /**
  144706. * Gets a boolean indicating that the system is stopping
  144707. * @returns true if the system is currently stopping
  144708. */
  144709. isStopping(): boolean;
  144710. /**
  144711. * Gets the number of particles active at the same time.
  144712. * @returns The number of active particles.
  144713. */
  144714. getActiveCount(): number;
  144715. /**
  144716. * Starts the particle system and begins to emit
  144717. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  144718. */
  144719. start(delay?: number): void;
  144720. /**
  144721. * Stops the particle system.
  144722. */
  144723. stop(): void;
  144724. /**
  144725. * Remove all active particles
  144726. */
  144727. reset(): void;
  144728. /**
  144729. * Returns the string "GPUParticleSystem"
  144730. * @returns a string containing the class name
  144731. */
  144732. getClassName(): string;
  144733. /**
  144734. * Gets the custom effect used to render the particles
  144735. * @param blendMode Blend mode for which the effect should be retrieved
  144736. * @returns The effect
  144737. */
  144738. getCustomEffect(blendMode?: number): Nullable<Effect>;
  144739. /**
  144740. * Sets the custom effect used to render the particles
  144741. * @param effect The effect to set
  144742. * @param blendMode Blend mode for which the effect should be set
  144743. */
  144744. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  144745. /** @hidden */
  144746. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  144747. /**
  144748. * Observable that will be called just before the particles are drawn
  144749. */
  144750. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  144751. /**
  144752. * Gets the name of the particle vertex shader
  144753. */
  144754. get vertexShaderName(): string;
  144755. private _colorGradientsTexture;
  144756. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  144757. /**
  144758. * Adds a new color gradient
  144759. * @param gradient defines the gradient to use (between 0 and 1)
  144760. * @param color1 defines the color to affect to the specified gradient
  144761. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  144762. * @returns the current particle system
  144763. */
  144764. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  144765. private _refreshColorGradient;
  144766. /** Force the system to rebuild all gradients that need to be resync */
  144767. forceRefreshGradients(): void;
  144768. /**
  144769. * Remove a specific color gradient
  144770. * @param gradient defines the gradient to remove
  144771. * @returns the current particle system
  144772. */
  144773. removeColorGradient(gradient: number): GPUParticleSystem;
  144774. private _angularSpeedGradientsTexture;
  144775. private _sizeGradientsTexture;
  144776. private _velocityGradientsTexture;
  144777. private _limitVelocityGradientsTexture;
  144778. private _dragGradientsTexture;
  144779. private _addFactorGradient;
  144780. /**
  144781. * Adds a new size gradient
  144782. * @param gradient defines the gradient to use (between 0 and 1)
  144783. * @param factor defines the size factor to affect to the specified gradient
  144784. * @returns the current particle system
  144785. */
  144786. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  144787. /**
  144788. * Remove a specific size gradient
  144789. * @param gradient defines the gradient to remove
  144790. * @returns the current particle system
  144791. */
  144792. removeSizeGradient(gradient: number): GPUParticleSystem;
  144793. private _refreshFactorGradient;
  144794. /**
  144795. * Adds a new angular speed gradient
  144796. * @param gradient defines the gradient to use (between 0 and 1)
  144797. * @param factor defines the angular speed to affect to the specified gradient
  144798. * @returns the current particle system
  144799. */
  144800. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  144801. /**
  144802. * Remove a specific angular speed gradient
  144803. * @param gradient defines the gradient to remove
  144804. * @returns the current particle system
  144805. */
  144806. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  144807. /**
  144808. * Adds a new velocity gradient
  144809. * @param gradient defines the gradient to use (between 0 and 1)
  144810. * @param factor defines the velocity to affect to the specified gradient
  144811. * @returns the current particle system
  144812. */
  144813. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  144814. /**
  144815. * Remove a specific velocity gradient
  144816. * @param gradient defines the gradient to remove
  144817. * @returns the current particle system
  144818. */
  144819. removeVelocityGradient(gradient: number): GPUParticleSystem;
  144820. /**
  144821. * Adds a new limit velocity gradient
  144822. * @param gradient defines the gradient to use (between 0 and 1)
  144823. * @param factor defines the limit velocity value to affect to the specified gradient
  144824. * @returns the current particle system
  144825. */
  144826. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  144827. /**
  144828. * Remove a specific limit velocity gradient
  144829. * @param gradient defines the gradient to remove
  144830. * @returns the current particle system
  144831. */
  144832. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  144833. /**
  144834. * Adds a new drag gradient
  144835. * @param gradient defines the gradient to use (between 0 and 1)
  144836. * @param factor defines the drag value to affect to the specified gradient
  144837. * @returns the current particle system
  144838. */
  144839. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  144840. /**
  144841. * Remove a specific drag gradient
  144842. * @param gradient defines the gradient to remove
  144843. * @returns the current particle system
  144844. */
  144845. removeDragGradient(gradient: number): GPUParticleSystem;
  144846. /**
  144847. * Not supported by GPUParticleSystem
  144848. * @param gradient defines the gradient to use (between 0 and 1)
  144849. * @param factor defines the emit rate value to affect to the specified gradient
  144850. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  144851. * @returns the current particle system
  144852. */
  144853. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  144854. /**
  144855. * Not supported by GPUParticleSystem
  144856. * @param gradient defines the gradient to remove
  144857. * @returns the current particle system
  144858. */
  144859. removeEmitRateGradient(gradient: number): IParticleSystem;
  144860. /**
  144861. * Not supported by GPUParticleSystem
  144862. * @param gradient defines the gradient to use (between 0 and 1)
  144863. * @param factor defines the start size value to affect to the specified gradient
  144864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  144865. * @returns the current particle system
  144866. */
  144867. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  144868. /**
  144869. * Not supported by GPUParticleSystem
  144870. * @param gradient defines the gradient to remove
  144871. * @returns the current particle system
  144872. */
  144873. removeStartSizeGradient(gradient: number): IParticleSystem;
  144874. /**
  144875. * Not supported by GPUParticleSystem
  144876. * @param gradient defines the gradient to use (between 0 and 1)
  144877. * @param min defines the color remap minimal range
  144878. * @param max defines the color remap maximal range
  144879. * @returns the current particle system
  144880. */
  144881. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  144882. /**
  144883. * Not supported by GPUParticleSystem
  144884. * @param gradient defines the gradient to remove
  144885. * @returns the current particle system
  144886. */
  144887. removeColorRemapGradient(): IParticleSystem;
  144888. /**
  144889. * Not supported by GPUParticleSystem
  144890. * @param gradient defines the gradient to use (between 0 and 1)
  144891. * @param min defines the alpha remap minimal range
  144892. * @param max defines the alpha remap maximal range
  144893. * @returns the current particle system
  144894. */
  144895. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  144896. /**
  144897. * Not supported by GPUParticleSystem
  144898. * @param gradient defines the gradient to remove
  144899. * @returns the current particle system
  144900. */
  144901. removeAlphaRemapGradient(): IParticleSystem;
  144902. /**
  144903. * Not supported by GPUParticleSystem
  144904. * @param gradient defines the gradient to use (between 0 and 1)
  144905. * @param color defines the color to affect to the specified gradient
  144906. * @returns the current particle system
  144907. */
  144908. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  144909. /**
  144910. * Not supported by GPUParticleSystem
  144911. * @param gradient defines the gradient to remove
  144912. * @returns the current particle system
  144913. */
  144914. removeRampGradient(): IParticleSystem;
  144915. /**
  144916. * Not supported by GPUParticleSystem
  144917. * @returns the list of ramp gradients
  144918. */
  144919. getRampGradients(): Nullable<Array<Color3Gradient>>;
  144920. /**
  144921. * Not supported by GPUParticleSystem
  144922. * Gets or sets a boolean indicating that ramp gradients must be used
  144923. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  144924. */
  144925. get useRampGradients(): boolean;
  144926. set useRampGradients(value: boolean);
  144927. /**
  144928. * Not supported by GPUParticleSystem
  144929. * @param gradient defines the gradient to use (between 0 and 1)
  144930. * @param factor defines the life time factor to affect to the specified gradient
  144931. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  144932. * @returns the current particle system
  144933. */
  144934. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  144935. /**
  144936. * Not supported by GPUParticleSystem
  144937. * @param gradient defines the gradient to remove
  144938. * @returns the current particle system
  144939. */
  144940. removeLifeTimeGradient(gradient: number): IParticleSystem;
  144941. /**
  144942. * Instantiates a GPU particle system.
  144943. * 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.
  144944. * @param name The name of the particle system
  144945. * @param options The options used to create the system
  144946. * @param scene The scene the particle system belongs to
  144947. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  144948. * @param customEffect a custom effect used to change the way particles are rendered by default
  144949. */
  144950. constructor(name: string, options: Partial<{
  144951. capacity: number;
  144952. randomTextureSize: number;
  144953. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  144954. protected _reset(): void;
  144955. private _createUpdateVAO;
  144956. private _createRenderVAO;
  144957. private _initialize;
  144958. /** @hidden */
  144959. _recreateUpdateEffect(): void;
  144960. private _getEffect;
  144961. /**
  144962. * Fill the defines array according to the current settings of the particle system
  144963. * @param defines Array to be updated
  144964. * @param blendMode blend mode to take into account when updating the array
  144965. */
  144966. fillDefines(defines: Array<string>, blendMode?: number): void;
  144967. /**
  144968. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  144969. * @param uniforms Uniforms array to fill
  144970. * @param attributes Attributes array to fill
  144971. * @param samplers Samplers array to fill
  144972. */
  144973. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  144974. /** @hidden */
  144975. _recreateRenderEffect(): Effect;
  144976. /**
  144977. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  144978. * @param preWarm defines if we are in the pre-warmimg phase
  144979. */
  144980. animate(preWarm?: boolean): void;
  144981. private _createFactorGradientTexture;
  144982. private _createSizeGradientTexture;
  144983. private _createAngularSpeedGradientTexture;
  144984. private _createVelocityGradientTexture;
  144985. private _createLimitVelocityGradientTexture;
  144986. private _createDragGradientTexture;
  144987. private _createColorGradientTexture;
  144988. /**
  144989. * Renders the particle system in its current state
  144990. * @param preWarm defines if the system should only update the particles but not render them
  144991. * @returns the current number of particles
  144992. */
  144993. render(preWarm?: boolean): number;
  144994. /**
  144995. * Rebuilds the particle system
  144996. */
  144997. rebuild(): void;
  144998. private _releaseBuffers;
  144999. private _releaseVAOs;
  145000. /**
  145001. * Disposes the particle system and free the associated resources
  145002. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  145003. */
  145004. dispose(disposeTexture?: boolean): void;
  145005. /**
  145006. * Clones the particle system.
  145007. * @param name The name of the cloned object
  145008. * @param newEmitter The new emitter to use
  145009. * @returns the cloned particle system
  145010. */
  145011. clone(name: string, newEmitter: any): GPUParticleSystem;
  145012. /**
  145013. * Serializes the particle system to a JSON object
  145014. * @param serializeTexture defines if the texture must be serialized as well
  145015. * @returns the JSON object
  145016. */
  145017. serialize(serializeTexture?: boolean): any;
  145018. /**
  145019. * Parses a JSON object to create a GPU particle system.
  145020. * @param parsedParticleSystem The JSON object to parse
  145021. * @param scene The scene to create the particle system in
  145022. * @param rootUrl The root url to use to load external dependencies like texture
  145023. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  145024. * @returns the parsed GPU particle system
  145025. */
  145026. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  145027. }
  145028. }
  145029. declare module BABYLON {
  145030. /**
  145031. * Represents a set of particle systems working together to create a specific effect
  145032. */
  145033. export class ParticleSystemSet implements IDisposable {
  145034. /**
  145035. * Gets or sets base Assets URL
  145036. */
  145037. static BaseAssetsUrl: string;
  145038. private _emitterCreationOptions;
  145039. private _emitterNode;
  145040. /**
  145041. * Gets the particle system list
  145042. */
  145043. systems: IParticleSystem[];
  145044. /**
  145045. * Gets the emitter node used with this set
  145046. */
  145047. get emitterNode(): Nullable<TransformNode>;
  145048. /**
  145049. * Creates a new emitter mesh as a sphere
  145050. * @param options defines the options used to create the sphere
  145051. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  145052. * @param scene defines the hosting scene
  145053. */
  145054. setEmitterAsSphere(options: {
  145055. diameter: number;
  145056. segments: number;
  145057. color: Color3;
  145058. }, renderingGroupId: number, scene: Scene): void;
  145059. /**
  145060. * Starts all particle systems of the set
  145061. * @param emitter defines an optional mesh to use as emitter for the particle systems
  145062. */
  145063. start(emitter?: AbstractMesh): void;
  145064. /**
  145065. * Release all associated resources
  145066. */
  145067. dispose(): void;
  145068. /**
  145069. * Serialize the set into a JSON compatible object
  145070. * @param serializeTexture defines if the texture must be serialized as well
  145071. * @returns a JSON compatible representation of the set
  145072. */
  145073. serialize(serializeTexture?: boolean): any;
  145074. /**
  145075. * Parse a new ParticleSystemSet from a serialized source
  145076. * @param data defines a JSON compatible representation of the set
  145077. * @param scene defines the hosting scene
  145078. * @param gpu defines if we want GPU particles or CPU particles
  145079. * @returns a new ParticleSystemSet
  145080. */
  145081. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  145082. }
  145083. }
  145084. declare module BABYLON {
  145085. /**
  145086. * This class is made for on one-liner static method to help creating particle system set.
  145087. */
  145088. export class ParticleHelper {
  145089. /**
  145090. * Gets or sets base Assets URL
  145091. */
  145092. static BaseAssetsUrl: string;
  145093. /** Define the Url to load snippets */
  145094. static SnippetUrl: string;
  145095. /**
  145096. * Create a default particle system that you can tweak
  145097. * @param emitter defines the emitter to use
  145098. * @param capacity defines the system capacity (default is 500 particles)
  145099. * @param scene defines the hosting scene
  145100. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  145101. * @returns the new Particle system
  145102. */
  145103. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  145104. /**
  145105. * This is the main static method (one-liner) of this helper to create different particle systems
  145106. * @param type This string represents the type to the particle system to create
  145107. * @param scene The scene where the particle system should live
  145108. * @param gpu If the system will use gpu
  145109. * @returns the ParticleSystemSet created
  145110. */
  145111. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  145112. /**
  145113. * Static function used to export a particle system to a ParticleSystemSet variable.
  145114. * Please note that the emitter shape is not exported
  145115. * @param systems defines the particle systems to export
  145116. * @returns the created particle system set
  145117. */
  145118. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  145119. /**
  145120. * Creates a particle system from a snippet saved in a remote file
  145121. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  145122. * @param url defines the url to load from
  145123. * @param scene defines the hosting scene
  145124. * @param gpu If the system will use gpu
  145125. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  145126. * @returns a promise that will resolve to the new particle system
  145127. */
  145128. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  145129. /**
  145130. * Creates a particle system from a snippet saved by the particle system editor
  145131. * @param snippetId defines the snippet to load
  145132. * @param scene defines the hosting scene
  145133. * @param gpu If the system will use gpu
  145134. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  145135. * @returns a promise that will resolve to the new particle system
  145136. */
  145137. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  145138. }
  145139. }
  145140. declare module BABYLON {
  145141. interface Engine {
  145142. /**
  145143. * Create an effect to use with particle systems.
  145144. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  145145. * the particle system for which you want to create a custom effect in the last parameter
  145146. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  145147. * @param uniformsNames defines a list of attribute names
  145148. * @param samplers defines an array of string used to represent textures
  145149. * @param defines defines the string containing the defines to use to compile the shaders
  145150. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  145151. * @param onCompiled defines a function to call when the effect creation is successful
  145152. * @param onError defines a function to call when the effect creation has failed
  145153. * @param particleSystem the particle system you want to create the effect for
  145154. * @returns the new Effect
  145155. */
  145156. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  145157. }
  145158. interface Mesh {
  145159. /**
  145160. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  145161. * @returns an array of IParticleSystem
  145162. */
  145163. getEmittedParticleSystems(): IParticleSystem[];
  145164. /**
  145165. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  145166. * @returns an array of IParticleSystem
  145167. */
  145168. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  145169. }
  145170. }
  145171. declare module BABYLON {
  145172. /** Defines the 4 color options */
  145173. export enum PointColor {
  145174. /** color value */
  145175. Color = 2,
  145176. /** uv value */
  145177. UV = 1,
  145178. /** random value */
  145179. Random = 0,
  145180. /** stated value */
  145181. Stated = 3
  145182. }
  145183. /**
  145184. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  145185. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  145186. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  145187. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  145188. *
  145189. * Full documentation here : TO BE ENTERED
  145190. */
  145191. export class PointsCloudSystem implements IDisposable {
  145192. /**
  145193. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  145194. * Example : var p = SPS.particles[i];
  145195. */
  145196. particles: CloudPoint[];
  145197. /**
  145198. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  145199. */
  145200. nbParticles: number;
  145201. /**
  145202. * This a counter for your own usage. It's not set by any SPS functions.
  145203. */
  145204. counter: number;
  145205. /**
  145206. * The PCS name. This name is also given to the underlying mesh.
  145207. */
  145208. name: string;
  145209. /**
  145210. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  145211. */
  145212. mesh: Mesh;
  145213. /**
  145214. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  145215. * Please read :
  145216. */
  145217. vars: any;
  145218. /**
  145219. * @hidden
  145220. */
  145221. _size: number;
  145222. private _scene;
  145223. private _promises;
  145224. private _positions;
  145225. private _indices;
  145226. private _normals;
  145227. private _colors;
  145228. private _uvs;
  145229. private _indices32;
  145230. private _positions32;
  145231. private _colors32;
  145232. private _uvs32;
  145233. private _updatable;
  145234. private _isVisibilityBoxLocked;
  145235. private _alwaysVisible;
  145236. private _groups;
  145237. private _groupCounter;
  145238. private _computeParticleColor;
  145239. private _computeParticleTexture;
  145240. private _computeParticleRotation;
  145241. private _computeBoundingBox;
  145242. private _isReady;
  145243. /**
  145244. * Creates a PCS (Points Cloud System) object
  145245. * @param name (String) is the PCS name, this will be the underlying mesh name
  145246. * @param pointSize (number) is the size for each point
  145247. * @param scene (Scene) is the scene in which the PCS is added
  145248. * @param options defines the options of the PCS e.g.
  145249. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  145250. */
  145251. constructor(name: string, pointSize: number, scene: Scene, options?: {
  145252. updatable?: boolean;
  145253. });
  145254. /**
  145255. * Builds the PCS underlying mesh. Returns a standard Mesh.
  145256. * If no points were added to the PCS, the returned mesh is just a single point.
  145257. * @returns a promise for the created mesh
  145258. */
  145259. buildMeshAsync(): Promise<Mesh>;
  145260. /**
  145261. * @hidden
  145262. */
  145263. private _buildMesh;
  145264. private _addParticle;
  145265. private _randomUnitVector;
  145266. private _getColorIndicesForCoord;
  145267. private _setPointsColorOrUV;
  145268. private _colorFromTexture;
  145269. private _calculateDensity;
  145270. /**
  145271. * Adds points to the PCS in random positions within a unit sphere
  145272. * @param nb (positive integer) the number of particles to be created from this model
  145273. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  145274. * @returns the number of groups in the system
  145275. */
  145276. addPoints(nb: number, pointFunction?: any): number;
  145277. /**
  145278. * Adds points to the PCS from the surface of the model shape
  145279. * @param mesh is any Mesh object that will be used as a surface model for the points
  145280. * @param nb (positive integer) the number of particles to be created from this model
  145281. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  145282. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  145283. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  145284. * @returns the number of groups in the system
  145285. */
  145286. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  145287. /**
  145288. * Adds points to the PCS inside the model shape
  145289. * @param mesh is any Mesh object that will be used as a surface model for the points
  145290. * @param nb (positive integer) the number of particles to be created from this model
  145291. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  145292. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  145293. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  145294. * @returns the number of groups in the system
  145295. */
  145296. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  145297. /**
  145298. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  145299. * This method calls `updateParticle()` for each particle of the SPS.
  145300. * For an animated SPS, it is usually called within the render loop.
  145301. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  145302. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  145303. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  145304. * @returns the PCS.
  145305. */
  145306. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  145307. /**
  145308. * Disposes the PCS.
  145309. */
  145310. dispose(): void;
  145311. /**
  145312. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  145313. * doc :
  145314. * @returns the PCS.
  145315. */
  145316. refreshVisibleSize(): PointsCloudSystem;
  145317. /**
  145318. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  145319. * @param size the size (float) of the visibility box
  145320. * note : this doesn't lock the PCS mesh bounding box.
  145321. * doc :
  145322. */
  145323. setVisibilityBox(size: number): void;
  145324. /**
  145325. * Gets whether the PCS is always visible or not
  145326. * doc :
  145327. */
  145328. get isAlwaysVisible(): boolean;
  145329. /**
  145330. * Sets the PCS as always visible or not
  145331. * doc :
  145332. */
  145333. set isAlwaysVisible(val: boolean);
  145334. /**
  145335. * Tells to `setParticles()` to compute the particle rotations or not
  145336. * Default value : false. The PCS is faster when it's set to false
  145337. * Note : particle rotations are only applied to parent particles
  145338. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  145339. */
  145340. set computeParticleRotation(val: boolean);
  145341. /**
  145342. * Tells to `setParticles()` to compute the particle colors or not.
  145343. * Default value : true. The PCS is faster when it's set to false.
  145344. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  145345. */
  145346. set computeParticleColor(val: boolean);
  145347. set computeParticleTexture(val: boolean);
  145348. /**
  145349. * Gets if `setParticles()` computes the particle colors or not.
  145350. * Default value : false. The PCS is faster when it's set to false.
  145351. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  145352. */
  145353. get computeParticleColor(): boolean;
  145354. /**
  145355. * Gets if `setParticles()` computes the particle textures or not.
  145356. * Default value : false. The PCS is faster when it's set to false.
  145357. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  145358. */
  145359. get computeParticleTexture(): boolean;
  145360. /**
  145361. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  145362. */
  145363. set computeBoundingBox(val: boolean);
  145364. /**
  145365. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  145366. */
  145367. get computeBoundingBox(): boolean;
  145368. /**
  145369. * This function does nothing. It may be overwritten to set all the particle first values.
  145370. * The PCS doesn't call this function, you may have to call it by your own.
  145371. * doc :
  145372. */
  145373. initParticles(): void;
  145374. /**
  145375. * This function does nothing. It may be overwritten to recycle a particle
  145376. * The PCS doesn't call this function, you can to call it
  145377. * doc :
  145378. * @param particle The particle to recycle
  145379. * @returns the recycled particle
  145380. */
  145381. recycleParticle(particle: CloudPoint): CloudPoint;
  145382. /**
  145383. * Updates a particle : this function should be overwritten by the user.
  145384. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  145385. * doc :
  145386. * @example : just set a particle position or velocity and recycle conditions
  145387. * @param particle The particle to update
  145388. * @returns the updated particle
  145389. */
  145390. updateParticle(particle: CloudPoint): CloudPoint;
  145391. /**
  145392. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  145393. * This does nothing and may be overwritten by the user.
  145394. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  145395. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  145396. * @param update the boolean update value actually passed to setParticles()
  145397. */
  145398. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  145399. /**
  145400. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  145401. * This will be passed three parameters.
  145402. * This does nothing and may be overwritten by the user.
  145403. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  145404. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  145405. * @param update the boolean update value actually passed to setParticles()
  145406. */
  145407. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  145408. }
  145409. }
  145410. declare module BABYLON {
  145411. /**
  145412. * Represents one particle of a points cloud system.
  145413. */
  145414. export class CloudPoint {
  145415. /**
  145416. * particle global index
  145417. */
  145418. idx: number;
  145419. /**
  145420. * The color of the particle
  145421. */
  145422. color: Nullable<Color4>;
  145423. /**
  145424. * The world space position of the particle.
  145425. */
  145426. position: Vector3;
  145427. /**
  145428. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  145429. */
  145430. rotation: Vector3;
  145431. /**
  145432. * The world space rotation quaternion of the particle.
  145433. */
  145434. rotationQuaternion: Nullable<Quaternion>;
  145435. /**
  145436. * The uv of the particle.
  145437. */
  145438. uv: Nullable<Vector2>;
  145439. /**
  145440. * The current speed of the particle.
  145441. */
  145442. velocity: Vector3;
  145443. /**
  145444. * The pivot point in the particle local space.
  145445. */
  145446. pivot: Vector3;
  145447. /**
  145448. * Must the particle be translated from its pivot point in its local space ?
  145449. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  145450. * Default : false
  145451. */
  145452. translateFromPivot: boolean;
  145453. /**
  145454. * Index of this particle in the global "positions" array (Internal use)
  145455. * @hidden
  145456. */
  145457. _pos: number;
  145458. /**
  145459. * @hidden Index of this particle in the global "indices" array (Internal use)
  145460. */
  145461. _ind: number;
  145462. /**
  145463. * Group this particle belongs to
  145464. */
  145465. _group: PointsGroup;
  145466. /**
  145467. * Group id of this particle
  145468. */
  145469. groupId: number;
  145470. /**
  145471. * Index of the particle in its group id (Internal use)
  145472. */
  145473. idxInGroup: number;
  145474. /**
  145475. * @hidden Particle BoundingInfo object (Internal use)
  145476. */
  145477. _boundingInfo: BoundingInfo;
  145478. /**
  145479. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  145480. */
  145481. _pcs: PointsCloudSystem;
  145482. /**
  145483. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  145484. */
  145485. _stillInvisible: boolean;
  145486. /**
  145487. * @hidden Last computed particle rotation matrix
  145488. */
  145489. _rotationMatrix: number[];
  145490. /**
  145491. * Parent particle Id, if any.
  145492. * Default null.
  145493. */
  145494. parentId: Nullable<number>;
  145495. /**
  145496. * @hidden Internal global position in the PCS.
  145497. */
  145498. _globalPosition: Vector3;
  145499. /**
  145500. * Creates a Point Cloud object.
  145501. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  145502. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  145503. * @param group (PointsGroup) is the group the particle belongs to
  145504. * @param groupId (integer) is the group identifier in the PCS.
  145505. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  145506. * @param pcs defines the PCS it is associated to
  145507. */
  145508. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  145509. /**
  145510. * get point size
  145511. */
  145512. get size(): Vector3;
  145513. /**
  145514. * Set point size
  145515. */
  145516. set size(scale: Vector3);
  145517. /**
  145518. * Legacy support, changed quaternion to rotationQuaternion
  145519. */
  145520. get quaternion(): Nullable<Quaternion>;
  145521. /**
  145522. * Legacy support, changed quaternion to rotationQuaternion
  145523. */
  145524. set quaternion(q: Nullable<Quaternion>);
  145525. /**
  145526. * Returns a boolean. True if the particle intersects a mesh, else false
  145527. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  145528. * @param target is the object (point or mesh) what the intersection is computed against
  145529. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  145530. * @returns true if it intersects
  145531. */
  145532. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  145533. /**
  145534. * get the rotation matrix of the particle
  145535. * @hidden
  145536. */
  145537. getRotationMatrix(m: Matrix): void;
  145538. }
  145539. /**
  145540. * Represents a group of points in a points cloud system
  145541. * * PCS internal tool, don't use it manually.
  145542. */
  145543. export class PointsGroup {
  145544. /**
  145545. * The group id
  145546. * @hidden
  145547. */
  145548. groupID: number;
  145549. /**
  145550. * image data for group (internal use)
  145551. * @hidden
  145552. */
  145553. _groupImageData: Nullable<ArrayBufferView>;
  145554. /**
  145555. * Image Width (internal use)
  145556. * @hidden
  145557. */
  145558. _groupImgWidth: number;
  145559. /**
  145560. * Image Height (internal use)
  145561. * @hidden
  145562. */
  145563. _groupImgHeight: number;
  145564. /**
  145565. * Custom position function (internal use)
  145566. * @hidden
  145567. */
  145568. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  145569. /**
  145570. * density per facet for surface points
  145571. * @hidden
  145572. */
  145573. _groupDensity: number[];
  145574. /**
  145575. * Only when points are colored by texture carries pointer to texture list array
  145576. * @hidden
  145577. */
  145578. _textureNb: number;
  145579. /**
  145580. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  145581. * PCS internal tool, don't use it manually.
  145582. * @hidden
  145583. */
  145584. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  145585. }
  145586. }
  145587. declare module BABYLON {
  145588. interface Scene {
  145589. /** @hidden (Backing field) */
  145590. _physicsEngine: Nullable<IPhysicsEngine>;
  145591. /** @hidden */
  145592. _physicsTimeAccumulator: number;
  145593. /**
  145594. * Gets the current physics engine
  145595. * @returns a IPhysicsEngine or null if none attached
  145596. */
  145597. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  145598. /**
  145599. * Enables physics to the current scene
  145600. * @param gravity defines the scene's gravity for the physics engine
  145601. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  145602. * @return a boolean indicating if the physics engine was initialized
  145603. */
  145604. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  145605. /**
  145606. * Disables and disposes the physics engine associated with the scene
  145607. */
  145608. disablePhysicsEngine(): void;
  145609. /**
  145610. * Gets a boolean indicating if there is an active physics engine
  145611. * @returns a boolean indicating if there is an active physics engine
  145612. */
  145613. isPhysicsEnabled(): boolean;
  145614. /**
  145615. * Deletes a physics compound impostor
  145616. * @param compound defines the compound to delete
  145617. */
  145618. deleteCompoundImpostor(compound: any): void;
  145619. /**
  145620. * An event triggered when physic simulation is about to be run
  145621. */
  145622. onBeforePhysicsObservable: Observable<Scene>;
  145623. /**
  145624. * An event triggered when physic simulation has been done
  145625. */
  145626. onAfterPhysicsObservable: Observable<Scene>;
  145627. }
  145628. interface AbstractMesh {
  145629. /** @hidden */
  145630. _physicsImpostor: Nullable<PhysicsImpostor>;
  145631. /**
  145632. * Gets or sets impostor used for physic simulation
  145633. * @see https://doc.babylonjs.com/features/physics_engine
  145634. */
  145635. physicsImpostor: Nullable<PhysicsImpostor>;
  145636. /**
  145637. * Gets the current physics impostor
  145638. * @see https://doc.babylonjs.com/features/physics_engine
  145639. * @returns a physics impostor or null
  145640. */
  145641. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  145642. /** Apply a physic impulse to the mesh
  145643. * @param force defines the force to apply
  145644. * @param contactPoint defines where to apply the force
  145645. * @returns the current mesh
  145646. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  145647. */
  145648. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  145649. /**
  145650. * Creates a physic joint between two meshes
  145651. * @param otherMesh defines the other mesh to use
  145652. * @param pivot1 defines the pivot to use on this mesh
  145653. * @param pivot2 defines the pivot to use on the other mesh
  145654. * @param options defines additional options (can be plugin dependent)
  145655. * @returns the current mesh
  145656. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  145657. */
  145658. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  145659. /** @hidden */
  145660. _disposePhysicsObserver: Nullable<Observer<Node>>;
  145661. }
  145662. /**
  145663. * Defines the physics engine scene component responsible to manage a physics engine
  145664. */
  145665. export class PhysicsEngineSceneComponent implements ISceneComponent {
  145666. /**
  145667. * The component name helpful to identify the component in the list of scene components.
  145668. */
  145669. readonly name: string;
  145670. /**
  145671. * The scene the component belongs to.
  145672. */
  145673. scene: Scene;
  145674. /**
  145675. * Creates a new instance of the component for the given scene
  145676. * @param scene Defines the scene to register the component in
  145677. */
  145678. constructor(scene: Scene);
  145679. /**
  145680. * Registers the component in a given scene
  145681. */
  145682. register(): void;
  145683. /**
  145684. * Rebuilds the elements related to this component in case of
  145685. * context lost for instance.
  145686. */
  145687. rebuild(): void;
  145688. /**
  145689. * Disposes the component and the associated ressources
  145690. */
  145691. dispose(): void;
  145692. }
  145693. }
  145694. declare module BABYLON {
  145695. /**
  145696. * A helper for physics simulations
  145697. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145698. */
  145699. export class PhysicsHelper {
  145700. private _scene;
  145701. private _physicsEngine;
  145702. /**
  145703. * Initializes the Physics helper
  145704. * @param scene Babylon.js scene
  145705. */
  145706. constructor(scene: Scene);
  145707. /**
  145708. * Applies a radial explosion impulse
  145709. * @param origin the origin of the explosion
  145710. * @param radiusOrEventOptions the radius or the options of radial explosion
  145711. * @param strength the explosion strength
  145712. * @param falloff possible options: Constant & Linear. Defaults to Constant
  145713. * @returns A physics radial explosion event, or null
  145714. */
  145715. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  145716. /**
  145717. * Applies a radial explosion force
  145718. * @param origin the origin of the explosion
  145719. * @param radiusOrEventOptions the radius or the options of radial explosion
  145720. * @param strength the explosion strength
  145721. * @param falloff possible options: Constant & Linear. Defaults to Constant
  145722. * @returns A physics radial explosion event, or null
  145723. */
  145724. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  145725. /**
  145726. * Creates a gravitational field
  145727. * @param origin the origin of the explosion
  145728. * @param radiusOrEventOptions the radius or the options of radial explosion
  145729. * @param strength the explosion strength
  145730. * @param falloff possible options: Constant & Linear. Defaults to Constant
  145731. * @returns A physics gravitational field event, or null
  145732. */
  145733. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  145734. /**
  145735. * Creates a physics updraft event
  145736. * @param origin the origin of the updraft
  145737. * @param radiusOrEventOptions the radius or the options of the updraft
  145738. * @param strength the strength of the updraft
  145739. * @param height the height of the updraft
  145740. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  145741. * @returns A physics updraft event, or null
  145742. */
  145743. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  145744. /**
  145745. * Creates a physics vortex event
  145746. * @param origin the of the vortex
  145747. * @param radiusOrEventOptions the radius or the options of the vortex
  145748. * @param strength the strength of the vortex
  145749. * @param height the height of the vortex
  145750. * @returns a Physics vortex event, or null
  145751. * A physics vortex event or null
  145752. */
  145753. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  145754. }
  145755. /**
  145756. * Represents a physics radial explosion event
  145757. */
  145758. class PhysicsRadialExplosionEvent {
  145759. private _scene;
  145760. private _options;
  145761. private _sphere;
  145762. private _dataFetched;
  145763. /**
  145764. * Initializes a radial explosioin event
  145765. * @param _scene BabylonJS scene
  145766. * @param _options The options for the vortex event
  145767. */
  145768. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  145769. /**
  145770. * Returns the data related to the radial explosion event (sphere).
  145771. * @returns The radial explosion event data
  145772. */
  145773. getData(): PhysicsRadialExplosionEventData;
  145774. /**
  145775. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  145776. * @param impostor A physics imposter
  145777. * @param origin the origin of the explosion
  145778. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  145779. */
  145780. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  145781. /**
  145782. * Triggers affecterd impostors callbacks
  145783. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  145784. */
  145785. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  145786. /**
  145787. * Disposes the sphere.
  145788. * @param force Specifies if the sphere should be disposed by force
  145789. */
  145790. dispose(force?: boolean): void;
  145791. /*** Helpers ***/
  145792. private _prepareSphere;
  145793. private _intersectsWithSphere;
  145794. }
  145795. /**
  145796. * Represents a gravitational field event
  145797. */
  145798. class PhysicsGravitationalFieldEvent {
  145799. private _physicsHelper;
  145800. private _scene;
  145801. private _origin;
  145802. private _options;
  145803. private _tickCallback;
  145804. private _sphere;
  145805. private _dataFetched;
  145806. /**
  145807. * Initializes the physics gravitational field event
  145808. * @param _physicsHelper A physics helper
  145809. * @param _scene BabylonJS scene
  145810. * @param _origin The origin position of the gravitational field event
  145811. * @param _options The options for the vortex event
  145812. */
  145813. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  145814. /**
  145815. * Returns the data related to the gravitational field event (sphere).
  145816. * @returns A gravitational field event
  145817. */
  145818. getData(): PhysicsGravitationalFieldEventData;
  145819. /**
  145820. * Enables the gravitational field.
  145821. */
  145822. enable(): void;
  145823. /**
  145824. * Disables the gravitational field.
  145825. */
  145826. disable(): void;
  145827. /**
  145828. * Disposes the sphere.
  145829. * @param force The force to dispose from the gravitational field event
  145830. */
  145831. dispose(force?: boolean): void;
  145832. private _tick;
  145833. }
  145834. /**
  145835. * Represents a physics updraft event
  145836. */
  145837. class PhysicsUpdraftEvent {
  145838. private _scene;
  145839. private _origin;
  145840. private _options;
  145841. private _physicsEngine;
  145842. private _originTop;
  145843. private _originDirection;
  145844. private _tickCallback;
  145845. private _cylinder;
  145846. private _cylinderPosition;
  145847. private _dataFetched;
  145848. /**
  145849. * Initializes the physics updraft event
  145850. * @param _scene BabylonJS scene
  145851. * @param _origin The origin position of the updraft
  145852. * @param _options The options for the updraft event
  145853. */
  145854. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  145855. /**
  145856. * Returns the data related to the updraft event (cylinder).
  145857. * @returns A physics updraft event
  145858. */
  145859. getData(): PhysicsUpdraftEventData;
  145860. /**
  145861. * Enables the updraft.
  145862. */
  145863. enable(): void;
  145864. /**
  145865. * Disables the updraft.
  145866. */
  145867. disable(): void;
  145868. /**
  145869. * Disposes the cylinder.
  145870. * @param force Specifies if the updraft should be disposed by force
  145871. */
  145872. dispose(force?: boolean): void;
  145873. private getImpostorHitData;
  145874. private _tick;
  145875. /*** Helpers ***/
  145876. private _prepareCylinder;
  145877. private _intersectsWithCylinder;
  145878. }
  145879. /**
  145880. * Represents a physics vortex event
  145881. */
  145882. class PhysicsVortexEvent {
  145883. private _scene;
  145884. private _origin;
  145885. private _options;
  145886. private _physicsEngine;
  145887. private _originTop;
  145888. private _tickCallback;
  145889. private _cylinder;
  145890. private _cylinderPosition;
  145891. private _dataFetched;
  145892. /**
  145893. * Initializes the physics vortex event
  145894. * @param _scene The BabylonJS scene
  145895. * @param _origin The origin position of the vortex
  145896. * @param _options The options for the vortex event
  145897. */
  145898. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  145899. /**
  145900. * Returns the data related to the vortex event (cylinder).
  145901. * @returns The physics vortex event data
  145902. */
  145903. getData(): PhysicsVortexEventData;
  145904. /**
  145905. * Enables the vortex.
  145906. */
  145907. enable(): void;
  145908. /**
  145909. * Disables the cortex.
  145910. */
  145911. disable(): void;
  145912. /**
  145913. * Disposes the sphere.
  145914. * @param force
  145915. */
  145916. dispose(force?: boolean): void;
  145917. private getImpostorHitData;
  145918. private _tick;
  145919. /*** Helpers ***/
  145920. private _prepareCylinder;
  145921. private _intersectsWithCylinder;
  145922. }
  145923. /**
  145924. * Options fot the radial explosion event
  145925. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145926. */
  145927. export class PhysicsRadialExplosionEventOptions {
  145928. /**
  145929. * The radius of the sphere for the radial explosion.
  145930. */
  145931. radius: number;
  145932. /**
  145933. * The strenth of the explosion.
  145934. */
  145935. strength: number;
  145936. /**
  145937. * The strenght of the force in correspondence to the distance of the affected object
  145938. */
  145939. falloff: PhysicsRadialImpulseFalloff;
  145940. /**
  145941. * Sphere options for the radial explosion.
  145942. */
  145943. sphere: {
  145944. segments: number;
  145945. diameter: number;
  145946. };
  145947. /**
  145948. * Sphere options for the radial explosion.
  145949. */
  145950. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  145951. }
  145952. /**
  145953. * Options fot the updraft event
  145954. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145955. */
  145956. export class PhysicsUpdraftEventOptions {
  145957. /**
  145958. * The radius of the cylinder for the vortex
  145959. */
  145960. radius: number;
  145961. /**
  145962. * The strenth of the updraft.
  145963. */
  145964. strength: number;
  145965. /**
  145966. * The height of the cylinder for the updraft.
  145967. */
  145968. height: number;
  145969. /**
  145970. * The mode for the the updraft.
  145971. */
  145972. updraftMode: PhysicsUpdraftMode;
  145973. }
  145974. /**
  145975. * Options fot the vortex event
  145976. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145977. */
  145978. export class PhysicsVortexEventOptions {
  145979. /**
  145980. * The radius of the cylinder for the vortex
  145981. */
  145982. radius: number;
  145983. /**
  145984. * The strenth of the vortex.
  145985. */
  145986. strength: number;
  145987. /**
  145988. * The height of the cylinder for the vortex.
  145989. */
  145990. height: number;
  145991. /**
  145992. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  145993. */
  145994. centripetalForceThreshold: number;
  145995. /**
  145996. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  145997. */
  145998. centripetalForceMultiplier: number;
  145999. /**
  146000. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  146001. */
  146002. centrifugalForceMultiplier: number;
  146003. /**
  146004. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  146005. */
  146006. updraftForceMultiplier: number;
  146007. }
  146008. /**
  146009. * The strenght of the force in correspondence to the distance of the affected object
  146010. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146011. */
  146012. export enum PhysicsRadialImpulseFalloff {
  146013. /** Defines that impulse is constant in strength across it's whole radius */
  146014. Constant = 0,
  146015. /** Defines that impulse gets weaker if it's further from the origin */
  146016. Linear = 1
  146017. }
  146018. /**
  146019. * The strength of the force in correspondence to the distance of the affected object
  146020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146021. */
  146022. export enum PhysicsUpdraftMode {
  146023. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  146024. Center = 0,
  146025. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  146026. Perpendicular = 1
  146027. }
  146028. /**
  146029. * Interface for a physics hit data
  146030. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146031. */
  146032. export interface PhysicsHitData {
  146033. /**
  146034. * The force applied at the contact point
  146035. */
  146036. force: Vector3;
  146037. /**
  146038. * The contact point
  146039. */
  146040. contactPoint: Vector3;
  146041. /**
  146042. * The distance from the origin to the contact point
  146043. */
  146044. distanceFromOrigin: number;
  146045. }
  146046. /**
  146047. * Interface for radial explosion event data
  146048. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146049. */
  146050. export interface PhysicsRadialExplosionEventData {
  146051. /**
  146052. * A sphere used for the radial explosion event
  146053. */
  146054. sphere: Mesh;
  146055. }
  146056. /**
  146057. * Interface for gravitational field event data
  146058. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146059. */
  146060. export interface PhysicsGravitationalFieldEventData {
  146061. /**
  146062. * A sphere mesh used for the gravitational field event
  146063. */
  146064. sphere: Mesh;
  146065. }
  146066. /**
  146067. * Interface for updraft event data
  146068. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146069. */
  146070. export interface PhysicsUpdraftEventData {
  146071. /**
  146072. * A cylinder used for the updraft event
  146073. */
  146074. cylinder: Mesh;
  146075. }
  146076. /**
  146077. * Interface for vortex event data
  146078. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146079. */
  146080. export interface PhysicsVortexEventData {
  146081. /**
  146082. * A cylinder used for the vortex event
  146083. */
  146084. cylinder: Mesh;
  146085. }
  146086. /**
  146087. * Interface for an affected physics impostor
  146088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146089. */
  146090. export interface PhysicsAffectedImpostorWithData {
  146091. /**
  146092. * The impostor affected by the effect
  146093. */
  146094. impostor: PhysicsImpostor;
  146095. /**
  146096. * The data about the hit/horce from the explosion
  146097. */
  146098. hitData: PhysicsHitData;
  146099. }
  146100. }
  146101. declare module BABYLON {
  146102. /** @hidden */
  146103. export var blackAndWhitePixelShader: {
  146104. name: string;
  146105. shader: string;
  146106. };
  146107. }
  146108. declare module BABYLON {
  146109. /**
  146110. * Post process used to render in black and white
  146111. */
  146112. export class BlackAndWhitePostProcess extends PostProcess {
  146113. /**
  146114. * Linear about to convert he result to black and white (default: 1)
  146115. */
  146116. degree: number;
  146117. /**
  146118. * Creates a black and white post process
  146119. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  146120. * @param name The name of the effect.
  146121. * @param options The required width/height ratio to downsize to before computing the render pass.
  146122. * @param camera The camera to apply the render pass to.
  146123. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146124. * @param engine The engine which the post process will be applied. (default: current engine)
  146125. * @param reusable If the post process can be reused on the same frame. (default: false)
  146126. */
  146127. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146128. }
  146129. }
  146130. declare module BABYLON {
  146131. /**
  146132. * This represents a set of one or more post processes in Babylon.
  146133. * A post process can be used to apply a shader to a texture after it is rendered.
  146134. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  146135. */
  146136. export class PostProcessRenderEffect {
  146137. private _postProcesses;
  146138. private _getPostProcesses;
  146139. private _singleInstance;
  146140. private _cameras;
  146141. private _indicesForCamera;
  146142. /**
  146143. * Name of the effect
  146144. * @hidden
  146145. */
  146146. _name: string;
  146147. /**
  146148. * Instantiates a post process render effect.
  146149. * A post process can be used to apply a shader to a texture after it is rendered.
  146150. * @param engine The engine the effect is tied to
  146151. * @param name The name of the effect
  146152. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  146153. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  146154. */
  146155. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  146156. /**
  146157. * Checks if all the post processes in the effect are supported.
  146158. */
  146159. get isSupported(): boolean;
  146160. /**
  146161. * Updates the current state of the effect
  146162. * @hidden
  146163. */
  146164. _update(): void;
  146165. /**
  146166. * Attaches the effect on cameras
  146167. * @param cameras The camera to attach to.
  146168. * @hidden
  146169. */
  146170. _attachCameras(cameras: Camera): void;
  146171. /**
  146172. * Attaches the effect on cameras
  146173. * @param cameras The camera to attach to.
  146174. * @hidden
  146175. */
  146176. _attachCameras(cameras: Camera[]): void;
  146177. /**
  146178. * Detaches the effect on cameras
  146179. * @param cameras The camera to detatch from.
  146180. * @hidden
  146181. */
  146182. _detachCameras(cameras: Camera): void;
  146183. /**
  146184. * Detatches the effect on cameras
  146185. * @param cameras The camera to detatch from.
  146186. * @hidden
  146187. */
  146188. _detachCameras(cameras: Camera[]): void;
  146189. /**
  146190. * Enables the effect on given cameras
  146191. * @param cameras The camera to enable.
  146192. * @hidden
  146193. */
  146194. _enable(cameras: Camera): void;
  146195. /**
  146196. * Enables the effect on given cameras
  146197. * @param cameras The camera to enable.
  146198. * @hidden
  146199. */
  146200. _enable(cameras: Nullable<Camera[]>): void;
  146201. /**
  146202. * Disables the effect on the given cameras
  146203. * @param cameras The camera to disable.
  146204. * @hidden
  146205. */
  146206. _disable(cameras: Camera): void;
  146207. /**
  146208. * Disables the effect on the given cameras
  146209. * @param cameras The camera to disable.
  146210. * @hidden
  146211. */
  146212. _disable(cameras: Nullable<Camera[]>): void;
  146213. /**
  146214. * Gets a list of the post processes contained in the effect.
  146215. * @param camera The camera to get the post processes on.
  146216. * @returns The list of the post processes in the effect.
  146217. */
  146218. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  146219. }
  146220. }
  146221. declare module BABYLON {
  146222. /** @hidden */
  146223. export var extractHighlightsPixelShader: {
  146224. name: string;
  146225. shader: string;
  146226. };
  146227. }
  146228. declare module BABYLON {
  146229. /**
  146230. * 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.
  146231. */
  146232. export class ExtractHighlightsPostProcess extends PostProcess {
  146233. /**
  146234. * The luminance threshold, pixels below this value will be set to black.
  146235. */
  146236. threshold: number;
  146237. /** @hidden */
  146238. _exposure: number;
  146239. /**
  146240. * Post process which has the input texture to be used when performing highlight extraction
  146241. * @hidden
  146242. */
  146243. _inputPostProcess: Nullable<PostProcess>;
  146244. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146245. }
  146246. }
  146247. declare module BABYLON {
  146248. /** @hidden */
  146249. export var bloomMergePixelShader: {
  146250. name: string;
  146251. shader: string;
  146252. };
  146253. }
  146254. declare module BABYLON {
  146255. /**
  146256. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  146257. */
  146258. export class BloomMergePostProcess extends PostProcess {
  146259. /** Weight of the bloom to be added to the original input. */
  146260. weight: number;
  146261. /**
  146262. * Creates a new instance of @see BloomMergePostProcess
  146263. * @param name The name of the effect.
  146264. * @param originalFromInput Post process which's input will be used for the merge.
  146265. * @param blurred Blurred highlights post process which's output will be used.
  146266. * @param weight Weight of the bloom to be added to the original input.
  146267. * @param options The required width/height ratio to downsize to before computing the render pass.
  146268. * @param camera The camera to apply the render pass to.
  146269. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146270. * @param engine The engine which the post process will be applied. (default: current engine)
  146271. * @param reusable If the post process can be reused on the same frame. (default: false)
  146272. * @param textureType Type of textures used when performing the post process. (default: 0)
  146273. * @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)
  146274. */
  146275. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  146276. /** Weight of the bloom to be added to the original input. */
  146277. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146278. }
  146279. }
  146280. declare module BABYLON {
  146281. /**
  146282. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  146283. */
  146284. export class BloomEffect extends PostProcessRenderEffect {
  146285. private bloomScale;
  146286. /**
  146287. * @hidden Internal
  146288. */
  146289. _effects: Array<PostProcess>;
  146290. /**
  146291. * @hidden Internal
  146292. */
  146293. _downscale: ExtractHighlightsPostProcess;
  146294. private _blurX;
  146295. private _blurY;
  146296. private _merge;
  146297. /**
  146298. * The luminance threshold to find bright areas of the image to bloom.
  146299. */
  146300. get threshold(): number;
  146301. set threshold(value: number);
  146302. /**
  146303. * The strength of the bloom.
  146304. */
  146305. get weight(): number;
  146306. set weight(value: number);
  146307. /**
  146308. * Specifies the size of the bloom blur kernel, relative to the final output size
  146309. */
  146310. get kernel(): number;
  146311. set kernel(value: number);
  146312. /**
  146313. * Creates a new instance of @see BloomEffect
  146314. * @param scene The scene the effect belongs to.
  146315. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  146316. * @param bloomKernel The size of the kernel to be used when applying the blur.
  146317. * @param bloomWeight The the strength of bloom.
  146318. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  146319. * @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)
  146320. */
  146321. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  146322. /**
  146323. * Disposes each of the internal effects for a given camera.
  146324. * @param camera The camera to dispose the effect on.
  146325. */
  146326. disposeEffects(camera: Camera): void;
  146327. /**
  146328. * @hidden Internal
  146329. */
  146330. _updateEffects(): void;
  146331. /**
  146332. * Internal
  146333. * @returns if all the contained post processes are ready.
  146334. * @hidden
  146335. */
  146336. _isReady(): boolean;
  146337. }
  146338. }
  146339. declare module BABYLON {
  146340. /** @hidden */
  146341. export var chromaticAberrationPixelShader: {
  146342. name: string;
  146343. shader: string;
  146344. };
  146345. }
  146346. declare module BABYLON {
  146347. /**
  146348. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  146349. */
  146350. export class ChromaticAberrationPostProcess extends PostProcess {
  146351. /**
  146352. * The amount of seperation of rgb channels (default: 30)
  146353. */
  146354. aberrationAmount: number;
  146355. /**
  146356. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  146357. */
  146358. radialIntensity: number;
  146359. /**
  146360. * 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))
  146361. */
  146362. direction: Vector2;
  146363. /**
  146364. * 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))
  146365. */
  146366. centerPosition: Vector2;
  146367. /**
  146368. * Creates a new instance ChromaticAberrationPostProcess
  146369. * @param name The name of the effect.
  146370. * @param screenWidth The width of the screen to apply the effect on.
  146371. * @param screenHeight The height of the screen to apply the effect on.
  146372. * @param options The required width/height ratio to downsize to before computing the render pass.
  146373. * @param camera The camera to apply the render pass to.
  146374. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146375. * @param engine The engine which the post process will be applied. (default: current engine)
  146376. * @param reusable If the post process can be reused on the same frame. (default: false)
  146377. * @param textureType Type of textures used when performing the post process. (default: 0)
  146378. * @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)
  146379. */
  146380. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146381. }
  146382. }
  146383. declare module BABYLON {
  146384. /** @hidden */
  146385. export var circleOfConfusionPixelShader: {
  146386. name: string;
  146387. shader: string;
  146388. };
  146389. }
  146390. declare module BABYLON {
  146391. /**
  146392. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  146393. */
  146394. export class CircleOfConfusionPostProcess extends PostProcess {
  146395. /**
  146396. * 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.
  146397. */
  146398. lensSize: number;
  146399. /**
  146400. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  146401. */
  146402. fStop: number;
  146403. /**
  146404. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  146405. */
  146406. focusDistance: number;
  146407. /**
  146408. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  146409. */
  146410. focalLength: number;
  146411. private _depthTexture;
  146412. /**
  146413. * Creates a new instance CircleOfConfusionPostProcess
  146414. * @param name The name of the effect.
  146415. * @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.
  146416. * @param options The required width/height ratio to downsize to before computing the render pass.
  146417. * @param camera The camera to apply the render pass to.
  146418. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146419. * @param engine The engine which the post process will be applied. (default: current engine)
  146420. * @param reusable If the post process can be reused on the same frame. (default: false)
  146421. * @param textureType Type of textures used when performing the post process. (default: 0)
  146422. * @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)
  146423. */
  146424. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146425. /**
  146426. * 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.
  146427. */
  146428. set depthTexture(value: RenderTargetTexture);
  146429. }
  146430. }
  146431. declare module BABYLON {
  146432. /** @hidden */
  146433. export var colorCorrectionPixelShader: {
  146434. name: string;
  146435. shader: string;
  146436. };
  146437. }
  146438. declare module BABYLON {
  146439. /**
  146440. *
  146441. * This post-process allows the modification of rendered colors by using
  146442. * a 'look-up table' (LUT). This effect is also called Color Grading.
  146443. *
  146444. * The object needs to be provided an url to a texture containing the color
  146445. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  146446. * Use an image editing software to tweak the LUT to match your needs.
  146447. *
  146448. * For an example of a color LUT, see here:
  146449. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  146450. * For explanations on color grading, see here:
  146451. * @see http://udn.epicgames.com/Three/ColorGrading.html
  146452. *
  146453. */
  146454. export class ColorCorrectionPostProcess extends PostProcess {
  146455. private _colorTableTexture;
  146456. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146457. }
  146458. }
  146459. declare module BABYLON {
  146460. /** @hidden */
  146461. export var convolutionPixelShader: {
  146462. name: string;
  146463. shader: string;
  146464. };
  146465. }
  146466. declare module BABYLON {
  146467. /**
  146468. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  146469. * input texture to perform effects such as edge detection or sharpening
  146470. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  146471. */
  146472. export class ConvolutionPostProcess extends PostProcess {
  146473. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  146474. kernel: number[];
  146475. /**
  146476. * Creates a new instance ConvolutionPostProcess
  146477. * @param name The name of the effect.
  146478. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  146479. * @param options The required width/height ratio to downsize to before computing the render pass.
  146480. * @param camera The camera to apply the render pass to.
  146481. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146482. * @param engine The engine which the post process will be applied. (default: current engine)
  146483. * @param reusable If the post process can be reused on the same frame. (default: false)
  146484. * @param textureType Type of textures used when performing the post process. (default: 0)
  146485. */
  146486. constructor(name: string,
  146487. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  146488. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  146489. /**
  146490. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146491. */
  146492. static EdgeDetect0Kernel: number[];
  146493. /**
  146494. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146495. */
  146496. static EdgeDetect1Kernel: number[];
  146497. /**
  146498. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146499. */
  146500. static EdgeDetect2Kernel: number[];
  146501. /**
  146502. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146503. */
  146504. static SharpenKernel: number[];
  146505. /**
  146506. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146507. */
  146508. static EmbossKernel: number[];
  146509. /**
  146510. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146511. */
  146512. static GaussianKernel: number[];
  146513. }
  146514. }
  146515. declare module BABYLON {
  146516. /**
  146517. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  146518. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  146519. * based on samples that have a large difference in distance than the center pixel.
  146520. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  146521. */
  146522. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  146523. direction: Vector2;
  146524. /**
  146525. * Creates a new instance CircleOfConfusionPostProcess
  146526. * @param name The name of the effect.
  146527. * @param scene The scene the effect belongs to.
  146528. * @param direction The direction the blur should be applied.
  146529. * @param kernel The size of the kernel used to blur.
  146530. * @param options The required width/height ratio to downsize to before computing the render pass.
  146531. * @param camera The camera to apply the render pass to.
  146532. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  146533. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  146534. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146535. * @param engine The engine which the post process will be applied. (default: current engine)
  146536. * @param reusable If the post process can be reused on the same frame. (default: false)
  146537. * @param textureType Type of textures used when performing the post process. (default: 0)
  146538. * @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)
  146539. */
  146540. 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);
  146541. }
  146542. }
  146543. declare module BABYLON {
  146544. /** @hidden */
  146545. export var depthOfFieldMergePixelShader: {
  146546. name: string;
  146547. shader: string;
  146548. };
  146549. }
  146550. declare module BABYLON {
  146551. /**
  146552. * Options to be set when merging outputs from the default pipeline.
  146553. */
  146554. export class DepthOfFieldMergePostProcessOptions {
  146555. /**
  146556. * The original image to merge on top of
  146557. */
  146558. originalFromInput: PostProcess;
  146559. /**
  146560. * Parameters to perform the merge of the depth of field effect
  146561. */
  146562. depthOfField?: {
  146563. circleOfConfusion: PostProcess;
  146564. blurSteps: Array<PostProcess>;
  146565. };
  146566. /**
  146567. * Parameters to perform the merge of bloom effect
  146568. */
  146569. bloom?: {
  146570. blurred: PostProcess;
  146571. weight: number;
  146572. };
  146573. }
  146574. /**
  146575. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  146576. */
  146577. export class DepthOfFieldMergePostProcess extends PostProcess {
  146578. private blurSteps;
  146579. /**
  146580. * Creates a new instance of DepthOfFieldMergePostProcess
  146581. * @param name The name of the effect.
  146582. * @param originalFromInput Post process which's input will be used for the merge.
  146583. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  146584. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  146585. * @param options The required width/height ratio to downsize to before computing the render pass.
  146586. * @param camera The camera to apply the render pass to.
  146587. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146588. * @param engine The engine which the post process will be applied. (default: current engine)
  146589. * @param reusable If the post process can be reused on the same frame. (default: false)
  146590. * @param textureType Type of textures used when performing the post process. (default: 0)
  146591. * @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)
  146592. */
  146593. 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);
  146594. /**
  146595. * Updates the effect with the current post process compile time values and recompiles the shader.
  146596. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  146597. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  146598. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  146599. * @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
  146600. * @param onCompiled Called when the shader has been compiled.
  146601. * @param onError Called if there is an error when compiling a shader.
  146602. */
  146603. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  146604. }
  146605. }
  146606. declare module BABYLON {
  146607. /**
  146608. * Specifies the level of max blur that should be applied when using the depth of field effect
  146609. */
  146610. export enum DepthOfFieldEffectBlurLevel {
  146611. /**
  146612. * Subtle blur
  146613. */
  146614. Low = 0,
  146615. /**
  146616. * Medium blur
  146617. */
  146618. Medium = 1,
  146619. /**
  146620. * Large blur
  146621. */
  146622. High = 2
  146623. }
  146624. /**
  146625. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  146626. */
  146627. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  146628. private _circleOfConfusion;
  146629. /**
  146630. * @hidden Internal, blurs from high to low
  146631. */
  146632. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  146633. private _depthOfFieldBlurY;
  146634. private _dofMerge;
  146635. /**
  146636. * @hidden Internal post processes in depth of field effect
  146637. */
  146638. _effects: Array<PostProcess>;
  146639. /**
  146640. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  146641. */
  146642. set focalLength(value: number);
  146643. get focalLength(): number;
  146644. /**
  146645. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  146646. */
  146647. set fStop(value: number);
  146648. get fStop(): number;
  146649. /**
  146650. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  146651. */
  146652. set focusDistance(value: number);
  146653. get focusDistance(): number;
  146654. /**
  146655. * 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.
  146656. */
  146657. set lensSize(value: number);
  146658. get lensSize(): number;
  146659. /**
  146660. * Creates a new instance DepthOfFieldEffect
  146661. * @param scene The scene the effect belongs to.
  146662. * @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.
  146663. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  146664. * @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)
  146665. */
  146666. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  146667. /**
  146668. * Get the current class name of the current effet
  146669. * @returns "DepthOfFieldEffect"
  146670. */
  146671. getClassName(): string;
  146672. /**
  146673. * 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.
  146674. */
  146675. set depthTexture(value: RenderTargetTexture);
  146676. /**
  146677. * Disposes each of the internal effects for a given camera.
  146678. * @param camera The camera to dispose the effect on.
  146679. */
  146680. disposeEffects(camera: Camera): void;
  146681. /**
  146682. * @hidden Internal
  146683. */
  146684. _updateEffects(): void;
  146685. /**
  146686. * Internal
  146687. * @returns if all the contained post processes are ready.
  146688. * @hidden
  146689. */
  146690. _isReady(): boolean;
  146691. }
  146692. }
  146693. declare module BABYLON {
  146694. /** @hidden */
  146695. export var displayPassPixelShader: {
  146696. name: string;
  146697. shader: string;
  146698. };
  146699. }
  146700. declare module BABYLON {
  146701. /**
  146702. * DisplayPassPostProcess which produces an output the same as it's input
  146703. */
  146704. export class DisplayPassPostProcess extends PostProcess {
  146705. /**
  146706. * Creates the DisplayPassPostProcess
  146707. * @param name The name of the effect.
  146708. * @param options The required width/height ratio to downsize to before computing the render pass.
  146709. * @param camera The camera to apply the render pass to.
  146710. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146711. * @param engine The engine which the post process will be applied. (default: current engine)
  146712. * @param reusable If the post process can be reused on the same frame. (default: false)
  146713. */
  146714. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146715. }
  146716. }
  146717. declare module BABYLON {
  146718. /** @hidden */
  146719. export var filterPixelShader: {
  146720. name: string;
  146721. shader: string;
  146722. };
  146723. }
  146724. declare module BABYLON {
  146725. /**
  146726. * Applies a kernel filter to the image
  146727. */
  146728. export class FilterPostProcess extends PostProcess {
  146729. /** The matrix to be applied to the image */
  146730. kernelMatrix: Matrix;
  146731. /**
  146732. *
  146733. * @param name The name of the effect.
  146734. * @param kernelMatrix The matrix to be applied to the image
  146735. * @param options The required width/height ratio to downsize to before computing the render pass.
  146736. * @param camera The camera to apply the render pass to.
  146737. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146738. * @param engine The engine which the post process will be applied. (default: current engine)
  146739. * @param reusable If the post process can be reused on the same frame. (default: false)
  146740. */
  146741. constructor(name: string,
  146742. /** The matrix to be applied to the image */
  146743. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146744. }
  146745. }
  146746. declare module BABYLON {
  146747. /** @hidden */
  146748. export var fxaaPixelShader: {
  146749. name: string;
  146750. shader: string;
  146751. };
  146752. }
  146753. declare module BABYLON {
  146754. /** @hidden */
  146755. export var fxaaVertexShader: {
  146756. name: string;
  146757. shader: string;
  146758. };
  146759. }
  146760. declare module BABYLON {
  146761. /**
  146762. * Fxaa post process
  146763. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  146764. */
  146765. export class FxaaPostProcess extends PostProcess {
  146766. /** @hidden */
  146767. texelWidth: number;
  146768. /** @hidden */
  146769. texelHeight: number;
  146770. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  146771. private _getDefines;
  146772. }
  146773. }
  146774. declare module BABYLON {
  146775. /** @hidden */
  146776. export var grainPixelShader: {
  146777. name: string;
  146778. shader: string;
  146779. };
  146780. }
  146781. declare module BABYLON {
  146782. /**
  146783. * The GrainPostProcess adds noise to the image at mid luminance levels
  146784. */
  146785. export class GrainPostProcess extends PostProcess {
  146786. /**
  146787. * The intensity of the grain added (default: 30)
  146788. */
  146789. intensity: number;
  146790. /**
  146791. * If the grain should be randomized on every frame
  146792. */
  146793. animated: boolean;
  146794. /**
  146795. * Creates a new instance of @see GrainPostProcess
  146796. * @param name The name of the effect.
  146797. * @param options The required width/height ratio to downsize to before computing the render pass.
  146798. * @param camera The camera to apply the render pass to.
  146799. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146800. * @param engine The engine which the post process will be applied. (default: current engine)
  146801. * @param reusable If the post process can be reused on the same frame. (default: false)
  146802. * @param textureType Type of textures used when performing the post process. (default: 0)
  146803. * @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)
  146804. */
  146805. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146806. }
  146807. }
  146808. declare module BABYLON {
  146809. /** @hidden */
  146810. export var highlightsPixelShader: {
  146811. name: string;
  146812. shader: string;
  146813. };
  146814. }
  146815. declare module BABYLON {
  146816. /**
  146817. * Extracts highlights from the image
  146818. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  146819. */
  146820. export class HighlightsPostProcess extends PostProcess {
  146821. /**
  146822. * Extracts highlights from the image
  146823. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  146824. * @param name The name of the effect.
  146825. * @param options The required width/height ratio to downsize to before computing the render pass.
  146826. * @param camera The camera to apply the render pass to.
  146827. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146828. * @param engine The engine which the post process will be applied. (default: current engine)
  146829. * @param reusable If the post process can be reused on the same frame. (default: false)
  146830. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  146831. */
  146832. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  146833. }
  146834. }
  146835. declare module BABYLON {
  146836. /** @hidden */
  146837. export var mrtFragmentDeclaration: {
  146838. name: string;
  146839. shader: string;
  146840. };
  146841. }
  146842. declare module BABYLON {
  146843. /** @hidden */
  146844. export var geometryPixelShader: {
  146845. name: string;
  146846. shader: string;
  146847. };
  146848. }
  146849. declare module BABYLON {
  146850. /** @hidden */
  146851. export var geometryVertexShader: {
  146852. name: string;
  146853. shader: string;
  146854. };
  146855. }
  146856. declare module BABYLON {
  146857. /** @hidden */
  146858. interface ISavedTransformationMatrix {
  146859. world: Matrix;
  146860. viewProjection: Matrix;
  146861. }
  146862. /**
  146863. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  146864. */
  146865. export class GeometryBufferRenderer {
  146866. /**
  146867. * Constant used to retrieve the position texture index in the G-Buffer textures array
  146868. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  146869. */
  146870. static readonly POSITION_TEXTURE_TYPE: number;
  146871. /**
  146872. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  146873. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  146874. */
  146875. static readonly VELOCITY_TEXTURE_TYPE: number;
  146876. /**
  146877. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  146878. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  146879. */
  146880. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  146881. /**
  146882. * Dictionary used to store the previous transformation matrices of each rendered mesh
  146883. * in order to compute objects velocities when enableVelocity is set to "true"
  146884. * @hidden
  146885. */
  146886. _previousTransformationMatrices: {
  146887. [index: number]: ISavedTransformationMatrix;
  146888. };
  146889. /**
  146890. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  146891. * in order to compute objects velocities when enableVelocity is set to "true"
  146892. * @hidden
  146893. */
  146894. _previousBonesTransformationMatrices: {
  146895. [index: number]: Float32Array;
  146896. };
  146897. /**
  146898. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  146899. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  146900. */
  146901. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  146902. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  146903. renderTransparentMeshes: boolean;
  146904. private _scene;
  146905. private _multiRenderTarget;
  146906. private _ratio;
  146907. private _enablePosition;
  146908. private _enableVelocity;
  146909. private _enableReflectivity;
  146910. private _positionIndex;
  146911. private _velocityIndex;
  146912. private _reflectivityIndex;
  146913. protected _effect: Effect;
  146914. protected _cachedDefines: string;
  146915. /**
  146916. * Set the render list (meshes to be rendered) used in the G buffer.
  146917. */
  146918. set renderList(meshes: Mesh[]);
  146919. /**
  146920. * Gets wether or not G buffer are supported by the running hardware.
  146921. * This requires draw buffer supports
  146922. */
  146923. get isSupported(): boolean;
  146924. /**
  146925. * Returns the index of the given texture type in the G-Buffer textures array
  146926. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  146927. * @returns the index of the given texture type in the G-Buffer textures array
  146928. */
  146929. getTextureIndex(textureType: number): number;
  146930. /**
  146931. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  146932. */
  146933. get enablePosition(): boolean;
  146934. /**
  146935. * Sets whether or not objects positions are enabled for the G buffer.
  146936. */
  146937. set enablePosition(enable: boolean);
  146938. /**
  146939. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  146940. */
  146941. get enableVelocity(): boolean;
  146942. /**
  146943. * Sets wether or not objects velocities are enabled for the G buffer.
  146944. */
  146945. set enableVelocity(enable: boolean);
  146946. /**
  146947. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  146948. */
  146949. get enableReflectivity(): boolean;
  146950. /**
  146951. * Sets wether or not objects roughness are enabled for the G buffer.
  146952. */
  146953. set enableReflectivity(enable: boolean);
  146954. /**
  146955. * Gets the scene associated with the buffer.
  146956. */
  146957. get scene(): Scene;
  146958. /**
  146959. * Gets the ratio used by the buffer during its creation.
  146960. * How big is the buffer related to the main canvas.
  146961. */
  146962. get ratio(): number;
  146963. /** @hidden */
  146964. static _SceneComponentInitialization: (scene: Scene) => void;
  146965. /**
  146966. * Creates a new G Buffer for the scene
  146967. * @param scene The scene the buffer belongs to
  146968. * @param ratio How big is the buffer related to the main canvas.
  146969. */
  146970. constructor(scene: Scene, ratio?: number);
  146971. /**
  146972. * Checks wether everything is ready to render a submesh to the G buffer.
  146973. * @param subMesh the submesh to check readiness for
  146974. * @param useInstances is the mesh drawn using instance or not
  146975. * @returns true if ready otherwise false
  146976. */
  146977. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  146978. /**
  146979. * Gets the current underlying G Buffer.
  146980. * @returns the buffer
  146981. */
  146982. getGBuffer(): MultiRenderTarget;
  146983. /**
  146984. * Gets the number of samples used to render the buffer (anti aliasing).
  146985. */
  146986. get samples(): number;
  146987. /**
  146988. * Sets the number of samples used to render the buffer (anti aliasing).
  146989. */
  146990. set samples(value: number);
  146991. /**
  146992. * Disposes the renderer and frees up associated resources.
  146993. */
  146994. dispose(): void;
  146995. protected _createRenderTargets(): void;
  146996. private _copyBonesTransformationMatrices;
  146997. }
  146998. }
  146999. declare module BABYLON {
  147000. interface Scene {
  147001. /** @hidden (Backing field) */
  147002. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  147003. /**
  147004. * Gets or Sets the current geometry buffer associated to the scene.
  147005. */
  147006. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  147007. /**
  147008. * Enables a GeometryBufferRender and associates it with the scene
  147009. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  147010. * @returns the GeometryBufferRenderer
  147011. */
  147012. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  147013. /**
  147014. * Disables the GeometryBufferRender associated with the scene
  147015. */
  147016. disableGeometryBufferRenderer(): void;
  147017. }
  147018. /**
  147019. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  147020. * in several rendering techniques.
  147021. */
  147022. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  147023. /**
  147024. * The component name helpful to identify the component in the list of scene components.
  147025. */
  147026. readonly name: string;
  147027. /**
  147028. * The scene the component belongs to.
  147029. */
  147030. scene: Scene;
  147031. /**
  147032. * Creates a new instance of the component for the given scene
  147033. * @param scene Defines the scene to register the component in
  147034. */
  147035. constructor(scene: Scene);
  147036. /**
  147037. * Registers the component in a given scene
  147038. */
  147039. register(): void;
  147040. /**
  147041. * Rebuilds the elements related to this component in case of
  147042. * context lost for instance.
  147043. */
  147044. rebuild(): void;
  147045. /**
  147046. * Disposes the component and the associated ressources
  147047. */
  147048. dispose(): void;
  147049. private _gatherRenderTargets;
  147050. }
  147051. }
  147052. declare module BABYLON {
  147053. /** @hidden */
  147054. export var motionBlurPixelShader: {
  147055. name: string;
  147056. shader: string;
  147057. };
  147058. }
  147059. declare module BABYLON {
  147060. /**
  147061. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  147062. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  147063. * As an example, all you have to do is to create the post-process:
  147064. * var mb = new BABYLON.MotionBlurPostProcess(
  147065. * 'mb', // The name of the effect.
  147066. * scene, // The scene containing the objects to blur according to their velocity.
  147067. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  147068. * camera // The camera to apply the render pass to.
  147069. * );
  147070. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  147071. */
  147072. export class MotionBlurPostProcess extends PostProcess {
  147073. /**
  147074. * Defines how much the image is blurred by the movement. Default value is equal to 1
  147075. */
  147076. motionStrength: number;
  147077. /**
  147078. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  147079. */
  147080. get motionBlurSamples(): number;
  147081. /**
  147082. * Sets the number of iterations to be used for motion blur quality
  147083. */
  147084. set motionBlurSamples(samples: number);
  147085. private _motionBlurSamples;
  147086. private _geometryBufferRenderer;
  147087. /**
  147088. * Creates a new instance MotionBlurPostProcess
  147089. * @param name The name of the effect.
  147090. * @param scene The scene containing the objects to blur according to their velocity.
  147091. * @param options The required width/height ratio to downsize to before computing the render pass.
  147092. * @param camera The camera to apply the render pass to.
  147093. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147094. * @param engine The engine which the post process will be applied. (default: current engine)
  147095. * @param reusable If the post process can be reused on the same frame. (default: false)
  147096. * @param textureType Type of textures used when performing the post process. (default: 0)
  147097. * @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)
  147098. */
  147099. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147100. /**
  147101. * Excludes the given skinned mesh from computing bones velocities.
  147102. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  147103. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  147104. */
  147105. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  147106. /**
  147107. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  147108. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  147109. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  147110. */
  147111. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  147112. /**
  147113. * Disposes the post process.
  147114. * @param camera The camera to dispose the post process on.
  147115. */
  147116. dispose(camera?: Camera): void;
  147117. }
  147118. }
  147119. declare module BABYLON {
  147120. /** @hidden */
  147121. export var refractionPixelShader: {
  147122. name: string;
  147123. shader: string;
  147124. };
  147125. }
  147126. declare module BABYLON {
  147127. /**
  147128. * Post process which applies a refractin texture
  147129. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  147130. */
  147131. export class RefractionPostProcess extends PostProcess {
  147132. /** the base color of the refraction (used to taint the rendering) */
  147133. color: Color3;
  147134. /** simulated refraction depth */
  147135. depth: number;
  147136. /** the coefficient of the base color (0 to remove base color tainting) */
  147137. colorLevel: number;
  147138. private _refTexture;
  147139. private _ownRefractionTexture;
  147140. /**
  147141. * Gets or sets the refraction texture
  147142. * Please note that you are responsible for disposing the texture if you set it manually
  147143. */
  147144. get refractionTexture(): Texture;
  147145. set refractionTexture(value: Texture);
  147146. /**
  147147. * Initializes the RefractionPostProcess
  147148. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  147149. * @param name The name of the effect.
  147150. * @param refractionTextureUrl Url of the refraction texture to use
  147151. * @param color the base color of the refraction (used to taint the rendering)
  147152. * @param depth simulated refraction depth
  147153. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  147154. * @param camera The camera to apply the render pass to.
  147155. * @param options The required width/height ratio to downsize to before computing the render pass.
  147156. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147157. * @param engine The engine which the post process will be applied. (default: current engine)
  147158. * @param reusable If the post process can be reused on the same frame. (default: false)
  147159. */
  147160. constructor(name: string, refractionTextureUrl: string,
  147161. /** the base color of the refraction (used to taint the rendering) */
  147162. color: Color3,
  147163. /** simulated refraction depth */
  147164. depth: number,
  147165. /** the coefficient of the base color (0 to remove base color tainting) */
  147166. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147167. /**
  147168. * Disposes of the post process
  147169. * @param camera Camera to dispose post process on
  147170. */
  147171. dispose(camera: Camera): void;
  147172. }
  147173. }
  147174. declare module BABYLON {
  147175. /** @hidden */
  147176. export var sharpenPixelShader: {
  147177. name: string;
  147178. shader: string;
  147179. };
  147180. }
  147181. declare module BABYLON {
  147182. /**
  147183. * The SharpenPostProcess applies a sharpen kernel to every pixel
  147184. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  147185. */
  147186. export class SharpenPostProcess extends PostProcess {
  147187. /**
  147188. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  147189. */
  147190. colorAmount: number;
  147191. /**
  147192. * How much sharpness should be applied (default: 0.3)
  147193. */
  147194. edgeAmount: number;
  147195. /**
  147196. * Creates a new instance ConvolutionPostProcess
  147197. * @param name The name of the effect.
  147198. * @param options The required width/height ratio to downsize to before computing the render pass.
  147199. * @param camera The camera to apply the render pass to.
  147200. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147201. * @param engine The engine which the post process will be applied. (default: current engine)
  147202. * @param reusable If the post process can be reused on the same frame. (default: false)
  147203. * @param textureType Type of textures used when performing the post process. (default: 0)
  147204. * @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)
  147205. */
  147206. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147207. }
  147208. }
  147209. declare module BABYLON {
  147210. /**
  147211. * PostProcessRenderPipeline
  147212. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147213. */
  147214. export class PostProcessRenderPipeline {
  147215. private engine;
  147216. private _renderEffects;
  147217. private _renderEffectsForIsolatedPass;
  147218. /**
  147219. * List of inspectable custom properties (used by the Inspector)
  147220. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  147221. */
  147222. inspectableCustomProperties: IInspectable[];
  147223. /**
  147224. * @hidden
  147225. */
  147226. protected _cameras: Camera[];
  147227. /** @hidden */
  147228. _name: string;
  147229. /**
  147230. * Gets pipeline name
  147231. */
  147232. get name(): string;
  147233. /** Gets the list of attached cameras */
  147234. get cameras(): Camera[];
  147235. /**
  147236. * Initializes a PostProcessRenderPipeline
  147237. * @param engine engine to add the pipeline to
  147238. * @param name name of the pipeline
  147239. */
  147240. constructor(engine: Engine, name: string);
  147241. /**
  147242. * Gets the class name
  147243. * @returns "PostProcessRenderPipeline"
  147244. */
  147245. getClassName(): string;
  147246. /**
  147247. * If all the render effects in the pipeline are supported
  147248. */
  147249. get isSupported(): boolean;
  147250. /**
  147251. * Adds an effect to the pipeline
  147252. * @param renderEffect the effect to add
  147253. */
  147254. addEffect(renderEffect: PostProcessRenderEffect): void;
  147255. /** @hidden */
  147256. _rebuild(): void;
  147257. /** @hidden */
  147258. _enableEffect(renderEffectName: string, cameras: Camera): void;
  147259. /** @hidden */
  147260. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  147261. /** @hidden */
  147262. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  147263. /** @hidden */
  147264. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  147265. /** @hidden */
  147266. _attachCameras(cameras: Camera, unique: boolean): void;
  147267. /** @hidden */
  147268. _attachCameras(cameras: Camera[], unique: boolean): void;
  147269. /** @hidden */
  147270. _detachCameras(cameras: Camera): void;
  147271. /** @hidden */
  147272. _detachCameras(cameras: Nullable<Camera[]>): void;
  147273. /** @hidden */
  147274. _update(): void;
  147275. /** @hidden */
  147276. _reset(): void;
  147277. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  147278. /**
  147279. * Disposes of the pipeline
  147280. */
  147281. dispose(): void;
  147282. }
  147283. }
  147284. declare module BABYLON {
  147285. /**
  147286. * PostProcessRenderPipelineManager class
  147287. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147288. */
  147289. export class PostProcessRenderPipelineManager {
  147290. private _renderPipelines;
  147291. /**
  147292. * Initializes a PostProcessRenderPipelineManager
  147293. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147294. */
  147295. constructor();
  147296. /**
  147297. * Gets the list of supported render pipelines
  147298. */
  147299. get supportedPipelines(): PostProcessRenderPipeline[];
  147300. /**
  147301. * Adds a pipeline to the manager
  147302. * @param renderPipeline The pipeline to add
  147303. */
  147304. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  147305. /**
  147306. * Attaches a camera to the pipeline
  147307. * @param renderPipelineName The name of the pipeline to attach to
  147308. * @param cameras the camera to attach
  147309. * @param unique if the camera can be attached multiple times to the pipeline
  147310. */
  147311. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  147312. /**
  147313. * Detaches a camera from the pipeline
  147314. * @param renderPipelineName The name of the pipeline to detach from
  147315. * @param cameras the camera to detach
  147316. */
  147317. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  147318. /**
  147319. * Enables an effect by name on a pipeline
  147320. * @param renderPipelineName the name of the pipeline to enable the effect in
  147321. * @param renderEffectName the name of the effect to enable
  147322. * @param cameras the cameras that the effect should be enabled on
  147323. */
  147324. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  147325. /**
  147326. * Disables an effect by name on a pipeline
  147327. * @param renderPipelineName the name of the pipeline to disable the effect in
  147328. * @param renderEffectName the name of the effect to disable
  147329. * @param cameras the cameras that the effect should be disabled on
  147330. */
  147331. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  147332. /**
  147333. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  147334. */
  147335. update(): void;
  147336. /** @hidden */
  147337. _rebuild(): void;
  147338. /**
  147339. * Disposes of the manager and pipelines
  147340. */
  147341. dispose(): void;
  147342. }
  147343. }
  147344. declare module BABYLON {
  147345. interface Scene {
  147346. /** @hidden (Backing field) */
  147347. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  147348. /**
  147349. * Gets the postprocess render pipeline manager
  147350. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147351. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  147352. */
  147353. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  147354. }
  147355. /**
  147356. * Defines the Render Pipeline scene component responsible to rendering pipelines
  147357. */
  147358. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  147359. /**
  147360. * The component name helpfull to identify the component in the list of scene components.
  147361. */
  147362. readonly name: string;
  147363. /**
  147364. * The scene the component belongs to.
  147365. */
  147366. scene: Scene;
  147367. /**
  147368. * Creates a new instance of the component for the given scene
  147369. * @param scene Defines the scene to register the component in
  147370. */
  147371. constructor(scene: Scene);
  147372. /**
  147373. * Registers the component in a given scene
  147374. */
  147375. register(): void;
  147376. /**
  147377. * Rebuilds the elements related to this component in case of
  147378. * context lost for instance.
  147379. */
  147380. rebuild(): void;
  147381. /**
  147382. * Disposes the component and the associated ressources
  147383. */
  147384. dispose(): void;
  147385. private _gatherRenderTargets;
  147386. }
  147387. }
  147388. declare module BABYLON {
  147389. /**
  147390. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  147391. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  147392. */
  147393. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  147394. private _scene;
  147395. private _camerasToBeAttached;
  147396. /**
  147397. * ID of the sharpen post process,
  147398. */
  147399. private readonly SharpenPostProcessId;
  147400. /**
  147401. * @ignore
  147402. * ID of the image processing post process;
  147403. */
  147404. readonly ImageProcessingPostProcessId: string;
  147405. /**
  147406. * @ignore
  147407. * ID of the Fast Approximate Anti-Aliasing post process;
  147408. */
  147409. readonly FxaaPostProcessId: string;
  147410. /**
  147411. * ID of the chromatic aberration post process,
  147412. */
  147413. private readonly ChromaticAberrationPostProcessId;
  147414. /**
  147415. * ID of the grain post process
  147416. */
  147417. private readonly GrainPostProcessId;
  147418. /**
  147419. * Sharpen post process which will apply a sharpen convolution to enhance edges
  147420. */
  147421. sharpen: SharpenPostProcess;
  147422. private _sharpenEffect;
  147423. private bloom;
  147424. /**
  147425. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  147426. */
  147427. depthOfField: DepthOfFieldEffect;
  147428. /**
  147429. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  147430. */
  147431. fxaa: FxaaPostProcess;
  147432. /**
  147433. * Image post processing pass used to perform operations such as tone mapping or color grading.
  147434. */
  147435. imageProcessing: ImageProcessingPostProcess;
  147436. /**
  147437. * Chromatic aberration post process which will shift rgb colors in the image
  147438. */
  147439. chromaticAberration: ChromaticAberrationPostProcess;
  147440. private _chromaticAberrationEffect;
  147441. /**
  147442. * Grain post process which add noise to the image
  147443. */
  147444. grain: GrainPostProcess;
  147445. private _grainEffect;
  147446. /**
  147447. * Glow post process which adds a glow to emissive areas of the image
  147448. */
  147449. private _glowLayer;
  147450. /**
  147451. * Animations which can be used to tweak settings over a period of time
  147452. */
  147453. animations: Animation[];
  147454. private _imageProcessingConfigurationObserver;
  147455. private _sharpenEnabled;
  147456. private _bloomEnabled;
  147457. private _depthOfFieldEnabled;
  147458. private _depthOfFieldBlurLevel;
  147459. private _fxaaEnabled;
  147460. private _imageProcessingEnabled;
  147461. private _defaultPipelineTextureType;
  147462. private _bloomScale;
  147463. private _chromaticAberrationEnabled;
  147464. private _grainEnabled;
  147465. private _buildAllowed;
  147466. /**
  147467. * Gets active scene
  147468. */
  147469. get scene(): Scene;
  147470. /**
  147471. * Enable or disable the sharpen process from the pipeline
  147472. */
  147473. set sharpenEnabled(enabled: boolean);
  147474. get sharpenEnabled(): boolean;
  147475. private _resizeObserver;
  147476. private _hardwareScaleLevel;
  147477. private _bloomKernel;
  147478. /**
  147479. * Specifies the size of the bloom blur kernel, relative to the final output size
  147480. */
  147481. get bloomKernel(): number;
  147482. set bloomKernel(value: number);
  147483. /**
  147484. * Specifies the weight of the bloom in the final rendering
  147485. */
  147486. private _bloomWeight;
  147487. /**
  147488. * Specifies the luma threshold for the area that will be blurred by the bloom
  147489. */
  147490. private _bloomThreshold;
  147491. private _hdr;
  147492. /**
  147493. * The strength of the bloom.
  147494. */
  147495. set bloomWeight(value: number);
  147496. get bloomWeight(): number;
  147497. /**
  147498. * The strength of the bloom.
  147499. */
  147500. set bloomThreshold(value: number);
  147501. get bloomThreshold(): number;
  147502. /**
  147503. * The scale of the bloom, lower value will provide better performance.
  147504. */
  147505. set bloomScale(value: number);
  147506. get bloomScale(): number;
  147507. /**
  147508. * Enable or disable the bloom from the pipeline
  147509. */
  147510. set bloomEnabled(enabled: boolean);
  147511. get bloomEnabled(): boolean;
  147512. private _rebuildBloom;
  147513. /**
  147514. * If the depth of field is enabled.
  147515. */
  147516. get depthOfFieldEnabled(): boolean;
  147517. set depthOfFieldEnabled(enabled: boolean);
  147518. /**
  147519. * Blur level of the depth of field effect. (Higher blur will effect performance)
  147520. */
  147521. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  147522. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  147523. /**
  147524. * If the anti aliasing is enabled.
  147525. */
  147526. set fxaaEnabled(enabled: boolean);
  147527. get fxaaEnabled(): boolean;
  147528. private _samples;
  147529. /**
  147530. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  147531. */
  147532. set samples(sampleCount: number);
  147533. get samples(): number;
  147534. /**
  147535. * If image processing is enabled.
  147536. */
  147537. set imageProcessingEnabled(enabled: boolean);
  147538. get imageProcessingEnabled(): boolean;
  147539. /**
  147540. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  147541. */
  147542. set glowLayerEnabled(enabled: boolean);
  147543. get glowLayerEnabled(): boolean;
  147544. /**
  147545. * Gets the glow layer (or null if not defined)
  147546. */
  147547. get glowLayer(): Nullable<GlowLayer>;
  147548. /**
  147549. * Enable or disable the chromaticAberration process from the pipeline
  147550. */
  147551. set chromaticAberrationEnabled(enabled: boolean);
  147552. get chromaticAberrationEnabled(): boolean;
  147553. /**
  147554. * Enable or disable the grain process from the pipeline
  147555. */
  147556. set grainEnabled(enabled: boolean);
  147557. get grainEnabled(): boolean;
  147558. /**
  147559. * @constructor
  147560. * @param name - The rendering pipeline name (default: "")
  147561. * @param hdr - If high dynamic range textures should be used (default: true)
  147562. * @param scene - The scene linked to this pipeline (default: the last created scene)
  147563. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  147564. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  147565. */
  147566. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  147567. /**
  147568. * Get the class name
  147569. * @returns "DefaultRenderingPipeline"
  147570. */
  147571. getClassName(): string;
  147572. /**
  147573. * Force the compilation of the entire pipeline.
  147574. */
  147575. prepare(): void;
  147576. private _hasCleared;
  147577. private _prevPostProcess;
  147578. private _prevPrevPostProcess;
  147579. private _setAutoClearAndTextureSharing;
  147580. private _depthOfFieldSceneObserver;
  147581. private _buildPipeline;
  147582. private _disposePostProcesses;
  147583. /**
  147584. * Adds a camera to the pipeline
  147585. * @param camera the camera to be added
  147586. */
  147587. addCamera(camera: Camera): void;
  147588. /**
  147589. * Removes a camera from the pipeline
  147590. * @param camera the camera to remove
  147591. */
  147592. removeCamera(camera: Camera): void;
  147593. /**
  147594. * Dispose of the pipeline and stop all post processes
  147595. */
  147596. dispose(): void;
  147597. /**
  147598. * Serialize the rendering pipeline (Used when exporting)
  147599. * @returns the serialized object
  147600. */
  147601. serialize(): any;
  147602. /**
  147603. * Parse the serialized pipeline
  147604. * @param source Source pipeline.
  147605. * @param scene The scene to load the pipeline to.
  147606. * @param rootUrl The URL of the serialized pipeline.
  147607. * @returns An instantiated pipeline from the serialized object.
  147608. */
  147609. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  147610. }
  147611. }
  147612. declare module BABYLON {
  147613. /** @hidden */
  147614. export var lensHighlightsPixelShader: {
  147615. name: string;
  147616. shader: string;
  147617. };
  147618. }
  147619. declare module BABYLON {
  147620. /** @hidden */
  147621. export var depthOfFieldPixelShader: {
  147622. name: string;
  147623. shader: string;
  147624. };
  147625. }
  147626. declare module BABYLON {
  147627. /**
  147628. * BABYLON.JS Chromatic Aberration GLSL Shader
  147629. * Author: Olivier Guyot
  147630. * Separates very slightly R, G and B colors on the edges of the screen
  147631. * Inspired by Francois Tarlier & Martins Upitis
  147632. */
  147633. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  147634. /**
  147635. * @ignore
  147636. * The chromatic aberration PostProcess id in the pipeline
  147637. */
  147638. LensChromaticAberrationEffect: string;
  147639. /**
  147640. * @ignore
  147641. * The highlights enhancing PostProcess id in the pipeline
  147642. */
  147643. HighlightsEnhancingEffect: string;
  147644. /**
  147645. * @ignore
  147646. * The depth-of-field PostProcess id in the pipeline
  147647. */
  147648. LensDepthOfFieldEffect: string;
  147649. private _scene;
  147650. private _depthTexture;
  147651. private _grainTexture;
  147652. private _chromaticAberrationPostProcess;
  147653. private _highlightsPostProcess;
  147654. private _depthOfFieldPostProcess;
  147655. private _edgeBlur;
  147656. private _grainAmount;
  147657. private _chromaticAberration;
  147658. private _distortion;
  147659. private _highlightsGain;
  147660. private _highlightsThreshold;
  147661. private _dofDistance;
  147662. private _dofAperture;
  147663. private _dofDarken;
  147664. private _dofPentagon;
  147665. private _blurNoise;
  147666. /**
  147667. * @constructor
  147668. *
  147669. * Effect parameters are as follow:
  147670. * {
  147671. * chromatic_aberration: number; // from 0 to x (1 for realism)
  147672. * edge_blur: number; // from 0 to x (1 for realism)
  147673. * distortion: number; // from 0 to x (1 for realism)
  147674. * grain_amount: number; // from 0 to 1
  147675. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  147676. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  147677. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  147678. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  147679. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  147680. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  147681. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  147682. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  147683. * }
  147684. * Note: if an effect parameter is unset, effect is disabled
  147685. *
  147686. * @param name The rendering pipeline name
  147687. * @param parameters - An object containing all parameters (see above)
  147688. * @param scene The scene linked to this pipeline
  147689. * @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)
  147690. * @param cameras The array of cameras that the rendering pipeline will be attached to
  147691. */
  147692. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  147693. /**
  147694. * Get the class name
  147695. * @returns "LensRenderingPipeline"
  147696. */
  147697. getClassName(): string;
  147698. /**
  147699. * Gets associated scene
  147700. */
  147701. get scene(): Scene;
  147702. /**
  147703. * Gets or sets the edge blur
  147704. */
  147705. get edgeBlur(): number;
  147706. set edgeBlur(value: number);
  147707. /**
  147708. * Gets or sets the grain amount
  147709. */
  147710. get grainAmount(): number;
  147711. set grainAmount(value: number);
  147712. /**
  147713. * Gets or sets the chromatic aberration amount
  147714. */
  147715. get chromaticAberration(): number;
  147716. set chromaticAberration(value: number);
  147717. /**
  147718. * Gets or sets the depth of field aperture
  147719. */
  147720. get dofAperture(): number;
  147721. set dofAperture(value: number);
  147722. /**
  147723. * Gets or sets the edge distortion
  147724. */
  147725. get edgeDistortion(): number;
  147726. set edgeDistortion(value: number);
  147727. /**
  147728. * Gets or sets the depth of field distortion
  147729. */
  147730. get dofDistortion(): number;
  147731. set dofDistortion(value: number);
  147732. /**
  147733. * Gets or sets the darken out of focus amount
  147734. */
  147735. get darkenOutOfFocus(): number;
  147736. set darkenOutOfFocus(value: number);
  147737. /**
  147738. * Gets or sets a boolean indicating if blur noise is enabled
  147739. */
  147740. get blurNoise(): boolean;
  147741. set blurNoise(value: boolean);
  147742. /**
  147743. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  147744. */
  147745. get pentagonBokeh(): boolean;
  147746. set pentagonBokeh(value: boolean);
  147747. /**
  147748. * Gets or sets the highlight grain amount
  147749. */
  147750. get highlightsGain(): number;
  147751. set highlightsGain(value: number);
  147752. /**
  147753. * Gets or sets the highlight threshold
  147754. */
  147755. get highlightsThreshold(): number;
  147756. set highlightsThreshold(value: number);
  147757. /**
  147758. * Sets the amount of blur at the edges
  147759. * @param amount blur amount
  147760. */
  147761. setEdgeBlur(amount: number): void;
  147762. /**
  147763. * Sets edge blur to 0
  147764. */
  147765. disableEdgeBlur(): void;
  147766. /**
  147767. * Sets the amout of grain
  147768. * @param amount Amount of grain
  147769. */
  147770. setGrainAmount(amount: number): void;
  147771. /**
  147772. * Set grain amount to 0
  147773. */
  147774. disableGrain(): void;
  147775. /**
  147776. * Sets the chromatic aberration amount
  147777. * @param amount amount of chromatic aberration
  147778. */
  147779. setChromaticAberration(amount: number): void;
  147780. /**
  147781. * Sets chromatic aberration amount to 0
  147782. */
  147783. disableChromaticAberration(): void;
  147784. /**
  147785. * Sets the EdgeDistortion amount
  147786. * @param amount amount of EdgeDistortion
  147787. */
  147788. setEdgeDistortion(amount: number): void;
  147789. /**
  147790. * Sets edge distortion to 0
  147791. */
  147792. disableEdgeDistortion(): void;
  147793. /**
  147794. * Sets the FocusDistance amount
  147795. * @param amount amount of FocusDistance
  147796. */
  147797. setFocusDistance(amount: number): void;
  147798. /**
  147799. * Disables depth of field
  147800. */
  147801. disableDepthOfField(): void;
  147802. /**
  147803. * Sets the Aperture amount
  147804. * @param amount amount of Aperture
  147805. */
  147806. setAperture(amount: number): void;
  147807. /**
  147808. * Sets the DarkenOutOfFocus amount
  147809. * @param amount amount of DarkenOutOfFocus
  147810. */
  147811. setDarkenOutOfFocus(amount: number): void;
  147812. private _pentagonBokehIsEnabled;
  147813. /**
  147814. * Creates a pentagon bokeh effect
  147815. */
  147816. enablePentagonBokeh(): void;
  147817. /**
  147818. * Disables the pentagon bokeh effect
  147819. */
  147820. disablePentagonBokeh(): void;
  147821. /**
  147822. * Enables noise blur
  147823. */
  147824. enableNoiseBlur(): void;
  147825. /**
  147826. * Disables noise blur
  147827. */
  147828. disableNoiseBlur(): void;
  147829. /**
  147830. * Sets the HighlightsGain amount
  147831. * @param amount amount of HighlightsGain
  147832. */
  147833. setHighlightsGain(amount: number): void;
  147834. /**
  147835. * Sets the HighlightsThreshold amount
  147836. * @param amount amount of HighlightsThreshold
  147837. */
  147838. setHighlightsThreshold(amount: number): void;
  147839. /**
  147840. * Disables highlights
  147841. */
  147842. disableHighlights(): void;
  147843. /**
  147844. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  147845. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  147846. */
  147847. dispose(disableDepthRender?: boolean): void;
  147848. private _createChromaticAberrationPostProcess;
  147849. private _createHighlightsPostProcess;
  147850. private _createDepthOfFieldPostProcess;
  147851. private _createGrainTexture;
  147852. }
  147853. }
  147854. declare module BABYLON {
  147855. /** @hidden */
  147856. export var ssao2PixelShader: {
  147857. name: string;
  147858. shader: string;
  147859. };
  147860. }
  147861. declare module BABYLON {
  147862. /** @hidden */
  147863. export var ssaoCombinePixelShader: {
  147864. name: string;
  147865. shader: string;
  147866. };
  147867. }
  147868. declare module BABYLON {
  147869. /**
  147870. * Render pipeline to produce ssao effect
  147871. */
  147872. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  147873. /**
  147874. * @ignore
  147875. * The PassPostProcess id in the pipeline that contains the original scene color
  147876. */
  147877. SSAOOriginalSceneColorEffect: string;
  147878. /**
  147879. * @ignore
  147880. * The SSAO PostProcess id in the pipeline
  147881. */
  147882. SSAORenderEffect: string;
  147883. /**
  147884. * @ignore
  147885. * The horizontal blur PostProcess id in the pipeline
  147886. */
  147887. SSAOBlurHRenderEffect: string;
  147888. /**
  147889. * @ignore
  147890. * The vertical blur PostProcess id in the pipeline
  147891. */
  147892. SSAOBlurVRenderEffect: string;
  147893. /**
  147894. * @ignore
  147895. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  147896. */
  147897. SSAOCombineRenderEffect: string;
  147898. /**
  147899. * The output strength of the SSAO post-process. Default value is 1.0.
  147900. */
  147901. totalStrength: number;
  147902. /**
  147903. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  147904. */
  147905. maxZ: number;
  147906. /**
  147907. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  147908. */
  147909. minZAspect: number;
  147910. private _samples;
  147911. /**
  147912. * Number of samples used for the SSAO calculations. Default value is 8
  147913. */
  147914. set samples(n: number);
  147915. get samples(): number;
  147916. private _textureSamples;
  147917. /**
  147918. * Number of samples to use for antialiasing
  147919. */
  147920. set textureSamples(n: number);
  147921. get textureSamples(): number;
  147922. /**
  147923. * Ratio object used for SSAO ratio and blur ratio
  147924. */
  147925. private _ratio;
  147926. /**
  147927. * Dynamically generated sphere sampler.
  147928. */
  147929. private _sampleSphere;
  147930. /**
  147931. * Blur filter offsets
  147932. */
  147933. private _samplerOffsets;
  147934. private _expensiveBlur;
  147935. /**
  147936. * If bilateral blur should be used
  147937. */
  147938. set expensiveBlur(b: boolean);
  147939. get expensiveBlur(): boolean;
  147940. /**
  147941. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  147942. */
  147943. radius: number;
  147944. /**
  147945. * The base color of the SSAO post-process
  147946. * The final result is "base + ssao" between [0, 1]
  147947. */
  147948. base: number;
  147949. /**
  147950. * Support test.
  147951. */
  147952. static get IsSupported(): boolean;
  147953. private _scene;
  147954. private _depthTexture;
  147955. private _normalTexture;
  147956. private _randomTexture;
  147957. private _originalColorPostProcess;
  147958. private _ssaoPostProcess;
  147959. private _blurHPostProcess;
  147960. private _blurVPostProcess;
  147961. private _ssaoCombinePostProcess;
  147962. /**
  147963. * Gets active scene
  147964. */
  147965. get scene(): Scene;
  147966. /**
  147967. * @constructor
  147968. * @param name The rendering pipeline name
  147969. * @param scene The scene linked to this pipeline
  147970. * @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 }
  147971. * @param cameras The array of cameras that the rendering pipeline will be attached to
  147972. */
  147973. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  147974. /**
  147975. * Get the class name
  147976. * @returns "SSAO2RenderingPipeline"
  147977. */
  147978. getClassName(): string;
  147979. /**
  147980. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  147981. */
  147982. dispose(disableGeometryBufferRenderer?: boolean): void;
  147983. private _createBlurPostProcess;
  147984. /** @hidden */
  147985. _rebuild(): void;
  147986. private _bits;
  147987. private _radicalInverse_VdC;
  147988. private _hammersley;
  147989. private _hemisphereSample_uniform;
  147990. private _generateHemisphere;
  147991. private _createSSAOPostProcess;
  147992. private _createSSAOCombinePostProcess;
  147993. private _createRandomTexture;
  147994. /**
  147995. * Serialize the rendering pipeline (Used when exporting)
  147996. * @returns the serialized object
  147997. */
  147998. serialize(): any;
  147999. /**
  148000. * Parse the serialized pipeline
  148001. * @param source Source pipeline.
  148002. * @param scene The scene to load the pipeline to.
  148003. * @param rootUrl The URL of the serialized pipeline.
  148004. * @returns An instantiated pipeline from the serialized object.
  148005. */
  148006. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  148007. }
  148008. }
  148009. declare module BABYLON {
  148010. /** @hidden */
  148011. export var ssaoPixelShader: {
  148012. name: string;
  148013. shader: string;
  148014. };
  148015. }
  148016. declare module BABYLON {
  148017. /**
  148018. * Render pipeline to produce ssao effect
  148019. */
  148020. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  148021. /**
  148022. * @ignore
  148023. * The PassPostProcess id in the pipeline that contains the original scene color
  148024. */
  148025. SSAOOriginalSceneColorEffect: string;
  148026. /**
  148027. * @ignore
  148028. * The SSAO PostProcess id in the pipeline
  148029. */
  148030. SSAORenderEffect: string;
  148031. /**
  148032. * @ignore
  148033. * The horizontal blur PostProcess id in the pipeline
  148034. */
  148035. SSAOBlurHRenderEffect: string;
  148036. /**
  148037. * @ignore
  148038. * The vertical blur PostProcess id in the pipeline
  148039. */
  148040. SSAOBlurVRenderEffect: string;
  148041. /**
  148042. * @ignore
  148043. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  148044. */
  148045. SSAOCombineRenderEffect: string;
  148046. /**
  148047. * The output strength of the SSAO post-process. Default value is 1.0.
  148048. */
  148049. totalStrength: number;
  148050. /**
  148051. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  148052. */
  148053. radius: number;
  148054. /**
  148055. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  148056. * Must not be equal to fallOff and superior to fallOff.
  148057. * Default value is 0.0075
  148058. */
  148059. area: number;
  148060. /**
  148061. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  148062. * Must not be equal to area and inferior to area.
  148063. * Default value is 0.000001
  148064. */
  148065. fallOff: number;
  148066. /**
  148067. * The base color of the SSAO post-process
  148068. * The final result is "base + ssao" between [0, 1]
  148069. */
  148070. base: number;
  148071. private _scene;
  148072. private _depthTexture;
  148073. private _randomTexture;
  148074. private _originalColorPostProcess;
  148075. private _ssaoPostProcess;
  148076. private _blurHPostProcess;
  148077. private _blurVPostProcess;
  148078. private _ssaoCombinePostProcess;
  148079. private _firstUpdate;
  148080. /**
  148081. * Gets active scene
  148082. */
  148083. get scene(): Scene;
  148084. /**
  148085. * @constructor
  148086. * @param name - The rendering pipeline name
  148087. * @param scene - The scene linked to this pipeline
  148088. * @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 }
  148089. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  148090. */
  148091. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  148092. /**
  148093. * Get the class name
  148094. * @returns "SSAORenderingPipeline"
  148095. */
  148096. getClassName(): string;
  148097. /**
  148098. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  148099. */
  148100. dispose(disableDepthRender?: boolean): void;
  148101. private _createBlurPostProcess;
  148102. /** @hidden */
  148103. _rebuild(): void;
  148104. private _createSSAOPostProcess;
  148105. private _createSSAOCombinePostProcess;
  148106. private _createRandomTexture;
  148107. }
  148108. }
  148109. declare module BABYLON {
  148110. /** @hidden */
  148111. export var screenSpaceReflectionPixelShader: {
  148112. name: string;
  148113. shader: string;
  148114. };
  148115. }
  148116. declare module BABYLON {
  148117. /**
  148118. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  148119. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  148120. */
  148121. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  148122. /**
  148123. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  148124. */
  148125. threshold: number;
  148126. /**
  148127. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  148128. */
  148129. strength: number;
  148130. /**
  148131. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  148132. */
  148133. reflectionSpecularFalloffExponent: number;
  148134. /**
  148135. * Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]
  148136. */
  148137. step: number;
  148138. /**
  148139. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  148140. */
  148141. roughnessFactor: number;
  148142. private _geometryBufferRenderer;
  148143. private _enableSmoothReflections;
  148144. private _reflectionSamples;
  148145. private _smoothSteps;
  148146. /**
  148147. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  148148. * @param name The name of the effect.
  148149. * @param scene The scene containing the objects to calculate reflections.
  148150. * @param options The required width/height ratio to downsize to before computing the render pass.
  148151. * @param camera The camera to apply the render pass to.
  148152. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148153. * @param engine The engine which the post process will be applied. (default: current engine)
  148154. * @param reusable If the post process can be reused on the same frame. (default: false)
  148155. * @param textureType Type of textures used when performing the post process. (default: 0)
  148156. * @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)
  148157. */
  148158. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148159. /**
  148160. * Gets wether or not smoothing reflections is enabled.
  148161. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  148162. */
  148163. get enableSmoothReflections(): boolean;
  148164. /**
  148165. * Sets wether or not smoothing reflections is enabled.
  148166. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  148167. */
  148168. set enableSmoothReflections(enabled: boolean);
  148169. /**
  148170. * Gets the number of samples taken while computing reflections. More samples count is high,
  148171. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  148172. */
  148173. get reflectionSamples(): number;
  148174. /**
  148175. * Sets the number of samples taken while computing reflections. More samples count is high,
  148176. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  148177. */
  148178. set reflectionSamples(samples: number);
  148179. /**
  148180. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  148181. * more the post-process will require GPU power and can generate a drop in FPS.
  148182. * Default value (5.0) work pretty well in all cases but can be adjusted.
  148183. */
  148184. get smoothSteps(): number;
  148185. set smoothSteps(steps: number);
  148186. private _updateEffectDefines;
  148187. }
  148188. }
  148189. declare module BABYLON {
  148190. /** @hidden */
  148191. export var standardPixelShader: {
  148192. name: string;
  148193. shader: string;
  148194. };
  148195. }
  148196. declare module BABYLON {
  148197. /**
  148198. * Standard rendering pipeline
  148199. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  148200. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  148201. */
  148202. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  148203. /**
  148204. * Public members
  148205. */
  148206. /**
  148207. * Post-process which contains the original scene color before the pipeline applies all the effects
  148208. */
  148209. originalPostProcess: Nullable<PostProcess>;
  148210. /**
  148211. * Post-process used to down scale an image x4
  148212. */
  148213. downSampleX4PostProcess: Nullable<PostProcess>;
  148214. /**
  148215. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  148216. */
  148217. brightPassPostProcess: Nullable<PostProcess>;
  148218. /**
  148219. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  148220. */
  148221. blurHPostProcesses: PostProcess[];
  148222. /**
  148223. * Post-process array storing all the vertical blur post-processes used by the pipeline
  148224. */
  148225. blurVPostProcesses: PostProcess[];
  148226. /**
  148227. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  148228. */
  148229. textureAdderPostProcess: Nullable<PostProcess>;
  148230. /**
  148231. * Post-process used to create volumetric lighting effect
  148232. */
  148233. volumetricLightPostProcess: Nullable<PostProcess>;
  148234. /**
  148235. * Post-process used to smooth the previous volumetric light post-process on the X axis
  148236. */
  148237. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  148238. /**
  148239. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  148240. */
  148241. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  148242. /**
  148243. * Post-process used to merge the volumetric light effect and the real scene color
  148244. */
  148245. volumetricLightMergePostProces: Nullable<PostProcess>;
  148246. /**
  148247. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  148248. */
  148249. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  148250. /**
  148251. * Base post-process used to calculate the average luminance of the final image for HDR
  148252. */
  148253. luminancePostProcess: Nullable<PostProcess>;
  148254. /**
  148255. * Post-processes used to create down sample post-processes in order to get
  148256. * the average luminance of the final image for HDR
  148257. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  148258. */
  148259. luminanceDownSamplePostProcesses: PostProcess[];
  148260. /**
  148261. * Post-process used to create a HDR effect (light adaptation)
  148262. */
  148263. hdrPostProcess: Nullable<PostProcess>;
  148264. /**
  148265. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  148266. */
  148267. textureAdderFinalPostProcess: Nullable<PostProcess>;
  148268. /**
  148269. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  148270. */
  148271. lensFlareFinalPostProcess: Nullable<PostProcess>;
  148272. /**
  148273. * Post-process used to merge the final HDR post-process and the real scene color
  148274. */
  148275. hdrFinalPostProcess: Nullable<PostProcess>;
  148276. /**
  148277. * Post-process used to create a lens flare effect
  148278. */
  148279. lensFlarePostProcess: Nullable<PostProcess>;
  148280. /**
  148281. * Post-process that merges the result of the lens flare post-process and the real scene color
  148282. */
  148283. lensFlareComposePostProcess: Nullable<PostProcess>;
  148284. /**
  148285. * Post-process used to create a motion blur effect
  148286. */
  148287. motionBlurPostProcess: Nullable<PostProcess>;
  148288. /**
  148289. * Post-process used to create a depth of field effect
  148290. */
  148291. depthOfFieldPostProcess: Nullable<PostProcess>;
  148292. /**
  148293. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  148294. */
  148295. fxaaPostProcess: Nullable<FxaaPostProcess>;
  148296. /**
  148297. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  148298. */
  148299. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  148300. /**
  148301. * Represents the brightness threshold in order to configure the illuminated surfaces
  148302. */
  148303. brightThreshold: number;
  148304. /**
  148305. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  148306. */
  148307. blurWidth: number;
  148308. /**
  148309. * Sets if the blur for highlighted surfaces must be only horizontal
  148310. */
  148311. horizontalBlur: boolean;
  148312. /**
  148313. * Gets the overall exposure used by the pipeline
  148314. */
  148315. get exposure(): number;
  148316. /**
  148317. * Sets the overall exposure used by the pipeline
  148318. */
  148319. set exposure(value: number);
  148320. /**
  148321. * Texture used typically to simulate "dirty" on camera lens
  148322. */
  148323. lensTexture: Nullable<Texture>;
  148324. /**
  148325. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  148326. */
  148327. volumetricLightCoefficient: number;
  148328. /**
  148329. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  148330. */
  148331. volumetricLightPower: number;
  148332. /**
  148333. * Used the set the blur intensity to smooth the volumetric lights
  148334. */
  148335. volumetricLightBlurScale: number;
  148336. /**
  148337. * Light (spot or directional) used to generate the volumetric lights rays
  148338. * The source light must have a shadow generate so the pipeline can get its
  148339. * depth map
  148340. */
  148341. sourceLight: Nullable<SpotLight | DirectionalLight>;
  148342. /**
  148343. * For eye adaptation, represents the minimum luminance the eye can see
  148344. */
  148345. hdrMinimumLuminance: number;
  148346. /**
  148347. * For eye adaptation, represents the decrease luminance speed
  148348. */
  148349. hdrDecreaseRate: number;
  148350. /**
  148351. * For eye adaptation, represents the increase luminance speed
  148352. */
  148353. hdrIncreaseRate: number;
  148354. /**
  148355. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  148356. */
  148357. get hdrAutoExposure(): boolean;
  148358. /**
  148359. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  148360. */
  148361. set hdrAutoExposure(value: boolean);
  148362. /**
  148363. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  148364. */
  148365. lensColorTexture: Nullable<Texture>;
  148366. /**
  148367. * The overall strengh for the lens flare effect
  148368. */
  148369. lensFlareStrength: number;
  148370. /**
  148371. * Dispersion coefficient for lens flare ghosts
  148372. */
  148373. lensFlareGhostDispersal: number;
  148374. /**
  148375. * Main lens flare halo width
  148376. */
  148377. lensFlareHaloWidth: number;
  148378. /**
  148379. * Based on the lens distortion effect, defines how much the lens flare result
  148380. * is distorted
  148381. */
  148382. lensFlareDistortionStrength: number;
  148383. /**
  148384. * Configures the blur intensity used for for lens flare (halo)
  148385. */
  148386. lensFlareBlurWidth: number;
  148387. /**
  148388. * Lens star texture must be used to simulate rays on the flares and is available
  148389. * in the documentation
  148390. */
  148391. lensStarTexture: Nullable<Texture>;
  148392. /**
  148393. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  148394. * flare effect by taking account of the dirt texture
  148395. */
  148396. lensFlareDirtTexture: Nullable<Texture>;
  148397. /**
  148398. * Represents the focal length for the depth of field effect
  148399. */
  148400. depthOfFieldDistance: number;
  148401. /**
  148402. * Represents the blur intensity for the blurred part of the depth of field effect
  148403. */
  148404. depthOfFieldBlurWidth: number;
  148405. /**
  148406. * Gets how much the image is blurred by the movement while using the motion blur post-process
  148407. */
  148408. get motionStrength(): number;
  148409. /**
  148410. * Sets how much the image is blurred by the movement while using the motion blur post-process
  148411. */
  148412. set motionStrength(strength: number);
  148413. /**
  148414. * Gets wether or not the motion blur post-process is object based or screen based.
  148415. */
  148416. get objectBasedMotionBlur(): boolean;
  148417. /**
  148418. * Sets wether or not the motion blur post-process should be object based or screen based
  148419. */
  148420. set objectBasedMotionBlur(value: boolean);
  148421. /**
  148422. * List of animations for the pipeline (IAnimatable implementation)
  148423. */
  148424. animations: Animation[];
  148425. /**
  148426. * Private members
  148427. */
  148428. private _scene;
  148429. private _currentDepthOfFieldSource;
  148430. private _basePostProcess;
  148431. private _fixedExposure;
  148432. private _currentExposure;
  148433. private _hdrAutoExposure;
  148434. private _hdrCurrentLuminance;
  148435. private _motionStrength;
  148436. private _isObjectBasedMotionBlur;
  148437. private _floatTextureType;
  148438. private _camerasToBeAttached;
  148439. private _ratio;
  148440. private _bloomEnabled;
  148441. private _depthOfFieldEnabled;
  148442. private _vlsEnabled;
  148443. private _lensFlareEnabled;
  148444. private _hdrEnabled;
  148445. private _motionBlurEnabled;
  148446. private _fxaaEnabled;
  148447. private _screenSpaceReflectionsEnabled;
  148448. private _motionBlurSamples;
  148449. private _volumetricLightStepsCount;
  148450. private _samples;
  148451. /**
  148452. * @ignore
  148453. * Specifies if the bloom pipeline is enabled
  148454. */
  148455. get BloomEnabled(): boolean;
  148456. set BloomEnabled(enabled: boolean);
  148457. /**
  148458. * @ignore
  148459. * Specifies if the depth of field pipeline is enabed
  148460. */
  148461. get DepthOfFieldEnabled(): boolean;
  148462. set DepthOfFieldEnabled(enabled: boolean);
  148463. /**
  148464. * @ignore
  148465. * Specifies if the lens flare pipeline is enabed
  148466. */
  148467. get LensFlareEnabled(): boolean;
  148468. set LensFlareEnabled(enabled: boolean);
  148469. /**
  148470. * @ignore
  148471. * Specifies if the HDR pipeline is enabled
  148472. */
  148473. get HDREnabled(): boolean;
  148474. set HDREnabled(enabled: boolean);
  148475. /**
  148476. * @ignore
  148477. * Specifies if the volumetric lights scattering effect is enabled
  148478. */
  148479. get VLSEnabled(): boolean;
  148480. set VLSEnabled(enabled: boolean);
  148481. /**
  148482. * @ignore
  148483. * Specifies if the motion blur effect is enabled
  148484. */
  148485. get MotionBlurEnabled(): boolean;
  148486. set MotionBlurEnabled(enabled: boolean);
  148487. /**
  148488. * Specifies if anti-aliasing is enabled
  148489. */
  148490. get fxaaEnabled(): boolean;
  148491. set fxaaEnabled(enabled: boolean);
  148492. /**
  148493. * Specifies if screen space reflections are enabled.
  148494. */
  148495. get screenSpaceReflectionsEnabled(): boolean;
  148496. set screenSpaceReflectionsEnabled(enabled: boolean);
  148497. /**
  148498. * Specifies the number of steps used to calculate the volumetric lights
  148499. * Typically in interval [50, 200]
  148500. */
  148501. get volumetricLightStepsCount(): number;
  148502. set volumetricLightStepsCount(count: number);
  148503. /**
  148504. * Specifies the number of samples used for the motion blur effect
  148505. * Typically in interval [16, 64]
  148506. */
  148507. get motionBlurSamples(): number;
  148508. set motionBlurSamples(samples: number);
  148509. /**
  148510. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  148511. */
  148512. get samples(): number;
  148513. set samples(sampleCount: number);
  148514. /**
  148515. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  148516. * @constructor
  148517. * @param name The rendering pipeline name
  148518. * @param scene The scene linked to this pipeline
  148519. * @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)
  148520. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  148521. * @param cameras The array of cameras that the rendering pipeline will be attached to
  148522. */
  148523. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  148524. private _buildPipeline;
  148525. private _createDownSampleX4PostProcess;
  148526. private _createBrightPassPostProcess;
  148527. private _createBlurPostProcesses;
  148528. private _createTextureAdderPostProcess;
  148529. private _createVolumetricLightPostProcess;
  148530. private _createLuminancePostProcesses;
  148531. private _createHdrPostProcess;
  148532. private _createLensFlarePostProcess;
  148533. private _createDepthOfFieldPostProcess;
  148534. private _createMotionBlurPostProcess;
  148535. private _getDepthTexture;
  148536. private _disposePostProcesses;
  148537. /**
  148538. * Dispose of the pipeline and stop all post processes
  148539. */
  148540. dispose(): void;
  148541. /**
  148542. * Serialize the rendering pipeline (Used when exporting)
  148543. * @returns the serialized object
  148544. */
  148545. serialize(): any;
  148546. /**
  148547. * Parse the serialized pipeline
  148548. * @param source Source pipeline.
  148549. * @param scene The scene to load the pipeline to.
  148550. * @param rootUrl The URL of the serialized pipeline.
  148551. * @returns An instantiated pipeline from the serialized object.
  148552. */
  148553. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  148554. /**
  148555. * Luminance steps
  148556. */
  148557. static LuminanceSteps: number;
  148558. }
  148559. }
  148560. declare module BABYLON {
  148561. /** @hidden */
  148562. export var stereoscopicInterlacePixelShader: {
  148563. name: string;
  148564. shader: string;
  148565. };
  148566. }
  148567. declare module BABYLON {
  148568. /**
  148569. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  148570. */
  148571. export class StereoscopicInterlacePostProcessI extends PostProcess {
  148572. private _stepSize;
  148573. private _passedProcess;
  148574. /**
  148575. * Initializes a StereoscopicInterlacePostProcessI
  148576. * @param name The name of the effect.
  148577. * @param rigCameras The rig cameras to be appled to the post process
  148578. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  148579. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  148580. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148581. * @param engine The engine which the post process will be applied. (default: current engine)
  148582. * @param reusable If the post process can be reused on the same frame. (default: false)
  148583. */
  148584. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148585. }
  148586. /**
  148587. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  148588. */
  148589. export class StereoscopicInterlacePostProcess extends PostProcess {
  148590. private _stepSize;
  148591. private _passedProcess;
  148592. /**
  148593. * Initializes a StereoscopicInterlacePostProcess
  148594. * @param name The name of the effect.
  148595. * @param rigCameras The rig cameras to be appled to the post process
  148596. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  148597. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148598. * @param engine The engine which the post process will be applied. (default: current engine)
  148599. * @param reusable If the post process can be reused on the same frame. (default: false)
  148600. */
  148601. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148602. }
  148603. }
  148604. declare module BABYLON {
  148605. /** @hidden */
  148606. export var tonemapPixelShader: {
  148607. name: string;
  148608. shader: string;
  148609. };
  148610. }
  148611. declare module BABYLON {
  148612. /** Defines operator used for tonemapping */
  148613. export enum TonemappingOperator {
  148614. /** Hable */
  148615. Hable = 0,
  148616. /** Reinhard */
  148617. Reinhard = 1,
  148618. /** HejiDawson */
  148619. HejiDawson = 2,
  148620. /** Photographic */
  148621. Photographic = 3
  148622. }
  148623. /**
  148624. * Defines a post process to apply tone mapping
  148625. */
  148626. export class TonemapPostProcess extends PostProcess {
  148627. private _operator;
  148628. /** Defines the required exposure adjustement */
  148629. exposureAdjustment: number;
  148630. /**
  148631. * Creates a new TonemapPostProcess
  148632. * @param name defines the name of the postprocess
  148633. * @param _operator defines the operator to use
  148634. * @param exposureAdjustment defines the required exposure adjustement
  148635. * @param camera defines the camera to use (can be null)
  148636. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  148637. * @param engine defines the hosting engine (can be ignore if camera is set)
  148638. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  148639. */
  148640. constructor(name: string, _operator: TonemappingOperator,
  148641. /** Defines the required exposure adjustement */
  148642. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  148643. }
  148644. }
  148645. declare module BABYLON {
  148646. /** @hidden */
  148647. export var volumetricLightScatteringPixelShader: {
  148648. name: string;
  148649. shader: string;
  148650. };
  148651. }
  148652. declare module BABYLON {
  148653. /** @hidden */
  148654. export var volumetricLightScatteringPassVertexShader: {
  148655. name: string;
  148656. shader: string;
  148657. };
  148658. }
  148659. declare module BABYLON {
  148660. /** @hidden */
  148661. export var volumetricLightScatteringPassPixelShader: {
  148662. name: string;
  148663. shader: string;
  148664. };
  148665. }
  148666. declare module BABYLON {
  148667. /**
  148668. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  148669. */
  148670. export class VolumetricLightScatteringPostProcess extends PostProcess {
  148671. private _volumetricLightScatteringPass;
  148672. private _volumetricLightScatteringRTT;
  148673. private _viewPort;
  148674. private _screenCoordinates;
  148675. private _cachedDefines;
  148676. /**
  148677. * If not undefined, the mesh position is computed from the attached node position
  148678. */
  148679. attachedNode: {
  148680. position: Vector3;
  148681. };
  148682. /**
  148683. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  148684. */
  148685. customMeshPosition: Vector3;
  148686. /**
  148687. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  148688. */
  148689. useCustomMeshPosition: boolean;
  148690. /**
  148691. * If the post-process should inverse the light scattering direction
  148692. */
  148693. invert: boolean;
  148694. /**
  148695. * The internal mesh used by the post-process
  148696. */
  148697. mesh: Mesh;
  148698. /**
  148699. * @hidden
  148700. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  148701. */
  148702. get useDiffuseColor(): boolean;
  148703. set useDiffuseColor(useDiffuseColor: boolean);
  148704. /**
  148705. * Array containing the excluded meshes not rendered in the internal pass
  148706. */
  148707. excludedMeshes: AbstractMesh[];
  148708. /**
  148709. * Controls the overall intensity of the post-process
  148710. */
  148711. exposure: number;
  148712. /**
  148713. * Dissipates each sample's contribution in range [0, 1]
  148714. */
  148715. decay: number;
  148716. /**
  148717. * Controls the overall intensity of each sample
  148718. */
  148719. weight: number;
  148720. /**
  148721. * Controls the density of each sample
  148722. */
  148723. density: number;
  148724. /**
  148725. * @constructor
  148726. * @param name The post-process name
  148727. * @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)
  148728. * @param camera The camera that the post-process will be attached to
  148729. * @param mesh The mesh used to create the light scattering
  148730. * @param samples The post-process quality, default 100
  148731. * @param samplingModeThe post-process filtering mode
  148732. * @param engine The babylon engine
  148733. * @param reusable If the post-process is reusable
  148734. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  148735. */
  148736. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  148737. /**
  148738. * Returns the string "VolumetricLightScatteringPostProcess"
  148739. * @returns "VolumetricLightScatteringPostProcess"
  148740. */
  148741. getClassName(): string;
  148742. private _isReady;
  148743. /**
  148744. * Sets the new light position for light scattering effect
  148745. * @param position The new custom light position
  148746. */
  148747. setCustomMeshPosition(position: Vector3): void;
  148748. /**
  148749. * Returns the light position for light scattering effect
  148750. * @return Vector3 The custom light position
  148751. */
  148752. getCustomMeshPosition(): Vector3;
  148753. /**
  148754. * Disposes the internal assets and detaches the post-process from the camera
  148755. */
  148756. dispose(camera: Camera): void;
  148757. /**
  148758. * Returns the render target texture used by the post-process
  148759. * @return the render target texture used by the post-process
  148760. */
  148761. getPass(): RenderTargetTexture;
  148762. private _meshExcluded;
  148763. private _createPass;
  148764. private _updateMeshScreenCoordinates;
  148765. /**
  148766. * Creates a default mesh for the Volumeric Light Scattering post-process
  148767. * @param name The mesh name
  148768. * @param scene The scene where to create the mesh
  148769. * @return the default mesh
  148770. */
  148771. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  148772. }
  148773. }
  148774. declare module BABYLON {
  148775. interface Scene {
  148776. /** @hidden (Backing field) */
  148777. _boundingBoxRenderer: BoundingBoxRenderer;
  148778. /** @hidden (Backing field) */
  148779. _forceShowBoundingBoxes: boolean;
  148780. /**
  148781. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  148782. */
  148783. forceShowBoundingBoxes: boolean;
  148784. /**
  148785. * Gets the bounding box renderer associated with the scene
  148786. * @returns a BoundingBoxRenderer
  148787. */
  148788. getBoundingBoxRenderer(): BoundingBoxRenderer;
  148789. }
  148790. interface AbstractMesh {
  148791. /** @hidden (Backing field) */
  148792. _showBoundingBox: boolean;
  148793. /**
  148794. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  148795. */
  148796. showBoundingBox: boolean;
  148797. }
  148798. /**
  148799. * Component responsible of rendering the bounding box of the meshes in a scene.
  148800. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  148801. */
  148802. export class BoundingBoxRenderer implements ISceneComponent {
  148803. /**
  148804. * The component name helpfull to identify the component in the list of scene components.
  148805. */
  148806. readonly name: string;
  148807. /**
  148808. * The scene the component belongs to.
  148809. */
  148810. scene: Scene;
  148811. /**
  148812. * Color of the bounding box lines placed in front of an object
  148813. */
  148814. frontColor: Color3;
  148815. /**
  148816. * Color of the bounding box lines placed behind an object
  148817. */
  148818. backColor: Color3;
  148819. /**
  148820. * Defines if the renderer should show the back lines or not
  148821. */
  148822. showBackLines: boolean;
  148823. /**
  148824. * Observable raised before rendering a bounding box
  148825. */
  148826. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  148827. /**
  148828. * Observable raised after rendering a bounding box
  148829. */
  148830. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  148831. /**
  148832. * @hidden
  148833. */
  148834. renderList: SmartArray<BoundingBox>;
  148835. private _colorShader;
  148836. private _vertexBuffers;
  148837. private _indexBuffer;
  148838. private _fillIndexBuffer;
  148839. private _fillIndexData;
  148840. /**
  148841. * Instantiates a new bounding box renderer in a scene.
  148842. * @param scene the scene the renderer renders in
  148843. */
  148844. constructor(scene: Scene);
  148845. /**
  148846. * Registers the component in a given scene
  148847. */
  148848. register(): void;
  148849. private _evaluateSubMesh;
  148850. private _activeMesh;
  148851. private _prepareRessources;
  148852. private _createIndexBuffer;
  148853. /**
  148854. * Rebuilds the elements related to this component in case of
  148855. * context lost for instance.
  148856. */
  148857. rebuild(): void;
  148858. /**
  148859. * @hidden
  148860. */
  148861. reset(): void;
  148862. /**
  148863. * Render the bounding boxes of a specific rendering group
  148864. * @param renderingGroupId defines the rendering group to render
  148865. */
  148866. render(renderingGroupId: number): void;
  148867. /**
  148868. * In case of occlusion queries, we can render the occlusion bounding box through this method
  148869. * @param mesh Define the mesh to render the occlusion bounding box for
  148870. */
  148871. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  148872. /**
  148873. * Dispose and release the resources attached to this renderer.
  148874. */
  148875. dispose(): void;
  148876. }
  148877. }
  148878. declare module BABYLON {
  148879. interface Scene {
  148880. /** @hidden (Backing field) */
  148881. _depthRenderer: {
  148882. [id: string]: DepthRenderer;
  148883. };
  148884. /**
  148885. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  148886. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  148887. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  148888. * @returns the created depth renderer
  148889. */
  148890. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  148891. /**
  148892. * Disables a depth renderer for a given camera
  148893. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  148894. */
  148895. disableDepthRenderer(camera?: Nullable<Camera>): void;
  148896. }
  148897. /**
  148898. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  148899. * in several rendering techniques.
  148900. */
  148901. export class DepthRendererSceneComponent implements ISceneComponent {
  148902. /**
  148903. * The component name helpfull to identify the component in the list of scene components.
  148904. */
  148905. readonly name: string;
  148906. /**
  148907. * The scene the component belongs to.
  148908. */
  148909. scene: Scene;
  148910. /**
  148911. * Creates a new instance of the component for the given scene
  148912. * @param scene Defines the scene to register the component in
  148913. */
  148914. constructor(scene: Scene);
  148915. /**
  148916. * Registers the component in a given scene
  148917. */
  148918. register(): void;
  148919. /**
  148920. * Rebuilds the elements related to this component in case of
  148921. * context lost for instance.
  148922. */
  148923. rebuild(): void;
  148924. /**
  148925. * Disposes the component and the associated ressources
  148926. */
  148927. dispose(): void;
  148928. private _gatherRenderTargets;
  148929. private _gatherActiveCameraRenderTargets;
  148930. }
  148931. }
  148932. declare module BABYLON {
  148933. /** @hidden */
  148934. export var fibonacci: {
  148935. name: string;
  148936. shader: string;
  148937. };
  148938. }
  148939. declare module BABYLON {
  148940. /** @hidden */
  148941. export var diffusionProfile: {
  148942. name: string;
  148943. shader: string;
  148944. };
  148945. }
  148946. declare module BABYLON {
  148947. /** @hidden */
  148948. export var subSurfaceScatteringPixelShader: {
  148949. name: string;
  148950. shader: string;
  148951. };
  148952. }
  148953. declare module BABYLON {
  148954. /**
  148955. * Sub surface scattering post process
  148956. */
  148957. export class SubSurfaceScatteringPostProcess extends PostProcess {
  148958. /** @hidden */
  148959. texelWidth: number;
  148960. /** @hidden */
  148961. texelHeight: number;
  148962. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  148963. }
  148964. }
  148965. declare module BABYLON {
  148966. /**
  148967. * Contains all parameters needed for the prepass to perform
  148968. * screen space subsurface scattering
  148969. */
  148970. export class SubSurfaceConfiguration {
  148971. private _ssDiffusionS;
  148972. private _ssFilterRadii;
  148973. private _ssDiffusionD;
  148974. /**
  148975. * Diffusion profile color for subsurface scattering
  148976. */
  148977. get ssDiffusionS(): number[];
  148978. /**
  148979. * Diffusion profile max color channel value for subsurface scattering
  148980. */
  148981. get ssDiffusionD(): number[];
  148982. /**
  148983. * Diffusion profile filter radius for subsurface scattering
  148984. */
  148985. get ssFilterRadii(): number[];
  148986. /**
  148987. * Diffusion profile colors for subsurface scattering
  148988. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  148989. * See ...
  148990. * Note that you can only store up to 5 of them
  148991. */
  148992. ssDiffusionProfileColors: Color3[];
  148993. /**
  148994. * Defines the ratio real world => scene units.
  148995. * Used for subsurface scattering
  148996. */
  148997. metersPerUnit: number;
  148998. /**
  148999. * Builds a subsurface configuration object
  149000. * @param scene The scene
  149001. */
  149002. constructor();
  149003. /**
  149004. * Adds a new diffusion profile.
  149005. * Useful for more realistic subsurface scattering on diverse materials.
  149006. * @param color The color of the diffusion profile. Should be the average color of the material.
  149007. * @return The index of the diffusion profile for the material subsurface configuration
  149008. */
  149009. addDiffusionProfile(color: Color3): number;
  149010. /**
  149011. * Deletes all diffusion profiles.
  149012. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  149013. */
  149014. clearAllDiffusionProfiles(): void;
  149015. /**
  149016. * Disposes this object
  149017. */
  149018. dispose(): void;
  149019. /**
  149020. * @hidden
  149021. * https://zero-radiance.github.io/post/sampling-diffusion/
  149022. *
  149023. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  149024. * ------------------------------------------------------------------------------------
  149025. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  149026. * PDF[r, phi, s] = r * R[r, phi, s]
  149027. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  149028. * ------------------------------------------------------------------------------------
  149029. * We importance sample the color channel with the widest scattering distance.
  149030. */
  149031. getDiffusionProfileParameters(color: Color3): number;
  149032. /**
  149033. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  149034. * 'u' is the random number (the value of the CDF): [0, 1).
  149035. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  149036. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  149037. */
  149038. private _sampleBurleyDiffusionProfile;
  149039. }
  149040. }
  149041. declare module BABYLON {
  149042. /**
  149043. * Renders a pre pass of the scene
  149044. * This means every mesh in the scene will be rendered to a render target texture
  149045. * And then this texture will be composited to the rendering canvas with post processes
  149046. * It is necessary for effects like subsurface scattering or deferred shading
  149047. */
  149048. export class PrePassRenderer {
  149049. /** @hidden */
  149050. static _SceneComponentInitialization: (scene: Scene) => void;
  149051. private _scene;
  149052. private _engine;
  149053. private _isDirty;
  149054. /**
  149055. * Number of textures in the multi render target texture where the scene is directly rendered
  149056. */
  149057. readonly mrtCount: number;
  149058. /**
  149059. * The render target where the scene is directly rendered
  149060. */
  149061. prePassRT: MultiRenderTarget;
  149062. private _mrtTypes;
  149063. private _multiRenderAttachments;
  149064. private _defaultAttachments;
  149065. private _clearAttachments;
  149066. private readonly _clearColor;
  149067. /**
  149068. * Image processing post process for composition
  149069. */
  149070. imageProcessingPostProcess: ImageProcessingPostProcess;
  149071. /**
  149072. * Post process for subsurface scattering
  149073. */
  149074. subSurfaceScatteringPostProcess: SubSurfaceScatteringPostProcess;
  149075. /**
  149076. * Configuration for sub surface scattering post process
  149077. */
  149078. subSurfaceConfiguration: SubSurfaceConfiguration;
  149079. private _enabled;
  149080. /**
  149081. * Indicates if the prepass is enabled
  149082. */
  149083. get enabled(): boolean;
  149084. /**
  149085. * How many samples are used for MSAA of the scene render target
  149086. */
  149087. get samples(): number;
  149088. set samples(n: number);
  149089. /**
  149090. * Instanciates a prepass renderer
  149091. * @param scene The scene
  149092. */
  149093. constructor(scene: Scene);
  149094. private _initializeAttachments;
  149095. private _createEffects;
  149096. /**
  149097. * Indicates if rendering a prepass is supported
  149098. */
  149099. get isSupported(): boolean;
  149100. /**
  149101. * Sets the proper output textures to draw in the engine.
  149102. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  149103. */
  149104. bindAttachmentsForEffect(effect: Effect): void;
  149105. /**
  149106. * @hidden
  149107. */
  149108. _beforeCameraDraw(): void;
  149109. /**
  149110. * @hidden
  149111. */
  149112. _afterCameraDraw(): void;
  149113. private _checkRTSize;
  149114. private _bindFrameBuffer;
  149115. /**
  149116. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  149117. */
  149118. clear(): void;
  149119. private _setState;
  149120. private _enable;
  149121. private _disable;
  149122. /**
  149123. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  149124. */
  149125. markAsDirty(): void;
  149126. private _update;
  149127. /**
  149128. * Disposes the prepass renderer.
  149129. */
  149130. dispose(): void;
  149131. }
  149132. }
  149133. declare module BABYLON {
  149134. interface AbstractScene {
  149135. /** @hidden (Backing field) */
  149136. _prePassRenderer: Nullable<PrePassRenderer>;
  149137. /**
  149138. * Gets or Sets the current prepass renderer associated to the scene.
  149139. */
  149140. prePassRenderer: Nullable<PrePassRenderer>;
  149141. /**
  149142. * Enables the prepass and associates it with the scene
  149143. * @returns the PrePassRenderer
  149144. */
  149145. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  149146. /**
  149147. * Disables the prepass associated with the scene
  149148. */
  149149. disablePrePassRenderer(): void;
  149150. }
  149151. /**
  149152. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  149153. * in several rendering techniques.
  149154. */
  149155. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  149156. /**
  149157. * The component name helpful to identify the component in the list of scene components.
  149158. */
  149159. readonly name: string;
  149160. /**
  149161. * The scene the component belongs to.
  149162. */
  149163. scene: Scene;
  149164. /**
  149165. * Creates a new instance of the component for the given scene
  149166. * @param scene Defines the scene to register the component in
  149167. */
  149168. constructor(scene: Scene);
  149169. /**
  149170. * Registers the component in a given scene
  149171. */
  149172. register(): void;
  149173. private _beforeCameraDraw;
  149174. private _afterCameraDraw;
  149175. private _beforeClearStage;
  149176. /**
  149177. * Serializes the component data to the specified json object
  149178. * @param serializationObject The object to serialize to
  149179. */
  149180. serialize(serializationObject: any): void;
  149181. /**
  149182. * Adds all the elements from the container to the scene
  149183. * @param container the container holding the elements
  149184. */
  149185. addFromContainer(container: AbstractScene): void;
  149186. /**
  149187. * Removes all the elements in the container from the scene
  149188. * @param container contains the elements to remove
  149189. * @param dispose if the removed element should be disposed (default: false)
  149190. */
  149191. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  149192. /**
  149193. * Rebuilds the elements related to this component in case of
  149194. * context lost for instance.
  149195. */
  149196. rebuild(): void;
  149197. /**
  149198. * Disposes the component and the associated ressources
  149199. */
  149200. dispose(): void;
  149201. }
  149202. }
  149203. declare module BABYLON {
  149204. /** @hidden */
  149205. export var outlinePixelShader: {
  149206. name: string;
  149207. shader: string;
  149208. };
  149209. }
  149210. declare module BABYLON {
  149211. /** @hidden */
  149212. export var outlineVertexShader: {
  149213. name: string;
  149214. shader: string;
  149215. };
  149216. }
  149217. declare module BABYLON {
  149218. interface Scene {
  149219. /** @hidden */
  149220. _outlineRenderer: OutlineRenderer;
  149221. /**
  149222. * Gets the outline renderer associated with the scene
  149223. * @returns a OutlineRenderer
  149224. */
  149225. getOutlineRenderer(): OutlineRenderer;
  149226. }
  149227. interface AbstractMesh {
  149228. /** @hidden (Backing field) */
  149229. _renderOutline: boolean;
  149230. /**
  149231. * Gets or sets a boolean indicating if the outline must be rendered as well
  149232. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  149233. */
  149234. renderOutline: boolean;
  149235. /** @hidden (Backing field) */
  149236. _renderOverlay: boolean;
  149237. /**
  149238. * Gets or sets a boolean indicating if the overlay must be rendered as well
  149239. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  149240. */
  149241. renderOverlay: boolean;
  149242. }
  149243. /**
  149244. * This class is responsible to draw bothe outline/overlay of meshes.
  149245. * It should not be used directly but through the available method on mesh.
  149246. */
  149247. export class OutlineRenderer implements ISceneComponent {
  149248. /**
  149249. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  149250. */
  149251. private static _StencilReference;
  149252. /**
  149253. * The name of the component. Each component must have a unique name.
  149254. */
  149255. name: string;
  149256. /**
  149257. * The scene the component belongs to.
  149258. */
  149259. scene: Scene;
  149260. /**
  149261. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  149262. */
  149263. zOffset: number;
  149264. private _engine;
  149265. private _effect;
  149266. private _cachedDefines;
  149267. private _savedDepthWrite;
  149268. /**
  149269. * Instantiates a new outline renderer. (There could be only one per scene).
  149270. * @param scene Defines the scene it belongs to
  149271. */
  149272. constructor(scene: Scene);
  149273. /**
  149274. * Register the component to one instance of a scene.
  149275. */
  149276. register(): void;
  149277. /**
  149278. * Rebuilds the elements related to this component in case of
  149279. * context lost for instance.
  149280. */
  149281. rebuild(): void;
  149282. /**
  149283. * Disposes the component and the associated ressources.
  149284. */
  149285. dispose(): void;
  149286. /**
  149287. * Renders the outline in the canvas.
  149288. * @param subMesh Defines the sumesh to render
  149289. * @param batch Defines the batch of meshes in case of instances
  149290. * @param useOverlay Defines if the rendering is for the overlay or the outline
  149291. */
  149292. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  149293. /**
  149294. * Returns whether or not the outline renderer is ready for a given submesh.
  149295. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  149296. * @param subMesh Defines the submesh to check readyness for
  149297. * @param useInstances Defines wheter wee are trying to render instances or not
  149298. * @returns true if ready otherwise false
  149299. */
  149300. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  149301. private _beforeRenderingMesh;
  149302. private _afterRenderingMesh;
  149303. }
  149304. }
  149305. declare module BABYLON {
  149306. /**
  149307. * Defines the basic options interface of a Sprite Frame Source Size.
  149308. */
  149309. export interface ISpriteJSONSpriteSourceSize {
  149310. /**
  149311. * number of the original width of the Frame
  149312. */
  149313. w: number;
  149314. /**
  149315. * number of the original height of the Frame
  149316. */
  149317. h: number;
  149318. }
  149319. /**
  149320. * Defines the basic options interface of a Sprite Frame Data.
  149321. */
  149322. export interface ISpriteJSONSpriteFrameData {
  149323. /**
  149324. * number of the x offset of the Frame
  149325. */
  149326. x: number;
  149327. /**
  149328. * number of the y offset of the Frame
  149329. */
  149330. y: number;
  149331. /**
  149332. * number of the width of the Frame
  149333. */
  149334. w: number;
  149335. /**
  149336. * number of the height of the Frame
  149337. */
  149338. h: number;
  149339. }
  149340. /**
  149341. * Defines the basic options interface of a JSON Sprite.
  149342. */
  149343. export interface ISpriteJSONSprite {
  149344. /**
  149345. * string name of the Frame
  149346. */
  149347. filename: string;
  149348. /**
  149349. * ISpriteJSONSpriteFrame basic object of the frame data
  149350. */
  149351. frame: ISpriteJSONSpriteFrameData;
  149352. /**
  149353. * boolean to flag is the frame was rotated.
  149354. */
  149355. rotated: boolean;
  149356. /**
  149357. * boolean to flag is the frame was trimmed.
  149358. */
  149359. trimmed: boolean;
  149360. /**
  149361. * ISpriteJSONSpriteFrame basic object of the source data
  149362. */
  149363. spriteSourceSize: ISpriteJSONSpriteFrameData;
  149364. /**
  149365. * ISpriteJSONSpriteFrame basic object of the source data
  149366. */
  149367. sourceSize: ISpriteJSONSpriteSourceSize;
  149368. }
  149369. /**
  149370. * Defines the basic options interface of a JSON atlas.
  149371. */
  149372. export interface ISpriteJSONAtlas {
  149373. /**
  149374. * Array of objects that contain the frame data.
  149375. */
  149376. frames: Array<ISpriteJSONSprite>;
  149377. /**
  149378. * object basic object containing the sprite meta data.
  149379. */
  149380. meta?: object;
  149381. }
  149382. }
  149383. declare module BABYLON {
  149384. /** @hidden */
  149385. export var spriteMapPixelShader: {
  149386. name: string;
  149387. shader: string;
  149388. };
  149389. }
  149390. declare module BABYLON {
  149391. /** @hidden */
  149392. export var spriteMapVertexShader: {
  149393. name: string;
  149394. shader: string;
  149395. };
  149396. }
  149397. declare module BABYLON {
  149398. /**
  149399. * Defines the basic options interface of a SpriteMap
  149400. */
  149401. export interface ISpriteMapOptions {
  149402. /**
  149403. * Vector2 of the number of cells in the grid.
  149404. */
  149405. stageSize?: Vector2;
  149406. /**
  149407. * Vector2 of the size of the output plane in World Units.
  149408. */
  149409. outputSize?: Vector2;
  149410. /**
  149411. * Vector3 of the position of the output plane in World Units.
  149412. */
  149413. outputPosition?: Vector3;
  149414. /**
  149415. * Vector3 of the rotation of the output plane.
  149416. */
  149417. outputRotation?: Vector3;
  149418. /**
  149419. * number of layers that the system will reserve in resources.
  149420. */
  149421. layerCount?: number;
  149422. /**
  149423. * number of max animation frames a single cell will reserve in resources.
  149424. */
  149425. maxAnimationFrames?: number;
  149426. /**
  149427. * number cell index of the base tile when the system compiles.
  149428. */
  149429. baseTile?: number;
  149430. /**
  149431. * boolean flip the sprite after its been repositioned by the framing data.
  149432. */
  149433. flipU?: boolean;
  149434. /**
  149435. * Vector3 scalar of the global RGB values of the SpriteMap.
  149436. */
  149437. colorMultiply?: Vector3;
  149438. }
  149439. /**
  149440. * Defines the IDisposable interface in order to be cleanable from resources.
  149441. */
  149442. export interface ISpriteMap extends IDisposable {
  149443. /**
  149444. * String name of the SpriteMap.
  149445. */
  149446. name: string;
  149447. /**
  149448. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  149449. */
  149450. atlasJSON: ISpriteJSONAtlas;
  149451. /**
  149452. * Texture of the SpriteMap.
  149453. */
  149454. spriteSheet: Texture;
  149455. /**
  149456. * The parameters to initialize the SpriteMap with.
  149457. */
  149458. options: ISpriteMapOptions;
  149459. }
  149460. /**
  149461. * Class used to manage a grid restricted sprite deployment on an Output plane.
  149462. */
  149463. export class SpriteMap implements ISpriteMap {
  149464. /** The Name of the spriteMap */
  149465. name: string;
  149466. /** The JSON file with the frame and meta data */
  149467. atlasJSON: ISpriteJSONAtlas;
  149468. /** The systems Sprite Sheet Texture */
  149469. spriteSheet: Texture;
  149470. /** Arguments passed with the Constructor */
  149471. options: ISpriteMapOptions;
  149472. /** Public Sprite Storage array, parsed from atlasJSON */
  149473. sprites: Array<ISpriteJSONSprite>;
  149474. /** Returns the Number of Sprites in the System */
  149475. get spriteCount(): number;
  149476. /** Returns the Position of Output Plane*/
  149477. get position(): Vector3;
  149478. /** Returns the Position of Output Plane*/
  149479. set position(v: Vector3);
  149480. /** Returns the Rotation of Output Plane*/
  149481. get rotation(): Vector3;
  149482. /** Returns the Rotation of Output Plane*/
  149483. set rotation(v: Vector3);
  149484. /** Sets the AnimationMap*/
  149485. get animationMap(): RawTexture;
  149486. /** Sets the AnimationMap*/
  149487. set animationMap(v: RawTexture);
  149488. /** Scene that the SpriteMap was created in */
  149489. private _scene;
  149490. /** Texture Buffer of Float32 that holds tile frame data*/
  149491. private _frameMap;
  149492. /** Texture Buffers of Float32 that holds tileMap data*/
  149493. private _tileMaps;
  149494. /** Texture Buffer of Float32 that holds Animation Data*/
  149495. private _animationMap;
  149496. /** Custom ShaderMaterial Central to the System*/
  149497. private _material;
  149498. /** Custom ShaderMaterial Central to the System*/
  149499. private _output;
  149500. /** Systems Time Ticker*/
  149501. private _time;
  149502. /**
  149503. * Creates a new SpriteMap
  149504. * @param name defines the SpriteMaps Name
  149505. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  149506. * @param spriteSheet is the Texture that the Sprites are on.
  149507. * @param options a basic deployment configuration
  149508. * @param scene The Scene that the map is deployed on
  149509. */
  149510. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  149511. /**
  149512. * Returns tileID location
  149513. * @returns Vector2 the cell position ID
  149514. */
  149515. getTileID(): Vector2;
  149516. /**
  149517. * Gets the UV location of the mouse over the SpriteMap.
  149518. * @returns Vector2 the UV position of the mouse interaction
  149519. */
  149520. getMousePosition(): Vector2;
  149521. /**
  149522. * Creates the "frame" texture Buffer
  149523. * -------------------------------------
  149524. * Structure of frames
  149525. * "filename": "Falling-Water-2.png",
  149526. * "frame": {"x":69,"y":103,"w":24,"h":32},
  149527. * "rotated": true,
  149528. * "trimmed": true,
  149529. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  149530. * "sourceSize": {"w":32,"h":32}
  149531. * @returns RawTexture of the frameMap
  149532. */
  149533. private _createFrameBuffer;
  149534. /**
  149535. * Creates the tileMap texture Buffer
  149536. * @param buffer normally and array of numbers, or a false to generate from scratch
  149537. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  149538. * @returns RawTexture of the tileMap
  149539. */
  149540. private _createTileBuffer;
  149541. /**
  149542. * Modifies the data of the tileMaps
  149543. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  149544. * @param pos is the iVector2 Coordinates of the Tile
  149545. * @param tile The SpriteIndex of the new Tile
  149546. */
  149547. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  149548. /**
  149549. * Creates the animationMap texture Buffer
  149550. * @param buffer normally and array of numbers, or a false to generate from scratch
  149551. * @returns RawTexture of the animationMap
  149552. */
  149553. private _createTileAnimationBuffer;
  149554. /**
  149555. * Modifies the data of the animationMap
  149556. * @param cellID is the Index of the Sprite
  149557. * @param _frame is the target Animation frame
  149558. * @param toCell is the Target Index of the next frame of the animation
  149559. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  149560. * @param speed is a global scalar of the time variable on the map.
  149561. */
  149562. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  149563. /**
  149564. * Exports the .tilemaps file
  149565. */
  149566. saveTileMaps(): void;
  149567. /**
  149568. * Imports the .tilemaps file
  149569. * @param url of the .tilemaps file
  149570. */
  149571. loadTileMaps(url: string): void;
  149572. /**
  149573. * Release associated resources
  149574. */
  149575. dispose(): void;
  149576. }
  149577. }
  149578. declare module BABYLON {
  149579. /**
  149580. * Class used to manage multiple sprites of different sizes on the same spritesheet
  149581. * @see https://doc.babylonjs.com/babylon101/sprites
  149582. */
  149583. export class SpritePackedManager extends SpriteManager {
  149584. /** defines the packed manager's name */
  149585. name: string;
  149586. /**
  149587. * Creates a new sprite manager from a packed sprite sheet
  149588. * @param name defines the manager's name
  149589. * @param imgUrl defines the sprite sheet url
  149590. * @param capacity defines the maximum allowed number of sprites
  149591. * @param scene defines the hosting scene
  149592. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  149593. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  149594. * @param samplingMode defines the smapling mode to use with spritesheet
  149595. * @param fromPacked set to true; do not alter
  149596. */
  149597. constructor(
  149598. /** defines the packed manager's name */
  149599. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  149600. }
  149601. }
  149602. declare module BABYLON {
  149603. /**
  149604. * Defines the list of states available for a task inside a AssetsManager
  149605. */
  149606. export enum AssetTaskState {
  149607. /**
  149608. * Initialization
  149609. */
  149610. INIT = 0,
  149611. /**
  149612. * Running
  149613. */
  149614. RUNNING = 1,
  149615. /**
  149616. * Done
  149617. */
  149618. DONE = 2,
  149619. /**
  149620. * Error
  149621. */
  149622. ERROR = 3
  149623. }
  149624. /**
  149625. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  149626. */
  149627. export abstract class AbstractAssetTask {
  149628. /**
  149629. * Task name
  149630. */ name: string;
  149631. /**
  149632. * Callback called when the task is successful
  149633. */
  149634. onSuccess: (task: any) => void;
  149635. /**
  149636. * Callback called when the task is not successful
  149637. */
  149638. onError: (task: any, message?: string, exception?: any) => void;
  149639. /**
  149640. * Creates a new AssetsManager
  149641. * @param name defines the name of the task
  149642. */
  149643. constructor(
  149644. /**
  149645. * Task name
  149646. */ name: string);
  149647. private _isCompleted;
  149648. private _taskState;
  149649. private _errorObject;
  149650. /**
  149651. * Get if the task is completed
  149652. */
  149653. get isCompleted(): boolean;
  149654. /**
  149655. * Gets the current state of the task
  149656. */
  149657. get taskState(): AssetTaskState;
  149658. /**
  149659. * Gets the current error object (if task is in error)
  149660. */
  149661. get errorObject(): {
  149662. message?: string;
  149663. exception?: any;
  149664. };
  149665. /**
  149666. * Internal only
  149667. * @hidden
  149668. */
  149669. _setErrorObject(message?: string, exception?: any): void;
  149670. /**
  149671. * Execute the current task
  149672. * @param scene defines the scene where you want your assets to be loaded
  149673. * @param onSuccess is a callback called when the task is successfully executed
  149674. * @param onError is a callback called if an error occurs
  149675. */
  149676. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149677. /**
  149678. * Execute the current task
  149679. * @param scene defines the scene where you want your assets to be loaded
  149680. * @param onSuccess is a callback called when the task is successfully executed
  149681. * @param onError is a callback called if an error occurs
  149682. */
  149683. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149684. /**
  149685. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  149686. * This can be used with failed tasks that have the reason for failure fixed.
  149687. */
  149688. reset(): void;
  149689. private onErrorCallback;
  149690. private onDoneCallback;
  149691. }
  149692. /**
  149693. * Define the interface used by progress events raised during assets loading
  149694. */
  149695. export interface IAssetsProgressEvent {
  149696. /**
  149697. * Defines the number of remaining tasks to process
  149698. */
  149699. remainingCount: number;
  149700. /**
  149701. * Defines the total number of tasks
  149702. */
  149703. totalCount: number;
  149704. /**
  149705. * Defines the task that was just processed
  149706. */
  149707. task: AbstractAssetTask;
  149708. }
  149709. /**
  149710. * Class used to share progress information about assets loading
  149711. */
  149712. export class AssetsProgressEvent implements IAssetsProgressEvent {
  149713. /**
  149714. * Defines the number of remaining tasks to process
  149715. */
  149716. remainingCount: number;
  149717. /**
  149718. * Defines the total number of tasks
  149719. */
  149720. totalCount: number;
  149721. /**
  149722. * Defines the task that was just processed
  149723. */
  149724. task: AbstractAssetTask;
  149725. /**
  149726. * Creates a AssetsProgressEvent
  149727. * @param remainingCount defines the number of remaining tasks to process
  149728. * @param totalCount defines the total number of tasks
  149729. * @param task defines the task that was just processed
  149730. */
  149731. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  149732. }
  149733. /**
  149734. * Define a task used by AssetsManager to load meshes
  149735. */
  149736. export class MeshAssetTask extends AbstractAssetTask {
  149737. /**
  149738. * Defines the name of the task
  149739. */
  149740. name: string;
  149741. /**
  149742. * Defines the list of mesh's names you want to load
  149743. */
  149744. meshesNames: any;
  149745. /**
  149746. * Defines the root url to use as a base to load your meshes and associated resources
  149747. */
  149748. rootUrl: string;
  149749. /**
  149750. * Defines the filename or File of the scene to load from
  149751. */
  149752. sceneFilename: string | File;
  149753. /**
  149754. * Gets the list of loaded meshes
  149755. */
  149756. loadedMeshes: Array<AbstractMesh>;
  149757. /**
  149758. * Gets the list of loaded particle systems
  149759. */
  149760. loadedParticleSystems: Array<IParticleSystem>;
  149761. /**
  149762. * Gets the list of loaded skeletons
  149763. */
  149764. loadedSkeletons: Array<Skeleton>;
  149765. /**
  149766. * Gets the list of loaded animation groups
  149767. */
  149768. loadedAnimationGroups: Array<AnimationGroup>;
  149769. /**
  149770. * Callback called when the task is successful
  149771. */
  149772. onSuccess: (task: MeshAssetTask) => void;
  149773. /**
  149774. * Callback called when the task is successful
  149775. */
  149776. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  149777. /**
  149778. * Creates a new MeshAssetTask
  149779. * @param name defines the name of the task
  149780. * @param meshesNames defines the list of mesh's names you want to load
  149781. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  149782. * @param sceneFilename defines the filename or File of the scene to load from
  149783. */
  149784. constructor(
  149785. /**
  149786. * Defines the name of the task
  149787. */
  149788. name: string,
  149789. /**
  149790. * Defines the list of mesh's names you want to load
  149791. */
  149792. meshesNames: any,
  149793. /**
  149794. * Defines the root url to use as a base to load your meshes and associated resources
  149795. */
  149796. rootUrl: string,
  149797. /**
  149798. * Defines the filename or File of the scene to load from
  149799. */
  149800. sceneFilename: string | File);
  149801. /**
  149802. * Execute the current task
  149803. * @param scene defines the scene where you want your assets to be loaded
  149804. * @param onSuccess is a callback called when the task is successfully executed
  149805. * @param onError is a callback called if an error occurs
  149806. */
  149807. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149808. }
  149809. /**
  149810. * Define a task used by AssetsManager to load text content
  149811. */
  149812. export class TextFileAssetTask extends AbstractAssetTask {
  149813. /**
  149814. * Defines the name of the task
  149815. */
  149816. name: string;
  149817. /**
  149818. * Defines the location of the file to load
  149819. */
  149820. url: string;
  149821. /**
  149822. * Gets the loaded text string
  149823. */
  149824. text: string;
  149825. /**
  149826. * Callback called when the task is successful
  149827. */
  149828. onSuccess: (task: TextFileAssetTask) => void;
  149829. /**
  149830. * Callback called when the task is successful
  149831. */
  149832. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  149833. /**
  149834. * Creates a new TextFileAssetTask object
  149835. * @param name defines the name of the task
  149836. * @param url defines the location of the file to load
  149837. */
  149838. constructor(
  149839. /**
  149840. * Defines the name of the task
  149841. */
  149842. name: string,
  149843. /**
  149844. * Defines the location of the file to load
  149845. */
  149846. url: string);
  149847. /**
  149848. * Execute the current task
  149849. * @param scene defines the scene where you want your assets to be loaded
  149850. * @param onSuccess is a callback called when the task is successfully executed
  149851. * @param onError is a callback called if an error occurs
  149852. */
  149853. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149854. }
  149855. /**
  149856. * Define a task used by AssetsManager to load binary data
  149857. */
  149858. export class BinaryFileAssetTask extends AbstractAssetTask {
  149859. /**
  149860. * Defines the name of the task
  149861. */
  149862. name: string;
  149863. /**
  149864. * Defines the location of the file to load
  149865. */
  149866. url: string;
  149867. /**
  149868. * Gets the lodaded data (as an array buffer)
  149869. */
  149870. data: ArrayBuffer;
  149871. /**
  149872. * Callback called when the task is successful
  149873. */
  149874. onSuccess: (task: BinaryFileAssetTask) => void;
  149875. /**
  149876. * Callback called when the task is successful
  149877. */
  149878. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  149879. /**
  149880. * Creates a new BinaryFileAssetTask object
  149881. * @param name defines the name of the new task
  149882. * @param url defines the location of the file to load
  149883. */
  149884. constructor(
  149885. /**
  149886. * Defines the name of the task
  149887. */
  149888. name: string,
  149889. /**
  149890. * Defines the location of the file to load
  149891. */
  149892. url: string);
  149893. /**
  149894. * Execute the current task
  149895. * @param scene defines the scene where you want your assets to be loaded
  149896. * @param onSuccess is a callback called when the task is successfully executed
  149897. * @param onError is a callback called if an error occurs
  149898. */
  149899. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149900. }
  149901. /**
  149902. * Define a task used by AssetsManager to load images
  149903. */
  149904. export class ImageAssetTask extends AbstractAssetTask {
  149905. /**
  149906. * Defines the name of the task
  149907. */
  149908. name: string;
  149909. /**
  149910. * Defines the location of the image to load
  149911. */
  149912. url: string;
  149913. /**
  149914. * Gets the loaded images
  149915. */
  149916. image: HTMLImageElement;
  149917. /**
  149918. * Callback called when the task is successful
  149919. */
  149920. onSuccess: (task: ImageAssetTask) => void;
  149921. /**
  149922. * Callback called when the task is successful
  149923. */
  149924. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  149925. /**
  149926. * Creates a new ImageAssetTask
  149927. * @param name defines the name of the task
  149928. * @param url defines the location of the image to load
  149929. */
  149930. constructor(
  149931. /**
  149932. * Defines the name of the task
  149933. */
  149934. name: string,
  149935. /**
  149936. * Defines the location of the image to load
  149937. */
  149938. url: string);
  149939. /**
  149940. * Execute the current task
  149941. * @param scene defines the scene where you want your assets to be loaded
  149942. * @param onSuccess is a callback called when the task is successfully executed
  149943. * @param onError is a callback called if an error occurs
  149944. */
  149945. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149946. }
  149947. /**
  149948. * Defines the interface used by texture loading tasks
  149949. */
  149950. export interface ITextureAssetTask<TEX extends BaseTexture> {
  149951. /**
  149952. * Gets the loaded texture
  149953. */
  149954. texture: TEX;
  149955. }
  149956. /**
  149957. * Define a task used by AssetsManager to load 2D textures
  149958. */
  149959. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  149960. /**
  149961. * Defines the name of the task
  149962. */
  149963. name: string;
  149964. /**
  149965. * Defines the location of the file to load
  149966. */
  149967. url: string;
  149968. /**
  149969. * Defines if mipmap should not be generated (default is false)
  149970. */
  149971. noMipmap?: boolean | undefined;
  149972. /**
  149973. * Defines if texture must be inverted on Y axis (default is true)
  149974. */
  149975. invertY: boolean;
  149976. /**
  149977. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  149978. */
  149979. samplingMode: number;
  149980. /**
  149981. * Gets the loaded texture
  149982. */
  149983. texture: Texture;
  149984. /**
  149985. * Callback called when the task is successful
  149986. */
  149987. onSuccess: (task: TextureAssetTask) => void;
  149988. /**
  149989. * Callback called when the task is successful
  149990. */
  149991. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  149992. /**
  149993. * Creates a new TextureAssetTask object
  149994. * @param name defines the name of the task
  149995. * @param url defines the location of the file to load
  149996. * @param noMipmap defines if mipmap should not be generated (default is false)
  149997. * @param invertY defines if texture must be inverted on Y axis (default is true)
  149998. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  149999. */
  150000. constructor(
  150001. /**
  150002. * Defines the name of the task
  150003. */
  150004. name: string,
  150005. /**
  150006. * Defines the location of the file to load
  150007. */
  150008. url: string,
  150009. /**
  150010. * Defines if mipmap should not be generated (default is false)
  150011. */
  150012. noMipmap?: boolean | undefined,
  150013. /**
  150014. * Defines if texture must be inverted on Y axis (default is true)
  150015. */
  150016. invertY?: boolean,
  150017. /**
  150018. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  150019. */
  150020. samplingMode?: number);
  150021. /**
  150022. * Execute the current task
  150023. * @param scene defines the scene where you want your assets to be loaded
  150024. * @param onSuccess is a callback called when the task is successfully executed
  150025. * @param onError is a callback called if an error occurs
  150026. */
  150027. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150028. }
  150029. /**
  150030. * Define a task used by AssetsManager to load cube textures
  150031. */
  150032. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  150033. /**
  150034. * Defines the name of the task
  150035. */
  150036. name: string;
  150037. /**
  150038. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  150039. */
  150040. url: string;
  150041. /**
  150042. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  150043. */
  150044. extensions?: string[] | undefined;
  150045. /**
  150046. * Defines if mipmaps should not be generated (default is false)
  150047. */
  150048. noMipmap?: boolean | undefined;
  150049. /**
  150050. * Defines the explicit list of files (undefined by default)
  150051. */
  150052. files?: string[] | undefined;
  150053. /**
  150054. * Gets the loaded texture
  150055. */
  150056. texture: CubeTexture;
  150057. /**
  150058. * Callback called when the task is successful
  150059. */
  150060. onSuccess: (task: CubeTextureAssetTask) => void;
  150061. /**
  150062. * Callback called when the task is successful
  150063. */
  150064. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  150065. /**
  150066. * Creates a new CubeTextureAssetTask
  150067. * @param name defines the name of the task
  150068. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  150069. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  150070. * @param noMipmap defines if mipmaps should not be generated (default is false)
  150071. * @param files defines the explicit list of files (undefined by default)
  150072. */
  150073. constructor(
  150074. /**
  150075. * Defines the name of the task
  150076. */
  150077. name: string,
  150078. /**
  150079. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  150080. */
  150081. url: string,
  150082. /**
  150083. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  150084. */
  150085. extensions?: string[] | undefined,
  150086. /**
  150087. * Defines if mipmaps should not be generated (default is false)
  150088. */
  150089. noMipmap?: boolean | undefined,
  150090. /**
  150091. * Defines the explicit list of files (undefined by default)
  150092. */
  150093. files?: string[] | undefined);
  150094. /**
  150095. * Execute the current task
  150096. * @param scene defines the scene where you want your assets to be loaded
  150097. * @param onSuccess is a callback called when the task is successfully executed
  150098. * @param onError is a callback called if an error occurs
  150099. */
  150100. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150101. }
  150102. /**
  150103. * Define a task used by AssetsManager to load HDR cube textures
  150104. */
  150105. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  150106. /**
  150107. * Defines the name of the task
  150108. */
  150109. name: string;
  150110. /**
  150111. * Defines the location of the file to load
  150112. */
  150113. url: string;
  150114. /**
  150115. * Defines the desired size (the more it increases the longer the generation will be)
  150116. */
  150117. size: number;
  150118. /**
  150119. * Defines if mipmaps should not be generated (default is false)
  150120. */
  150121. noMipmap: boolean;
  150122. /**
  150123. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  150124. */
  150125. generateHarmonics: boolean;
  150126. /**
  150127. * 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)
  150128. */
  150129. gammaSpace: boolean;
  150130. /**
  150131. * Internal Use Only
  150132. */
  150133. reserved: boolean;
  150134. /**
  150135. * Gets the loaded texture
  150136. */
  150137. texture: HDRCubeTexture;
  150138. /**
  150139. * Callback called when the task is successful
  150140. */
  150141. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  150142. /**
  150143. * Callback called when the task is successful
  150144. */
  150145. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  150146. /**
  150147. * Creates a new HDRCubeTextureAssetTask object
  150148. * @param name defines the name of the task
  150149. * @param url defines the location of the file to load
  150150. * @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.
  150151. * @param noMipmap defines if mipmaps should not be generated (default is false)
  150152. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  150153. * @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)
  150154. * @param reserved Internal use only
  150155. */
  150156. constructor(
  150157. /**
  150158. * Defines the name of the task
  150159. */
  150160. name: string,
  150161. /**
  150162. * Defines the location of the file to load
  150163. */
  150164. url: string,
  150165. /**
  150166. * Defines the desired size (the more it increases the longer the generation will be)
  150167. */
  150168. size: number,
  150169. /**
  150170. * Defines if mipmaps should not be generated (default is false)
  150171. */
  150172. noMipmap?: boolean,
  150173. /**
  150174. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  150175. */
  150176. generateHarmonics?: boolean,
  150177. /**
  150178. * 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)
  150179. */
  150180. gammaSpace?: boolean,
  150181. /**
  150182. * Internal Use Only
  150183. */
  150184. reserved?: boolean);
  150185. /**
  150186. * Execute the current task
  150187. * @param scene defines the scene where you want your assets to be loaded
  150188. * @param onSuccess is a callback called when the task is successfully executed
  150189. * @param onError is a callback called if an error occurs
  150190. */
  150191. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150192. }
  150193. /**
  150194. * Define a task used by AssetsManager to load Equirectangular cube textures
  150195. */
  150196. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  150197. /**
  150198. * Defines the name of the task
  150199. */
  150200. name: string;
  150201. /**
  150202. * Defines the location of the file to load
  150203. */
  150204. url: string;
  150205. /**
  150206. * Defines the desired size (the more it increases the longer the generation will be)
  150207. */
  150208. size: number;
  150209. /**
  150210. * Defines if mipmaps should not be generated (default is false)
  150211. */
  150212. noMipmap: boolean;
  150213. /**
  150214. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  150215. * but the standard material would require them in Gamma space) (default is true)
  150216. */
  150217. gammaSpace: boolean;
  150218. /**
  150219. * Gets the loaded texture
  150220. */
  150221. texture: EquiRectangularCubeTexture;
  150222. /**
  150223. * Callback called when the task is successful
  150224. */
  150225. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  150226. /**
  150227. * Callback called when the task is successful
  150228. */
  150229. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  150230. /**
  150231. * Creates a new EquiRectangularCubeTextureAssetTask object
  150232. * @param name defines the name of the task
  150233. * @param url defines the location of the file to load
  150234. * @param size defines the desired size (the more it increases the longer the generation will be)
  150235. * If the size is omitted this implies you are using a preprocessed cubemap.
  150236. * @param noMipmap defines if mipmaps should not be generated (default is false)
  150237. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  150238. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  150239. * (default is true)
  150240. */
  150241. constructor(
  150242. /**
  150243. * Defines the name of the task
  150244. */
  150245. name: string,
  150246. /**
  150247. * Defines the location of the file to load
  150248. */
  150249. url: string,
  150250. /**
  150251. * Defines the desired size (the more it increases the longer the generation will be)
  150252. */
  150253. size: number,
  150254. /**
  150255. * Defines if mipmaps should not be generated (default is false)
  150256. */
  150257. noMipmap?: boolean,
  150258. /**
  150259. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  150260. * but the standard material would require them in Gamma space) (default is true)
  150261. */
  150262. gammaSpace?: boolean);
  150263. /**
  150264. * Execute the current task
  150265. * @param scene defines the scene where you want your assets to be loaded
  150266. * @param onSuccess is a callback called when the task is successfully executed
  150267. * @param onError is a callback called if an error occurs
  150268. */
  150269. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150270. }
  150271. /**
  150272. * This class can be used to easily import assets into a scene
  150273. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  150274. */
  150275. export class AssetsManager {
  150276. private _scene;
  150277. private _isLoading;
  150278. protected _tasks: AbstractAssetTask[];
  150279. protected _waitingTasksCount: number;
  150280. protected _totalTasksCount: number;
  150281. /**
  150282. * Callback called when all tasks are processed
  150283. */
  150284. onFinish: (tasks: AbstractAssetTask[]) => void;
  150285. /**
  150286. * Callback called when a task is successful
  150287. */
  150288. onTaskSuccess: (task: AbstractAssetTask) => void;
  150289. /**
  150290. * Callback called when a task had an error
  150291. */
  150292. onTaskError: (task: AbstractAssetTask) => void;
  150293. /**
  150294. * Callback called when a task is done (whatever the result is)
  150295. */
  150296. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  150297. /**
  150298. * Observable called when all tasks are processed
  150299. */
  150300. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  150301. /**
  150302. * Observable called when a task had an error
  150303. */
  150304. onTaskErrorObservable: Observable<AbstractAssetTask>;
  150305. /**
  150306. * Observable called when all tasks were executed
  150307. */
  150308. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  150309. /**
  150310. * Observable called when a task is done (whatever the result is)
  150311. */
  150312. onProgressObservable: Observable<IAssetsProgressEvent>;
  150313. /**
  150314. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  150315. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  150316. */
  150317. useDefaultLoadingScreen: boolean;
  150318. /**
  150319. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  150320. * when all assets have been downloaded.
  150321. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  150322. */
  150323. autoHideLoadingUI: boolean;
  150324. /**
  150325. * Creates a new AssetsManager
  150326. * @param scene defines the scene to work on
  150327. */
  150328. constructor(scene: Scene);
  150329. /**
  150330. * Add a MeshAssetTask to the list of active tasks
  150331. * @param taskName defines the name of the new task
  150332. * @param meshesNames defines the name of meshes to load
  150333. * @param rootUrl defines the root url to use to locate files
  150334. * @param sceneFilename defines the filename of the scene file
  150335. * @returns a new MeshAssetTask object
  150336. */
  150337. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  150338. /**
  150339. * Add a TextFileAssetTask to the list of active tasks
  150340. * @param taskName defines the name of the new task
  150341. * @param url defines the url of the file to load
  150342. * @returns a new TextFileAssetTask object
  150343. */
  150344. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  150345. /**
  150346. * Add a BinaryFileAssetTask to the list of active tasks
  150347. * @param taskName defines the name of the new task
  150348. * @param url defines the url of the file to load
  150349. * @returns a new BinaryFileAssetTask object
  150350. */
  150351. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  150352. /**
  150353. * Add a ImageAssetTask to the list of active tasks
  150354. * @param taskName defines the name of the new task
  150355. * @param url defines the url of the file to load
  150356. * @returns a new ImageAssetTask object
  150357. */
  150358. addImageTask(taskName: string, url: string): ImageAssetTask;
  150359. /**
  150360. * Add a TextureAssetTask to the list of active tasks
  150361. * @param taskName defines the name of the new task
  150362. * @param url defines the url of the file to load
  150363. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  150364. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  150365. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  150366. * @returns a new TextureAssetTask object
  150367. */
  150368. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  150369. /**
  150370. * Add a CubeTextureAssetTask to the list of active tasks
  150371. * @param taskName defines the name of the new task
  150372. * @param url defines the url of the file to load
  150373. * @param extensions defines the extension to use to load the cube map (can be null)
  150374. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  150375. * @param files defines the list of files to load (can be null)
  150376. * @returns a new CubeTextureAssetTask object
  150377. */
  150378. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  150379. /**
  150380. *
  150381. * Add a HDRCubeTextureAssetTask to the list of active tasks
  150382. * @param taskName defines the name of the new task
  150383. * @param url defines the url of the file to load
  150384. * @param size defines the size you want for the cubemap (can be null)
  150385. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  150386. * @param generateHarmonics defines if you want to automatically generate (true by default)
  150387. * @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)
  150388. * @param reserved Internal use only
  150389. * @returns a new HDRCubeTextureAssetTask object
  150390. */
  150391. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  150392. /**
  150393. *
  150394. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  150395. * @param taskName defines the name of the new task
  150396. * @param url defines the url of the file to load
  150397. * @param size defines the size you want for the cubemap (can be null)
  150398. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  150399. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  150400. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  150401. * @returns a new EquiRectangularCubeTextureAssetTask object
  150402. */
  150403. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  150404. /**
  150405. * Remove a task from the assets manager.
  150406. * @param task the task to remove
  150407. */
  150408. removeTask(task: AbstractAssetTask): void;
  150409. private _decreaseWaitingTasksCount;
  150410. private _runTask;
  150411. /**
  150412. * Reset the AssetsManager and remove all tasks
  150413. * @return the current instance of the AssetsManager
  150414. */
  150415. reset(): AssetsManager;
  150416. /**
  150417. * Start the loading process
  150418. * @return the current instance of the AssetsManager
  150419. */
  150420. load(): AssetsManager;
  150421. /**
  150422. * Start the loading process as an async operation
  150423. * @return a promise returning the list of failed tasks
  150424. */
  150425. loadAsync(): Promise<void>;
  150426. }
  150427. }
  150428. declare module BABYLON {
  150429. /**
  150430. * Wrapper class for promise with external resolve and reject.
  150431. */
  150432. export class Deferred<T> {
  150433. /**
  150434. * The promise associated with this deferred object.
  150435. */
  150436. readonly promise: Promise<T>;
  150437. private _resolve;
  150438. private _reject;
  150439. /**
  150440. * The resolve method of the promise associated with this deferred object.
  150441. */
  150442. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  150443. /**
  150444. * The reject method of the promise associated with this deferred object.
  150445. */
  150446. get reject(): (reason?: any) => void;
  150447. /**
  150448. * Constructor for this deferred object.
  150449. */
  150450. constructor();
  150451. }
  150452. }
  150453. declare module BABYLON {
  150454. /**
  150455. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  150456. */
  150457. export class MeshExploder {
  150458. private _centerMesh;
  150459. private _meshes;
  150460. private _meshesOrigins;
  150461. private _toCenterVectors;
  150462. private _scaledDirection;
  150463. private _newPosition;
  150464. private _centerPosition;
  150465. /**
  150466. * Explodes meshes from a center mesh.
  150467. * @param meshes The meshes to explode.
  150468. * @param centerMesh The mesh to be center of explosion.
  150469. */
  150470. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  150471. private _setCenterMesh;
  150472. /**
  150473. * Get class name
  150474. * @returns "MeshExploder"
  150475. */
  150476. getClassName(): string;
  150477. /**
  150478. * "Exploded meshes"
  150479. * @returns Array of meshes with the centerMesh at index 0.
  150480. */
  150481. getMeshes(): Array<Mesh>;
  150482. /**
  150483. * Explodes meshes giving a specific direction
  150484. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  150485. */
  150486. explode(direction?: number): void;
  150487. }
  150488. }
  150489. declare module BABYLON {
  150490. /**
  150491. * Class used to help managing file picking and drag'n'drop
  150492. */
  150493. export class FilesInput {
  150494. /**
  150495. * List of files ready to be loaded
  150496. */
  150497. static get FilesToLoad(): {
  150498. [key: string]: File;
  150499. };
  150500. /**
  150501. * Callback called when a file is processed
  150502. */
  150503. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  150504. private _engine;
  150505. private _currentScene;
  150506. private _sceneLoadedCallback;
  150507. private _progressCallback;
  150508. private _additionalRenderLoopLogicCallback;
  150509. private _textureLoadingCallback;
  150510. private _startingProcessingFilesCallback;
  150511. private _onReloadCallback;
  150512. private _errorCallback;
  150513. private _elementToMonitor;
  150514. private _sceneFileToLoad;
  150515. private _filesToLoad;
  150516. /**
  150517. * Creates a new FilesInput
  150518. * @param engine defines the rendering engine
  150519. * @param scene defines the hosting scene
  150520. * @param sceneLoadedCallback callback called when scene is loaded
  150521. * @param progressCallback callback called to track progress
  150522. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  150523. * @param textureLoadingCallback callback called when a texture is loading
  150524. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  150525. * @param onReloadCallback callback called when a reload is requested
  150526. * @param errorCallback callback call if an error occurs
  150527. */
  150528. constructor(engine: Engine, scene: Nullable<Scene>, sceneLoadedCallback: Nullable<(sceneFile: File, scene: Scene) => void>, progressCallback: Nullable<(progress: ISceneLoaderProgressEvent) => void>, additionalRenderLoopLogicCallback: Nullable<() => void>, textureLoadingCallback: Nullable<(remaining: number) => void>, startingProcessingFilesCallback: Nullable<(files?: File[]) => void>, onReloadCallback: Nullable<(sceneFile: File) => void>, errorCallback: Nullable<(sceneFile: File, scene: Nullable<Scene>, message: string) => void>);
  150529. private _dragEnterHandler;
  150530. private _dragOverHandler;
  150531. private _dropHandler;
  150532. /**
  150533. * Calls this function to listen to drag'n'drop events on a specific DOM element
  150534. * @param elementToMonitor defines the DOM element to track
  150535. */
  150536. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  150537. /** Gets the current list of files to load */
  150538. get filesToLoad(): File[];
  150539. /**
  150540. * Release all associated resources
  150541. */
  150542. dispose(): void;
  150543. private renderFunction;
  150544. private drag;
  150545. private drop;
  150546. private _traverseFolder;
  150547. private _processFiles;
  150548. /**
  150549. * Load files from a drop event
  150550. * @param event defines the drop event to use as source
  150551. */
  150552. loadFiles(event: any): void;
  150553. private _processReload;
  150554. /**
  150555. * Reload the current scene from the loaded files
  150556. */
  150557. reload(): void;
  150558. }
  150559. }
  150560. declare module BABYLON {
  150561. /**
  150562. * Defines the root class used to create scene optimization to use with SceneOptimizer
  150563. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150564. */
  150565. export class SceneOptimization {
  150566. /**
  150567. * Defines the priority of this optimization (0 by default which means first in the list)
  150568. */
  150569. priority: number;
  150570. /**
  150571. * Gets a string describing the action executed by the current optimization
  150572. * @returns description string
  150573. */
  150574. getDescription(): string;
  150575. /**
  150576. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150577. * @param scene defines the current scene where to apply this optimization
  150578. * @param optimizer defines the current optimizer
  150579. * @returns true if everything that can be done was applied
  150580. */
  150581. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150582. /**
  150583. * Creates the SceneOptimization object
  150584. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  150585. * @param desc defines the description associated with the optimization
  150586. */
  150587. constructor(
  150588. /**
  150589. * Defines the priority of this optimization (0 by default which means first in the list)
  150590. */
  150591. priority?: number);
  150592. }
  150593. /**
  150594. * Defines an optimization used to reduce the size of render target textures
  150595. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150596. */
  150597. export class TextureOptimization extends SceneOptimization {
  150598. /**
  150599. * Defines the priority of this optimization (0 by default which means first in the list)
  150600. */
  150601. priority: number;
  150602. /**
  150603. * 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
  150604. */
  150605. maximumSize: number;
  150606. /**
  150607. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  150608. */
  150609. step: number;
  150610. /**
  150611. * Gets a string describing the action executed by the current optimization
  150612. * @returns description string
  150613. */
  150614. getDescription(): string;
  150615. /**
  150616. * Creates the TextureOptimization object
  150617. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  150618. * @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
  150619. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  150620. */
  150621. constructor(
  150622. /**
  150623. * Defines the priority of this optimization (0 by default which means first in the list)
  150624. */
  150625. priority?: number,
  150626. /**
  150627. * 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
  150628. */
  150629. maximumSize?: number,
  150630. /**
  150631. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  150632. */
  150633. step?: number);
  150634. /**
  150635. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150636. * @param scene defines the current scene where to apply this optimization
  150637. * @param optimizer defines the current optimizer
  150638. * @returns true if everything that can be done was applied
  150639. */
  150640. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150641. }
  150642. /**
  150643. * Defines an optimization used to increase or decrease the rendering resolution
  150644. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150645. */
  150646. export class HardwareScalingOptimization extends SceneOptimization {
  150647. /**
  150648. * Defines the priority of this optimization (0 by default which means first in the list)
  150649. */
  150650. priority: number;
  150651. /**
  150652. * Defines the maximum scale to use (2 by default)
  150653. */
  150654. maximumScale: number;
  150655. /**
  150656. * Defines the step to use between two passes (0.5 by default)
  150657. */
  150658. step: number;
  150659. private _currentScale;
  150660. private _directionOffset;
  150661. /**
  150662. * Gets a string describing the action executed by the current optimization
  150663. * @return description string
  150664. */
  150665. getDescription(): string;
  150666. /**
  150667. * Creates the HardwareScalingOptimization object
  150668. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  150669. * @param maximumScale defines the maximum scale to use (2 by default)
  150670. * @param step defines the step to use between two passes (0.5 by default)
  150671. */
  150672. constructor(
  150673. /**
  150674. * Defines the priority of this optimization (0 by default which means first in the list)
  150675. */
  150676. priority?: number,
  150677. /**
  150678. * Defines the maximum scale to use (2 by default)
  150679. */
  150680. maximumScale?: number,
  150681. /**
  150682. * Defines the step to use between two passes (0.5 by default)
  150683. */
  150684. step?: number);
  150685. /**
  150686. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150687. * @param scene defines the current scene where to apply this optimization
  150688. * @param optimizer defines the current optimizer
  150689. * @returns true if everything that can be done was applied
  150690. */
  150691. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150692. }
  150693. /**
  150694. * Defines an optimization used to remove shadows
  150695. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150696. */
  150697. export class ShadowsOptimization extends SceneOptimization {
  150698. /**
  150699. * Gets a string describing the action executed by the current optimization
  150700. * @return description string
  150701. */
  150702. getDescription(): string;
  150703. /**
  150704. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150705. * @param scene defines the current scene where to apply this optimization
  150706. * @param optimizer defines the current optimizer
  150707. * @returns true if everything that can be done was applied
  150708. */
  150709. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150710. }
  150711. /**
  150712. * Defines an optimization used to turn post-processes off
  150713. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150714. */
  150715. export class PostProcessesOptimization extends SceneOptimization {
  150716. /**
  150717. * Gets a string describing the action executed by the current optimization
  150718. * @return description string
  150719. */
  150720. getDescription(): string;
  150721. /**
  150722. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150723. * @param scene defines the current scene where to apply this optimization
  150724. * @param optimizer defines the current optimizer
  150725. * @returns true if everything that can be done was applied
  150726. */
  150727. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150728. }
  150729. /**
  150730. * Defines an optimization used to turn lens flares off
  150731. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150732. */
  150733. export class LensFlaresOptimization extends SceneOptimization {
  150734. /**
  150735. * Gets a string describing the action executed by the current optimization
  150736. * @return description string
  150737. */
  150738. getDescription(): string;
  150739. /**
  150740. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150741. * @param scene defines the current scene where to apply this optimization
  150742. * @param optimizer defines the current optimizer
  150743. * @returns true if everything that can be done was applied
  150744. */
  150745. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150746. }
  150747. /**
  150748. * Defines an optimization based on user defined callback.
  150749. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150750. */
  150751. export class CustomOptimization extends SceneOptimization {
  150752. /**
  150753. * Callback called to apply the custom optimization.
  150754. */
  150755. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  150756. /**
  150757. * Callback called to get custom description
  150758. */
  150759. onGetDescription: () => string;
  150760. /**
  150761. * Gets a string describing the action executed by the current optimization
  150762. * @returns description string
  150763. */
  150764. getDescription(): string;
  150765. /**
  150766. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150767. * @param scene defines the current scene where to apply this optimization
  150768. * @param optimizer defines the current optimizer
  150769. * @returns true if everything that can be done was applied
  150770. */
  150771. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150772. }
  150773. /**
  150774. * Defines an optimization used to turn particles off
  150775. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150776. */
  150777. export class ParticlesOptimization extends SceneOptimization {
  150778. /**
  150779. * Gets a string describing the action executed by the current optimization
  150780. * @return description string
  150781. */
  150782. getDescription(): string;
  150783. /**
  150784. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150785. * @param scene defines the current scene where to apply this optimization
  150786. * @param optimizer defines the current optimizer
  150787. * @returns true if everything that can be done was applied
  150788. */
  150789. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150790. }
  150791. /**
  150792. * Defines an optimization used to turn render targets off
  150793. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150794. */
  150795. export class RenderTargetsOptimization extends SceneOptimization {
  150796. /**
  150797. * Gets a string describing the action executed by the current optimization
  150798. * @return description string
  150799. */
  150800. getDescription(): string;
  150801. /**
  150802. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150803. * @param scene defines the current scene where to apply this optimization
  150804. * @param optimizer defines the current optimizer
  150805. * @returns true if everything that can be done was applied
  150806. */
  150807. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150808. }
  150809. /**
  150810. * Defines an optimization used to merge meshes with compatible materials
  150811. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150812. */
  150813. export class MergeMeshesOptimization extends SceneOptimization {
  150814. private static _UpdateSelectionTree;
  150815. /**
  150816. * Gets or sets a boolean which defines if optimization octree has to be updated
  150817. */
  150818. static get UpdateSelectionTree(): boolean;
  150819. /**
  150820. * Gets or sets a boolean which defines if optimization octree has to be updated
  150821. */
  150822. static set UpdateSelectionTree(value: boolean);
  150823. /**
  150824. * Gets a string describing the action executed by the current optimization
  150825. * @return description string
  150826. */
  150827. getDescription(): string;
  150828. private _canBeMerged;
  150829. /**
  150830. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150831. * @param scene defines the current scene where to apply this optimization
  150832. * @param optimizer defines the current optimizer
  150833. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  150834. * @returns true if everything that can be done was applied
  150835. */
  150836. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  150837. }
  150838. /**
  150839. * Defines a list of options used by SceneOptimizer
  150840. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150841. */
  150842. export class SceneOptimizerOptions {
  150843. /**
  150844. * Defines the target frame rate to reach (60 by default)
  150845. */
  150846. targetFrameRate: number;
  150847. /**
  150848. * Defines the interval between two checkes (2000ms by default)
  150849. */
  150850. trackerDuration: number;
  150851. /**
  150852. * Gets the list of optimizations to apply
  150853. */
  150854. optimizations: SceneOptimization[];
  150855. /**
  150856. * Creates a new list of options used by SceneOptimizer
  150857. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  150858. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  150859. */
  150860. constructor(
  150861. /**
  150862. * Defines the target frame rate to reach (60 by default)
  150863. */
  150864. targetFrameRate?: number,
  150865. /**
  150866. * Defines the interval between two checkes (2000ms by default)
  150867. */
  150868. trackerDuration?: number);
  150869. /**
  150870. * Add a new optimization
  150871. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  150872. * @returns the current SceneOptimizerOptions
  150873. */
  150874. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  150875. /**
  150876. * Add a new custom optimization
  150877. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  150878. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  150879. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  150880. * @returns the current SceneOptimizerOptions
  150881. */
  150882. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  150883. /**
  150884. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  150885. * @param targetFrameRate defines the target frame rate (60 by default)
  150886. * @returns a SceneOptimizerOptions object
  150887. */
  150888. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  150889. /**
  150890. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  150891. * @param targetFrameRate defines the target frame rate (60 by default)
  150892. * @returns a SceneOptimizerOptions object
  150893. */
  150894. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  150895. /**
  150896. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  150897. * @param targetFrameRate defines the target frame rate (60 by default)
  150898. * @returns a SceneOptimizerOptions object
  150899. */
  150900. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  150901. }
  150902. /**
  150903. * Class used to run optimizations in order to reach a target frame rate
  150904. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150905. */
  150906. export class SceneOptimizer implements IDisposable {
  150907. private _isRunning;
  150908. private _options;
  150909. private _scene;
  150910. private _currentPriorityLevel;
  150911. private _targetFrameRate;
  150912. private _trackerDuration;
  150913. private _currentFrameRate;
  150914. private _sceneDisposeObserver;
  150915. private _improvementMode;
  150916. /**
  150917. * Defines an observable called when the optimizer reaches the target frame rate
  150918. */
  150919. onSuccessObservable: Observable<SceneOptimizer>;
  150920. /**
  150921. * Defines an observable called when the optimizer enables an optimization
  150922. */
  150923. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  150924. /**
  150925. * Defines an observable called when the optimizer is not able to reach the target frame rate
  150926. */
  150927. onFailureObservable: Observable<SceneOptimizer>;
  150928. /**
  150929. * Gets a boolean indicating if the optimizer is in improvement mode
  150930. */
  150931. get isInImprovementMode(): boolean;
  150932. /**
  150933. * Gets the current priority level (0 at start)
  150934. */
  150935. get currentPriorityLevel(): number;
  150936. /**
  150937. * Gets the current frame rate checked by the SceneOptimizer
  150938. */
  150939. get currentFrameRate(): number;
  150940. /**
  150941. * Gets or sets the current target frame rate (60 by default)
  150942. */
  150943. get targetFrameRate(): number;
  150944. /**
  150945. * Gets or sets the current target frame rate (60 by default)
  150946. */
  150947. set targetFrameRate(value: number);
  150948. /**
  150949. * Gets or sets the current interval between two checks (every 2000ms by default)
  150950. */
  150951. get trackerDuration(): number;
  150952. /**
  150953. * Gets or sets the current interval between two checks (every 2000ms by default)
  150954. */
  150955. set trackerDuration(value: number);
  150956. /**
  150957. * Gets the list of active optimizations
  150958. */
  150959. get optimizations(): SceneOptimization[];
  150960. /**
  150961. * Creates a new SceneOptimizer
  150962. * @param scene defines the scene to work on
  150963. * @param options defines the options to use with the SceneOptimizer
  150964. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  150965. * @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)
  150966. */
  150967. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  150968. /**
  150969. * Stops the current optimizer
  150970. */
  150971. stop(): void;
  150972. /**
  150973. * Reset the optimizer to initial step (current priority level = 0)
  150974. */
  150975. reset(): void;
  150976. /**
  150977. * Start the optimizer. By default it will try to reach a specific framerate
  150978. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  150979. */
  150980. start(): void;
  150981. private _checkCurrentState;
  150982. /**
  150983. * Release all resources
  150984. */
  150985. dispose(): void;
  150986. /**
  150987. * Helper function to create a SceneOptimizer with one single line of code
  150988. * @param scene defines the scene to work on
  150989. * @param options defines the options to use with the SceneOptimizer
  150990. * @param onSuccess defines a callback to call on success
  150991. * @param onFailure defines a callback to call on failure
  150992. * @returns the new SceneOptimizer object
  150993. */
  150994. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  150995. }
  150996. }
  150997. declare module BABYLON {
  150998. /**
  150999. * Class used to serialize a scene into a string
  151000. */
  151001. export class SceneSerializer {
  151002. /**
  151003. * Clear cache used by a previous serialization
  151004. */
  151005. static ClearCache(): void;
  151006. /**
  151007. * Serialize a scene into a JSON compatible object
  151008. * @param scene defines the scene to serialize
  151009. * @returns a JSON compatible object
  151010. */
  151011. static Serialize(scene: Scene): any;
  151012. /**
  151013. * Serialize a mesh into a JSON compatible object
  151014. * @param toSerialize defines the mesh to serialize
  151015. * @param withParents defines if parents must be serialized as well
  151016. * @param withChildren defines if children must be serialized as well
  151017. * @returns a JSON compatible object
  151018. */
  151019. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  151020. }
  151021. }
  151022. declare module BABYLON {
  151023. /**
  151024. * Class used to host texture specific utilities
  151025. */
  151026. export class TextureTools {
  151027. /**
  151028. * Uses the GPU to create a copy texture rescaled at a given size
  151029. * @param texture Texture to copy from
  151030. * @param width defines the desired width
  151031. * @param height defines the desired height
  151032. * @param useBilinearMode defines if bilinear mode has to be used
  151033. * @return the generated texture
  151034. */
  151035. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  151036. }
  151037. }
  151038. declare module BABYLON {
  151039. /**
  151040. * This represents the different options available for the video capture.
  151041. */
  151042. export interface VideoRecorderOptions {
  151043. /** Defines the mime type of the video. */
  151044. mimeType: string;
  151045. /** Defines the FPS the video should be recorded at. */
  151046. fps: number;
  151047. /** Defines the chunk size for the recording data. */
  151048. recordChunckSize: number;
  151049. /** The audio tracks to attach to the recording. */
  151050. audioTracks?: MediaStreamTrack[];
  151051. }
  151052. /**
  151053. * This can help with recording videos from BabylonJS.
  151054. * This is based on the available WebRTC functionalities of the browser.
  151055. *
  151056. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  151057. */
  151058. export class VideoRecorder {
  151059. private static readonly _defaultOptions;
  151060. /**
  151061. * Returns whether or not the VideoRecorder is available in your browser.
  151062. * @param engine Defines the Babylon Engine.
  151063. * @returns true if supported otherwise false.
  151064. */
  151065. static IsSupported(engine: Engine): boolean;
  151066. private readonly _options;
  151067. private _canvas;
  151068. private _mediaRecorder;
  151069. private _recordedChunks;
  151070. private _fileName;
  151071. private _resolve;
  151072. private _reject;
  151073. /**
  151074. * True when a recording is already in progress.
  151075. */
  151076. get isRecording(): boolean;
  151077. /**
  151078. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  151079. * @param engine Defines the BabylonJS Engine you wish to record.
  151080. * @param options Defines options that can be used to customize the capture.
  151081. */
  151082. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  151083. /**
  151084. * Stops the current recording before the default capture timeout passed in the startRecording function.
  151085. */
  151086. stopRecording(): void;
  151087. /**
  151088. * Starts recording the canvas for a max duration specified in parameters.
  151089. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  151090. * If null no automatic download will start and you can rely on the promise to get the data back.
  151091. * @param maxDuration Defines the maximum recording time in seconds.
  151092. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  151093. * @return A promise callback at the end of the recording with the video data in Blob.
  151094. */
  151095. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  151096. /**
  151097. * Releases internal resources used during the recording.
  151098. */
  151099. dispose(): void;
  151100. private _handleDataAvailable;
  151101. private _handleError;
  151102. private _handleStop;
  151103. }
  151104. }
  151105. declare module BABYLON {
  151106. /**
  151107. * Class containing a set of static utilities functions for screenshots
  151108. */
  151109. export class ScreenshotTools {
  151110. /**
  151111. * Captures a screenshot of the current rendering
  151112. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151113. * @param engine defines the rendering engine
  151114. * @param camera defines the source camera
  151115. * @param size This parameter can be set to a single number or to an object with the
  151116. * following (optional) properties: precision, width, height. If a single number is passed,
  151117. * it will be used for both width and height. If an object is passed, the screenshot size
  151118. * will be derived from the parameters. The precision property is a multiplier allowing
  151119. * rendering at a higher or lower resolution
  151120. * @param successCallback defines the callback receives a single parameter which contains the
  151121. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  151122. * src parameter of an <img> to display it
  151123. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  151124. * Check your browser for supported MIME types
  151125. */
  151126. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  151127. /**
  151128. * Captures a screenshot of the current rendering
  151129. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151130. * @param engine defines the rendering engine
  151131. * @param camera defines the source camera
  151132. * @param size This parameter can be set to a single number or to an object with the
  151133. * following (optional) properties: precision, width, height. If a single number is passed,
  151134. * it will be used for both width and height. If an object is passed, the screenshot size
  151135. * will be derived from the parameters. The precision property is a multiplier allowing
  151136. * rendering at a higher or lower resolution
  151137. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  151138. * Check your browser for supported MIME types
  151139. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  151140. * to the src parameter of an <img> to display it
  151141. */
  151142. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  151143. /**
  151144. * Generates an image screenshot from the specified camera.
  151145. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151146. * @param engine The engine to use for rendering
  151147. * @param camera The camera to use for rendering
  151148. * @param size This parameter can be set to a single number or to an object with the
  151149. * following (optional) properties: precision, width, height. If a single number is passed,
  151150. * it will be used for both width and height. If an object is passed, the screenshot size
  151151. * will be derived from the parameters. The precision property is a multiplier allowing
  151152. * rendering at a higher or lower resolution
  151153. * @param successCallback The callback receives a single parameter which contains the
  151154. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  151155. * src parameter of an <img> to display it
  151156. * @param mimeType The MIME type of the screenshot image (default: image/png).
  151157. * Check your browser for supported MIME types
  151158. * @param samples Texture samples (default: 1)
  151159. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  151160. * @param fileName A name for for the downloaded file.
  151161. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  151162. */
  151163. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  151164. /**
  151165. * Generates an image screenshot from the specified camera.
  151166. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151167. * @param engine The engine to use for rendering
  151168. * @param camera The camera to use for rendering
  151169. * @param size This parameter can be set to a single number or to an object with the
  151170. * following (optional) properties: precision, width, height. If a single number is passed,
  151171. * it will be used for both width and height. If an object is passed, the screenshot size
  151172. * will be derived from the parameters. The precision property is a multiplier allowing
  151173. * rendering at a higher or lower resolution
  151174. * @param mimeType The MIME type of the screenshot image (default: image/png).
  151175. * Check your browser for supported MIME types
  151176. * @param samples Texture samples (default: 1)
  151177. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  151178. * @param fileName A name for for the downloaded file.
  151179. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  151180. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  151181. * to the src parameter of an <img> to display it
  151182. */
  151183. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  151184. /**
  151185. * Gets height and width for screenshot size
  151186. * @private
  151187. */
  151188. private static _getScreenshotSize;
  151189. }
  151190. }
  151191. declare module BABYLON {
  151192. /**
  151193. * Interface for a data buffer
  151194. */
  151195. export interface IDataBuffer {
  151196. /**
  151197. * Reads bytes from the data buffer.
  151198. * @param byteOffset The byte offset to read
  151199. * @param byteLength The byte length to read
  151200. * @returns A promise that resolves when the bytes are read
  151201. */
  151202. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  151203. /**
  151204. * The byte length of the buffer.
  151205. */
  151206. readonly byteLength: number;
  151207. }
  151208. /**
  151209. * Utility class for reading from a data buffer
  151210. */
  151211. export class DataReader {
  151212. /**
  151213. * The data buffer associated with this data reader.
  151214. */
  151215. readonly buffer: IDataBuffer;
  151216. /**
  151217. * The current byte offset from the beginning of the data buffer.
  151218. */
  151219. byteOffset: number;
  151220. private _dataView;
  151221. private _dataByteOffset;
  151222. /**
  151223. * Constructor
  151224. * @param buffer The buffer to read
  151225. */
  151226. constructor(buffer: IDataBuffer);
  151227. /**
  151228. * Loads the given byte length.
  151229. * @param byteLength The byte length to load
  151230. * @returns A promise that resolves when the load is complete
  151231. */
  151232. loadAsync(byteLength: number): Promise<void>;
  151233. /**
  151234. * Read a unsigned 32-bit integer from the currently loaded data range.
  151235. * @returns The 32-bit integer read
  151236. */
  151237. readUint32(): number;
  151238. /**
  151239. * Read a byte array from the currently loaded data range.
  151240. * @param byteLength The byte length to read
  151241. * @returns The byte array read
  151242. */
  151243. readUint8Array(byteLength: number): Uint8Array;
  151244. /**
  151245. * Read a string from the currently loaded data range.
  151246. * @param byteLength The byte length to read
  151247. * @returns The string read
  151248. */
  151249. readString(byteLength: number): string;
  151250. /**
  151251. * Skips the given byte length the currently loaded data range.
  151252. * @param byteLength The byte length to skip
  151253. */
  151254. skipBytes(byteLength: number): void;
  151255. }
  151256. }
  151257. declare module BABYLON {
  151258. /**
  151259. * Class for storing data to local storage if available or in-memory storage otherwise
  151260. */
  151261. export class DataStorage {
  151262. private static _Storage;
  151263. private static _GetStorage;
  151264. /**
  151265. * Reads a string from the data storage
  151266. * @param key The key to read
  151267. * @param defaultValue The value if the key doesn't exist
  151268. * @returns The string value
  151269. */
  151270. static ReadString(key: string, defaultValue: string): string;
  151271. /**
  151272. * Writes a string to the data storage
  151273. * @param key The key to write
  151274. * @param value The value to write
  151275. */
  151276. static WriteString(key: string, value: string): void;
  151277. /**
  151278. * Reads a boolean from the data storage
  151279. * @param key The key to read
  151280. * @param defaultValue The value if the key doesn't exist
  151281. * @returns The boolean value
  151282. */
  151283. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  151284. /**
  151285. * Writes a boolean to the data storage
  151286. * @param key The key to write
  151287. * @param value The value to write
  151288. */
  151289. static WriteBoolean(key: string, value: boolean): void;
  151290. /**
  151291. * Reads a number from the data storage
  151292. * @param key The key to read
  151293. * @param defaultValue The value if the key doesn't exist
  151294. * @returns The number value
  151295. */
  151296. static ReadNumber(key: string, defaultValue: number): number;
  151297. /**
  151298. * Writes a number to the data storage
  151299. * @param key The key to write
  151300. * @param value The value to write
  151301. */
  151302. static WriteNumber(key: string, value: number): void;
  151303. }
  151304. }
  151305. declare module BABYLON {
  151306. /**
  151307. * An interface for all Hit test features
  151308. */
  151309. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  151310. /**
  151311. * Triggered when new babylon (transformed) hit test results are available
  151312. */
  151313. onHitTestResultObservable: Observable<T[]>;
  151314. }
  151315. /**
  151316. * Options used for hit testing
  151317. */
  151318. export interface IWebXRLegacyHitTestOptions {
  151319. /**
  151320. * Only test when user interacted with the scene. Default - hit test every frame
  151321. */
  151322. testOnPointerDownOnly?: boolean;
  151323. /**
  151324. * The node to use to transform the local results to world coordinates
  151325. */
  151326. worldParentNode?: TransformNode;
  151327. }
  151328. /**
  151329. * Interface defining the babylon result of raycasting/hit-test
  151330. */
  151331. export interface IWebXRLegacyHitResult {
  151332. /**
  151333. * Transformation matrix that can be applied to a node that will put it in the hit point location
  151334. */
  151335. transformationMatrix: Matrix;
  151336. /**
  151337. * The native hit test result
  151338. */
  151339. xrHitResult: XRHitResult | XRHitTestResult;
  151340. }
  151341. /**
  151342. * The currently-working hit-test module.
  151343. * Hit test (or Ray-casting) is used to interact with the real world.
  151344. * For further information read here - https://github.com/immersive-web/hit-test
  151345. */
  151346. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  151347. /**
  151348. * options to use when constructing this feature
  151349. */
  151350. readonly options: IWebXRLegacyHitTestOptions;
  151351. private _direction;
  151352. private _mat;
  151353. private _onSelectEnabled;
  151354. private _origin;
  151355. /**
  151356. * The module's name
  151357. */
  151358. static readonly Name: string;
  151359. /**
  151360. * The (Babylon) version of this module.
  151361. * This is an integer representing the implementation version.
  151362. * This number does not correspond to the WebXR specs version
  151363. */
  151364. static readonly Version: number;
  151365. /**
  151366. * Populated with the last native XR Hit Results
  151367. */
  151368. lastNativeXRHitResults: XRHitResult[];
  151369. /**
  151370. * Triggered when new babylon (transformed) hit test results are available
  151371. */
  151372. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  151373. /**
  151374. * Creates a new instance of the (legacy version) hit test feature
  151375. * @param _xrSessionManager an instance of WebXRSessionManager
  151376. * @param options options to use when constructing this feature
  151377. */
  151378. constructor(_xrSessionManager: WebXRSessionManager,
  151379. /**
  151380. * options to use when constructing this feature
  151381. */
  151382. options?: IWebXRLegacyHitTestOptions);
  151383. /**
  151384. * execute a hit test with an XR Ray
  151385. *
  151386. * @param xrSession a native xrSession that will execute this hit test
  151387. * @param xrRay the ray (position and direction) to use for ray-casting
  151388. * @param referenceSpace native XR reference space to use for the hit-test
  151389. * @param filter filter function that will filter the results
  151390. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  151391. */
  151392. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  151393. /**
  151394. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  151395. * @param event the (select) event to use to select with
  151396. * @param referenceSpace the reference space to use for this hit test
  151397. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  151398. */
  151399. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  151400. /**
  151401. * attach this feature
  151402. * Will usually be called by the features manager
  151403. *
  151404. * @returns true if successful.
  151405. */
  151406. attach(): boolean;
  151407. /**
  151408. * detach this feature.
  151409. * Will usually be called by the features manager
  151410. *
  151411. * @returns true if successful.
  151412. */
  151413. detach(): boolean;
  151414. /**
  151415. * Dispose this feature and all of the resources attached
  151416. */
  151417. dispose(): void;
  151418. protected _onXRFrame(frame: XRFrame): void;
  151419. private _onHitTestResults;
  151420. private _onSelect;
  151421. }
  151422. }
  151423. declare module BABYLON {
  151424. /**
  151425. * Options used for hit testing (version 2)
  151426. */
  151427. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  151428. /**
  151429. * Do not create a permanent hit test. Will usually be used when only
  151430. * transient inputs are needed.
  151431. */
  151432. disablePermanentHitTest?: boolean;
  151433. /**
  151434. * Enable transient (for example touch-based) hit test inspections
  151435. */
  151436. enableTransientHitTest?: boolean;
  151437. /**
  151438. * Offset ray for the permanent hit test
  151439. */
  151440. offsetRay?: Vector3;
  151441. /**
  151442. * Offset ray for the transient hit test
  151443. */
  151444. transientOffsetRay?: Vector3;
  151445. /**
  151446. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  151447. */
  151448. useReferenceSpace?: boolean;
  151449. }
  151450. /**
  151451. * Interface defining the babylon result of hit-test
  151452. */
  151453. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  151454. /**
  151455. * The input source that generated this hit test (if transient)
  151456. */
  151457. inputSource?: XRInputSource;
  151458. /**
  151459. * Is this a transient hit test
  151460. */
  151461. isTransient?: boolean;
  151462. /**
  151463. * Position of the hit test result
  151464. */
  151465. position: Vector3;
  151466. /**
  151467. * Rotation of the hit test result
  151468. */
  151469. rotationQuaternion: Quaternion;
  151470. /**
  151471. * The native hit test result
  151472. */
  151473. xrHitResult: XRHitTestResult;
  151474. }
  151475. /**
  151476. * The currently-working hit-test module.
  151477. * Hit test (or Ray-casting) is used to interact with the real world.
  151478. * For further information read here - https://github.com/immersive-web/hit-test
  151479. *
  151480. * Tested on chrome (mobile) 80.
  151481. */
  151482. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  151483. /**
  151484. * options to use when constructing this feature
  151485. */
  151486. readonly options: IWebXRHitTestOptions;
  151487. private _tmpMat;
  151488. private _tmpPos;
  151489. private _tmpQuat;
  151490. private _transientXrHitTestSource;
  151491. private _xrHitTestSource;
  151492. private initHitTestSource;
  151493. /**
  151494. * The module's name
  151495. */
  151496. static readonly Name: string;
  151497. /**
  151498. * The (Babylon) version of this module.
  151499. * This is an integer representing the implementation version.
  151500. * This number does not correspond to the WebXR specs version
  151501. */
  151502. static readonly Version: number;
  151503. /**
  151504. * When set to true, each hit test will have its own position/rotation objects
  151505. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  151506. * the developers will clone them or copy them as they see fit.
  151507. */
  151508. autoCloneTransformation: boolean;
  151509. /**
  151510. * Triggered when new babylon (transformed) hit test results are available
  151511. */
  151512. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  151513. /**
  151514. * Use this to temporarily pause hit test checks.
  151515. */
  151516. paused: boolean;
  151517. /**
  151518. * Creates a new instance of the hit test feature
  151519. * @param _xrSessionManager an instance of WebXRSessionManager
  151520. * @param options options to use when constructing this feature
  151521. */
  151522. constructor(_xrSessionManager: WebXRSessionManager,
  151523. /**
  151524. * options to use when constructing this feature
  151525. */
  151526. options?: IWebXRHitTestOptions);
  151527. /**
  151528. * attach this feature
  151529. * Will usually be called by the features manager
  151530. *
  151531. * @returns true if successful.
  151532. */
  151533. attach(): boolean;
  151534. /**
  151535. * detach this feature.
  151536. * Will usually be called by the features manager
  151537. *
  151538. * @returns true if successful.
  151539. */
  151540. detach(): boolean;
  151541. /**
  151542. * Dispose this feature and all of the resources attached
  151543. */
  151544. dispose(): void;
  151545. protected _onXRFrame(frame: XRFrame): void;
  151546. private _processWebXRHitTestResult;
  151547. }
  151548. }
  151549. declare module BABYLON {
  151550. /**
  151551. * Configuration options of the anchor system
  151552. */
  151553. export interface IWebXRAnchorSystemOptions {
  151554. /**
  151555. * a node that will be used to convert local to world coordinates
  151556. */
  151557. worldParentNode?: TransformNode;
  151558. /**
  151559. * If set to true a reference of the created anchors will be kept until the next session starts
  151560. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  151561. */
  151562. doNotRemoveAnchorsOnSessionEnded?: boolean;
  151563. }
  151564. /**
  151565. * A babylon container for an XR Anchor
  151566. */
  151567. export interface IWebXRAnchor {
  151568. /**
  151569. * A babylon-assigned ID for this anchor
  151570. */
  151571. id: number;
  151572. /**
  151573. * Transformation matrix to apply to an object attached to this anchor
  151574. */
  151575. transformationMatrix: Matrix;
  151576. /**
  151577. * The native anchor object
  151578. */
  151579. xrAnchor: XRAnchor;
  151580. /**
  151581. * if defined, this object will be constantly updated by the anchor's position and rotation
  151582. */
  151583. attachedNode?: TransformNode;
  151584. }
  151585. /**
  151586. * An implementation of the anchor system for WebXR.
  151587. * For further information see https://github.com/immersive-web/anchors/
  151588. */
  151589. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  151590. private _options;
  151591. private _lastFrameDetected;
  151592. private _trackedAnchors;
  151593. private _referenceSpaceForFrameAnchors;
  151594. private _futureAnchors;
  151595. /**
  151596. * The module's name
  151597. */
  151598. static readonly Name: string;
  151599. /**
  151600. * The (Babylon) version of this module.
  151601. * This is an integer representing the implementation version.
  151602. * This number does not correspond to the WebXR specs version
  151603. */
  151604. static readonly Version: number;
  151605. /**
  151606. * Observers registered here will be executed when a new anchor was added to the session
  151607. */
  151608. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  151609. /**
  151610. * Observers registered here will be executed when an anchor was removed from the session
  151611. */
  151612. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  151613. /**
  151614. * Observers registered here will be executed when an existing anchor updates
  151615. * This can execute N times every frame
  151616. */
  151617. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  151618. /**
  151619. * Set the reference space to use for anchor creation, when not using a hit test.
  151620. * Will default to the session's reference space if not defined
  151621. */
  151622. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  151623. /**
  151624. * constructs a new anchor system
  151625. * @param _xrSessionManager an instance of WebXRSessionManager
  151626. * @param _options configuration object for this feature
  151627. */
  151628. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  151629. private _tmpVector;
  151630. private _tmpQuaternion;
  151631. private _populateTmpTransformation;
  151632. /**
  151633. * Create a new anchor point using a hit test result at a specific point in the scene
  151634. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  151635. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  151636. *
  151637. * @param hitTestResult The hit test result to use for this anchor creation
  151638. * @param position an optional position offset for this anchor
  151639. * @param rotationQuaternion an optional rotation offset for this anchor
  151640. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  151641. */
  151642. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  151643. /**
  151644. * Add a new anchor at a specific position and rotation
  151645. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  151646. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  151647. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  151648. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  151649. *
  151650. * @param position the position in which to add an anchor
  151651. * @param rotationQuaternion an optional rotation for the anchor transformation
  151652. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  151653. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  151654. */
  151655. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  151656. /**
  151657. * detach this feature.
  151658. * Will usually be called by the features manager
  151659. *
  151660. * @returns true if successful.
  151661. */
  151662. detach(): boolean;
  151663. /**
  151664. * Dispose this feature and all of the resources attached
  151665. */
  151666. dispose(): void;
  151667. protected _onXRFrame(frame: XRFrame): void;
  151668. /**
  151669. * avoiding using Array.find for global support.
  151670. * @param xrAnchor the plane to find in the array
  151671. */
  151672. private _findIndexInAnchorArray;
  151673. private _updateAnchorWithXRFrame;
  151674. private _createAnchorAtTransformation;
  151675. }
  151676. }
  151677. declare module BABYLON {
  151678. /**
  151679. * Options used in the plane detector module
  151680. */
  151681. export interface IWebXRPlaneDetectorOptions {
  151682. /**
  151683. * The node to use to transform the local results to world coordinates
  151684. */
  151685. worldParentNode?: TransformNode;
  151686. /**
  151687. * If set to true a reference of the created planes will be kept until the next session starts
  151688. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  151689. */
  151690. doNotRemovePlanesOnSessionEnded?: boolean;
  151691. }
  151692. /**
  151693. * A babylon interface for a WebXR plane.
  151694. * A Plane is actually a polygon, built from N points in space
  151695. *
  151696. * Supported in chrome 79, not supported in canary 81 ATM
  151697. */
  151698. export interface IWebXRPlane {
  151699. /**
  151700. * a babylon-assigned ID for this polygon
  151701. */
  151702. id: number;
  151703. /**
  151704. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  151705. */
  151706. polygonDefinition: Array<Vector3>;
  151707. /**
  151708. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  151709. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  151710. */
  151711. transformationMatrix: Matrix;
  151712. /**
  151713. * the native xr-plane object
  151714. */
  151715. xrPlane: XRPlane;
  151716. }
  151717. /**
  151718. * The plane detector is used to detect planes in the real world when in AR
  151719. * For more information see https://github.com/immersive-web/real-world-geometry/
  151720. */
  151721. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  151722. private _options;
  151723. private _detectedPlanes;
  151724. private _enabled;
  151725. private _lastFrameDetected;
  151726. /**
  151727. * The module's name
  151728. */
  151729. static readonly Name: string;
  151730. /**
  151731. * The (Babylon) version of this module.
  151732. * This is an integer representing the implementation version.
  151733. * This number does not correspond to the WebXR specs version
  151734. */
  151735. static readonly Version: number;
  151736. /**
  151737. * Observers registered here will be executed when a new plane was added to the session
  151738. */
  151739. onPlaneAddedObservable: Observable<IWebXRPlane>;
  151740. /**
  151741. * Observers registered here will be executed when a plane is no longer detected in the session
  151742. */
  151743. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  151744. /**
  151745. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  151746. * This can execute N times every frame
  151747. */
  151748. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  151749. /**
  151750. * construct a new Plane Detector
  151751. * @param _xrSessionManager an instance of xr Session manager
  151752. * @param _options configuration to use when constructing this feature
  151753. */
  151754. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  151755. /**
  151756. * detach this feature.
  151757. * Will usually be called by the features manager
  151758. *
  151759. * @returns true if successful.
  151760. */
  151761. detach(): boolean;
  151762. /**
  151763. * Dispose this feature and all of the resources attached
  151764. */
  151765. dispose(): void;
  151766. protected _onXRFrame(frame: XRFrame): void;
  151767. private _init;
  151768. private _updatePlaneWithXRPlane;
  151769. /**
  151770. * avoiding using Array.find for global support.
  151771. * @param xrPlane the plane to find in the array
  151772. */
  151773. private findIndexInPlaneArray;
  151774. }
  151775. }
  151776. declare module BABYLON {
  151777. /**
  151778. * Options interface for the background remover plugin
  151779. */
  151780. export interface IWebXRBackgroundRemoverOptions {
  151781. /**
  151782. * Further background meshes to disable when entering AR
  151783. */
  151784. backgroundMeshes?: AbstractMesh[];
  151785. /**
  151786. * flags to configure the removal of the environment helper.
  151787. * If not set, the entire background will be removed. If set, flags should be set as well.
  151788. */
  151789. environmentHelperRemovalFlags?: {
  151790. /**
  151791. * Should the skybox be removed (default false)
  151792. */
  151793. skyBox?: boolean;
  151794. /**
  151795. * Should the ground be removed (default false)
  151796. */
  151797. ground?: boolean;
  151798. };
  151799. /**
  151800. * don't disable the environment helper
  151801. */
  151802. ignoreEnvironmentHelper?: boolean;
  151803. }
  151804. /**
  151805. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  151806. */
  151807. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  151808. /**
  151809. * read-only options to be used in this module
  151810. */
  151811. readonly options: IWebXRBackgroundRemoverOptions;
  151812. /**
  151813. * The module's name
  151814. */
  151815. static readonly Name: string;
  151816. /**
  151817. * The (Babylon) version of this module.
  151818. * This is an integer representing the implementation version.
  151819. * This number does not correspond to the WebXR specs version
  151820. */
  151821. static readonly Version: number;
  151822. /**
  151823. * registered observers will be triggered when the background state changes
  151824. */
  151825. onBackgroundStateChangedObservable: Observable<boolean>;
  151826. /**
  151827. * constructs a new background remover module
  151828. * @param _xrSessionManager the session manager for this module
  151829. * @param options read-only options to be used in this module
  151830. */
  151831. constructor(_xrSessionManager: WebXRSessionManager,
  151832. /**
  151833. * read-only options to be used in this module
  151834. */
  151835. options?: IWebXRBackgroundRemoverOptions);
  151836. /**
  151837. * attach this feature
  151838. * Will usually be called by the features manager
  151839. *
  151840. * @returns true if successful.
  151841. */
  151842. attach(): boolean;
  151843. /**
  151844. * detach this feature.
  151845. * Will usually be called by the features manager
  151846. *
  151847. * @returns true if successful.
  151848. */
  151849. detach(): boolean;
  151850. /**
  151851. * Dispose this feature and all of the resources attached
  151852. */
  151853. dispose(): void;
  151854. protected _onXRFrame(_xrFrame: XRFrame): void;
  151855. private _setBackgroundState;
  151856. }
  151857. }
  151858. declare module BABYLON {
  151859. /**
  151860. * Options for the controller physics feature
  151861. */
  151862. export class IWebXRControllerPhysicsOptions {
  151863. /**
  151864. * Should the headset get its own impostor
  151865. */
  151866. enableHeadsetImpostor?: boolean;
  151867. /**
  151868. * Optional parameters for the headset impostor
  151869. */
  151870. headsetImpostorParams?: {
  151871. /**
  151872. * The type of impostor to create. Default is sphere
  151873. */
  151874. impostorType: number;
  151875. /**
  151876. * the size of the impostor. Defaults to 10cm
  151877. */
  151878. impostorSize?: number | {
  151879. width: number;
  151880. height: number;
  151881. depth: number;
  151882. };
  151883. /**
  151884. * Friction definitions
  151885. */
  151886. friction?: number;
  151887. /**
  151888. * Restitution
  151889. */
  151890. restitution?: number;
  151891. };
  151892. /**
  151893. * The physics properties of the future impostors
  151894. */
  151895. physicsProperties?: {
  151896. /**
  151897. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  151898. * Note that this requires a physics engine that supports mesh impostors!
  151899. */
  151900. useControllerMesh?: boolean;
  151901. /**
  151902. * The type of impostor to create. Default is sphere
  151903. */
  151904. impostorType?: number;
  151905. /**
  151906. * the size of the impostor. Defaults to 10cm
  151907. */
  151908. impostorSize?: number | {
  151909. width: number;
  151910. height: number;
  151911. depth: number;
  151912. };
  151913. /**
  151914. * Friction definitions
  151915. */
  151916. friction?: number;
  151917. /**
  151918. * Restitution
  151919. */
  151920. restitution?: number;
  151921. };
  151922. /**
  151923. * the xr input to use with this pointer selection
  151924. */
  151925. xrInput: WebXRInput;
  151926. }
  151927. /**
  151928. * Add physics impostor to your webxr controllers,
  151929. * including naive calculation of their linear and angular velocity
  151930. */
  151931. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  151932. private readonly _options;
  151933. private _attachController;
  151934. private _controllers;
  151935. private _debugMode;
  151936. private _delta;
  151937. private _headsetImpostor?;
  151938. private _headsetMesh?;
  151939. private _lastTimestamp;
  151940. private _tmpQuaternion;
  151941. private _tmpVector;
  151942. /**
  151943. * The module's name
  151944. */
  151945. static readonly Name: string;
  151946. /**
  151947. * The (Babylon) version of this module.
  151948. * This is an integer representing the implementation version.
  151949. * This number does not correspond to the webxr specs version
  151950. */
  151951. static readonly Version: number;
  151952. /**
  151953. * Construct a new Controller Physics Feature
  151954. * @param _xrSessionManager the corresponding xr session manager
  151955. * @param _options options to create this feature with
  151956. */
  151957. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  151958. /**
  151959. * @hidden
  151960. * enable debugging - will show console outputs and the impostor mesh
  151961. */
  151962. _enablePhysicsDebug(): void;
  151963. /**
  151964. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  151965. * @param xrController the controller to add
  151966. */
  151967. addController(xrController: WebXRInputSource): void;
  151968. /**
  151969. * attach this feature
  151970. * Will usually be called by the features manager
  151971. *
  151972. * @returns true if successful.
  151973. */
  151974. attach(): boolean;
  151975. /**
  151976. * detach this feature.
  151977. * Will usually be called by the features manager
  151978. *
  151979. * @returns true if successful.
  151980. */
  151981. detach(): boolean;
  151982. /**
  151983. * Get the headset impostor, if enabled
  151984. * @returns the impostor
  151985. */
  151986. getHeadsetImpostor(): PhysicsImpostor | undefined;
  151987. /**
  151988. * Get the physics impostor of a specific controller.
  151989. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  151990. * @param controller the controller or the controller id of which to get the impostor
  151991. * @returns the impostor or null
  151992. */
  151993. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  151994. /**
  151995. * Update the physics properties provided in the constructor
  151996. * @param newProperties the new properties object
  151997. */
  151998. setPhysicsProperties(newProperties: {
  151999. impostorType?: number;
  152000. impostorSize?: number | {
  152001. width: number;
  152002. height: number;
  152003. depth: number;
  152004. };
  152005. friction?: number;
  152006. restitution?: number;
  152007. }): void;
  152008. protected _onXRFrame(_xrFrame: any): void;
  152009. private _detachController;
  152010. }
  152011. }
  152012. declare module BABYLON {
  152013. /**
  152014. * The motion controller class for all microsoft mixed reality controllers
  152015. */
  152016. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  152017. protected readonly _mapping: {
  152018. defaultButton: {
  152019. valueNodeName: string;
  152020. unpressedNodeName: string;
  152021. pressedNodeName: string;
  152022. };
  152023. defaultAxis: {
  152024. valueNodeName: string;
  152025. minNodeName: string;
  152026. maxNodeName: string;
  152027. };
  152028. buttons: {
  152029. "xr-standard-trigger": {
  152030. rootNodeName: string;
  152031. componentProperty: string;
  152032. states: string[];
  152033. };
  152034. "xr-standard-squeeze": {
  152035. rootNodeName: string;
  152036. componentProperty: string;
  152037. states: string[];
  152038. };
  152039. "xr-standard-touchpad": {
  152040. rootNodeName: string;
  152041. labelAnchorNodeName: string;
  152042. touchPointNodeName: string;
  152043. };
  152044. "xr-standard-thumbstick": {
  152045. rootNodeName: string;
  152046. componentProperty: string;
  152047. states: string[];
  152048. };
  152049. };
  152050. axes: {
  152051. "xr-standard-touchpad": {
  152052. "x-axis": {
  152053. rootNodeName: string;
  152054. };
  152055. "y-axis": {
  152056. rootNodeName: string;
  152057. };
  152058. };
  152059. "xr-standard-thumbstick": {
  152060. "x-axis": {
  152061. rootNodeName: string;
  152062. };
  152063. "y-axis": {
  152064. rootNodeName: string;
  152065. };
  152066. };
  152067. };
  152068. };
  152069. /**
  152070. * The base url used to load the left and right controller models
  152071. */
  152072. static MODEL_BASE_URL: string;
  152073. /**
  152074. * The name of the left controller model file
  152075. */
  152076. static MODEL_LEFT_FILENAME: string;
  152077. /**
  152078. * The name of the right controller model file
  152079. */
  152080. static MODEL_RIGHT_FILENAME: string;
  152081. profileId: string;
  152082. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  152083. protected _getFilenameAndPath(): {
  152084. filename: string;
  152085. path: string;
  152086. };
  152087. protected _getModelLoadingConstraints(): boolean;
  152088. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  152089. protected _setRootMesh(meshes: AbstractMesh[]): void;
  152090. protected _updateModel(): void;
  152091. }
  152092. }
  152093. declare module BABYLON {
  152094. /**
  152095. * The motion controller class for oculus touch (quest, rift).
  152096. * This class supports legacy mapping as well the standard xr mapping
  152097. */
  152098. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  152099. private _forceLegacyControllers;
  152100. private _modelRootNode;
  152101. /**
  152102. * The base url used to load the left and right controller models
  152103. */
  152104. static MODEL_BASE_URL: string;
  152105. /**
  152106. * The name of the left controller model file
  152107. */
  152108. static MODEL_LEFT_FILENAME: string;
  152109. /**
  152110. * The name of the right controller model file
  152111. */
  152112. static MODEL_RIGHT_FILENAME: string;
  152113. /**
  152114. * Base Url for the Quest controller model.
  152115. */
  152116. static QUEST_MODEL_BASE_URL: string;
  152117. profileId: string;
  152118. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  152119. protected _getFilenameAndPath(): {
  152120. filename: string;
  152121. path: string;
  152122. };
  152123. protected _getModelLoadingConstraints(): boolean;
  152124. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  152125. protected _setRootMesh(meshes: AbstractMesh[]): void;
  152126. protected _updateModel(): void;
  152127. /**
  152128. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  152129. * between the touch and touch 2.
  152130. */
  152131. private _isQuest;
  152132. }
  152133. }
  152134. declare module BABYLON {
  152135. /**
  152136. * The motion controller class for the standard HTC-Vive controllers
  152137. */
  152138. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  152139. private _modelRootNode;
  152140. /**
  152141. * The base url used to load the left and right controller models
  152142. */
  152143. static MODEL_BASE_URL: string;
  152144. /**
  152145. * File name for the controller model.
  152146. */
  152147. static MODEL_FILENAME: string;
  152148. profileId: string;
  152149. /**
  152150. * Create a new Vive motion controller object
  152151. * @param scene the scene to use to create this controller
  152152. * @param gamepadObject the corresponding gamepad object
  152153. * @param handedness the handedness of the controller
  152154. */
  152155. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  152156. protected _getFilenameAndPath(): {
  152157. filename: string;
  152158. path: string;
  152159. };
  152160. protected _getModelLoadingConstraints(): boolean;
  152161. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  152162. protected _setRootMesh(meshes: AbstractMesh[]): void;
  152163. protected _updateModel(): void;
  152164. }
  152165. }
  152166. declare module BABYLON {
  152167. /**
  152168. * A cursor which tracks a point on a path
  152169. */
  152170. export class PathCursor {
  152171. private path;
  152172. /**
  152173. * Stores path cursor callbacks for when an onchange event is triggered
  152174. */
  152175. private _onchange;
  152176. /**
  152177. * The value of the path cursor
  152178. */
  152179. value: number;
  152180. /**
  152181. * The animation array of the path cursor
  152182. */
  152183. animations: Animation[];
  152184. /**
  152185. * Initializes the path cursor
  152186. * @param path The path to track
  152187. */
  152188. constructor(path: Path2);
  152189. /**
  152190. * Gets the cursor point on the path
  152191. * @returns A point on the path cursor at the cursor location
  152192. */
  152193. getPoint(): Vector3;
  152194. /**
  152195. * Moves the cursor ahead by the step amount
  152196. * @param step The amount to move the cursor forward
  152197. * @returns This path cursor
  152198. */
  152199. moveAhead(step?: number): PathCursor;
  152200. /**
  152201. * Moves the cursor behind by the step amount
  152202. * @param step The amount to move the cursor back
  152203. * @returns This path cursor
  152204. */
  152205. moveBack(step?: number): PathCursor;
  152206. /**
  152207. * Moves the cursor by the step amount
  152208. * If the step amount is greater than one, an exception is thrown
  152209. * @param step The amount to move the cursor
  152210. * @returns This path cursor
  152211. */
  152212. move(step: number): PathCursor;
  152213. /**
  152214. * Ensures that the value is limited between zero and one
  152215. * @returns This path cursor
  152216. */
  152217. private ensureLimits;
  152218. /**
  152219. * Runs onchange callbacks on change (used by the animation engine)
  152220. * @returns This path cursor
  152221. */
  152222. private raiseOnChange;
  152223. /**
  152224. * Executes a function on change
  152225. * @param f A path cursor onchange callback
  152226. * @returns This path cursor
  152227. */
  152228. onchange(f: (cursor: PathCursor) => void): PathCursor;
  152229. }
  152230. }
  152231. declare module BABYLON {
  152232. /** @hidden */
  152233. export var blurPixelShader: {
  152234. name: string;
  152235. shader: string;
  152236. };
  152237. }
  152238. declare module BABYLON {
  152239. /** @hidden */
  152240. export var pointCloudVertexDeclaration: {
  152241. name: string;
  152242. shader: string;
  152243. };
  152244. }
  152245. // Mixins
  152246. interface Window {
  152247. mozIndexedDB: IDBFactory;
  152248. webkitIndexedDB: IDBFactory;
  152249. msIndexedDB: IDBFactory;
  152250. webkitURL: typeof URL;
  152251. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  152252. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  152253. WebGLRenderingContext: WebGLRenderingContext;
  152254. MSGesture: MSGesture;
  152255. CANNON: any;
  152256. AudioContext: AudioContext;
  152257. webkitAudioContext: AudioContext;
  152258. PointerEvent: any;
  152259. Math: Math;
  152260. Uint8Array: Uint8ArrayConstructor;
  152261. Float32Array: Float32ArrayConstructor;
  152262. mozURL: typeof URL;
  152263. msURL: typeof URL;
  152264. VRFrameData: any; // WebVR, from specs 1.1
  152265. DracoDecoderModule: any;
  152266. setImmediate(handler: (...args: any[]) => void): number;
  152267. }
  152268. interface HTMLCanvasElement {
  152269. requestPointerLock(): void;
  152270. msRequestPointerLock?(): void;
  152271. mozRequestPointerLock?(): void;
  152272. webkitRequestPointerLock?(): void;
  152273. /** Track wether a record is in progress */
  152274. isRecording: boolean;
  152275. /** Capture Stream method defined by some browsers */
  152276. captureStream(fps?: number): MediaStream;
  152277. }
  152278. interface CanvasRenderingContext2D {
  152279. msImageSmoothingEnabled: boolean;
  152280. }
  152281. interface MouseEvent {
  152282. mozMovementX: number;
  152283. mozMovementY: number;
  152284. webkitMovementX: number;
  152285. webkitMovementY: number;
  152286. msMovementX: number;
  152287. msMovementY: number;
  152288. }
  152289. interface Navigator {
  152290. mozGetVRDevices: (any: any) => any;
  152291. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  152292. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  152293. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  152294. webkitGetGamepads(): Gamepad[];
  152295. msGetGamepads(): Gamepad[];
  152296. webkitGamepads(): Gamepad[];
  152297. }
  152298. interface HTMLVideoElement {
  152299. mozSrcObject: any;
  152300. }
  152301. interface Math {
  152302. fround(x: number): number;
  152303. imul(a: number, b: number): number;
  152304. }
  152305. interface WebGLRenderingContext {
  152306. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  152307. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  152308. vertexAttribDivisor(index: number, divisor: number): void;
  152309. createVertexArray(): any;
  152310. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  152311. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  152312. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  152313. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  152314. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  152315. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  152316. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  152317. // Queries
  152318. createQuery(): WebGLQuery;
  152319. deleteQuery(query: WebGLQuery): void;
  152320. beginQuery(target: number, query: WebGLQuery): void;
  152321. endQuery(target: number): void;
  152322. getQueryParameter(query: WebGLQuery, pname: number): any;
  152323. getQuery(target: number, pname: number): any;
  152324. MAX_SAMPLES: number;
  152325. RGBA8: number;
  152326. READ_FRAMEBUFFER: number;
  152327. DRAW_FRAMEBUFFER: number;
  152328. UNIFORM_BUFFER: number;
  152329. HALF_FLOAT_OES: number;
  152330. RGBA16F: number;
  152331. RGBA32F: number;
  152332. R32F: number;
  152333. RG32F: number;
  152334. RGB32F: number;
  152335. R16F: number;
  152336. RG16F: number;
  152337. RGB16F: number;
  152338. RED: number;
  152339. RG: number;
  152340. R8: number;
  152341. RG8: number;
  152342. UNSIGNED_INT_24_8: number;
  152343. DEPTH24_STENCIL8: number;
  152344. MIN: number;
  152345. MAX: number;
  152346. /* Multiple Render Targets */
  152347. drawBuffers(buffers: number[]): void;
  152348. readBuffer(src: number): void;
  152349. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  152350. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  152351. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  152352. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  152353. // Occlusion Query
  152354. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  152355. ANY_SAMPLES_PASSED: number;
  152356. QUERY_RESULT_AVAILABLE: number;
  152357. QUERY_RESULT: number;
  152358. }
  152359. interface WebGLProgram {
  152360. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  152361. }
  152362. interface EXT_disjoint_timer_query {
  152363. QUERY_COUNTER_BITS_EXT: number;
  152364. TIME_ELAPSED_EXT: number;
  152365. TIMESTAMP_EXT: number;
  152366. GPU_DISJOINT_EXT: number;
  152367. QUERY_RESULT_EXT: number;
  152368. QUERY_RESULT_AVAILABLE_EXT: number;
  152369. queryCounterEXT(query: WebGLQuery, target: number): void;
  152370. createQueryEXT(): WebGLQuery;
  152371. beginQueryEXT(target: number, query: WebGLQuery): void;
  152372. endQueryEXT(target: number): void;
  152373. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  152374. deleteQueryEXT(query: WebGLQuery): void;
  152375. }
  152376. interface WebGLUniformLocation {
  152377. _currentState: any;
  152378. }
  152379. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  152380. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  152381. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  152382. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  152383. interface WebGLRenderingContext {
  152384. readonly RASTERIZER_DISCARD: number;
  152385. readonly DEPTH_COMPONENT24: number;
  152386. readonly TEXTURE_3D: number;
  152387. readonly TEXTURE_2D_ARRAY: number;
  152388. readonly TEXTURE_COMPARE_FUNC: number;
  152389. readonly TEXTURE_COMPARE_MODE: number;
  152390. readonly COMPARE_REF_TO_TEXTURE: number;
  152391. readonly TEXTURE_WRAP_R: number;
  152392. readonly HALF_FLOAT: number;
  152393. readonly RGB8: number;
  152394. readonly RED_INTEGER: number;
  152395. readonly RG_INTEGER: number;
  152396. readonly RGB_INTEGER: number;
  152397. readonly RGBA_INTEGER: number;
  152398. readonly R8_SNORM: number;
  152399. readonly RG8_SNORM: number;
  152400. readonly RGB8_SNORM: number;
  152401. readonly RGBA8_SNORM: number;
  152402. readonly R8I: number;
  152403. readonly RG8I: number;
  152404. readonly RGB8I: number;
  152405. readonly RGBA8I: number;
  152406. readonly R8UI: number;
  152407. readonly RG8UI: number;
  152408. readonly RGB8UI: number;
  152409. readonly RGBA8UI: number;
  152410. readonly R16I: number;
  152411. readonly RG16I: number;
  152412. readonly RGB16I: number;
  152413. readonly RGBA16I: number;
  152414. readonly R16UI: number;
  152415. readonly RG16UI: number;
  152416. readonly RGB16UI: number;
  152417. readonly RGBA16UI: number;
  152418. readonly R32I: number;
  152419. readonly RG32I: number;
  152420. readonly RGB32I: number;
  152421. readonly RGBA32I: number;
  152422. readonly R32UI: number;
  152423. readonly RG32UI: number;
  152424. readonly RGB32UI: number;
  152425. readonly RGBA32UI: number;
  152426. readonly RGB10_A2UI: number;
  152427. readonly R11F_G11F_B10F: number;
  152428. readonly RGB9_E5: number;
  152429. readonly RGB10_A2: number;
  152430. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  152431. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  152432. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  152433. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  152434. readonly DEPTH_COMPONENT32F: number;
  152435. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  152436. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  152437. 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;
  152438. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  152439. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  152440. readonly TRANSFORM_FEEDBACK: number;
  152441. readonly INTERLEAVED_ATTRIBS: number;
  152442. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  152443. createTransformFeedback(): WebGLTransformFeedback;
  152444. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  152445. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  152446. beginTransformFeedback(primitiveMode: number): void;
  152447. endTransformFeedback(): void;
  152448. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  152449. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  152450. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  152451. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  152452. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  152453. }
  152454. interface ImageBitmap {
  152455. readonly width: number;
  152456. readonly height: number;
  152457. close(): void;
  152458. }
  152459. interface WebGLQuery extends WebGLObject {
  152460. }
  152461. declare var WebGLQuery: {
  152462. prototype: WebGLQuery;
  152463. new(): WebGLQuery;
  152464. };
  152465. interface WebGLSampler extends WebGLObject {
  152466. }
  152467. declare var WebGLSampler: {
  152468. prototype: WebGLSampler;
  152469. new(): WebGLSampler;
  152470. };
  152471. interface WebGLSync extends WebGLObject {
  152472. }
  152473. declare var WebGLSync: {
  152474. prototype: WebGLSync;
  152475. new(): WebGLSync;
  152476. };
  152477. interface WebGLTransformFeedback extends WebGLObject {
  152478. }
  152479. declare var WebGLTransformFeedback: {
  152480. prototype: WebGLTransformFeedback;
  152481. new(): WebGLTransformFeedback;
  152482. };
  152483. interface WebGLVertexArrayObject extends WebGLObject {
  152484. }
  152485. declare var WebGLVertexArrayObject: {
  152486. prototype: WebGLVertexArrayObject;
  152487. new(): WebGLVertexArrayObject;
  152488. };
  152489. // Type definitions for WebVR API
  152490. // Project: https://w3c.github.io/webvr/
  152491. // Definitions by: six a <https://github.com/lostfictions>
  152492. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  152493. interface VRDisplay extends EventTarget {
  152494. /**
  152495. * Dictionary of capabilities describing the VRDisplay.
  152496. */
  152497. readonly capabilities: VRDisplayCapabilities;
  152498. /**
  152499. * z-depth defining the far plane of the eye view frustum
  152500. * enables mapping of values in the render target depth
  152501. * attachment to scene coordinates. Initially set to 10000.0.
  152502. */
  152503. depthFar: number;
  152504. /**
  152505. * z-depth defining the near plane of the eye view frustum
  152506. * enables mapping of values in the render target depth
  152507. * attachment to scene coordinates. Initially set to 0.01.
  152508. */
  152509. depthNear: number;
  152510. /**
  152511. * An identifier for this distinct VRDisplay. Used as an
  152512. * association point in the Gamepad API.
  152513. */
  152514. readonly displayId: number;
  152515. /**
  152516. * A display name, a user-readable name identifying it.
  152517. */
  152518. readonly displayName: string;
  152519. readonly isConnected: boolean;
  152520. readonly isPresenting: boolean;
  152521. /**
  152522. * If this VRDisplay supports room-scale experiences, the optional
  152523. * stage attribute contains details on the room-scale parameters.
  152524. */
  152525. readonly stageParameters: VRStageParameters | null;
  152526. /**
  152527. * Passing the value returned by `requestAnimationFrame` to
  152528. * `cancelAnimationFrame` will unregister the callback.
  152529. * @param handle Define the hanle of the request to cancel
  152530. */
  152531. cancelAnimationFrame(handle: number): void;
  152532. /**
  152533. * Stops presenting to the VRDisplay.
  152534. * @returns a promise to know when it stopped
  152535. */
  152536. exitPresent(): Promise<void>;
  152537. /**
  152538. * Return the current VREyeParameters for the given eye.
  152539. * @param whichEye Define the eye we want the parameter for
  152540. * @returns the eye parameters
  152541. */
  152542. getEyeParameters(whichEye: string): VREyeParameters;
  152543. /**
  152544. * Populates the passed VRFrameData with the information required to render
  152545. * the current frame.
  152546. * @param frameData Define the data structure to populate
  152547. * @returns true if ok otherwise false
  152548. */
  152549. getFrameData(frameData: VRFrameData): boolean;
  152550. /**
  152551. * Get the layers currently being presented.
  152552. * @returns the list of VR layers
  152553. */
  152554. getLayers(): VRLayer[];
  152555. /**
  152556. * Return a VRPose containing the future predicted pose of the VRDisplay
  152557. * when the current frame will be presented. The value returned will not
  152558. * change until JavaScript has returned control to the browser.
  152559. *
  152560. * The VRPose will contain the position, orientation, velocity,
  152561. * and acceleration of each of these properties.
  152562. * @returns the pose object
  152563. */
  152564. getPose(): VRPose;
  152565. /**
  152566. * Return the current instantaneous pose of the VRDisplay, with no
  152567. * prediction applied.
  152568. * @returns the current instantaneous pose
  152569. */
  152570. getImmediatePose(): VRPose;
  152571. /**
  152572. * The callback passed to `requestAnimationFrame` will be called
  152573. * any time a new frame should be rendered. When the VRDisplay is
  152574. * presenting the callback will be called at the native refresh
  152575. * rate of the HMD. When not presenting this function acts
  152576. * identically to how window.requestAnimationFrame acts. Content should
  152577. * make no assumptions of frame rate or vsync behavior as the HMD runs
  152578. * asynchronously from other displays and at differing refresh rates.
  152579. * @param callback Define the eaction to run next frame
  152580. * @returns the request handle it
  152581. */
  152582. requestAnimationFrame(callback: FrameRequestCallback): number;
  152583. /**
  152584. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  152585. * Repeat calls while already presenting will update the VRLayers being displayed.
  152586. * @param layers Define the list of layer to present
  152587. * @returns a promise to know when the request has been fulfilled
  152588. */
  152589. requestPresent(layers: VRLayer[]): Promise<void>;
  152590. /**
  152591. * Reset the pose for this display, treating its current position and
  152592. * orientation as the "origin/zero" values. VRPose.position,
  152593. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  152594. * updated when calling resetPose(). This should be called in only
  152595. * sitting-space experiences.
  152596. */
  152597. resetPose(): void;
  152598. /**
  152599. * The VRLayer provided to the VRDisplay will be captured and presented
  152600. * in the HMD. Calling this function has the same effect on the source
  152601. * canvas as any other operation that uses its source image, and canvases
  152602. * created without preserveDrawingBuffer set to true will be cleared.
  152603. * @param pose Define the pose to submit
  152604. */
  152605. submitFrame(pose?: VRPose): void;
  152606. }
  152607. declare var VRDisplay: {
  152608. prototype: VRDisplay;
  152609. new(): VRDisplay;
  152610. };
  152611. interface VRLayer {
  152612. leftBounds?: number[] | Float32Array | null;
  152613. rightBounds?: number[] | Float32Array | null;
  152614. source?: HTMLCanvasElement | null;
  152615. }
  152616. interface VRDisplayCapabilities {
  152617. readonly canPresent: boolean;
  152618. readonly hasExternalDisplay: boolean;
  152619. readonly hasOrientation: boolean;
  152620. readonly hasPosition: boolean;
  152621. readonly maxLayers: number;
  152622. }
  152623. interface VREyeParameters {
  152624. /** @deprecated */
  152625. readonly fieldOfView: VRFieldOfView;
  152626. readonly offset: Float32Array;
  152627. readonly renderHeight: number;
  152628. readonly renderWidth: number;
  152629. }
  152630. interface VRFieldOfView {
  152631. readonly downDegrees: number;
  152632. readonly leftDegrees: number;
  152633. readonly rightDegrees: number;
  152634. readonly upDegrees: number;
  152635. }
  152636. interface VRFrameData {
  152637. readonly leftProjectionMatrix: Float32Array;
  152638. readonly leftViewMatrix: Float32Array;
  152639. readonly pose: VRPose;
  152640. readonly rightProjectionMatrix: Float32Array;
  152641. readonly rightViewMatrix: Float32Array;
  152642. readonly timestamp: number;
  152643. }
  152644. interface VRPose {
  152645. readonly angularAcceleration: Float32Array | null;
  152646. readonly angularVelocity: Float32Array | null;
  152647. readonly linearAcceleration: Float32Array | null;
  152648. readonly linearVelocity: Float32Array | null;
  152649. readonly orientation: Float32Array | null;
  152650. readonly position: Float32Array | null;
  152651. readonly timestamp: number;
  152652. }
  152653. interface VRStageParameters {
  152654. sittingToStandingTransform?: Float32Array;
  152655. sizeX?: number;
  152656. sizeY?: number;
  152657. }
  152658. interface Navigator {
  152659. getVRDisplays(): Promise<VRDisplay[]>;
  152660. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  152661. }
  152662. interface Window {
  152663. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  152664. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  152665. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  152666. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  152667. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  152668. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  152669. }
  152670. interface Gamepad {
  152671. readonly displayId: number;
  152672. }
  152673. type XRSessionMode =
  152674. | "inline"
  152675. | "immersive-vr"
  152676. | "immersive-ar";
  152677. type XRReferenceSpaceType =
  152678. | "viewer"
  152679. | "local"
  152680. | "local-floor"
  152681. | "bounded-floor"
  152682. | "unbounded";
  152683. type XREnvironmentBlendMode =
  152684. | "opaque"
  152685. | "additive"
  152686. | "alpha-blend";
  152687. type XRVisibilityState =
  152688. | "visible"
  152689. | "visible-blurred"
  152690. | "hidden";
  152691. type XRHandedness =
  152692. | "none"
  152693. | "left"
  152694. | "right";
  152695. type XRTargetRayMode =
  152696. | "gaze"
  152697. | "tracked-pointer"
  152698. | "screen";
  152699. type XREye =
  152700. | "none"
  152701. | "left"
  152702. | "right";
  152703. type XREventType =
  152704. | "devicechange"
  152705. | "visibilitychange"
  152706. | "end"
  152707. | "inputsourceschange"
  152708. | "select"
  152709. | "selectstart"
  152710. | "selectend"
  152711. | "squeeze"
  152712. | "squeezestart"
  152713. | "squeezeend"
  152714. | "reset";
  152715. interface XRSpace extends EventTarget {
  152716. }
  152717. interface XRRenderState {
  152718. depthNear?: number;
  152719. depthFar?: number;
  152720. inlineVerticalFieldOfView?: number;
  152721. baseLayer?: XRWebGLLayer;
  152722. }
  152723. interface XRInputSource {
  152724. handedness: XRHandedness;
  152725. targetRayMode: XRTargetRayMode;
  152726. targetRaySpace: XRSpace;
  152727. gripSpace: XRSpace | undefined;
  152728. gamepad: Gamepad | undefined;
  152729. profiles: Array<string>;
  152730. }
  152731. interface XRSessionInit {
  152732. optionalFeatures?: string[];
  152733. requiredFeatures?: string[];
  152734. }
  152735. interface XRSession {
  152736. addEventListener: Function;
  152737. removeEventListener: Function;
  152738. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  152739. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  152740. requestAnimationFrame: Function;
  152741. end(): Promise<void>;
  152742. renderState: XRRenderState;
  152743. inputSources: Array<XRInputSource>;
  152744. // hit test
  152745. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  152746. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  152747. // legacy AR hit test
  152748. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  152749. // legacy plane detection
  152750. updateWorldTrackingState(options: {
  152751. planeDetectionState?: { enabled: boolean; }
  152752. }): void;
  152753. }
  152754. interface XRReferenceSpace extends XRSpace {
  152755. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  152756. onreset: any;
  152757. }
  152758. type XRPlaneSet = Set<XRPlane>;
  152759. type XRAnchorSet = Set<XRAnchor>;
  152760. interface XRFrame {
  152761. session: XRSession;
  152762. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  152763. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  152764. // AR
  152765. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  152766. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  152767. // Anchors
  152768. trackedAnchors?: XRAnchorSet;
  152769. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  152770. // Planes
  152771. worldInformation: {
  152772. detectedPlanes?: XRPlaneSet;
  152773. };
  152774. }
  152775. interface XRViewerPose extends XRPose {
  152776. views: Array<XRView>;
  152777. }
  152778. interface XRPose {
  152779. transform: XRRigidTransform;
  152780. emulatedPosition: boolean;
  152781. }
  152782. interface XRWebGLLayerOptions {
  152783. antialias?: boolean;
  152784. depth?: boolean;
  152785. stencil?: boolean;
  152786. alpha?: boolean;
  152787. multiview?: boolean;
  152788. framebufferScaleFactor?: number;
  152789. }
  152790. declare var XRWebGLLayer: {
  152791. prototype: XRWebGLLayer;
  152792. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  152793. };
  152794. interface XRWebGLLayer {
  152795. framebuffer: WebGLFramebuffer;
  152796. framebufferWidth: number;
  152797. framebufferHeight: number;
  152798. getViewport: Function;
  152799. }
  152800. declare class XRRigidTransform {
  152801. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  152802. position: DOMPointReadOnly;
  152803. orientation: DOMPointReadOnly;
  152804. matrix: Float32Array;
  152805. inverse: XRRigidTransform;
  152806. }
  152807. interface XRView {
  152808. eye: XREye;
  152809. projectionMatrix: Float32Array;
  152810. transform: XRRigidTransform;
  152811. }
  152812. interface XRInputSourceChangeEvent {
  152813. session: XRSession;
  152814. removed: Array<XRInputSource>;
  152815. added: Array<XRInputSource>;
  152816. }
  152817. interface XRInputSourceEvent extends Event {
  152818. readonly frame: XRFrame;
  152819. readonly inputSource: XRInputSource;
  152820. }
  152821. // Experimental(er) features
  152822. declare class XRRay {
  152823. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  152824. origin: DOMPointReadOnly;
  152825. direction: DOMPointReadOnly;
  152826. matrix: Float32Array;
  152827. }
  152828. declare enum XRHitTestTrackableType {
  152829. "point",
  152830. "plane"
  152831. }
  152832. interface XRHitResult {
  152833. hitMatrix: Float32Array;
  152834. }
  152835. interface XRTransientInputHitTestResult {
  152836. readonly inputSource: XRInputSource;
  152837. readonly results: Array<XRHitTestResult>;
  152838. }
  152839. interface XRHitTestResult {
  152840. getPose(baseSpace: XRSpace): XRPose | undefined;
  152841. // When anchor system is enabled
  152842. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  152843. }
  152844. interface XRHitTestSource {
  152845. cancel(): void;
  152846. }
  152847. interface XRTransientInputHitTestSource {
  152848. cancel(): void;
  152849. }
  152850. interface XRHitTestOptionsInit {
  152851. space: XRSpace;
  152852. entityTypes?: Array<XRHitTestTrackableType>;
  152853. offsetRay?: XRRay;
  152854. }
  152855. interface XRTransientInputHitTestOptionsInit {
  152856. profile: string;
  152857. entityTypes?: Array<XRHitTestTrackableType>;
  152858. offsetRay?: XRRay;
  152859. }
  152860. interface XRAnchor {
  152861. anchorSpace: XRSpace;
  152862. delete(): void;
  152863. }
  152864. interface XRPlane {
  152865. orientation: "Horizontal" | "Vertical";
  152866. planeSpace: XRSpace;
  152867. polygon: Array<DOMPointReadOnly>;
  152868. lastChangedTime: number;
  152869. }